Tailwind replaces writing CSS files with composing utility classes directly in HTML. This lesson covers setup, the utility-first philosophy, and building layouts with Flexbox and Grid.
Traditional CSS: you write .card { padding: 16px; background: white; border-radius: 8px; } in a CSS file, then apply class="card". With Tailwind: class="p-4 bg-white rounded-lg". No separate CSS file. No naming classes.
The tradeoff: HTML gets more verbose, but you never context-switch to a CSS file and you never worry about naming. Most developers prefer it after one project.
npm create vite@latest my-app -- --template vanilla
cd my-app && npm install
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p/** @type {import('tailwindcss').Config} */
export default {
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx,vue,svelte}'],
theme: { extend: {} },
plugins: []
}@tailwind base;
@tailwind components;
@tailwind utilities;
Spacing
Heading
Body text
Blue background
Warm box
Sized box
Left (grows)
Right (fixed)
Title
Content
Main
Sidebar
Card
p-4 is 16px, p-6 is 24px, p-8 is 32px. After a day of using it, you internalize the scale and stop thinking in pixels.p-4=16px, p-6=24px, p-8=32px.flex items-center justify-between gap-4 — the most common flex pattern.grid grid-cols-3 gap-6 — three equal columns with 24px gap.