Bootstrap CSS
Bootstrap CSS is the stylesheet part of Bootstrap 5: a ready-made set of base styles and utility classes that you apply by adding class names to your HTML. Instead of writing your own CSS for spacing, colours, borders or alignment, you add classes like mt-3 or text-center and get consistent, responsive results across the page.
Adding the stylesheet to a page
The quickest way is to link the compiled file from a CDN in the <head>, along with the viewport meta tag that Bootstrap's responsive features rely on. In larger projects you can install it with npm install bootstrap and import it through your build tool.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<title>Bootstrap page</title>
</head>
<body>
<div class="container py-4">
<h2 class="text-primary mb-3">Welcome</h2>
<p class="lead">Styled with Bootstrap classes only.</p>
<div class="p-3 bg-light border rounded-3 shadow-sm">
A padded, bordered box with rounded corners.
</div>
</div>
</body>
</html>
Reboot: the base layer
When the stylesheet loads, it first applies Reboot, a set of element-level rules. Reboot sets box-sizing: border-box on every element, removes the default top margin from headings and paragraphs, uses a system font stack and gives the body a sensible line height. That is why a page looks slightly different the moment you add Bootstrap, even before you use a single class.
Reading utility class names
Most utilities follow a short pattern of property, side and size. Learning the pattern once lets you guess the rest:
| Class | What it does |
|---|---|
m-0, mt-3, mx-auto | Margin on all sides, top, or left and right. |
p-2, px-4, py-5 | Padding, on the same side scheme. |
text-center, text-md-start | Text alignment, optionally from a breakpoint up. |
bg-dark, text-white, text-body-secondary | Background and text colours from the theme. |
d-none, d-md-block, d-flex | Display values, including responsive show and hide. |
border, rounded, shadow | Borders, corner radius and box shadows. |
Spacing sizes run from 0 to 5, each a fixed step based on the root font size. Inserting a breakpoint, as in mt-md-5, applies the rule only from that screen width upward, matching Bootstrap's mobile-first approach.
CSS variables and theming
Bootstrap 5 exposes many values as CSS custom properties, such as --bs-primary and --bs-body-font-size. You can override some of them in your own stylesheet for small changes. For deeper theme changes, like a new primary colour that updates every button and link state, the recommended route is compiling Bootstrap from its Sass source with your own variables. Version 5.3 also supports a dark colour mode through data-bs-theme="dark" on an element.
Common mistake: fighting the cascade
Beginners often write a custom rule like .btn { padding: 4px; } and find it ignored. Usually the custom stylesheet is linked before Bootstrap, so Bootstrap's rule wins. Link your own CSS after Bootstrap. Avoid sprinkling !important to force changes; note that utility classes already use !important on purpose, so a utility such as p-0 will beat your normal rules. If you keep overriding the same thing, a utility or a theme variable is usually the better tool.
In short
Bootstrap CSS gives you Reboot defaults plus a predictable utility vocabulary. Link it with the viewport tag, learn the property-side-size naming, add breakpoints for responsive tweaks, and load your own styles afterwards so small customisations apply cleanly.
Ready to master real-world web development?
Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.