Before you begin
Know how HTML elements, classes and basic CSS work. Bootstrap makes common patterns faster; it does not remove those foundations.
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.
Know how HTML elements, classes and basic CSS work. Bootstrap makes common patterns faster; it does not remove those foundations.
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 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.
<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>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.
<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>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.
<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>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.
<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>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.
<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>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.
<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>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.
<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>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.
<html lang="en" data-bs-theme="light">
<body>
<div class="card"><div class="card-body">Theme-aware content</div></div>
</body>
</html>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.
:root {
--bs-primary: #245f4a;
--bs-primary-rgb: 36, 95, 74;
}
.btn-primary { --bs-btn-bg: #245f4a; --bs-btn-border-color: #245f4a; }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.
<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>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 →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.
The official version guide lists Bootstrap 6 as upcoming alpha. This guide uses the stable Bootstrap 5.3 line.
Core layout and visual components use CSS. Interactive components such as a collapsible navbar need Bootstrap JavaScript.