Direct answer
Tailwind CSS is a utility-first CSS framework. You style each element with small classes such as flex, p-6 and text-center, written in your HTML. Tailwind then generates only the CSS those classes need. This page shows how it works with code, how it compares with plain CSS and Bootstrap, and how to install it.

What is Tailwind CSS?
Tailwind CSS is a utility-first CSS framework. Instead of writing a .card or .button rule in a stylesheet, you put small single-purpose classes on the element itself: flex for layout, p-6 for padding, rounded-xl for corners, text-xl for size.
Tailwind's own description is that the classes "can be composed to build any design, directly in your markup". You get building blocks and design the components yourself.
Tailwind does not ship one big stylesheet. When you build your project, it scans your HTML, JavaScript components and templates for class names and writes only the CSS for the classes it finds. It has no runtime in the browser.
How Tailwind works: a card built from utility classes
Here is a small notification card from Tailwind's own docs. Every style comes from a class in the markup, and no separate CSS file is needed.
<div class="mx-auto flex max-w-sm items-center gap-x-4 rounded-xl bg-white p-6 shadow-lg">
<img class="size-12 shrink-0" src="/logo.svg" alt="ChitChat logo" />
<div>
<div class="text-xl font-medium text-black">ChitChat</div>
<p class="text-gray-500">You have a new message!</p>
</div>
</div>What each class in that card does
| Classes | CSS property | Effect on the card |
|---|---|---|
flex, shrink-0, p-6 | CSS property display, flex-shrink, padding | Effect on the card Lays out the logo and text side by side with padding |
max-w-sm, mx-auto | CSS property max-width, margin | Effect on the card Caps the card width and centers it |
bg-white, rounded-xl, shadow-lg | CSS property background, border-radius, box-shadow | Effect on the card Gives the card its surface |
size-12 | CSS property width and height | Effect on the card Sets the logo to a fixed square |
gap-x-4 | CSS property gap | Effect on the card Spaces the logo from the text |
text-xl, font-medium, text-gray-500 | CSS property font-size, font-weight, color | Effect on the card Styles the title and message |
Tailwind vs traditional CSS: the same button twice
With traditional CSS you name the element, write a rule for it in a separate file, and keep the two files matching. Here is a button styled the traditional way, used in HTML as <button class="btn-primary">Save changes</button>:
.btn-primary {
padding: 0.5rem 1.25rem;
border-radius: 9999px;
background-color: #8b5cf6;
color: #fff;
font-weight: 600;
}
.btn-primary:hover {
background-color: #6d28d9;
}The same button with Tailwind utility classes
The hover style moves into the class list with the hover: variant, so there is no second rule to keep in step with the first.
<button class="rounded-full bg-violet-500 px-5 py-2 font-semibold text-white hover:bg-violet-700">
Save changes
</button>Why developers choose utility classes
Tailwind's docs give four reasons:
- Faster work: you stop inventing class names and switching between HTML and CSS files.
- Safer changes: adding or removing a class affects only that element, so you do not break another page that shares the same CSS.
- Easier maintenance: to change an old screen you find the element and edit its classes, instead of tracing custom CSS you wrote months ago.
- Portable code: structure and styling live together, so you can copy a block of UI between projects.
Is Tailwind just inline styles?
No. Tailwind's docs name three differences:
- Utilities come from a design system, so you pick set spacing and color values instead of typing magic numbers.
- Utilities can style states such as hover and focus. Inline styles cannot.
- Utilities can apply from a breakpoint up. Inline styles cannot use media queries.
Responsive design with breakpoint prefixes
Every utility can apply from a breakpoint up. Put the breakpoint name and a colon before the class. Tailwind is mobile-first: an unprefixed class applies everywhere, and md:w-32 applies from the md breakpoint up. To style phones, use the unprefixed class and override it at larger breakpoints.
<img class="w-16 md:w-32 lg:w-48" src="/photo.jpg" alt="Team photo" />
<div class="text-center sm:text-left">Centered on phones, left-aligned from sm up</div>Tailwind's default breakpoints
| Prefix | Minimum width | Media query |
|---|---|---|
sm | Minimum width 40rem (640px) | Media query @media (width >= 40rem) |
md | Minimum width 48rem (768px) | Media query @media (width >= 48rem) |
lg | Minimum width 64rem (1024px) | Media query @media (width >= 64rem) |
xl | Minimum width 80rem (1280px) | Media query @media (width >= 80rem) |
2xl | Minimum width 96rem (1536px) | Media query @media (width >= 96rem) |
Hover, focus and dark mode
State variants work the same way as breakpoints: hover:, focus:, disabled: and dark: apply a class only when that condition is true, and you can stack them, as in disabled:hover:bg-sky-500. The dark: variant follows the visitor's system setting through prefers-color-scheme by default.
<button class="bg-sky-500 hover:bg-sky-700 focus:outline-2 disabled:hover:bg-sky-500 dark:bg-sky-600">
Save changes
</button>How to install Tailwind CSS with Vite
Tailwind's recommended setup for Vite-based frameworks, such as SvelteKit, React Router and Nuxt, takes three steps. First, create the project and install the two packages:
npm create vite@latest my-project
cd my-project
npm install tailwindcss @tailwindcss/viteTailwind CSS in four steps
The four steps, in the order you take them.

