Font Size & Line Height in Tailwind CSS
Font size and line height are the two most fundamental typographic
controls on any page. Tailwind's
text-* utilities cover a
complete 13-step type scale from
text-xs (12px) to
text-9xl (128px), and each
size ships with a sensible default line height built in. The
companion leading-* utilities
let you override that default — from
leading-none (1.0) for tight
display type to
leading-relaxed (1.625) for
comfortable body reading. Tailwind v3.3 also introduced a
shorthand — text-xl/relaxed —
that sets both properties in one class.
text-xs through
text-9xl with px values
text-base (16px) for body text and understand
the rem relationship
leading-none through
leading-loose
text-xl/relaxed for size
and line height together
text-2xl md:text-4xl lg:text-6xl
text-[17px],
text-[clamp(1rem,4vw,3rem)]
What is Font Size & Line Height? — The Two Typography Axes
Font size controls how tall characters are rendered. Line height (also called leading) controls the vertical spacing between lines of text — specifically the distance from one baseline to the next, expressed as a multiplier of the font size. A line height of 1.5 on 16px text creates 24px of space between baselines. Too tight and lines collide; too loose and the eye struggles to jump from line-end back to the start of the next line. Tailwind's defaults are carefully tuned: small text gets generous spacing, large display type gets tight spacing.
text-sm (14px) for
secondary UI text, table cells, and helper text.
text-base (16px) for
primary body paragraphs. Both include 1.5× line height by
default — comfortable for reading blocks of text.
text-xs (12px) for tags,
badges, timestamps, and supplementary metadata.
text-sm (14px) for form
labels, navigation links, and button text. Combine with
font-medium or
tracking-wide for clarity
at small sizes.
text-xl–text-3xl
for section subheadings and card titles.
text-4xl–text-5xl
for page-level h1. Combine with
leading-tight or
leading-none to tighten
the default heading spacing.
text-6xl (60px) through
text-9xl (128px) for hero
banners, landing page headlines, and full-screen typography.
These default to
leading-none — always
pair with a tight or custom line height so multi-line display
text doesn't have excessive gaps.
rem (root em) units,
not px. 1rem equals the browser's root
font size — 16px by default. This means if a user has increased
their browser's default font size to 20px for accessibility,
text-base automatically renders at 20px rather than a
fixed 16px. Never override the browser's root font size with
html { font-size: 10px } — this breaks accessibility
and user preferences.
The Type Scale — text-* Utility Reference
Every text-* class sets both
font-size and a
line-height simultaneously.
Tailwind's defaults follow a simple rule: small text gets
proportionally more line height for readability; large display
text gets
leading-none (line-height 1)
because the letter-forms themselves provide visual spacing at
large sizes.
font-medium or tracking-wide to
maintain legibility.
text-xl (20px) for card titles and
h4; text-2xl (24px) for section subheadings and
h3; text-3xl (30px) for page-level h2. All come
with proportional line heights — override with
leading-tight for a more compact look.
text-4xl still has a rem-based line-height
(40px); text-5xl switches to
leading-none (line-height: 1). Add
leading-tight when these wrap to two lines to
avoid excessive gaps.
text-6xl (60px),
text-7xl (72px), text-8xl (96px),
text-9xl (128px). Use for full-screen landing
pages, portfolio hero text, and typographic statements. Always
add leading-none or
leading-tight explicitly — they already default
to it but the explicit class makes intent clear.
<!-- Display hero text -->
<h1 class="text-5xl md:text-7xl font-extrabold leading-none
tracking-tight text-white">
Build faster
</h1>
<!-- Page section heading -->
<h2 class="text-3xl font-bold text-gray-900 dark:text-white leading-tight">
Everything you need
</h2>
<!-- Card title -->
<h3 class="text-xl font-semibold text-gray-800 dark:text-gray-100">
Feature card title
</h3>
<!-- Lead paragraph -->
<p class="text-lg text-gray-600 dark:text-gray-400 leading-relaxed">
The opening paragraph of an article, slightly larger than body text.
</p>
<!-- Body paragraph (default size) -->
<p class="text-base text-gray-700 dark:text-gray-300 leading-relaxed">
Regular body copy at 16px — the most comfortable reading size for web content.
</p>
<!-- UI label / button text -->
<button class="text-sm font-semibold px-5 py-2.5 bg-cyan-500
text-white rounded-lg">
Get started
</button>
<!-- Caption / badge text -->
<span class="text-xs font-medium text-gray-500 dark:text-gray-400
uppercase tracking-wide">
Posted 3 hours ago
</span>
<!-- Arbitrary font size -->
<p class="text-[17px] leading-[1.7]">
Exact 17px with precise line height — use when scale doesn't match design spec
</p>
Line Height — leading-* Utilities
leading-* sets the
line-height CSS property — the
vertical space allocated for each line of text. Tailwind provides
named ratios (leading-none
through leading-loose) for the
most common values, plus a numeric pixel scale (leading-3
through leading-10) for
precise control, and arbitrary values for anything else.
h1–h3 elements in UI-heavy designs.
text-xl–text-2xl) that may wrap but
need more space than the heading-level tight setting. Also
good for card bodies and feature description text.
text-base and most sizes below
text-5xl.
text-base and
text-lg body copy.
leading-[1.7],
leading-[2.2], leading-[32px]. Any
valid CSS line-height value in square brackets. Use when the
named scale doesn't match a specific design specification.
<!-- Display headline: leading-none (lines tight, letterforms give space) -->
<h1 class="text-6xl font-black leading-none tracking-tight text-white">
Ship
faster
</h1>
<!-- Multi-line section heading: leading-tight (cohesive at 2–3 lines) -->
<h2 class="text-4xl font-bold leading-tight text-gray-900 dark:text-white">
Everything you need to build
a great product
</h2>
<!-- Body paragraph: leading-relaxed (ideal for reading) -->
<p class="text-base leading-relaxed text-gray-700 dark:text-gray-300">
Tailwind CSS is a utility-first CSS framework that gives you the building
blocks to build any design directly in your markup. Instead of writing
custom CSS, you compose small utility classes to build complex components.
</p>
<!-- Caption text: leading-normal (concise, not too tight at small size) -->
<figcaption class="text-xs leading-normal text-gray-500 dark:text-gray-400 mt-2">
Figure 1 — Tailwind's utility class composition model
</figcaption>
<!-- Numeric scale: leading-6 = 24px (matches text-base's default) -->
<p class="text-base leading-6">Explicit 24px line height</p>
<!-- Arbitrary leading: precise control for a specific design -->
<p class="text-[17px] leading-[1.8]">Custom size + line height combo</p>
Combining Font Size & Line Height — The Shorthand Syntax
Tailwind v3.3 introduced a slash shorthand that
sets both font size and line height in a single class:
text-{size}/{leading}. For
example, text-xl/relaxed sets
font-size: 1.25rem and
line-height: 1.625 in one
class, replacing the two-class pattern
text-xl leading-relaxed. You
can use any named leading value or an arbitrary number as the
modifier.
<!-- Shorthand: text-{size}/{leading} replaces two separate classes -->
<!-- Before (Tailwind v3.2 and earlier) -->
<p class="text-base leading-relaxed">Body paragraph</p>
<h2 class="text-3xl leading-tight">Section heading</h2>
<!-- After (Tailwind v3.3+ shorthand) -->
<p class="text-base/relaxed">Body paragraph — same result</p>
<h2 class="text-3xl/tight">Section heading — same result</h2>
<!-- Common production patterns with shorthand -->
<!-- Hero: large, tight leading -->
<h1 class="text-5xl/none md:text-7xl/none font-black tracking-tight text-white">
Build faster
</h1>
<!-- Article subtitle: medium size, relaxed spacing -->
<p class="text-xl/relaxed text-gray-600 dark:text-gray-400 max-w-prose">
A beautifully designed utility-first CSS framework built with modern web standards.
</p>
<!-- Card body: sm with generous leading for dense UIs -->
<p class="text-sm/relaxed text-gray-500 dark:text-gray-400">
Secondary description text inside a card component.
</p>
<!-- Arbitrary leading in shorthand -->
<p class="text-lg/[1.8]">Precise 1.8 line-height</p>
<!-- Override shorthand inline leading (responsive) -->
<h2 class="text-2xl/tight md:text-4xl/none font-bold text-white">
Responsive heading — tight on mobile, none on desktop
</h2>
text-xl leading-relaxed). In v3.3+,
the shorthand (text-xl/relaxed) is preferred for
clarity. Both work with responsive prefixes:
md:text-4xl/tight is valid.
Responsive Typography — Scaling Font Size Across Breakpoints
All text-* and
leading-* utilities accept the
five responsive prefixes. The standard pattern for headings is to
start small on mobile and scale up at wider breakpoints — creating
fluid, readable typography without writing a single media query.
<!-- Hero h1: compact on mobile, massive on large screens -->
<h1 class="text-3xl sm:text-4xl md:text-5xl lg:text-7xl
font-extrabold leading-none tracking-tight text-white">
Build beautiful UIs
</h1>
<!-- Section heading: two responsive steps -->
<h2 class="text-2xl md:text-3xl lg:text-4xl font-bold leading-tight
text-gray-900 dark:text-white">
Everything you need
</h2>
<!-- Body: slightly larger on desktop for long-form reading -->
<p class="text-base md:text-lg leading-relaxed text-gray-700 dark:text-gray-300">
Article body text — 16px on mobile, 18px on desktop for better readability.
</p>
<!-- Fluid type with CSS clamp() — no breakpoints needed -->
<h2 class="text-[clamp(1.5rem,4vw,3.75rem)] font-bold leading-tight text-white">
Fluid heading — grows smoothly from 24px to 60px
</h2>
<!-- Responsive leading: tight on mobile, relaxed on desktop -->
<p class="text-sm leading-normal md:text-base md:leading-relaxed
text-gray-700 dark:text-gray-300">
Compact on mobile to save space, more relaxed on wider screens.
</p>
<!-- Article layout: full typographic hierarchy -->
<article class="max-w-2xl mx-auto px-4 py-12">
<h1 class="text-3xl md:text-5xl/tight font-bold text-gray-900 dark:text-white mb-4">Article title</h1>
<p class="text-lg/relaxed text-gray-600 dark:text-gray-400 mb-8">Subtitle / lead</p>
<p class="text-base/relaxed text-gray-700 dark:text-gray-300">Body</p>
<p class="text-xs/normal text-gray-400 mt-8">Posted 3 hours ago · 6 min read</p>
</article>
Quick Reference — Font Size & Line Height
| Class | font-size / line-height | Notes |
|---|---|---|
text-xs |
0.75rem / 1rem (12px / 16px) | Tags, badges, timestamps ★ |
text-sm |
0.875rem / 1.25rem (14px / 20px) | UI labels, buttons, nav ★★ |
text-base |
1rem / 1.5rem (16px / 24px) | Body text default ★★ |
text-lg |
1.125rem / 1.75rem (18px / 28px) | Lead paragraphs ★ |
text-xl |
1.25rem / 1.75rem (20px / 28px) | Card titles, h4 ★ |
text-2xl |
1.5rem / 2rem (24px / 32px) | Section subheadings, h3 ★ |
text-3xl |
1.875rem / 2.25rem (30px / 36px) | Page headings, h2 ★ |
text-4xl |
2.25rem / 2.5rem (36px / 40px) | Hero h1 mobile ★ |
text-5xl |
3rem / 1 (48px / leading-none) | Hero h1 desktop ★ |
text-6xl |
3.75rem / 1 (60px) | Display type ★ |
text-7xl |
4.5rem / 1 (72px) | Large display |
text-8xl |
6rem / 1 (96px) | Extra large display |
text-9xl |
8rem / 1 (128px) | Maximum display |
text-[N] |
Custom | Arbitrary: text-[17px], text-[clamp()] ★ |
leading-none |
line-height: 1 | Display headings, text-5xl+ ★ |
leading-tight |
line-height: 1.25 | Multi-line headings h1–h3 ★★ |
leading-snug |
line-height: 1.375 | Subheadings, feature text ★ |
leading-normal |
line-height: 1.5 | Browser default, captions ★ |
leading-relaxed |
line-height: 1.625 | Body text, prose ★★ |
leading-loose |
line-height: 2 | Airy list items (use sparingly) |
leading-3…10 |
0.75rem–2.5rem | Numeric pixel scale (12px–40px) |
leading-[N] |
Custom | Arbitrary: leading-[1.8] ★ |
text-xl/relaxed |
Both in one class | v3.3+ shorthand ★★ |
text-3xl/tight |
Both in one class | v3.3+ shorthand for headings ★ |
★ = commonly used • ★★ = used on virtually every project
-
13-step type scale —
text-xs(12px) throughtext-9xl(128px). Each step usesremunits anchored to the 16px browser default, so type scales with user preferences — never usehtml { font-size: 10px }as it breaks accessibility. -
text-base = 16px — The CSS default and the
anchor of the entire rem scale. Use for primary body paragraphs.
text-sm(14px) for UI labels and buttons;text-xs(12px) for badges and timestamps. Always pair small text withfont-mediumfor legibility. -
Built-in line heights — Every
text-*class sets a default line height: small sizes get proportional spacing (text-base defaults to leading-6 = 24px); large display sizes default toleading-none(1) since letterforms provide visual breathing room. -
leading-relaxed (1.625) — The best line height
for body text and long-form prose. Use on all
text-baseandtext-lgparagraphs.leading-tight(1.25) for headings that may wrap;leading-none(1) for large display text. -
Shorthand syntax —
text-{size}/{leading}(e.g.text-xl/relaxed) sets both font size and line height in one class. Available in Tailwind v3.3+. Works with all named leading values and arbitrary numbers:text-lg/[1.8]. -
Responsive font scaling — Stack breakpoint
prefixes to scale headings:
text-2xl md:text-4xl lg:text-6xl. Start with a mobile-appropriate size and scale up — never start large and scale down, as that can miss intermediate sizes. The shorthand also accepts responsive prefixes:md:text-5xl/none. -
Arbitrary and fluid values —
text-[17px]for exact pixel sizes;text-[clamp(1.5rem,4vw,3.75rem)]for fluid type that scales smoothly without breakpoints.leading-[1.7]for precise line heights not in the named scale. -
Next chapter — Font Weight covers
font-thinthroughfont-black(100–900), how weights interact with variable fonts, and responsive weight patterns for headings and emphasis.
Quick Check — Questions & Answers
Test your understanding. Click a question to reveal the answer.
text-sm sets
font-size: 0.875rem (14px) with a default
line height of 1.25rem (20px). It is the standard size for
UI elements — form labels, button text, navigation links,
table cells, and secondary descriptions. Most design
systems use 14px as their primary UI text size.
text-base sets
font-size: 1rem (16px) with a default line
height of 1.5rem (24px). It is the CSS and browser default
and the anchor of the rem scale. Use for body paragraphs
and the root font-size setting.
text-lg sets
font-size: 1.125rem (18px) with a default
line height of 1.75rem (28px). Use for lead paragraphs
(the opening paragraph of an article), feature
descriptions, or anywhere 16px feels small — such as
editorial sites and content-heavy reads.
leading-* sets the CSS
line-height property — the vertical space
allocated for each line of text. Technically, it is the
distance from one text baseline to the next, expressed as
a multiplier of the font size. A
leading-relaxed (1.625) on 16px text means
each line gets 16 × 1.625 = 26px of vertical space, with
the remaining 10px distributed above and below the text
characters.
It is called "leading" (pronounced "ledding") because in traditional typesetting, strips of lead were inserted between rows of type to control their spacing. Too little leading (line-height: 1 or less) makes text blocks feel suffocating and hard to read across. Too much (line-height: 2+) makes text feel disconnected. For body copy, the sweet spot is 1.5–1.7.
Tailwind bakes a default line height into each
text-* class because the optimal line height
changes with font size. Small text needs proportionally
more spacing to be readable —
text-xs defaults to
leading-4 (ratio 1.33),
text-sm to leading-5 (ratio
1.43), and text-base to
leading-6 (ratio 1.5). This gives you
sensible typography out of the box without needing to
think about line height on every element.
Conversely, large display text (text-5xl and above)
defaults to leading-none (ratio 1) because at
large sizes the letterforms have enough visual space built
in. If you set leading-relaxed on a 60px
heading, the gaps between lines would look enormous. You
can always override the default by adding a
leading-* class explicitly.
Introduced in Tailwind v3.3, the slash shorthand
text-{size}/{leading} sets both
font-size and line-height in a
single class. For example, text-xl/relaxed is
equivalent to text-xl leading-relaxed — it
sets font-size to 1.25rem and line-height to 1.625. The
shorthand works with all named leading values (none,
tight, snug, normal, relaxed, loose) and with arbitrary
numbers: text-lg/[1.8].
It also works with responsive prefixes:
md:text-4xl/tight applies text-4xl with
leading-tight at md+ breakpoints. Both forms produce
identical CSS output — the shorthand is simply more
concise. Use it when you know you always want a specific
pairing — text-base/relaxed for body text,
text-4xl/tight for desktop headings.
Add breakpoint prefixes to any text-* class.
The pattern is mobile-first — the unprefixed class applies
to all sizes, and prefixed classes override at the
specified breakpoint and above. For a hero heading:
text-2xl sm:text-4xl md:text-5xl lg:text-7xl
starts at 24px on mobile and scales to 72px on large
screens.
The shorthand also accepts responsive prefixes:
text-2xl/tight md:text-5xl/none gives tight
heading spacing on mobile and no line-height multiplier on
desktop. For fully fluid type that scales between two
sizes without any breakpoints, use CSS clamp:
text-[clamp(1.5rem,4vw,3.75rem)] — this grows
smoothly from 24px to 60px as the viewport width changes.
MCQ Quiz — Test Yourself
Select the best answer. Correct answers are revealed on click.
leading-*
value gives the most comfortable line spacing for long-form body
text?
text-4xl/tight
do in Tailwind v3.3+?
Rate Us on Google
Join Our Learning Community
Connect with thousands of learners, get daily tips, ask questions and stay updated with new tutorials.