On this page9 sections
Lecture 057: Preprocessors & Frameworks: Sass, Bootstrap & Tailwind
| Category | 10: Tools & Workflow |
| Lecture | 057 of 057 |
| Estimated video length | 12 min |
| Target | CSS3 · any modern browser |
| Level | Intermediate |
You now know CSS itself. Many teams also use tools built on top of it. A preprocessor (Sass, Less) adds extra features and compiles to normal CSS; a framework (Bootstrap, Tailwind) gives you ready-made styles. This lecture shows what each offers, so you can choose, and read projects that use them.
Learning Objectives
- Explain what a preprocessor does and recognise Sass syntax
- Use Bootstrap's grid and components
- Read Tailwind's utility classes
- Decide when plain CSS, a preprocessor or a framework fits best
1. Sass
Sass files (.scss) are compiled into a normal .css file that the browser loads.
// variables
$brand: #1971c2;
$radius: 8px;
// mixins: reusable groups of declarations
@mixin card { padding: 16px; border-radius: $radius; box-shadow: 0 2px 8px rgba(0,0,0,.1); }
// nesting, mixins and functions
.button {
background: $brand;
border-radius: $radius;
&:hover { background: darken($brand, 10%); }
}
.product { @include card; }
// partials: split into files and combine
@use 'base';Many of Sass's best features now exist in plain CSS: variables (Lecture 046), nesting (Lecture 028) and
color-mix() (Lecture 034). Sass is still popular for mixins, loops and organising big projects.
Less is a similar, older preprocessor.
2. Bootstrap
Add Bootstrap's stylesheet and use its classes:
Example
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<div class="container py-3">
<div class="row g-3">
<div class="col-12 col-md-6"><div class="p-3 bg-primary text-white rounded">col-md-6</div></div>
<div class="col-12 col-md-6"><div class="p-3 bg-success text-white rounded">col-md-6</div></div>
</div>
<button class="btn btn-primary mt-3">Primary</button>
<button class="btn btn-outline-secondary mt-3">Secondary</button>
<div class="alert alert-warning mt-3">A ready-made alert box.</div>
</div>- A 12-column grid:
col-md-6means "half width from medium screens up". - Components: buttons, cards, navbars, modals and forms, all with consistent styles.
- Utilities:
p-3(padding),mt-3(margin-top),text-white,rounded.
3. Tailwind CSS
Tailwind is utility-first: instead of writing .card { … }, you combine small classes in the HTML.
Example
<script src="https://cdn.tailwindcss.com"></script>
<div class="max-w-sm mx-auto p-6 bg-white rounded-2xl shadow-lg flex items-center gap-4">
<div class="w-12 h-12 rounded-full bg-indigo-500"></div>
<div>
<p class="text-lg font-semibold text-gray-900">Tailwind card</p>
<p class="text-sm text-gray-500">Styled only with utility classes</p>
</div>
</div>
<button class="mt-4 px-4 py-2 rounded-lg bg-emerald-600 hover:bg-emerald-700 text-white">Hover me</button>| Class | Means |
|---|---|
p-6 | padding: 1.5rem |
mx-auto | margin-inline: auto |
flex items-center gap-4 | Flexbox, centred, 1rem gap |
md:grid-cols-3 | Three columns from medium screens up |
hover:bg-emerald-700 | Background colour on hover |
The CDN script is for trying Tailwind out; real projects install it with a build tool, which keeps only the classes you use.
4. Which Should You Use?
| Choice | Good for | Watch out for |
|---|---|---|
| Plain CSS | Learning, small sites, full control | You build every component yourself |
| Sass | Large stylesheets, design systems | A build step to compile it |
| Bootstrap | Quick, consistent sites and admin panels | Sites that all look alike unless customised |
| Tailwind | Custom designs built fast, component-based apps | Long class lists in the HTML |
Whatever you choose, it all becomes CSS in the end. Everything you've learned in this course is what makes these tools understandable.
Common Beginner Mistakes
1. Learning a framework before CSS. When something breaks, you won't know why.
2. Loading a whole framework for one button. It's a big download.
3. Fighting the framework. If you override most of Bootstrap, plain CSS (or Tailwind) may suit you better.
Practice Questions
- What does a CSS preprocessor do?
- Which Sass features now exist in plain CSS?
- In Bootstrap, what does
col-md-4mean? - What does "utility-first" mean in Tailwind?
- What does Tailwind's
md:prefix do? - Why is it worth learning plain CSS first?
Practice Answers
- It adds features such as variables, nesting and mixins, then compiles to normal CSS.
- Variables (custom properties), nesting and colour functions such as
color-mix(). - A third of the row (4 of 12 columns) on medium screens and up.
- You style elements by combining many small single-purpose classes in the HTML.
- It applies the class only from the medium breakpoint upwards.
- Every tool produces CSS, so understanding CSS lets you use, customise and debug any of them.
Key Takeaways
- Preprocessors (Sass, Less) add features and compile to CSS.
- Bootstrap gives a 12-column grid and ready components; Tailwind gives utility classes.
- Choose by project size and design needs, and remember it's all CSS underneath.
- You've finished the CSS course. Combine it with the HTML course, and you can build and style any page.