CSS framework · HTML and CSS foundations recommended

Learn Bootstrap step by step

Use Bootstrap to build responsive web pages with a grid, ready-made buttons, cards, forms and menus, then adjust the design for your project. Every module explains the idea in plain language, walks through a code example and gives you a small task to try yourself.

Version snapshot: Bootstrap 5.3.8. Latest stable 5.3 patch listed by the official version guide on 21 October 2026. Bootstrap 6 is an upcoming alpha; use it only for evaluation, not as the stable learning baseline.

Before you begin

Know how HTML elements, classes and basic CSS work. Bootstrap makes common patterns faster; it does not remove those foundations.

What you’ll be able to do

Create responsive pages with reusable Bootstrap components, minimal JavaScript and project-specific styling.

Work through the modules in order if you’re new to Bootstrap. If you already know the basics, use the contents list to jump to a topic. Try each example by changing one value, running it again and explaining the result in your own words.

Bootstrap terms in simple language

CSS framework
A collection of ready-made styles and components that helps build common page layouts faster.
Breakpoint
A screen-width point where a responsive layout can switch to a different arrangement.
Utility class
A small class that applies one common style, such as spacing or text alignment.
JavaScript plugin
Code that adds behavior to components such as a dropdown menu or collapsible navigation.
Container
A Bootstrap wrapper that controls page width and keeps content aligned.
Responsive grid
Bootstrap rows and columns that can rearrange as the screen becomes wider or narrower.
Sass customization
Changing Bootstrap’s design settings before its CSS is built, for deeper theme changes.
Color mode
A set of interface colors, such as light or dark, chosen to keep content readable.
Accessibility
Making pages and controls usable by people with different abilities and ways of interacting.
In this guide · 10 modules
  1. Key terms in simple language
  2. Add Bootstrap to a page
  3. Containers, breakpoints and the grid
  4. Spacing, display and responsive utilities
  5. Buttons, cards and alerts
  6. Navigation bars and responsive navigation
  7. Forms and validation feedback
  8. JavaScript plugins and data attributes
  9. Theme and color modes
  10. Customize Bootstrap with Sass and CSS variables
  11. Accessibility, performance and production checks
  12. Final project
  13. Official references
MODULE 01 / 10 · CONCEPT EXPLAINED

Add Bootstrap to a page

Bootstrap is a collection of ready-made CSS styles and optional JavaScript behaviors. Add its CSS file to use layout and component classes. Add the JavaScript bundle only if the page needs interactive features such as a dropdown or popup modal. Keep the CSS and JavaScript versions matched, and choose a specific version so your page does not silently change when a new release appears.

Follow this example
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" defer></script>
Try it yourself: Create a page with the official CSS and add a styled heading, button and alert.
MODULE 02 / 10 · CONCEPT EXPLAINED

Containers, breakpoints and the grid

Bootstrap’s grid helps you arrange page content into columns that can change size on different screens. A container sets a comfortable page width, a row groups columns, and column classes describe how much space each item needs. The 12-column idea is a measuring system, not a requirement to put 12 items on every page. In this example the article is wider than the related-links column on large screens, and they stack on small screens.

Follow this example
<div class="container py-4">
  <div class="row g-3">
    <main class="col-12 col-lg-8">Article</main>
    <aside class="col-12 col-lg-4">Related links</aside>
  </div>
</div>
Try it yourself: Build a two-column article layout that stacks on narrow screens.
MODULE 03 / 10 · CONCEPT EXPLAINED

Spacing, display and responsive utilities

Utilities provide common one-purpose styles such as spacing, alignment and display. Responsive infixes apply a utility from a breakpoint upward. Use a small set of consistent utilities and prefer a named component class when a page repeats the same complex pattern.

Follow this example
<section class="d-flex flex-column flex-md-row align-items-md-center gap-3 py-4">
  <h2 class="mb-0 me-md-auto">Your learning plan</h2>
  <a class="btn btn-primary" href="/learn/python">Open guide</a>
</section>
Try it yourself: Make an action row stack on mobile and align horizontally at a medium breakpoint.
MODULE 04 / 10 · CONCEPT EXPLAINED

Buttons, cards and alerts

Components combine styling conventions into predictable patterns. Use button variants for action hierarchy, card markup for grouped content and alerts for status messages. Don’t rely on color alone to communicate meaning; include clear text and choose appropriate semantics.

Follow this example
<article class="card h-100">
  <div class="card-body">
    <h2 class="h5 card-title">HTML foundations</h2>
    <p class="card-text">Build a meaningful document structure.</p>
    <a class="btn btn-primary" href="/learn/html">Start learning</a>
  </div>
</article>
Try it yourself: Build a three-card learning path and make every card action clear and keyboard accessible.
MODULE 05 / 10 · CONCEPT EXPLAINED

