Component Framework

Bootstrap

Bootstrap is the component-first CSS framework that ships a complete design system: a responsive grid, ready-made components and a deep layer of utilities.

beginner13 min readUpdated Sep 15, 2026
navbar.html
html
<!-- navbar.html -->
<nav class="navbar navbar-expand-lg bg-body-tertiary">
  <div class="container">
    <a class="navbar-brand" href="#">hackweb</a>
    <button class="navbar-toggler" data-bs-toggle="collapse"
            data-bs-target="#nav">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="nav">
      <ul class="navbar-nav ms-auto">
        <li class="nav-item"><a class="nav-link" href="#">Docs</a></li>
        <li class="nav-item"><a class="nav-link" href="#">Pricing</a></li>
      </ul>
    </div>
  </div>
</nav>
Current major
Bootstrap 5
Grid
12 responsive columns
Breakpoints
sm, md, lg, xl, xxl
JavaScript
No jQuery since v5
Theming
Sass variables + CSS vars
License
MIT, free for any use

Why it matters

Why teams still choose Bootstrap

Ship faster

A navbar, modal, carousel and form controls are ready on day one, so you build the product instead of the primitives.

Responsive by default

The twelve-column grid and utility classes make mobile-first layouts quick to assemble and easy to adjust.

Battle-tested components

Years of real-world use have ironed out keyboard, focus and ARIA details across the component set.

The big picture

The three layers of Bootstrap

Bootstrap is a grid, a component library and a utility system. You can use one layer without the others.

The grid

Layout

Containers, rows and columns form a twelve-column system with breakpoint-specific widths.

Components

Building blocks

Navbars, cards, modals, alerts and forms that look consistent and work everywhere.

Utilities

Fine-tuning

Spacing, flex, colour and display helpers that adjust layout without writing new CSS.

Bootstrap at a glance

What ships in the box

Containers

Fixed or fluid wrappers that centre content and set responsive gutters.

Grid rows and columns

row and col-* classes place content in a flexible twelve-column layout.

Components

Cards, navbars, modals, dropdowns, accordions and more.

Utilities

m-*, p-*, d-flex, gap-* and friends for quick, local adjustments.

JavaScript plugins

Interactive components driven by data attributes, no custom JS required.

Theming with Sass

Override variables before importing Bootstrap to rebrand the whole system.

A short history

From Twitter internal tool to industry standard

  1. 2011

    Twitter Bootstrap

    An internal style guide is open-sourced and quickly becomes the most popular CSS framework.

    11
  2. 2013

    Bootstrap 3

    A mobile-first rewrite introduces the flat design and the grid developers still recognise.

    13
  3. 2018

    Bootstrap 4

    Flexbox powers the grid and Sass becomes the primary customisation layer.

    18
  4. 2021

    Bootstrap 5

    jQuery is dropped, CSS custom properties arrive and the grid gains new utilities.

    21
  5. Today

    A dependable baseline

    Still the fastest way to build a conventional, responsive interface.

    Today

The complete guide

Bootstrap: Everything you need to know

What is Bootstrap?

Bootstrap is a component-first CSS framework. Instead of giving you primitives and asking you to assemble them, it hands you finished pieces: a responsive navbar, a modal, a card, a carousel, a full form system and a twelve-column grid. Drop in the stylesheet, copy some markup and you have a working interface in minutes.

It was created at Twitter in 2011 to bring consistency to internal tools and then open-sourced. More than a decade later it is still one of the most widely used front-end frameworks in the world, powering admin panels, marketing sites, prototypes and enterprise applications.

The responsive grid

The grid is the heart of Bootstrap. It is a twelve-column flexbox system built from three pieces: a container, rows and columns.

<!-- grid.html -->
<div class="container">
  <div class="row g-4">
    <div class="col-12 col-md-6 col-lg-4">One</div>
    <div class="col-12 col-md-6 col-lg-4">Two</div>
    <div class="col-12 col-md-6 col-lg-4">Three</div>
  </div>
</div>

Read col-12 col-md-6 col-lg-4 as: full width on phones, half width from the md breakpoint, one third from lg. Bootstrap is mobile-first, so unprefixed classes apply everywhere and prefixed ones apply from that breakpoint upward.

Breakpoint Prefix Applies from
Extra small (none) 0
Small sm 576px
Medium md 768px
Large lg 992px
Extra large xl 1200px
Extra extra large xxl 1400px

The g-* classes set gutters, and the same row system handles offsets, ordering and auto-layout columns when you need more than even thirds.

Containers

Every layout starts with a container, which sets a max width and centres your content with responsive padding.

<!-- containers.html -->
<div class="container">Fixed width, responsive</div>
<div class="container-fluid">Full width, edge to edge</div>
<div class="container-md">Full width until md, then fixed</div>

Use container for most pages, container-fluid for dashboards and full-bleed sections, and the breakpoint-specific variants when a section should go edge-to-edge on small screens but settle down on large ones.

Components

Bootstrap’s component library is where it saves the most time. A few examples:

