Bootstrap 5 is a modern, mobile-first front-end framework designed to accelerate responsive web development. It provides a cohesive suite of prebuilt components, utilities, and a flexible grid system—all built on standard HTML, CSS, and JavaScript (with no jQuery dependency). Unlike earlier versions, Bootstrap 5 drops support for Internet Explorer entirely, enabling leaner code, improved performance, and broader adoption of modern browser APIs.
Installation Options
Local File Integration
After downloading the official Bootstrap 5 compiled release from getbootstrap.com, extract the archive to reveal a structured directory:
bootstrap/
├── css/
│ ├── bootstrap.min.css
│ ├── bootstrap.min.css.map
│ ├── bootstrap.rtl.min.css
│ └── ...
└── js/
├── bootstrap.bundle.min.js
├── bootstrap.bundle.min.js.map
└── ...
To use locally, place the bootstrap/ folder alongside your project’s HTML files, then reference the core assets in your document:
- In the
<head>:
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet"> - Just before
</body>:
<script src="bootstrap/js/bootstrap.bundle.min.js"></script>
The bootstrap.bundle.min.js file includes Popper.js—required for dropdowns, tooltips, and popovers—so no additional dependencies are needed.
Minimal HTML Template
A valid Bootstrap 5 starter template includes essential meta tags for responsiveness:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<title>Bootstrap 5 Starter</title>
</head>
<body>
<!-- Your content here -->
<script src="bootstrap/js/bootstrap.bundle.min.js"></script>
</body>
</html>
Note the critical <meta name="viewport"> tag—it ensures proper scaling and touch behavior across devices.
CDN Integration
For rapid prototyping or lightweight projects, leverage a trusted CDN:
<!-- CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- JS (includes Popper) -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
Container Classes
Containers establish the foundational layout context for Bootstrap content. They provide padding, centering, and responsive width constraints.
.container: Fixed-width container with breakpoints that scale max-width per screen size..container-fluid: Full-width container (width: 100%) with no max-width limits..container-{sm|md|lg|xl|xxl}: Responsive containers that activate at specified breakpoints (e.g.,.container-mdbehaves like.container-fluidbelow 768px, then applies fixed widths above).
Example breakpoint behavior for .container-lg:
| Breakpoint | <576px | ≥576px | ≥768px | ≥992px | ≥1200px | ≥1400px |
|---|---|---|---|---|---|---|
| Max-width | 100% | 100% | 100% | 960px | 1140px | 1320px |
Usage:
<div class="container-lg">Responsive max-width container</div>
<div class="container-fluid">Full-bleed layout</div>
Grid System Architecture
Bootstrap’s grid is a 12-column, responsive, flexbox-based system. Columns automatically wrap, reorder, and resize based on viewport width using breakpoint-specific classes.
Core Column Classes
.col: Equal-width columns (flex: 1) — no breakpoint prefix..col-sm-*,.col-md-*,.col-lg-*,.col-xl-*,.col-xxl-*: Responsive column widths starting at defined breakpoints.
Each number (e.g., -4) represents how many of the 12 available columns the element occupies.
Structural Rules
- Containers (
.containeror.container-fluid) must wrap rows. - Rows (
.row) contain only columns (.col-*); nesting rows directly inside columns is discouraged. - Column sums per row should not exceed 12 (though Bootstrap handles overflow gracefully).
Practical Examples
Twelve equal columns on medium+ screens:
<div class="container">
<div class="row">
<div class="col-md-1">1</div>
<div class="col-md-1">2</div>
<div class="col-md-1">3</div>
<div class="col-md-1">4</div>
<div class="col-md-1">5</div>
<div class="col-md-1">6</div>
<div class="col-md-1">7</div>
<div class="col-md-1">8</div>
<div class="col-md-1">9</div>
<div class="col-md-1">10</div>
<div class="col-md-1">11</div>
<div class="col-md-1">12</div>
</div>
</div>
Three equal-width columns on medium+ screens (stacked on mobile):
<div class="row">
<div class="col-md-4">Left</div>
<div class="col-md-4">Center</div>
<div class="col-md-4">Right</div>
</div>
Mixed-width layout (4 + 8 columns) starting at small screens:
<div class="row">
<div class="col-sm-4">Sidebar</div>
<div class="col-sm-8">Main content</div>
</div>