Navigation bars and responsive navigation

A navbar groups a brand, navigation links and responsive collapse behavior. The toggler must identify the controlled element and expose its expanded state. Use nav and list markup consistently and avoid putting every site action into one crowded menu.

Follow this example
<nav class="navbar navbar-expand-lg bg-body-tertiary">
  <div class="container">
    <a class="navbar-brand" href="/">Study Lab</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#siteNav" aria-controls="siteNav" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
    <div class="collapse navbar-collapse" id="siteNav"><div class="navbar-nav"><a class="nav-link active" href="/learn">Learn</a></div></div>
  </div>
</nav>
Try it yourself: Add a responsive navbar and verify the collapsed menu works with touch, mouse and keyboard.
MODULE 06 / 10 · CONCEPT EXPLAINED

Forms and validation feedback

Bootstrap styles form controls but native HTML still defines their behavior and accessible labels. Use the right input type and associate labels with controls. Validation feedback should tell the user what happened and how to fix it; server-side validation is still required.

Follow this example
<div class="mb-3">
  <label for="email" class="form-label">Email address</label>
  <input id="email" class="form-control" type="email" required autocomplete="email">
  <div class="form-text">Use an address you can access.</div>
</div>
Try it yourself: Create a two-field form with persistent labels and a visible validation message.
MODULE 07 / 10 · CONCEPT EXPLAINED

JavaScript plugins and data attributes

Bootstrap’s JavaScript plugins add behaviors such as collapse, modal and dropdown. The bundle includes Popper where needed. Choose either data attributes or the documented JavaScript API, and avoid initializing the same plugin twice. Make sure interactive controls work without a mouse.

Follow this example
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#infoDialog">Read details</button>
<div class="modal fade" id="infoDialog" tabindex="-1" aria-labelledby="infoTitle" aria-hidden="true">
  <div class="modal-dialog"><div class="modal-content"><div class="modal-header"><h2 class="modal-title fs-5" id="infoTitle">Course details</h2><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button></div></div></div>
</div>
Try it yourself: Add a dialog that opens from a button, has a labelled heading and can be dismissed from the keyboard.
MODULE 08 / 10 · CONCEPT EXPLAINED

Theme and color modes

Bootstrap 5.3 supports color modes that can be selected with data attributes and CSS variables. Make the chosen palette readable and ensure form controls, borders and focus indicators fit the mode. Persist a user choice only if your page provides a clear way to change it.

Follow this example
<html lang="en" data-bs-theme="light">
<body>
  <div class="card"><div class="card-body">Theme-aware content</div></div>
</body>
</html>
Try it yourself: Switch a sample page between light and dark mode and check contrast and focus states in both.
MODULE 09 / 10 · CONCEPT EXPLAINED

Customize Bootstrap with Sass and CSS variables

For small changes, override a CSS variable or add a project class after Bootstrap. For deep theme customization, compile Bootstrap Sass and set configuration before importing the framework. Keep custom rules scoped to your components so framework upgrades remain understandable.

Follow this example
:root {
  --bs-primary: #245f4a;
  --bs-primary-rgb: 36, 95, 74;
}

.btn-primary { --bs-btn-bg: #245f4a; --bs-btn-border-color: #245f4a; }
Try it yourself: Customize primary button colors and test normal, hover, focus and disabled states.
MODULE 10 / 10 · CONCEPT EXPLAINED

Accessibility, performance and production checks

Framework classes do not guarantee accessible content. Check landmarks, labels, focus order, contrast, responsive overflow and reduced-motion behavior. Include only the CSS and JavaScript features you use where the build system allows it, and test the final page in a real browser.

Follow this example
<a class="btn btn-outline-primary" href="/learn/css">
  Continue to the CSS guide
</a>
<p class="visually-hidden">This link opens the next lesson.</p>
Try it yourself: Audit a mini landing page at keyboard-only, 200% zoom and phone width; fix every issue you can reproduce.
PUT THE MODULES TOGETHER

Your final project

Create a responsive course catalogue with a filter form, cards, accessible navigation and one keyboard-friendly dialog. Write down what the project should do, build it in small steps, and include a README that explains how to run it.

Find a guided course →

Official documentation and further reading

Use primary documentation for current language rules and version changes. The examples in this guide are learning starting points; verify details for the exact runtime and browser support your project needs.

Frequently asked questions

Is Bootstrap 6 ready for production?

The official version guide lists Bootstrap 6 as upcoming alpha. This guide uses the stable Bootstrap 5.3 line.

Do I need JavaScript to use Bootstrap?

Core layout and visual components use CSS. Interactive components such as a collapsible navbar need Bootstrap JavaScript.