agyanadda@gmail.com

Bootstrap Grid System

Bootstrap Basics 1 min read Updated Dec 1, 2026 Topic 4 of 32

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 »

Test Yourself With Exercises

Exercise 1 Multiple Choice

How many columns does one Bootstrap row have?

Exercise 2 True / False

col-md-6 makes a column half width on phones.

Exercise 3 Fill in the Blank

Columns must be placed inside a ___ element.

Frequently Asked Questions

The extra columns wrap onto a new line.