Episode 1 — Fundamentals / 1.9 — CSS Responsive Design

1.9.g — CSS Frameworks Overview

In one sentence: CSS frameworks provide pre-built styles and layout systems that speed up development — they come in utility-first, component-based, and hybrid flavors, each with trade-offs you should understand before adopting one.

Navigation: ← 1.9.f — Spacing & Rhythm · 1.9 Overview →


1. What is a CSS framework?

A CSS framework is a pre-written collection of CSS (and sometimes JavaScript) that provides:

  • A reset/normalize for consistent cross-browser defaults.
  • A grid/layout system for responsive page structure.
  • Pre-styled components (buttons, cards, forms, modals).
  • Utility classes or design tokens for rapid styling.

Instead of writing every style from scratch, you use the framework's conventions and customize where needed.


2. Framework categories

CategoryPhilosophyExample
Utility-firstSmall, single-purpose classes composed in HTMLTailwind CSS
Component-basedPre-designed components you drop in and customizeBootstrap, Bulma
HybridMix of pre-built components + utility classesFoundation

3. Component-based: Bootstrap

Bootstrap is the most widely-used CSS framework. It provides ready-made components with a class-based API.

How it works

<div class="container">
  <div class="row">
    <div class="col-md-8">Main content</div>
    <div class="col-md-4">Sidebar</div>
  </div>
</div>

<button class="btn btn-primary btn-lg">Get Started</button>

<div class="card">
  <img src="photo.jpg" class="card-img-top" alt="…" />
  <div class="card-body">
    <h5 class="card-title">Card title</h5>
    <p class="card-text">Some text.</p>
  </div>
</div>

Pros

AdvantageDetail
Fast prototypingDrop in classes, get polished components instantly
ComprehensiveModals, tooltips, carousels, forms — all included
DocumentationExtensive, well-organized docs with examples
Team familiarityMost developers have used Bootstrap at some point

Cons

DisadvantageDetail
Bundle sizeFull Bootstrap CSS is ~230 KB uncompressed (can be reduced with tree-shaking)
Generic lookSites look "Bootstrap-y" without significant customization
Override battlesCustomizing deeply means fighting specificity
Opinionated structureYour HTML is shaped by the framework's grid/class conventions

4. Utility-first: Tailwind CSS

Tailwind CSS provides low-level utility classes. You compose them directly in your HTML instead of writing custom CSS.

How it works

<div class="max-w-7xl mx-auto px-4">
  <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
    <div class="bg-white rounded-lg shadow-md p-6">
      <h3 class="text-xl font-bold mb-2">Card title</h3>
      <p class="text-gray-600">Some text.</p>
    </div>
  </div>
</div>

<button class="bg-blue-600 hover:bg-blue-700 text-white font-semibold
               py-3 px-6 rounded-lg transition-colors">
  Get Started
</button>

Pros

AdvantageDetail
No naming fatigueNo inventing class names like .card-wrapper-inner
Small production CSSPurges unused classes — final bundle often < 15 KB
Design consistencyConstrained values from a config (spacing, colors, sizes)
Rapid iterationChange styles without switching files

Cons

DisadvantageDetail
Verbose HTMLLong class strings reduce readability
Learning curveMust memorize utility class names
Tight couplingStyling lives in markup — harder to separate concerns
Custom CSS still neededComplex animations, pseudo-element patterns need regular CSS

5. Other frameworks (brief mentions)

FrameworkCategoryNotable trait
BulmaComponent-basedFlexbox-only, no JavaScript dependency
FoundationHybridEnterprise-grade, accessible, extensive grid
Pico CSSClasslessSemantic HTML looks good with zero classes
Open PropsToken libraryCSS custom properties for building your own system

6. When to use a framework vs custom CSS

ScenarioRecommendation
Prototype / MVPFramework — ship fast, iterate on design later
Marketing site / unique brandCustom CSS — frameworks fight custom design
Large team, many developersFramework — shared conventions reduce inconsistency
Learning CSSCustom CSS first — understand what frameworks abstract
Component library / design systemCustom or token library — full control over API
Admin dashboardFramework — components (tables, forms, modals) accelerate work

Rule of thumb: If the framework saves more time than it costs in customization and overrides, use it. If you spend more time fighting it than building, go custom.


7. Framework comparison at a glance

FeatureBootstrap 5Tailwind CSSCustom CSS
Pre-built componentsYes (50+)No (build your own)No
Bundle size (prod)~50 KB (purged)~10–15 KB (purged)Depends
Responsive grid12-column flex gridUtility-based grid/flexYour choice
CustomizationSass variables, themestailwind.config.jsUnlimited
JavaScript includedYes (dropdowns, modals)No (pair with headless UI)Your choice
Learning curveLow–MediumMediumVaries
Design uniquenessLow (without customization)HighHighest

8. Getting started (preview for 1.11)

Both Bootstrap and Tailwind will be covered in depth in Section 1.11. For now, understand the categories and trade-offs. When you reach 1.11:

  • Bootstrap: install via npm or CDN, use the class-based component API, customize with Sass variables.
  • Tailwind: install via npm, configure tailwind.config.js, add the Tailwind directives to your CSS, use utility classes in HTML.
# Bootstrap quick start
npm install bootstrap

# Tailwind quick start
npm install -D tailwindcss
npx tailwindcss init

9. Key takeaways

  1. Utility-first (Tailwind) = compose styles from small classes. Component-based (Bootstrap) = use pre-designed components.
  2. Frameworks trade control for speed — understand what you're giving up.
  3. Production bundle size matters — always purge/tree-shake unused framework CSS.
  4. Learn custom CSS first — frameworks are abstractions over concepts you need to understand.
  5. Pick the framework that matches your project type, team size, and design goals.

Explain-It Challenge

Explain without notes:

  1. What is the fundamental difference between how you build a card component in Bootstrap vs Tailwind?
  2. A teammate argues "we should use a framework so we don't need to learn CSS." Why is this problematic?
  3. When would custom CSS be a better choice than any framework, even for a large team?

Navigation: ← 1.9.f — Spacing & Rhythm · 1.9 Overview →