CSS Frameworks
A CSS framework is a ready-made collection of styles (and sometimes JavaScript) that helps you build interfaces faster. The two most popular are Bootstrap, which gives you finished components, and Tailwind CSS, which gives you small single-purpose classes to compose your own design. Both are free and open source.
Why use a framework?
- Speed: buttons, grids, forms and navigation bars are ready to use.
- Consistency: a shared system of spacing, colours and breakpoints across a team.
- Tested defaults: responsive and cross-browser behaviour that many people have already debugged.
The trade-offs are extra code to download or learn, and a risk that your site looks like many others. Most importantly, a framework doesn't replace knowing CSS: when something breaks or needs customising, you'll be reading and writing plain CSS anyway.
Bootstrap: components first
Bootstrap was created at Twitter by Mark Otto and Jacob Thornton and released as open source in 2011. It provides pre-designed components that you use by adding class names to your HTML: buttons, cards, navbars, modals, alerts, forms and a responsive 12-column grid. Some interactive components (dropdowns, modals) come with Bootstrap's own JavaScript.
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Weekly data bundle</h5>
<p class="card-text">5 GB for KES 300.</p>
<a href="#" class="btn btn-primary">Buy now</a>
</div>
</div>
</div>
</div>
</div>
With Bootstrap's stylesheet linked, this shows a bordered card containing a heading, text and a solid blue "Buy now" button. col-md-6 means "take 6 of the 12 columns (half the row) on medium screens and wider"; on smaller screens it fills the full width. You add Bootstrap by linking its CSS file (from a CDN or installed with npm); copy the exact link from the official documentation at getbootstrap.com. It can be customised by overriding its Sass variables or CSS variables.
Tailwind CSS: utility first
Tailwind takes the opposite approach. Instead of components, it provides thousands of tiny utility classes, each doing one job, such as p-4 (padding), bg-green-600 (background colour), rounded-lg (border radius) or flex. You build the design directly in your HTML by combining them.
<div class="max-w-sm rounded-lg bg-white p-6 shadow-md"> <h5 class="text-xl font-bold">Weekly data bundle</h5> <p class="mt-2 text-gray-600">5 GB for KES 300.</p> <a href="#" class="mt-4 inline-block rounded-md bg-green-600 px-4 py-2 text-white hover:bg-green-700">Buy now</a> </div>
Prefixes handle states and screen sizes: hover:bg-green-700 applies on hover, and md:grid-cols-3 applies three grid columns from the medium breakpoint upwards (Tailwind is mobile-first). Tailwind is normally installed with a build tool: it scans your HTML and JavaScript files and generates a stylesheet containing only the classes you actually used, which keeps the final CSS small. Its design scale (spacing, colours, fonts) can be customised in your project's configuration.
Comparing the approaches
| Bootstrap | Tailwind CSS | |
|---|---|---|
| Philosophy | Pre-built components | Small utility classes you combine |
| Typical HTML | class="btn btn-primary" | class="rounded bg-blue-600 px-4 py-2 text-white" |
| Look out of the box | Recognisable "Bootstrap" style unless customised | No default look; you design everything |
| Setup | Link one CSS file to start | Usually needs a build step |
| Strengths | Fast prototypes, admin dashboards, teams without a designer | Custom designs, component-based apps (React, Vue), consistent design tokens |
| Common criticism | Sites can look alike; overriding styles can fight specificity | Long class lists can make HTML harder to read |
Understanding utilities by building some
Utility classes are just ordinary CSS rules with one declaration each. Writing a few yourself shows exactly what a utility framework does, and needs no download:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Home-made utilities</title>
<style>
body { font-family: system-ui, sans-serif; margin: 1.5rem; background: #f1f5f9; }
/* component style */
.card { background: white; border-radius: 10px; padding: 1.5rem; max-width: 320px; }
.btn { display: inline-block; padding: 0.5rem 1rem; border-radius: 6px; background: #15803d; color: white; text-decoration: none; }
/* utility style: one job per class */
.p-6 { padding: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.bg-white { background: white; }
.rounded-lg { border-radius: 10px; }
.max-w-sm { max-width: 320px; }
.font-bold { font-weight: 700; }
.text-gray { color: #4b5563; }
.inline-block { display: inline-block; }
.px-4 { padding-inline: 1rem; }
.py-2 { padding-block: 0.5rem; }
.bg-green { background: #15803d; }
.text-white { color: white; }
.rounded-md { border-radius: 6px; }
</style>
</head>
<body>
<div class="card">
<h3>Component approach</h3>
<p>5 GB for KES 300.</p>
<a href="#" class="btn">Buy now</a>
</div>
<div class="bg-white rounded-lg p-6 max-w-sm mt-4">
<h3 class="font-bold">Utility approach</h3>
<p class="mt-2 text-gray">5 GB for KES 300.</p>
<a href="#" class="inline-block px-4 py-2 bg-green text-white rounded-md mt-4">Buy now</a>
</div>
</body>
</html>
Two almost identical white cards appear, each with a heading, a price line and a green "Buy now" button; the second card's price is grey. The first uses two meaningful class names backed by multi-line rules; the second gets the same look by stacking single-purpose classes in the HTML. That is the whole debate in miniature.
Which should you learn?
Learn plain CSS first, ideally this whole series, because every framework is built on it. After that, try both on small projects. Bootstrap is quick for prototypes, school projects and internal tools. Tailwind is popular in modern JavaScript projects and startups. Check job adverts in your area to see what employers are asking for, and remember that a strong grasp of Flexbox, Grid and the cascade transfers to any framework.
Frameworks release new major versions from time to time, and class names can change between them. Always follow the official documentation for the version you install rather than an old tutorial.
Key points
- Frameworks speed up development with tested, consistent styles.
- Bootstrap offers ready-made components and a 12-column responsive grid.
- Tailwind offers utility classes that you combine, usually with a build step that removes unused CSS.
- Neither replaces CSS knowledge; learn the fundamentals first.
Tip: use the ← and → keys to move between pages.
