Tutorials Tailwind CSS Font Size & Line Height
Ch 23 / 45
Chapter 23 Beginner 5 min read Tailwind CSS

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.

Advertisement
Google Ad Placeholder · 728×90 Leaderboard
What you'll learn
Apply the 13-step type scale: text-xs through text-9xl with px values
Use text-base (16px) for body text and understand the rem relationship
Control line height with leading-none through leading-loose
Use the shorthand syntax: text-xl/relaxed for size and line height together
Stack responsive font sizes: text-2xl md:text-4xl lg:text-6xl
Use arbitrary values: 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.

Tailwind type scale — 13 steps, each with a built-in default line height Class rem / px Default leading Visual size Use for text-xs 0.75rem / 12px leading-4 (16px) Tailwind CSS Tags, captions text-sm 0.875rem / 14px leading-5 (20px) Tailwind CSS UI labels, secondary text-base ★ 1rem / 16px leading-6 (24px) Tailwind CSS Body text default ★ text-lg 1.125rem / 18px leading-7 (28px) Tailwind Lead paragraphs text-xl 1.25rem / 20px leading-7 (28px) Tailwind Card titles, h4 text-2xl 1.5rem / 24px leading-8 (32px) Tailwind Section headings, h3 text-3xl 1.875rem / 30px leading-9 (36px) Tailwind Page headings, h2 text-4xl 2.25rem / 36px leading-10 (40px) Tailwind Hero h1 (mobile) text-5xl 3rem / 48px leading-none (1) Tw Hero h1 text-6xl … text-9xl 60px → 128px, leading-none Display & hero type 12px 14px 16px 18px 20px 24px 30px 36px 48px 60–128 ★ text-base (16px) is the browser default body size — the anchor for all rem calculations
Body Text (text-sm / text-base)
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.
UI Labels (text-xs / text-sm)
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.
Headings (text-xl → text-5xl)
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.
Display Type (text-6xl → text-9xl)
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 vs px — why it matters Tailwind's font size scale uses 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.
Advertisement
Google Ad Placeholder · 728×90 Leaderboard

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.

text-xs
font-size: 0.75rem (12px) / line-height: 1rem (16px) — The smallest named step. Use for badges, tags, timestamps, tooltip text, and supplementary metadata. At 12px, pair with font-medium or tracking-wide to maintain legibility.
text-sm
font-size: 0.875rem (14px) / line-height: 1.25rem (20px) — The standard UI text size for labels, buttons, form inputs, navigation, and table cells. Matches the font size used in most modern design systems (Material, Carbon, Ant Design).
text-base
font-size: 1rem (16px) / line-height: 1.5rem (24px) — The CSS and browser default. This is the anchor of the entire rem scale — all other steps are multiples of this. Use for primary body paragraphs and the default font size on the root element. The most commonly used font size in body copy.
text-lg
font-size: 1.125rem (18px) / line-height: 1.75rem (28px) — Slightly larger than body text. Use for lead paragraphs (the opening paragraph of an article), feature descriptions on landing pages, and comfortable reading in content-heavy UIs where 16px feels small.
text-xl … text-3xl
20px → 30px, line-heights 28–36px — The heading range. 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 … text-5xl
36px → 48px, line-heights 40px / 1 — Page-level h1 and hero section headings. 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 … text-9xl
60px → 128px, all default to leading-none (1) — Display and hero typography. 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.
HTML — type scale in practice: display, heading, body, caption
<!-- 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.

