Tailwind CSS Mastery
Learn the utility-first approach to styling. Build beautiful interfaces faster than ever with Tailwind CSS!
📚 Table of Contents
🌱 Beginner
- • What is a <div>?
- • How classes work
- • Colors & backgrounds
- • Spacing (padding/margin)
- • Typography basics
- • Borders & shadows
🚀 Intermediate
- • Flexbox layout
- • CSS Grid
- • Responsive design
- • Hover & states
- • Building cards
- • Layout patterns
⚡ Advanced
- • Custom animations
- • Glassmorphism
- • Complex gradients
- • Group & peer states
- • Arbitrary values
- • Performance tips
⚡ What is Tailwind CSS?
Tailwind CSS is a utility-first CSS framework that lets you build designs directly in your HTML using pre-built classes. Instead of writing custom CSS, you compose styles using utility classes!
A <div> is a container element in HTML. Think of it like a box that can hold other content. By itself, it does nothing visually - but with Tailwind classes, you can make it look however you want!
📝 The Code:
<div class="bg-blue-500 p-4">
Hello World!
</div>👀 The Result:
bg-blue-500 = blue backgroundp-4 = padding of 1rem (16px)
🎯 How Tailwind Classes Work:
Write your HTML element
<div></div>Add class attribute
<div class=""></div>Add Tailwind utility classes (space-separated)
<div class="bg-red-500 p-4 rounded-lg"></div>🧱 Common HTML Elements You will Style:
<div>Container/box - most common
<p>Paragraph text
<button>Clickable button
<span>Inline text wrapper
<h1> to <h6>Headings
<img>Images
Tailwind colors follow a pattern: {property}-{color}-{shade}
Example: bg-blue-500 or text-red-600
🎯 Color Prefixes:
bg-Background colortext-Text colorborder-Border colorring-Ring/outline color📊 Shade Numbers (100-900):
�� Available Colors:
redorangeyellowgreenbluepurplepinkgrayslatecyanemeraldindigo🎨 Try Colors Yourself!
bg-blue-500 text-white p-4 rounded-lg hover:bg-blue-600Padding = Space INSIDE the box (between border and content)
Margin = Space OUTSIDE the box (between this box and others)
📊 Visual Explanation:
📐 Spacing Scale:
| Class | Value | Pixels |
|---|---|---|
| p-0 | 0rem | 0px |
| p-1 | 0.25rem | 4px |
| p-2 | 0.5rem | 8px |
| p-4 | 1rem | 16px |
| p-6 | 1.5rem | 24px |
| p-8 | 2rem | 32px |
🎯 Direction Shortcuts:
p-4All sidespx-4Left & Rightpy-4Top & Bottompt-4Top onlypb-4Bottom onlypl-4Left onlypr-4Right onlySame pattern works for margin: m-, mx-, my-, mt-, etc.
📏 Try Spacing Yourself!
bg-blue-500 text-white p-4 rounded-lg hover:bg-blue-600📊 Text Sizes:
text-xsExtra Small Texttext-smSmall Texttext-baseBase Text (default)text-lgLarge Texttext-xlExtra Large Texttext-2xl2X Large Texttext-4xl4X Large💪 Font Weights:
font-thin (100)
font-light (300)
font-normal (400)
font-medium (500)
font-semibold (600)
font-bold (700)
font-extrabold (800)
🎨 Other Text Styles:
italic - Italic text
underline - Underlined
line-through - Strikethrough
uppercase
LOWERCASE (applied)
capitalize each word
tracking-wide (letter spacing)
✏️ Try Typography!
Hello Tailwind CSS! ✨
bg-blue-500 text-white p-4 rounded-lg hover:bg-blue-600📏 Border Width:
borderborder-2border-4🔵 Rounded Corners:
No roundedroundedrounded-lgrounded-xlrounded-full🔲 Try Borders & Shadows!
bg-blue-500 text-white p-4 rounded-lg hover:bg-blue-600📋 Beginner Cheat Sheet
🎨 Colors
- bg-{color}-500
- text-{color}-500
- border-{color}-500
📏 Spacing
- p-{0-12}
- m-{0-12}
- px-4 py-2
✏️ Text
- text-sm / text-xl
- font-bold
- rounded-lg