Lesson 1
10 min
Understand what Tailwind CSS is and why the utility-first approach changes the way you style a page.
Definition
Tailwind CSS is a utility-first CSS framework: instead of writing CSS rules yourself in a separate file, you style your elements directly in your HTML by combining small utility classes , each one responsible for a single visual property. For example,text-center centers the text,flex enables Flexbox andp-4 adds padding. By putting them together, you build complex interfaces without ever leaving your markup.
This approach is very different from "classic" CSS, where you would write a semantic class such as .product-card and then define its style in a separate CSS file. With Tailwind, the.product-card class no longer exists: you replace it with a combination of utility classes that you can read directly in the HTML.
The term utility-first literally means "utilities come first". You always start from utility classes to build your design, and you only create your own CSS class in the rare cases where it is truly necessary. This is the opposite of the usual approach, where you write custom CSS first and only use ready-made classes as a complement.
<!-- Classic CSS -->
<div class="product-card">My product</div>
<style>
.product-card {
padding: 1rem;
border-radius: 0.75rem;
background-color: white;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
</style>
<!-- With Tailwind CSS -->
<div class="p-4 rounded-xl bg-white shadow-sm">
My product
</div>In this example, each Tailwind class corresponds to exactly one CSS declaration: p-4 gives padding: 1rem,rounded-xl gives border-radius: 0.75rem,bg-white gives background-color: white andshadow-sm adds a subtle shadow. You get essentially the same result, but with no CSS file to maintain and no class name to invent.

Tailwind provides a consistent vocabulary of classes that you learn progressively. Most of them follow a simple, easy-to-remember logic: a prefix that indicates the property, followed by a value taken from a predefined scale.
p-4 (padding),m-2 (margin), gap-6 (gap). The number follows a scale where 4 corresponds to 1rem, or 16px.bg-blue-500 (background),text-slate-900 (text), border-red-300(border). Each color comes in shades from 50 to950.text-lg (size),font-bold (weight), leading-relaxed (line height).flex, grid,items-center, justify-between to align and organize your elements.You can then add a prefix in front of a class to change its behavior depending on the context: hover: on hover,focus: on focus, dark: in dark mode, ormd: from a medium-sized screen and up.
<button
class="px-4 py-2 rounded-lg bg-blue-600 text-white
hover:bg-blue-700 focus:ring-2 focus:ring-blue-300
dark:bg-blue-500 md:px-6 md:text-lg"
>
Send
</button>This single button handles its normal appearance, its hover state, its focus state, dark mode and a larger version on medium screens, all without writing a single line of CSS or a media query.
Tailwind has become established in a great many professional projects in recent years, for several concrete reasons:
!important everywhere).At first glance, Tailwind often comes as a surprise: it is criticized for producing "cluttered" HTML with lots of classes. This is a legitimate criticism, but it deserves some nuance:
hover:), breakpoints (md:) and a design scale, which is impossible with the style attribute.No, this is a common misconception. Tailwind is not a library of ready-made components like Bootstrap: it does not provide a ready-made "blue button". It provides the basic building blocks (colors, spacing, typography, layout) that you assemble yourself to create yourdesign, unique to your project. This is precisely why two sites built with Tailwind rarely look alike, unlike two Bootstrap sites.
Tailwind does include a base layer called Preflight , which normalizes the browsers' default styles (heading margins, list bullets, etc.). But this is only a clean starting point: the core of Tailwind remains its utility classes.
Tailwind is a great fit for the majority of modern web projects: showcase sites, applications, dashboards, blogs, online stores. It is particularly at ease with component-based approaches, because the style stays attached to the component that uses it.
It is, however, less relevant when you have to style content you do not control (for example HTML generated by a rich-text editor), or when a team already enforces a design system based on classic CSS. In the first case, the official @tailwindcss/typography plugin and itsprose class (used on this page) let you format plain text without adding classes to every tag.
Above all, remember this: Tailwind does not replace CSS, it simplifies it. Understanding the basics (box model, Flexbox, Grid, positioning) remains essential, because every Tailwind class is just a faster way of writing a CSS property you already know.
This course takes you step by step from installing Tailwind to building complete responsive interfaces: utility classes, colors and typography, spacing, Flexbox and Grid with Tailwind, responsive design, pseudo-classes (hover, focus, dark mode), theme customization, and finally best practices for keeping your code clean and maintainable on a real project.
To follow along comfortably, it is recommended that you know the basics of HTML and CSS (tags, selectors, notions of margins and colors). You do not need to master JavaScript: Tailwind is used simply by adding classes to your elements.
In the next lesson, you will install Tailwind in a project and write your first classes. Don't worry if the list of classes seems long for now: everything becomes natural with a bit of practice, and you will quickly recognize the patterns that keep coming back.
Before you continue
{ margin-top: 1rem; } would probably become themt-4 class.