Mobile-first layouts with Bootstrap 5

Beginner  Oct 30, 2026

How the Bootstrap grid works and how to build a clean responsive page quickly.

Mobile-first layouts with Bootstrap 5
The steps of this tutorial at a glance.
The steps of this tutorial at a glance.

Add Bootstrap

Put these in your page (use the current version from the Bootstrap website):

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
How the code in this section fits into the page.
How the code in this section fits into the page.

The grid in one minute

A page is made of a container, rows and columns. Each row has 12 columns. Size classes tell a column how wide to be at each screen size:

<div class="container">
  <div class="row g-4">
    <div class="col-12 col-md-6 col-lg-4">Box 1</div>
    <div class="col-12 col-md-6 col-lg-4">Box 2</div>
    <div class="col-12 col-md-12 col-lg-4">Box 3</div>
  </div>
</div>
  • col-12 means full width on phones
  • col-md-6 means half width from tablets up
  • col-lg-4 means one third from desktops up
The grid in one minute
The grid in one minute

Helpful utilities

  • Spacing: mt-3, py-5, mb-4
  • Text: text-center, fw-bold
  • Show or hide: d-none d-md-block
The main points of this section.
The main points of this section.

Tip

Do not fight the framework. Use the classes first and add only a small custom CSS file for your own brand colours and fonts.

More tutorials