Tailwind CSSIntermediateFree to read

Tailwind CSS for people who already write CSS

The same login form, grid and spacing built twice — once in plain CSS, once in Tailwind utilities — so you can see exactly what the utility classes replace.

What you will be able to do
  • Translate a block of hand-written CSS into the equivalent Tailwind utilities.
  • Read a long class list and see the layout it describes.
  • Extend the theme in the config instead of writing one-off CSS.

From CSS to Tailwind

How Tailwind CSS revolutionizes the way we style websites.

Traditional CSS Approach

With traditional CSS, you write styles in a separate stylesheet and reference them with class names:

  • Create a CSS file with your styles
  • Write selectors and properties
  • Link the stylesheet to your HTML
  • Add class names to HTML elements
  • Repeat for every component
styles.css
/* Traditional CSS Example */
.card {
  background: white;
  border-radius: 0.5rem;
  padding: 1.5rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: #1e40af;
}

CSS vs Tailwind Examples

See the difference between traditional CSS and Tailwind in common UI patterns.

Login Form

Traditional CSS Login Form

CSS
/* CSS for login form */
.login-form {
  max-width: 400px;
  margin: 2rem auto;
  padding: 2rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
HTML
<div class="login-form">
  <h2>Login</h2>
  <form>
    <div class="form-group">
      <label for="email">Email</label>
      <input type="email" id="email" />
    </div>
    <button type="submit">Sign In</button>
  </form>
</div>

Tailwind CSS Login Form

HTML
<!-- Tailwind login form -->
<div class="max-w-md mx-auto p-6 sm:p-8 bg-white rounded-lg shadow-md">
  <h2 class="text-xl sm:text-2xl font-bold mb-4 sm:mb-6">Login</h2>
  <form>
    <div class="mb-4 sm:mb-6">
      <label class="block text-gray-700 mb-2">Email</label>
      <input class="w-full px-3 py-2 border rounded-md" type="email" />
    </div>
    <button class="w-full bg-blue-700 text-white py-2 px-4 rounded-md">
      Sign In
    </button>
  </form>
</div>
What those utilities render
Login

Grid Layout

Traditional CSS Grid

CSS
/* CSS Grid styles */
.grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.grid-item {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
HTML
<div class="grid-container">
  <div class="grid-item">
    <h3>Item 1</h3>
    <p>Content</p>
  </div>
  <!-- More items -->
</div>

Tailwind CSS Grid

HTML
<!-- Tailwind grid -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 sm:gap-6">
  <div class="bg-white p-4 sm:p-6 rounded-lg shadow-sm">
    <h3 class="text-lg sm:text-xl font-semibold mb-2">Item 1</h3>
    <p class="text-gray-600">Content</p>
  </div>
  <!-- More items -->
</div>
What those utilities render
Item 1

Content goes here

Item 2

Content goes here

Item 3

Content goes here

Spacing

Traditional CSS Spacing

CSS
/* CSS for spacing */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.header {
  margin-bottom: 2rem;
  padding: 1.5rem;
}
HTML
<div class="container">
  <header class="header">
    <h1>Title</h1>
  </header>
  <div class="card">
    <p>Content</p>
  </div>
</div>

Tailwind CSS Spacing

HTML
<!-- Tailwind spacing -->
<div class="w-full max-w-6xl mx-auto px-4">
  <header class="mb-6 sm:mb-8 py-4 sm:py-6">
    <h1 class="text-xl sm:text-2xl font-bold">Title</h1>
  </header>
  <div class="mb-4 sm:mb-6 p-3 sm:p-4">
    <p>Content</p>
  </div>
</div>
What those utilities render
Title

Card content

Common Tailwind CSS Classes

Quick reference for the most frequently used Tailwind utility classes.

Layout & Structure

ClassWhat it does
containerCenters content with max-width
mx-autoHorizontal centering
flexDisplay flex
gridDisplay grid
blockDisplay block
hiddenDisplay none
relativePosition relative
absolutePosition absolute

Spacing

ClassWhat it does
m-4Margin all sides (1rem)
p-4Padding all sides (1rem)
gap-4Gap between items
mt-4Margin top (1rem)
mb-4Margin bottom (1rem)
ml-4Margin left (1rem)
mr-4Margin right (1rem)
px-4Padding left & right (1rem)

Sizing

ClassWhat it does
w-fullFull width
h-screenFull viewport height
w-1/250% width
min-h-screenMinimum viewport height
max-w-mdMax-width 28rem (448px)
w-autoWidth auto
h-12Height 3rem (48px)
min-w-maxMinimum width max-content

Typography

ClassWhat it does
text-xlExtra large text
font-boldFont weight bold
text-centerText align center
uppercaseText uppercase
leading-relaxedLine height 1.625
tracking-wideLetter spacing 0.025em
underlineText underline
italicText italic

Colors & Backgrounds

ClassWhat it does
bg-whiteWhite background
text-gray-600Gray text color
bg-blue-500Blue background
text-red-500Red text color
bg-opacity-50Background opacity 50%
bg-gradient-to-rRight gradient
hover:bg-gray-100Hover gray background
focus:ring-2Focus ring

Borders & Effects

ClassWhat it does
rounded-lgLarge border radius
shadow-mdMedium shadow
borderDefault border
border-22px border
border-blue-500Blue border
ring-2Focus ring
transition-allSmooth transitions
hover:shadow-lgHover larger shadow

Tailwind CSS Features

Why Tailwind is the perfect CSS framework for modern web development.

Utility-First

Build any design directly in your HTML with thousands of utility classes.

Responsive Design

Easy responsive design with built-in breakpoint prefixes like md: and lg:.

Customizable

Configure colors, spacing, fonts and more in the config file.

Component-Friendly

Extract component classes with @apply or use with React/Vue components.

Design Consistency

Built-in design system ensures spacing, colors and typography are consistent.

Performance

Purge unused styles in production for optimal performance.

CoachingTailwind CSS

Build modern websites — HTML5, Tailwind CSS and React

Take the layout ideas here into a real front end, reviewed line by line as you write it.

Learn it here. Build it with us when you are ready.

Every lesson on this site is free and stays free. When the utility classes stop making sense, a mentor will untangle them with you.

WhatsAppMessage us on WhatsApp
Visit12, Sri Vigneshwara Nagar, Amman Kovil
Saravanampatti, Coimbatore, TN, India — 641035

தெய்வத்தான் ஆகா தெனினும் முயற்சிதன்மெய்வருத்தக் கூலி தரும்.