- Step 1: Install Tailwind
- Step 2: Import it in CSS
- Step 3: Use utility classes
- Step 4: Set colors in @theme
Add the Tailwind plugin to Vite
Second, add the plugin to your Vite configuration file:
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [tailwindcss()],
})Import Tailwind in your CSS
Third, import Tailwind at the top of your main CSS file. You can then use utility classes in your markup.
@import "tailwindcss";Customize the theme and Tailwind CSS colors with @theme
Since version 4 you set Tailwind up in CSS instead of a tailwind.config.js file. Theme values are CSS variables inside an @theme block, and each one creates matching utilities. Tailwind CSS colors follow the same rule: the default palette gives every color 11 shades, from 50 to 950, written in OKLCH, and a new --color-* variable adds a color of your own.
@import "tailwindcss";
@theme {
--color-brand: oklch(0.62 0.19 260);
--font-display: "Inter", sans-serif;
--breakpoint-3xl: 120rem;
}
/* Now bg-brand, text-brand, font-display and 3xl: are available */Tailwind vs Bootstrap
Both are mobile-first CSS frameworks. They differ in what they hand you.
| What you compare | Tailwind CSS | Bootstrap |
|---|---|---|
What you get | Tailwind CSS Low-level utility classes you combine into any design | Bootstrap Prebuilt components such as navbars, modals, carousels and dropdowns |
JavaScript | Tailwind CSS None; behavior comes from your own code or a component library | Bootstrap A JavaScript bundle for modals, dropdowns, tooltips and other interactive parts |
Look out of the box | Tailwind CSS No set look; you design every component | Bootstrap Bootstrap's own visual style unless you customize it |
CSS shipped | Tailwind CSS Only the classes your files use | Bootstrap The full compiled stylesheet, unless you build only the Sass parts you need |
Customizing | Tailwind CSS CSS variables in @theme | Bootstrap Sass variables |
What changed in Tailwind CSS v4
Version 4 brought five main changes:
- A new engine: full builds up to 5 times faster and incremental builds over 100 times faster, by Tailwind's own measurements.
- CSS-first configuration: design tokens live in @theme as native CSS variables instead of a JavaScript settings file.
- Zero configuration: one @import line, and no list of template paths to maintain.
- A first-party Vite plugin, @tailwindcss/vite, alongside the PostCSS plugin.
- Container queries in core, plus 3D transforms, radial and conic gradients, and a not-* variant.
When Tailwind fits, and when it does not
Two cases where it fits, two that need care, and one where another tool is faster:
- It fits when you build your own design system and want styles from one set of tokens, with no unused CSS shipped.
- It fits component frameworks such as React and Vue, where a repeated pattern becomes a component instead of a CSS class.
- It needs care when classes conflict: two utilities for the same property on one element give an unpredictable winner, so components should expose props rather than accept extra classes.
- On a project with heavy existing CSS, Tailwind's important flag or prefix option keeps its utilities from clashing with older rules.
- If you want ready-made components and a set look on day one, a component framework such as Bootstrap gets you there with less design work.
Steal this workflow
Run this guide in your own assistant. The prompt carries the guide link and the workflow summary, so the assistant can adapt it to your project.
Read the guide "What is Tailwind CSS? How utility classes work, with code examples" at https://better-design.com/blog/what-is-tailwind-css and help me apply it to my project.
Tailwind CSS is a utility-first CSS framework. You style each element with small classes such as flex, p-6 and text-center, written in your HTML. Tailwind then generates only the CSS those classes need. This page shows how it works with code, how it compares with plain CSS and Bootstrap, and how to install it.
Start by asking what I am building and which tools I use. Then walk me through the workflow step by step, adapted to my answers.Claude and ChatGPT open with the prompt filled in. Gemini copies the prompt to your clipboard first, so paste it when the app opens.
Questions
What is Tailwind CSS used for?
Styling websites and apps directly in the markup with utility classes, instead of writing a custom CSS rule for each component.
Is Tailwind CSS just inline styles?
No. Utilities draw from a design system, can style hover and focus states, and can apply at breakpoints. Inline styles can do none of those.
Is Tailwind better than Bootstrap?
They solve different problems. Tailwind gives you building blocks for your own design. Bootstrap gives you finished components with its own look and JavaScript.
Does Tailwind CSS make my CSS file large?
No. Tailwind scans your files and writes only the classes you use, and removes unused CSS in production builds.
How do Tailwind CSS colors work?
Each default color has 11 shades from 50 to 950, exposed as CSS variables such as --color-blue-500. Add your own with a --color-* variable in @theme.
Where these Tailwind CSS facts come from
Each fact comes from the pages listed here, read on November 13, 2026. Products change, so check those pages for the current version.
Related
Build the interface in your own code instead
A coding agent such as Claude Code, Cursor or Codex can build your interface in your own code. Better Design gives that agent a design system, interface principles and review rules, so the result looks designed.