TExcelTAD
Home › Tailwind CSS › Tailwind Intro

Tailwind CSS Introduction

Tailwind CSS is a utility-first CSS framework. Instead of giving you ready-made components such as "card" or "navbar", it gives you hundreds of tiny, single-purpose classes — p-4 adds padding, text-center centres text, bg-sky-500 paints a blue background — and you build any design by combining them directly in your HTML.

This course teaches Tailwind CSS v4, the current major version. v4 was rewritten from the ground up: it is configured in CSS instead of JavaScript, uses modern CSS features such as cascade layers and oklch() colours, and builds much faster than v3.

A first look

Here is a small card styled entirely with Tailwind classes. Press ▶ Run, then try changing bg-sky-500 to bg-rose-500 or rounded-xl to rounded-none.

html · try it yourself
<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4.1.11"></script>
</head>
<body class="flex min-h-screen items-center justify-center bg-slate-100 p-4">
  <div class="max-w-xs rounded-xl bg-white p-6 shadow-lg">
    <div class="mb-3 flex size-12 items-center justify-center rounded-full bg-sky-500 text-2xl">🌊</div>
    <h1 class="text-xl font-bold text-slate-900">Hello, Tailwind!</h1>
    <p class="mt-2 text-slate-600">Every style on this card comes from a utility class.</p>
  </div>
</body>
</html>

Not a single line of custom CSS was written. Each class maps to one (or a few) CSS declarations:

Class CSS it generates
p-6 padding: calc(var(--spacing) * 6); (1.5rem)
rounded-xl border-radius: var(--radius-xl); (0.75rem)
bg-white background-color: var(--color-white);
shadow-lg a large, soft box-shadow
text-xl font-size: 1.25rem; plus a matching line height
font-bold font-weight: 700;

Why utility-first?

Traditional CSS asks you to invent class names (.profile-card__title--large), switch between two files, and worry that changing a rule might break a page you forgot about. Tailwind turns that around:

  • No naming — you describe what it looks like, not what it is called.
  • Local changes — editing the classes on one element can't break another element.
  • A built-in design system — spacing, colours and font sizes come from a consistent scale, so designs stay harmonious.
  • Tiny CSS in production — Tailwind scans your files and only generates CSS for the classes you actually use.
  • Responsive and interactive styles inline — prefixes such as md: and hover: work on every utility.
html · try it yourself
<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4.1.11"></script>
</head>
<body class="p-6">
  <button class="rounded-lg bg-indigo-600 px-5 py-2.5 font-semibold text-white hover:bg-indigo-500 active:scale-95">
    Hover and click me
  </button>
  <p class="mt-4 text-sm text-gray-500">The <code>hover:</code> and <code>active:</code> prefixes add interactive styles without writing CSS.</p>
</body>
</html>

"Isn't this just inline styles?"

It looks similar, but utilities are far more powerful than the style attribute:

Feature style="…" Tailwind classes
Hover / focus states ❌ impossible ✅ hover:bg-blue-600
Media queries ❌ impossible ✅ md:flex
Dark mode ❌ impossible ✅ dark:bg-gray-900
Consistent design scale ❌ any value goes ✅ p-4, p-6, p-8 …
Pseudo-elements ❌ ✅ before:content-['★']

Note: Long class lists are the trade-off. In real projects you tame repetition with components (a React/Vue component or a template partial) — see Reusing Styles & Components later in the course.

How this course works

Every runnable example on ExcelTAD loads Tailwind's official browser build from a CDN with one <script> tag. It compiles the classes it finds in the page on the fly, which is perfect for learning. In the next lesson you'll also see how real projects install Tailwind with Vite.

Tip: The preview pane is resizable. Drag its edge in the responsive lessons to watch layouts change at different widths.

Test yourself

What does 'utility-first' mean in Tailwind CSS?

  1. You import pre-built components like .card and .navbar
  2. You style elements by combining small single-purpose classes
  3. You write all CSS in JavaScript objects
  4. You must use inline style attributes

Which of these can Tailwind classes do that a style attribute cannot?

  1. Set a colour
  2. Set padding
  3. Apply styles only on hover or at a breakpoint
  4. Change font size

Where is Tailwind CSS v4 primarily configured?

  1. In tailwind.config.js only
  2. In your CSS file, using directives like @theme
  3. In package.json
  4. In an HTML <meta> tag