line-height (leading) — how much vertical space each line of text occupies leading-none line-height: 1 leading-tight line-height: 1.25 leading-normal line-height: 1.5 leading-relaxed line-height: 1.625 leading-loose line-height: 2 The quick brown fox jumps over the lazy Too tight for body — for large display headings only The quick brown fox jumps over the lazy dog Headings, h1–h3 multi-line titles The quick brown fox jumps over the lazy dog Browser default most elements The quick brown fox jumps over the lazy dog Body text ★★ prose, paragraphs The quick brown fox jumps over the lazy dog Very airy — use sparingly For body text: leading-relaxed (1.625) is ideal. For headings: leading-tight (1.25) or leading-none (1). For captions: leading-normal (1.5).
leading-none
line-height: 1 — Line height equals exactly the font size. Lines sit directly on top of each other with no extra space — letters may collide at smaller sizes. Use only for large display headings (text-5xl+) where the letterforms provide visual breathing room, or for single-line text that should never wrap.
leading-tight
line-height: 1.25 — Compact spacing used for headings and titles that may wrap to two or three lines. Keeps multi-line headings visually cohesive. The standard choice for h1–h3 elements in UI-heavy designs.
leading-snug
line-height: 1.375 — Between tight and normal. Use for medium-sized subheadings (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.
leading-normal
line-height: 1.5 — The CSS browser default for most elements. A reasonable baseline for short paragraphs and UI text. Used as the built-in default for text-base and most sizes below text-5xl.
leading-relaxed
line-height: 1.625 — The sweet spot for comfortable reading of body text and long-form prose. Research consistently shows line heights between 1.5 and 1.8 improve reading speed and comprehension for paragraphs longer than 2–3 lines. Use on all text-base and text-lg body copy.
leading-loose
line-height: 2 — Very open spacing at exactly double the font size. Use sparingly — mainly for single-line list items where generous vertical rhythm is part of the design intent, or for decorative typographic layouts. Too airy for multi-line body paragraphs.
leading-[N]
Arbitrary value — 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.
HTML — leading-* in practice for headings, body, and captions
<!-- 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>
Advertisement
Google Ad Placeholder · 728×90 Leaderboard

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.

text-{size}/{leading} shorthand — Tailwind v3.3+ text- 2xl / relaxed prefix any text-* step slash any leading value = font-size: 1.5rem + line-height: 1.625 Examples: text-base/relaxed text-3xl/tight text-lg/loose text-xl/[1.8] text-5xl/none Named leading values (none, tight, snug, normal, relaxed, loose) OR arbitrary numbers like [1.8] or [32px]
HTML — shorthand syntax and combined patterns
<!-- 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>
Shorthand vs separate classes Both approaches produce identical CSS — the shorthand is just more concise. If you're using Tailwind v3.2 or earlier, use the two-class form (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.
Advertisement
Google Ad Placeholder · 728×90 Leaderboard

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.

text-2xl
mobile default
24px — compact
sm:text-3xl
≥ 640px
30px — tablet
md:text-4xl
≥ 768px
36px — desktop
lg:text-5xl
≥ 1024px
48px — wide
xl:text-6xl
≥ 1280px
60px — large display
2xl:text-7xl
≥ 1536px
72px — ultra-wide
HTML — responsive font size patterns for headings, body, and fluid type
<!-- 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>
Advertisement
Google Ad Placeholder · 728×90 Leaderboard

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

Featured Course
Master Tailwind CSS — Typography, Layout & Production UI
From type scales to full dashboard layouts. Covers all Tailwind v4 utilities, responsive typography systems, dark mode, and 5 real-world projects with live mentoring.
45 Chapters 10+ Hours 5 Real Projects Certificate Live Mentoring
A
⭐ 4.9 · 1,200+ students
Tailwind CSS Font Size & Line Height Cheat Sheet
Free one-page cheat sheet covering the full text-* type scale, all leading-* values, the text/leading shorthand syntax, and responsive typography patterns.
text-xs to text-9xl leading-relaxed text-xl/relaxed Responsive type rem values clamp()
Download Free Cheat Sheet
Chapter Summary
  • 13-step type scale — text-xs (12px) through text-9xl (128px). Each step uses rem units anchored to the 16px browser default, so type scales with user preferences — never use html { 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 with font-medium for 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 to leading-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-base and text-lg paragraphs. 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-thin through font-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.

Question 1 of 4
Which class sets the standard body text size of 16px (1rem)?
Question 2 of 4
Which leading-* value gives the most comfortable line spacing for long-form body text?
Question 3 of 4
What does text-4xl/tight do in Tailwind v3.3+?
Question 4 of 4
Which class sets an arbitrary font size of exactly 17px?

Rate Us on Google

4.8 / 5
Enjoying this tutorial?
Your 5-star review helps other learners discover our free tutorials and encourages us to keep creating quality content.
80+ reviews
Write a Google Review
Join WhatsApp Channel