Bootstrap is the world's most popular open-source CSS framework. It provides a collection of ready-made components, a powerful grid system, and helpful utility classes that let you build responsive, mobile-first websites quickly and consistently — without writing a lot of custom CSS from scratch.
Building a website from scratch requires a lot of effort. Bootstrap solves common problems by giving you:
| Feature | Plain CSS | Bootstrap |
|---|---|---|
| Responsive grid | Write manually | Built-in (12-col grid) |
| UI Components | Build from scratch | Ready-to-use |
| JavaScript widgets | Needs custom JS | Included (modals, dropdowns…) |
| Learning curve | Low (just CSS) | Low (class-based) |
| File size | Minimal | Larger (CDN makes it fast) |
The easiest way to get started is to include Bootstrap from a CDN (Content Delivery Network) — no download required.
Paste this <link> tag inside your HTML <head> section:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css">
Paste this <script> tag just before the closing </body> tag to enable interactive components like modals and dropdowns:
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js"></script>
Here is a complete, working Bootstrap starter template:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Bootstrap Page</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<h1 class="text-primary mt-4">Hello, Bootstrap!</h1>
<p class="lead">This is my first Bootstrap page.</p>
<button class="btn btn-success">Click Me</button>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
meta name="viewport" tag is required for Bootstrap's responsive behaviour to work correctly on mobile devices.
| Concept | Description | Example Class |
|---|---|---|
| Container | Centers and constrains your page content | container, container-fluid |
| Grid | 12-column layout system using rows and columns | row, col-md-6 |
| Components | Ready-made UI elements | btn, card, navbar |
| Utilities | Helper classes for spacing, color, text, etc. | mt-3, text-center, bg-dark |
| Breakpoints | Screen size targets for responsive design | sm, md, lg, xl |
viewport meta tag for responsive behaviour