Now in this lesson, we will learn how to style text and colors — the things users notice first when viewing a UI.
By the end of this lesson, you’ll understand:
| Topic | What it means |
|---|---|
| Text size | How to make text bigger or smaller |
| Font weight | Control emphasis (bold / light / normal) |
| Text color | Apply color from Tailwind’s built-in palette |
| Background color | Color elements like buttons and sections |
| Hover color states | Change color when the user hovers |
Let’s go step-by-step.
text-*)Tailwind provides a wide range of text sizes:
<p class="text-sm">Small text</p><p class="text-base">Default text</p><p class="text-lg">Large text</p><p class="text-3xl">Very large text</p>
Common sizes you’ll use most:
| Class | Size |
|---|---|
text-sm | small text |
text-base | normal body text |
text-xl | section titles |
text-3xl | headings / hero titles |
font-*)Use font weight to emphasize text:
<p class="font-light">Thin text</p><p class="font-normal">Regular text</p><p class="font-bold">Bold text</p><p class="font-extrabold">Extra bold text</p>
text-*)Tailwind provides a large color palette. Here are examples with gray and blue:
<p class="text-gray-700">Neutral text</p><p class="text-blue-500">Colored text</p>
Common useful colors:
text-gray-600 (soft, readable)text-gray-800 (strong, high contrast)text-blue-500 (primary action)bg-*)Apply background colors easily:
<div class="bg-gray-100 p-4">Light gray background</div><button class="bg-blue-500 text-white px-4 py-2 rounded">Primary button</button>
hover:*)To add hover effects, just prefix with hover::
<button class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded">Hover Me</button>
Hover state should usually be slightly darker or lighter.
Here’s a simple hero block you can copy and use:
<section class="p-8 text-center"><h1 class="text-4xl font-bold text-gray-900 mb-4">Welcome to TailwindCSS</h1><p class="text-gray-600 mb-6">Build modern websites faster, easier, and without writing custom CSS.</p><button class="bg-blue-500 hover:bg-blue-600 text-white px-6 py-3 rounded">Get Started</button></section>
What you see here:
text-4xl font-bold → Large bold headlinetext-gray-600 → Soft body textbg-blue-500 hover:bg-blue-600 → Beautiful button with hover effectClean, simple, minimal design ✨
| Feature | Example | Purpose |
|---|---|---|
| Text size | text-lg, text-4xl | Control typography scale |
| Font weight | font-bold | Emphasize text |
| Text color | text-gray-700 | Make text readable |
| Background color | bg-blue-500 | Highlight elements |
| Hover states | hover:bg-blue-600 | UI feels alive and interactive |
Typography + Color = Professional looking UI