1 · Layout & grid systems
The 12-column grid is the skeleton of every Bootstrap page. Container holds it, rows slice it horizontally, columns divide each row.
Container
.container
The foundational building block. Wraps your page content, sets a responsive max-width at each breakpoint and centres everything horizontally. Almost every page starts with one.
.container-fluid for full width.Grid row
.row
A wrapper built exclusively to hold columns. Uses flexbox plus negative-margin maths so columns sit perfectly flush with the container's edges.
Grid columns
.col-*
Slices each row into fractions of a standard 12-column grid — .col-6 is half the row, .col-4 is a third. Add a breakpoint infix (.col-md-6) to change the split per screen size.
sm · md · lg · xl · xxlGutter controls
.g-*
Controls the horizontal and vertical spacing between columns without shifting their alignment. Set it once on the .row and every column follows.
.gx-* horizontal only · .gy-* vertical only<div class="container">
<div class="row g-3">
<div class="col-md-8">Main content</div>
<div class="col-md-4">Sidebar</div>
</div>
</div>
Live grid — shrink the window below 768px and the columns stack:
.col-md-4.col-md-4.col-md-4.col-md-8.col-md-4| Breakpoint | Class infix | Kicks in at | .container max-width |
|---|---|---|---|
| Extra small | (none) — .col-6 | < 576px | 100% |
| Small | sm | ≥ 576px | 540px |
| Medium | md | ≥ 768px | 720px |
| Large | lg | ≥ 992px | 960px |
| Extra large | xl | ≥ 1200px | 1140px |
| Extra extra large | xxl | ≥ 1400px | 1320px |
Think in twelfths
Column numbers in one row should add up to 12 (8 + 4, 4 + 4 + 4, 6 + 6…). Go over 12 and the extra columns wrap onto a new line — that wrapping is exactly what makes the grid responsive.
2 · Form components
Native form elements look different in every browser. These classes normalise them into clean, full-width fields with consistent focus styling.
Form control
.form-control
Turns plain text inputs and textareas into full-width, fluid fields with padding, borders and a custom focus state that match the rest of the framework.
<input> or <textarea>Form select
.form-select
Overrides the native platform appearance of dropdowns so a <select> looks identical in every browser, while keeping proper sizing and spacing.
<select> lookChecks & radios
.form-check
Wraps checkboxes and radio buttons in custom-rendered styling and keeps the label wired to its input. Toggle states stay clean and consistent.
.form-switch for toggle switchesInput group
.input-group
Bolts static text, buttons or icons onto the front or back edge of an input — think an @ before a username field, or a search button after a query box.
<label for="email" class="form-label">Email</label>
<input type="email" class="form-control" id="email" placeholder="you@example.com">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="darkMode">
<label class="form-check-label" for="darkMode">Dark mode</label>
</div>
Live form — every field below is one of the four classes above:
Checks & switches · .form-check
Every input needs a label
Pair each input with a <label for="…"> that matches the input's id. Screen readers rely on it, and clicking the label focuses the field — free usability.
4 · Overlays & content
Content containers and the layers that appear over the page. Cards are everyday workhorses; the other three are JavaScript-powered overlays.
Card panel
.card
The all-purpose content container: optional header, image cap, body text and an action footer. You will use these constantly — the hub's tiles are cards.
Modal popups
.modal
A lightweight dialog that opens over the whole viewport. Bootstrap manages the backdrop, locks body scrolling and traps keyboard focus so you don't have to.
Accordion
.accordion
Vertically stacked sections where clicking a header expands its panel. Panels can open one-at-a-time or independently, toggled via JavaScript events.
Offcanvas
.offcanvas
A hidden sidebar that slides in smoothly from any screen edge — left, right, top or bottom. Great for mobile menus and filter panels.
<!-- Trigger -->
<button class="btn btn-dark" data-bs-toggle="modal" data-bs-target="#myModal">
Open modal
</button>
<!-- The modal itself (hidden until triggered) -->
<div class="modal fade" id="myModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Hello!</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">Modal content goes here.</div>
</div>
</div>
</div>
Live card — every part is labelled with its own class:
.card-headerHeads up — modal, accordion & offcanvas need JavaScript
Cards are pure CSS, but anything that opens, closes or slides needs Bootstrap's JS bundle. If your modal does nothing when clicked, you forgot this line just before </body>:
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>