Typography
In this chapter, you learn how to style text with Tailwind CSS.
Font size
| Class | Size | Line height |
|---|---|---|
text-xs | 12px | 16px |
text-sm | 14px | 20px |
text-base | 16px | 24px |
text-lg | 18px | 28px |
text-xl | 20px | 28px |
text-2xl | 24px | 32px |
text-3xl | 30px | 36px |
text-4xl | 36px | 40px |
text-5xl | 48px | 1 (equivalent to 48px) |
text-6xl | 60px | 1 (equivalent to 60px) |
At text-5xl and above, the line height is set to the unitless value 1 (the same as the font size). This is because they are intended for use in large text such as headings. When you use them for body text, adjust the line height with leading-normal or leading-relaxed.
Note that in v4, line heights are defined on a calc() basis (for example, text-xs is calc(1 / 0.75)). The table above lists the computed px values.
<p class="text-sm">Small text</p>
<p class="text-base">Base text</p>
<p class="text-lg">Large text</p>
<h1 class="text-4xl">Heading</h1>
Font weight
| Class | weight |
|---|---|
font-thin | 100 |
font-light | 300 |
font-normal | 400 |
font-medium | 500 |
font-semibold | 600 |
font-bold | 700 |
font-extrabold | 800 |
font-black | 900 |
<p class="font-normal">Normal</p>
<p class="font-medium">Medium</p>
<p class="font-bold">Bold</p>
Font family
| Class | Font |
|---|---|
font-sans | The system sans-serif |
font-serif | A serif |
font-mono | A monospace font |
<p class="font-sans">Sans-serif</p>
<p class="font-serif">Serif</p>
<code class="font-mono">Monospace font</code>
Line height (line-height)
| Class | Value |
|---|---|
leading-none | 1 |
leading-tight | 1.25 |
leading-snug | 1.375 |
leading-normal | 1.5 |
leading-relaxed | 1.625 |
leading-loose | 2 |
<p class="leading-tight">Tight line height</p>
<p class="leading-normal">Normal line height</p>
<p class="leading-relaxed">Relaxed line height</p>
Letter spacing (letter-spacing)
| Class | Value |
|---|---|
tracking-tighter | -0.05em |
tracking-tight | -0.025em |
tracking-normal | 0 |
tracking-wide | 0.025em |
tracking-wider | 0.05em |
tracking-widest | 0.1em |
<p class="tracking-tight">Tight letter spacing</p>
<p class="tracking-wide">Wide letter spacing</p>
Text alignment
| Class | Alignment |
|---|---|
text-left | Left |
text-center | Center |
text-right | Right |
text-justify | Justified |
<p class="text-center">Centered text</p>
Text color
<p class="text-gray-500">Gray</p>
<p class="text-blue-600">Blue</p>
<p class="text-red-500">Red</p>
<p class="text-green-600">Green</p>
Text decoration
Underline and strikethrough
<p class="underline">Underline</p>
<p class="line-through">Strikethrough</p>
<p class="no-underline">No decoration</p>
Decoration styles
<p class="underline decoration-wavy">Wavy</p>
<p class="underline decoration-dotted">Dotted</p>
<p class="underline decoration-dashed">Dashed</p>
<p class="underline decoration-double">Double</p>
Decoration color and thickness
<p class="underline decoration-blue-500 decoration-2">
A thick blue underline
</p>
Text transform
<p class="uppercase">converted to uppercase</p>
<p class="lowercase">CONVERTED TO LOWERCASE</p>
<p class="capitalize">capitalized first letters</p>
<p class="normal-case">No transform</p>
Text overflow
Ellipsis
<p class="truncate w-48">
A long text gets truncated...
</p>
Wrapping
<p class="break-normal">Normal wrapping</p>
<p class="break-words">Wrap even mid-word</p>
<p class="break-all">Wrap at any position</p>
Whitespace
<p class="whitespace-nowrap">No wrapping</p>
<p class="whitespace-pre">Preserve whitespace</p>
<p class="whitespace-pre-wrap">Preserve whitespace + wrap</p>
Line clamp
Control truncation across multiple lines.
<p class="line-clamp-2">
A long text is truncated after 2 lines.
The third line and beyond are not shown.
More text continues...
</p>
<p class="line-clamp-3">Truncate after 3 lines</p>
Vertical alignment
<span class="align-baseline">Baseline</span>
<span class="align-top">Top</span>
<span class="align-middle">Middle</span>
<span class="align-bottom">Bottom</span>
Text indent
<p class="indent-4">First line indented by 16px</p>
<p class="indent-8">First line indented by 32px</p>
Practical examples
Heading and subtext
<div class="text-center">
<h1 class="text-4xl font-bold text-gray-900">
Main title
</h1>
<p class="mt-2 text-lg text-gray-600">
A subtitle goes here
</p>
</div>
Article body
<article>
<h2 class="text-2xl font-bold mb-4">Heading</h2>
<p class="text-gray-700 leading-relaxed mb-4">
This is the body text. A readable line height and proper contrast
improve readability for users.
</p>
<p class="text-gray-700 leading-relaxed">
This is the second paragraph...
</p>
</article>
Card text
<div class="p-4 bg-white rounded-lg shadow-sm">
<span class="text-xs font-semibold text-blue-600 uppercase tracking-wide">
Category
</span>
<h3 class="mt-2 text-xl font-bold text-gray-900">
Card title
</h3>
<p class="mt-2 text-sm text-gray-600 line-clamp-2">
This is the card description. If it is long, it is truncated after 2 lines.
More text continues here...
</p>
</div>
Quote
<blockquote class="pl-4 border-l-4 border-blue-500 italic text-gray-600">
<p class="text-lg">"A quotation goes here."</p>
<cite class="block mt-2 text-sm not-italic">— Author name</cite>
</blockquote>
Label and input
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">
Email address
</label>
<input
type="email"
class="w-full px-3 py-2 border border-gray-300 rounded-sm text-base"
placeholder="example@email.com"
/>
<p class="mt-1 text-xs text-gray-500">
* We will send you a confirmation email
</p>
</div>
Considerations for Japanese fonts
When you work on a project that handles Japanese, you need to be careful with font settings.
@theme {
--font-sans: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "メイリオ", sans-serif;
}
<p class="font-sans">日本語テキスト</p>
Japanese fonts have larger file sizes than English fonts, so when you load them from a service like Google Fonts, consider specifying font-display: swap and narrowing down the weights you use.
Summary
text-*for font sizefont-*for weight and familyleading-*for line heighttracking-*for letter spacingtext-center, etc. for alignmenttruncate/line-clamp-*for truncation- Combinations that keep readability in mind
What to read next
- Color system — Tailwind's color design and oklch support
- Backgrounds, borders & shadows — refine the surrounding decoration
- Tailwind CSS Guide table of contents — back to the structure of all 18 chapters