<!-- card.html -->
<div class="card" style="width: 18rem;">
  <img src="cover.jpg" class="card-img-top" alt="" />
  <div class="card-body">
    <h5 class="card-title">Card title</h5>
    <p class="card-text">A flexible content container.</p>
    <a href="#" class="btn btn-primary">Go somewhere</a>
  </div>
</div>

Buttons, alerts, badges, breadcrumbs, pagination, progress bars, tooltips, dropdowns, modals, offcanvas panels, accordions and toasts all follow the same predictable class naming. Because the components share a design language, mixing them rarely looks inconsistent.

Utilities

Bootstrap also ships a large utility layer for spacing, flexbox, display, colour and typography. These are the classes you reach for when you need a small adjustment without writing new CSS.

<!-- utilities.html -->
<div class="d-flex align-items-center justify-content-between gap-3 mt-4 p-3">
  <span class="fw-semibold text-primary">Left</span>
  <button class="btn btn-sm btn-outline-secondary">Right</button>
</div>

m-* and p-* control spacing, d-* controls display, gap-* controls flex and grid gaps, and text-* and bg-* handle colour. They are optional — the grid and components work without them — but they eliminate a lot of one-off CSS.

Interactive components with JavaScript

Bootstrap’s JavaScript plugins are driven by data attributes, so most interactions need no custom code at all.

<!-- modal.html -->
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#demo">
  Open modal
</button>

<div class="modal fade" id="demo" tabindex="-1">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Hello</h5>
        <button class="btn-close" data-bs-dismiss="modal"></button>
      </div>
      <div class="modal-body">Modal content goes here.</div>
    </div>
  </div>
</div>

The data-bs-* attributes wire the trigger to the component, and Bootstrap handles focus management, keyboard dismissal and accessibility. You can still control components programmatically with the JavaScript API when you need to.

Theming and customisation

The default look is recognisable, which is why customising matters. The recommended approach is to override Sass variables before importing Bootstrap, so the whole system recompiles around your brand.

// custom.scss
$primary: #14b8a6;
$border-radius: 0.75rem;
$font-family-sans-serif: "Inter", system-ui, sans-serif;

@import "bootstrap/scss/bootstrap";

Since Bootstrap 5, many values are also exposed as CSS custom properties, which means you can theme at runtime without a rebuild — handy for light and dark modes.

/* theme.css */
:root {
  --bs-primary: #14b8a6;
  --bs-body-bg: #0b0d0c;
  --bs-body-color: #e5e7eb;
}

When to use Bootstrap

Bootstrap is a strong fit when speed matters more than a unique visual identity: internal tools, admin dashboards, prototypes, marketing pages and projects with tight deadlines. Its grid and components let a small team ship a lot quickly, and its conventions are widely understood.

It is less compelling when you need a highly distinctive design or want to avoid the “Bootstrap look”. In those cases, a utility-first framework like Tailwind or hand-written CSS gives you more control. The right question is not which is better, but which matches the project.

Best practices

  • Customise the theme variables; do not ship the defaults untouched.
  • Use the grid for layout and utilities for spacing instead of writing one-off CSS.
  • Include only the JavaScript you need, or use the CSS-only build.
  • Keep custom CSS in a separate file and load it after Bootstrap so it wins.
  • Prefer Bootstrap’s spacing utilities over arbitrary margins for consistency.
  • Use semantic HTML inside the component classes for accessibility.
  • Check components at every breakpoint, not just desktop.

Common mistakes

  • Forgetting the container, so rows lose their alignment and gutters.
  • Nesting containers instead of using a single outer container with nested rows.
  • Overriding styles with !important instead of customising variables.
  • Loading custom CSS before Bootstrap and then fighting the cascade.
  • Using the JavaScript bundle when a CSS-only page would do.
  • Leaving the default blue everywhere and wondering why the site looks generic.

Where to go next

Bootstrap gives you a fast, conventional starting point. Pair it with a solid understanding of the CSS Grid it wraps, learn responsive design properly, and compare the approach with Tailwind CSS before committing to one for a long-lived project.

Building a row

Bootstrap's grid is faster for standard layouts, while custom CSS gives exact control when the design is unusual.

Bootstrap
<div class="row g-4">
  <div class="col-12 col-md-6">A</div>
  <div class="col-12 col-md-6">B</div>
</div>
Custom CSS
.row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}
@media (max-width: 768px) {
  .row { grid-template-columns: 1fr; }
}

Spacing an element

Use utility classes for one-off spacing instead of inventing new CSS rules.

Prefer
<section class="mt-5 p-4">
  <h2 class="mb-3">Title</h2>
</section>
Avoid
/* new CSS for a one-off gap */
.section {
  margin-top: 3rem;
  padding: 1.5rem;
}

FAQ

Frequently asked questions

Keep learning

Related topics from the roadmap.

$ start learning

Ready to start learning Bootstrap?

Our interactive tutorial walks you through Bootstrap step by step — with quizzes and real code you can run in the browser.