MyInternships.in

Getting Started

Utility-First Fundamentals

The core idea of Tailwind is "utility-first": build designs by combining many small classes, each mapping to one CSS declaration.


One class, one job

Each utility sets a single property. p-4 sets padding, text-center sets text alignment, rounded-lg sets border-radius. You layer them to create the final look.

ClassCSS it applies
p-4padding: 1rem
mt-2margin-top: 0.5rem
text-lgfont-size: 1.125rem
font-boldfont-weight: 700
flexdisplay: flex
rounded-lgborder-radius: 0.5rem

The spacing scale

Sizes use a numeric scale where 1 = 0.25rem (4px). So p-2 is 8px, p-4 is 16px, p-8 is 32px. The same scale powers padding, margin, width, height and gap — which is what keeps spacing consistent.

Composing utilities into a badge
Example
<span class="inline-flex items-center gap-1 bg-emerald-100 text-emerald-800 text-sm font-semibold px-3 py-1 rounded-full">
  <span class="w-2 h-2 rounded-full bg-emerald-500"></span>
  Verified
</span>
💡

Read classes left to right as a sentence: "inline-flex, items-center, gap-1, background emerald-100…". Once you learn the vocabulary, you can build almost anything without leaving your HTML.

Related Tailwind Topics

Keep learning with these closely related lessons.