agyanadda@gmail.com

Tailwind Utility-First Concept

Tailwind Basics 1 min read Updated Dec 1, 2026 Topic 3 of 27

Tailwind class names follow simple patterns. Once you learn them, you can guess most classes.

Pattern: property-value

Class CSS
p-4 padding: 1rem
mt-2 margin-top: 0.5rem
text-lg larger font size
font-bold font-weight: 700
bg-red-500 red background
w-full width: 100%
flex display: flex

The spacing scale

One step = 0.25rem (4px). So p-1 = 4px, p-4 = 16px, p-8 = 32px.

The colour scale

Every colour has shades from 50 (lightest) to 950 (darkest): bg-blue-50, bg-blue-500, bg-blue-900.

Variants with a colon

Prefix a class to apply it only in a state or screen size: hover:bg-blue-700, md:text-xl, dark:text-white.

Compared to normal CSS

You write no selectors and no CSS file — the class list is the design.

Example

Example — Same design: CSS vs Tailwind HTML
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
<style>
  .alert-css { background: #fef3c7; color: #92400e; padding: 1rem; border-radius: .5rem; border-left: 4px solid #f59e0b; margin: 1rem; }
</style>

<div class="alert-css">Written with normal CSS (style block + class name)</div>

<div class="bg-amber-100 text-amber-800 p-4 rounded-lg border-l-4 border-amber-500 m-4">Written with Tailwind utilities only</div>

Test Yourself With Exercises

Exercise 1 Multiple Choice

How much is p-4 in Tailwind?

Exercise 2 True / False

bg-blue-900 is darker than bg-blue-100.

Exercise 3 Fill in the Blank

Variants like hover and md are separated from the class with a ___.

Frequently Asked Questions

You do not need to. Learn the patterns, keep the official docs open, and install the Tailwind CSS IntelliSense extension in VS Code for autocomplete.