Aral Code

Layout Lesson 4 of 12

Bootstrap Responsive Breakpoints

Make layouts change with screen size using breakpoints sm, md, lg, xl and xxl, combine column classes, reorder columns, and hide or show content on phones.

The real power of the grid is that columns can have different widths on different screen sizes: stacked on a phone, side by side on a laptop. Bootstrap does this with breakpoints.

Breakpoints

NameInfixScreen widthTypical device
Extra small(none)under 576pxPhones
Smallsm≥ 576pxLarge phones
Mediummd≥ 768pxTablets
Largelg≥ 992pxLaptops
Extra largexl≥ 1200pxDesktops
XXLxxl≥ 1400pxBig monitors

A class like col-md-6 means "6 columns wide from medium screens up". Below medium, the column falls back to full width.

Stack on phones, side by side on bigger screens

Example Resize to see the change
<link rel="stylesheet" href="/vendor/bootstrap.min.css">
<div class="container py-3">
  <div class="row g-3">
    <div class="col-12 col-md-4"><div class="p-3 bg-primary-subtle">🧮 Math</div></div>
    <div class="col-12 col-md-4"><div class="p-3 bg-success-subtle">🔬 Science</div></div>
    <div class="col-12 col-md-4"><div class="p-3 bg-warning-subtle">📚 English</div></div>
  </div>
</div>

Open this on a phone, or press Try it and look at the result panel: in a narrow frame the boxes stack; at 768px or wider they sit in three columns. (col-12 is the default, so class="col-md-4" alone works too.)

Several breakpoints at once

Example 1, 2, 3 or 4 per row
<link rel="stylesheet" href="/vendor/bootstrap.min.css">
<div class="container py-3">
  <div class="row g-2">
    <div class="col-12 col-sm-6 col-lg-4 col-xl-3"><div class="p-3 border">Product 1</div></div>
    <div class="col-12 col-sm-6 col-lg-4 col-xl-3"><div class="p-3 border">Product 2</div></div>
    <div class="col-12 col-sm-6 col-lg-4 col-xl-3"><div class="p-3 border">Product 3</div></div>
    <div class="col-12 col-sm-6 col-lg-4 col-xl-3"><div class="p-3 border">Product 4</div></div>
  </div>
</div>

One per row on phones, two from sm, three from lg, four from xl. This is the typical layout for product grids.

The shortcut: row-cols

<div class="row row-cols-1 row-cols-sm-2 row-cols-lg-4 g-3">
  <div class="col">...</div>
  <div class="col">...</div>
</div>

row-cols-* on the row sets how many columns per line, so each child only needs col.

Showing and hiding by screen size

Example Different content on phones and laptops
<link rel="stylesheet" href="/vendor/bootstrap.min.css">
<div class="container py-3">
  <p class="d-md-none alert alert-warning">📱 You're on a small screen.</p>
  <p class="d-none d-md-block alert alert-success">💻 You're on a medium or larger screen.</p>
</div>
  • d-none hides an element on all sizes.
  • d-md-block shows it (as a block) from medium up.
  • d-md-none hides it from medium up.

Reordering columns

Example Sidebar first on laptops, last on phones
<link rel="stylesheet" href="/vendor/bootstrap.min.css">
<div class="container py-3">
  <div class="row g-2">
    <div class="col-md-8 order-md-2"><div class="p-3 bg-light border">Main content</div></div>
    <div class="col-md-4 order-md-1"><div class="p-3 bg-info-subtle">Sidebar</div></div>
  </div>
</div>

In the HTML, the main content comes first (good for phones and screen readers). From md up, order-md-1 moves the sidebar to the left.

Quick Quiz

Check what you learned. Walang grade ito, practice lang. 🙂

1. What does col-md-6 mean?
2. What width is a column with only col-lg-4 on a phone?
3. Which classes hide an element on phones but show it from md up?
4. What does row-cols-2 do?

By Sir Reyel · Last updated 2026-12-04