Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 37 ยท Getting Started

What Is Tailwind CSS?

Learn what Tailwind CSS v4 is, how utility-first styling differs from writing your own CSS classes, and when it is a good fit for your project.

Tailwind CSS is a CSS framework made of small, single-purpose classes called utilities. Instead of inventing a class name such as .profile-card and writing a block of CSS for it, you describe the look directly in your HTML: rounded-xl, bg-white, p-6, text-slate-700. Each class does exactly one thing, and you combine them to build any design.

This track teaches Tailwind CSS v4, the current major version. You will learn the utilities, how to make layouts that adapt to every screen, how to add dark mode and your own design tokens, and how to keep a large project tidy. You only need basic HTML and a little CSS knowledge; if you know what padding and display: flex mean, you are ready. If not, skim the CSS tutorial first.

The idea: utility-first

Traditional CSS separates structure from style. You write HTML with semantic class names, then style them somewhere else:

HTML
<div class="notice">Saved!</div>
CSS
.notice {
  padding: 1rem;
  border-radius: 0.5rem;
  background: #ecfdf5;
  color: #065f46;
}

With Tailwind you skip the stylesheet and put the declarations in the class list:

HTML
<div class="rounded-lg bg-emerald-50 p-4 text-emerald-800">Saved!</div>

Every class maps to one or two CSS declarations. p-4 means padding: 1rem (the number is a step on a spacing scale), rounded-lg sets a border radius, bg-emerald-50 picks a very light green from the built-in palette. There is no custom name to invent, and nothing to keep in sync between two files.

A notice built from utilities

Change emerald to sky or p-4 to p-8 and watch the result. That edit-and-look loop is the whole workflow.

What you get

Tailwind in a nutshell

Utilities One class, one job.
Design scale Spacing, colors, sizes.
Variants md:, hover:, dark:
1 / 2

Three ideas make Tailwind work:

  1. A constrained design scale. Spacing, font sizes, colors, shadows and breakpoints come from a fixed set of values. You pick p-4 or p-6, not an arbitrary 17px. Designs end up consistent without effort.
  2. Variants. Prefixes such as hover:, focus:, md: and dark: apply a utility only in some state or screen size: hover:bg-sky-700 or md:flex. You never write a media query by hand.
  3. On-demand output. Tailwind scans your files for class names and generates only the CSS you use. A typical production stylesheet is tiny, often well under 10 kB compressed.

A first look at variants

Here is a button that changes color on hover and gets bigger on wider screens. Hover it, and in the TryIt panel drag the preview wider if you can.

Hover and responsive variants

hover:bg-sky-700 means "on hover, use this background". md:px-6 means "from the md breakpoint (768px) upward, use this padding". Unprefixed utilities are the mobile-first default. Chapter 5 covers this in depth.

"Isn't this just inline styles?"

It looks similar, but utilities are different in ways that matter:

Inline styles Tailwind utilities
Any value you like Values from a shared scale
No hover, focus or media queries Variants for states, breakpoints, dark mode
Cannot be cached or reused as CSS One stylesheet, cached by the browser
Specificity wins over everything Normal, low-specificity classes

You also keep the benefits of components: when a pattern repeats, you extract it into a template partial or a framework component rather than a CSS class. The Utility-First Workflow previews this, and chapter 7 explores it fully.

Honest trade-offs

Tailwind is not magic. Long class lists make some HTML noisy, and teammates have to learn the vocabulary (an editor extension with autocomplete helps a lot). It also pushes you to reuse through components, so a project that is plain HTML copied across dozens of files will feel repetitive. In return you get fast iteration, consistent design and no dead CSS. Many teams find the trade worthwhile, others prefer semantic CSS or Bootstrap. Both are valid; you can judge for yourself after this track.

What is new in v4

Version 4 (released in 2025) rewrote the engine. The changes you will notice:

  • CSS-first configuration. You customize Tailwind in your CSS file with @theme instead of a JavaScript tailwind.config.js.
  • One import. @import "tailwindcss"; replaces the three @tailwind directives.
  • Automatic content detection. No content array: Tailwind finds your templates itself.
  • Modern CSS underneath. Colors use oklch(), and utilities are built on cascade layers, @property and color-mix().
  • Much faster builds, with a first-party Vite plugin.

Some class names also changed from v3 (for example shadow-sm became shadow-xs, and bg-gradient-to-r became bg-linear-to-r). This track uses the v4 names throughout and points out renames where they matter.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does the utility class p-4 do?

    p-4 is a step on the spacing scale; in v4 one step is 0.25rem, so p-4 is padding: 1rem.
  2. 2. Which prefix applies a utility only when the pointer is over the element?

    hover: is a variant. hover:bg-sky-700 changes the background on hover only.
  3. 3. How is a Tailwind utility different from an inline style?

    Utilities are real CSS classes, so variants can target hover, screen sizes and dark mode, which inline styles cannot.
  4. 4. How does v4 prefer you to customize design tokens?

    v4 uses CSS-first configuration: tokens are declared in your stylesheet with @theme.

Summary

  • Tailwind CSS is a utility-first framework: small classes that each do one job, combined in your HTML.
  • Values come from a design scale, so spacing, colors and sizes stay consistent.
  • Variants like hover:, md: and dark: handle states and screen sizes.
  • Only the classes you use end up in the final CSS.
  • v4 adds CSS-first configuration, one @import, automatic content detection and a faster engine.

Next: Installing Tailwind CSS