Originally published on CodingCush.
Tailwind CSS is a CSS framework that lets you style a web page by adding small ready made classes directly to your HTML, instead of writing custom CSS rules in a separate file. Each class does one small job, such as adding padding, setting a colour, or centring text. You combine these small classes like building blocks until the page looks the way you want. It is free and open source, and it is one of the most popular ways beginners style their first real websites today.
How Utility-First CSS Actually Works
In plain CSS you invent a class name, then write the rules for it. In Tailwind you skip the inventing, because the class name is the rule. The class bg-blue-500 gives an element a blue background. The class text-white makes its text white. The class p-6 adds padding on all four sides. You read a Tailwind class and you already know what it does, which is why the style is called utility-first. Here is the whole idea in one button:
<button class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded-xl">
Follow Me
</button>
That one line builds a blue button with white bold text, padding, rounded corners, and a darker blue on hover. Plain CSS would need a class name, a rule block, a hover rule, and a stylesheet. The official utility-first docs show the same idea with a small chat message card, and it is worth a look because the example is tiny and the result looks finished.
Your First Tailwind Page in 3 Steps
You can try Tailwind in under a minute with the Play CDN. One script tag loads Tailwind in the browser, so there is nothing to install. It is meant for learning and quick experiments, not for a finished production site.
Step 1. Create a plain HTML file and add the Play CDN script inside the <head> tag. The current script, from the official Play CDN page, is this:
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
</head>
<body>
<h1 class="text-2xl font-bold text-center mt-4">Hello, Tailwind!</h1>
</body>
</html>
Step 2. Open the file in your browser. You should see a large bold centred heading near the top of the page.
Step 3. Change a class and refresh. Try text-blue-500 on the heading, or swap mt-4 for mt-16 and watch it slide down. That instant feedback is the fastest way to learn.
The Utility Groups You Will Actually Use
Tailwind has hundreds of classes, but beginners use the same small set over and over. Learn these groups and you can style most pages.
1. Layout: flex, grid, and centring
-
flexandgrid: turn an element into a flexbox or grid container, so its children line up in a row or a neat grid. -
items-centerandjustify-center: centre children vertically and horizontally inside a flex container. -
min-h-screen: make a section at least as tall as the browser window, handy for a hero section or a centred card. -
grid-cols-1andmd:grid-cols-2: one column on a phone, two columns from the medium screen size up. Themd:part is a breakpoint prefix.
With flex, centring is one line: flex items-center justify-center min-h-screen on the parent. Our guide to how to center a div in CSS shows the same trick in plain CSS first.
2. Spacing: padding and margin
-
p-6: padding on all four sides. The number is a step on a spacing scale, sop-2is tight andp-8is roomy. -
px-4andpy-2: padding on the left and right only, or on the top and bottom only. -
mt-4andmb-2: margin on the top or the bottom, for pushing elements away from their neighbours. -
gap-4: space between the children of a flex or grid container, without margins on each child.
3. Text: size, weight, and alignment
-
text-sm,text-xl, andtext-2xl: small text, large text, and extra large text. Bigger numbers mean bigger text. -
font-boldandfont-medium: bold text and medium weight text. -
text-center: centre aligned text.
4. Colour and background
-
bg-whiteandbg-gray-100: a white background and a very light grey background, the classic card on a page combination. -
bg-blue-500: a medium blue. Shades run from 50, the lightest, to 950, the darkest. -
hover:bg-blue-600: change the background only while the mouse hovers over the element. Thehover:part is a state prefix, likemd:is a breakpoint prefix.
5. Borders, corners, and shadows
-
rounded-xl: nicely rounded corners. A smaller step,rounded, gives a slight curve. -
rounded-full: fully round corners, which turns a square image into a circle, perfect for avatars. -
shadow-lg: a large soft shadow that lifts a card off the page. -
max-w-sm: cap the width of an element so a card never stretches across a wide screen.
The official Tailwind CSS docs page "Styling with utility classes", showing the ChitChat message example built from utility classes.
Build a Profile Card With What You Just Learned
Now put the groups together. This profile card uses only classes from the cheatsheet above.
<body class="bg-gray-100 flex items-center justify-center min-h-screen">
<div class="bg-white rounded-xl shadow-lg p-6 max-w-sm text-center">
<img class="w-24 h-24 rounded-full mx-auto" src="avatar.jpg" alt="Priya Sharma" />
<h2 class="text-xl font-bold mt-4">Priya Sharma</h2>
<p class="text-gray-600 text-sm mt-2">Front-end developer learning Tailwind CSS.</p>
<button class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded-xl mt-4">
Follow Me
</button>
</div>
</body>
Expected output: a light grey page with one white card dead centre: a round photo, the name in large bold text, a small grey bio line, and a blue Follow Me button that darkens on hover. Swap avatar.jpg for a real image of your own. Build this card and you can build pricing, product, and testimonial cards too, because they are all the same pattern.
Tailwind vs Plain CSS: A Quick Comparison
| Question | Plain CSS | Tailwind CSS |
|---|---|---|
| Where does the style live? | In a separate stylesheet, under a class name you invent | Right in the HTML, as utility classes |
| How fast is the first styled button? | Minutes, with a class name, a rule, and a hover rule | Seconds, with one line of classes |
| How do you make it responsive? | Write your own media queries | Add a prefix such as md: to a class |
| Best for a beginner? | Best for learning how CSS truly works | Best for shipping a good looking page fast |
Neither side wins outright. Learn plain CSS first so you understand the classes, then let Tailwind do the typing. If you prefer a visual tool, the Webflow Designer beginner tour shows the drag and drop side of the same ideas.
Common Mistakes Beginners Make
-
Forgetting the script tag. If no Tailwind styles appear at all, check the Play CDN script is inside the
<head>and that you are online. Without it, the classes are just words in your HTML. -
Inventing a class name.
text-bigandbg-lightbluedo not exist. Use the scale:text-xlfor size andbg-sky-400for a light blue. If a class does nothing, check it against the docs first. - Using the Play CDN for a real project. The CDN is a learning tool. A finished site should use the proper Tailwind installation, which only ships the classes you actually use and keeps the site fast.
-
Forgetting that Tailwind resets styles. Tailwind includes a reset called Preflight, so headings lose their default size until you style them. If your heading looks small, that is why. Add
text-2xl font-boldand it is back.
Frequently Asked Questions
Is Tailwind CSS free?
Yes. Tailwind CSS is free and open source, and you can use it in personal and commercial projects without paying anything.
Do I need to know CSS before learning Tailwind?
It helps a lot. Tailwind classes map to CSS properties, so knowing what padding, margin, and flexbox mean makes every class obvious. You can learn both at the same time, but do not skip the CSS basics entirely.
Is Tailwind better than Bootstrap?
They solve the same problem in different ways. Bootstrap gives you ready made components such as navbars and modals, while Tailwind gives you small utilities to build your own components exactly the way you want.
Can I use Tailwind for a real job?
Yes. Tailwind is used in production by many companies, and it is a solid skill on a front-end developer CV. If you are planning that career path, our guide on how to become a front-end developer lays out the full road map, and Tailwind sits neatly in the styling step of it.
Conclusion
Tailwind CSS trades custom CSS rules for small ready made classes you combine in your HTML. Learn the five utility groups here, build the profile card once by hand, and you have the core skill. Then keep this cheatsheet beside you and style your next page with Tailwind.

Top comments (0)