The grid is the heart of Bootstrap. It splits a row into 12 columns that you combine to build layouts.
The three parts
<div class="container">
<div class="row">
<div class="col-md-8">Main</div>
<div class="col-md-4">Sidebar</div>
</div>
</div>
.container— the outer box.row— a horizontal group of columns.col-*— the columns; their numbers should add up to 12
Breakpoint classes
| Class | Applies from |
|---|---|
col- |
all screens |
col-sm- |
≥ 576px |
col-md- |
≥ 768px |
col-lg- |
≥ 992px |
col-xl- |
≥ 1200px |
col-xxl- |
≥ 1400px |
col-md-6 means: half width from tablets up, full width (stacked) on phones. This is mobile-first.
Auto columns
Use just .col and the columns share the space equally.
Example
Example — Responsive grid layout
HTML
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<style>.row > div { border: 1px solid #fff; padding: 12px; color: #fff; }</style>
<div class="container my-3">
<div class="row">
<div class="col bg-primary">col</div>
<div class="col bg-primary">col</div>
<div class="col bg-primary">col</div>
</div>
<div class="row">
<div class="col-md-8 bg-success">col-md-8 (main)</div>
<div class="col-md-4 bg-dark">col-md-4 (sidebar)</div>
</div>
<div class="row">
<div class="col-6 col-lg-3 bg-secondary">6 / lg-3</div>
<div class="col-6 col-lg-3 bg-secondary">6 / lg-3</div>
<div class="col-6 col-lg-3 bg-secondary">6 / lg-3</div>
<div class="col-6 col-lg-3 bg-secondary">6 / lg-3</div>
</div>
</div>
Resize the preview: columns stack or rearrange at different widths.
Try it Now »