Skip to content
BENIBIX Learn

CSS Frameworks and Sass

Level 4 · Page layout

How CSS variables, Sass, Bootstrap and Tailwind save you from writing the same styles twice. What each one adds, and what it costs.

Course contentsLesson 11 of 14

After this lesson you can

  • Set and reuse a CSS custom property
  • Say what Sass adds and how it becomes CSS
  • Tell Bootstrap's style from Tailwind's

13 mincovers 5 glossary entries

Worth reading first: CSS Selectors and Specificity

What each CSS tool saves you from writing

Plain CSS repeats itself fast. The same brand colour may appear 40 times in one file. Four tools cut that down. CSS custom properties store a value once. Sass adds extra features and turns into plain CSS. Bootstrap and Tailwind are CSS frameworks, ready-made sets of styles you use by class name.

A custom property, often called a CSS variable, is a name that starts with two dashes. You set --brand: #2a6df4 once, usually on :root, and use it with var(--brand) anywhere. Change the one line and every use changes. It also works live in the browser, so a dark theme can swap a few values.

Sass is a language that is turned into plain CSS before the browser sees it. Its files end in .scss. It lets you nest rules inside each other, split styles across many files, and write mixins, which are reusable chunks of styles. Browsers never read Sass itself. A build step turns it into a .css file.

Custom properties now do part of what Sass was used for. Plain CSS has started to allow nesting too. Sass is still common in older and larger projects. Many new projects use custom properties and plain CSS, and skip the extra step.

Bootstrap is a set of ready parts: buttons, menus, cards and forms, each with its own class. Its layout grid has 12 columns, so a box with class col-6 takes half the row. It first came out in 2011. Sites built with it are quick to make, and they often look alike.

Tailwind CSS takes another route. Each class does one small job: p-4 adds padding, text-lg makes text larger, flex turns on Flexbox. You build the look in the HTML from dozens of these. A build step then keeps only the classes you used, so the final CSS file stays small.

People often think a framework means you no longer need to learn CSS. But each Bootstrap class and each Tailwind class is plain CSS inside. When a layout breaks, you fix it with the same box model and the same scoring rules as before.

css
:root {
  --brand: #2a6df4;
  --space: 1rem;
}

.button {
  background: var(--brand);
  padding: var(--space);
}
Set the brand colour once. Every rule that uses var(--brand) follows when it changes.
Each tool saves writing the same CSS twice. All of them end as plain CSS in the browser.

Worked example

Emma rebrands a site in one line

Emma's client changes its brand colour from green to blue. The old CSS used the green code in 63 places.

She moves it into one custom property, --brand, and points all 63 rules at var(--brand). Next time the colour changes, she edits one line.

The words for this lesson5

Check yourself

Does a browser read Sass files directly?

Finished this lesson?

Marking it complete also marks its 5 glossary entries learned, which updates your roadmap and your saved page. 0 are already marked.