Introduction to Bootstrap
Bootstrap is a free, open-source front-end toolkit made of a CSS file and an optional JavaScript file. It gives you a responsive grid, consistent default styles and a set of ready-made components such as navbars, buttons, cards, forms and modals. You add its classes to your HTML, and the page picks up a tidy, mobile-friendly design without you writing all the CSS by hand. It is a good fit for dashboards, admin panels, prototypes and content sites where speed matters more than a unique visual identity.
What Bootstrap gives you out of the box
- Reboot: a light reset that makes elements look the same across browsers and sets sensible fonts and spacing.
- Layout: containers and a twelve-column flexbox grid with breakpoints for phones, tablets and desktops.
- Content styles: typography, tables, images and figures.
- Components: navbars, dropdowns, cards, modals, carousels, accordions, toasts and more.
- Utilities: small classes for spacing, colours, flexbox, borders and visibility.
How it connects to what you learned in CSS3 Responsive
In plain CSS you wrote media queries yourself. Bootstrap ships those media queries already, organised around named breakpoints: sm, md, lg, xl and xxl. It is mobile first, which means a class without a breakpoint applies to all screens, and a class with one, such as col-md-6, applies from that width upward. You still need to understand how media queries work, because you will override Bootstrap with your own CSS from time to time.
Adding Bootstrap to a page
The quickest way is the CDN links. For projects with a build step, you can install it with npm and import the files.
<head>
<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">
</head>
<body>
<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container">
<a class="navbar-brand" href="#">MySite</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#mainNav" aria-controls="mainNav"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="mainNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link active" href="#">Home</a></li>
<li class="nav-item"><a class="nav-link" href="#">Contact</a></li>
</ul>
</div>
</div>
</nav>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
That snippet produces a navbar that collapses into a hamburger menu on small screens, with no custom CSS or JavaScript.
Bootstrap 5 versus older versions
Bootstrap 5 dropped its dependency on jQuery, so its components run on plain JavaScript. It also removed support for Internet Explorer, renamed directional classes to use start and end instead of left and right, and added CSS custom properties so you can theme it more easily. It supports a dark colour mode through the data-bs-theme="dark" attribute. When you search for help, check that the answer is for version 5.
The trade-off to keep in mind
Because so many sites use Bootstrap, an untouched Bootstrap site can look generic. The common mistake is fighting the framework with heavy overrides marked !important, which makes the CSS hard to maintain. A better approach is to change Bootstrap's variables, either through its CSS custom properties or by compiling its Sass source with your own colours and fonts. Also, the full CSS file is fairly large; if you only use a few components, a Sass build lets you import just those parts.
In short
Bootstrap is a toolkit of responsive layout, base styles, components and utilities. Add the viewport tag and the CSS, load the JS bundle if you need interactive parts, and customise through variables rather than overrides.
Ready to master real-world web development?
Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.