Typography Guide for AI Coders
Fonts, sizes, weights, and spacing: everything you need to know about text on the web. Use our Font Picker to browse and pair Google Fonts instantly.
In this chapter
- How to pick fonts that look professional
- What font sizes, weights, and line heights to use
- How to pair two fonts without it looking messy
- How to ask AI to swap fonts on your whole site
Font Size Scale
Use consistent sizes from a scale. Here's the Tailwind CSS default type scale.
text-xs12pxExtra small: captions, labels, fine printtext-sm14pxSmall: secondary text, descriptions, metadatatext-base16pxBase: body text, paragraphs (browser default)text-lg18pxLarge: emphasized body text, subtitlestext-xl20pxExtra large: section subtitles, card headingstext-2xl24px2XL: section headingstext-3xl30px3XL: page headingstext-4xl36px4XL: hero headingstext-5xl48px5XL: large hero headingsFont Weights
Aa Bb Cc
font-light (300)Subtle, delicate
Aa Bb Cc
font-normal (400)Body text default
Aa Bb Cc
font-medium (500)Slightly emphasized
Aa Bb Cc
font-semibold (600)Subheadings, labels
Aa Bb Cc
font-bold (700)Headings, emphasis
Aa Bb Cc
font-extrabold (800)Hero headlines
Line Height & Letter Spacing
Line Height (leading)
Space between lines of text. Tighter for headings, looser for body text. See our spacing guide for more on vertical rhythm.
leading-tight1.25Headingsleading-snug1.375Subheadingsleading-normal1.5Body text (default)leading-relaxed1.625Easy readingleading-loose2Spacious textLetter Spacing (tracking)
Space between individual characters. Wider for uppercase labels.
tracking-tighter-0.05emLarge headingstracking-tight-0.025emHeadingstracking-normal0emDefaulttracking-wide0.025emBody texttracking-wider0.05emUppercase labelstracking-widest0.1emALL CAPS textPopular Font Pairings
Inter
Body text would look like this in Inter.
Inter + Inter
Clean, modern, versatile. The default for most web apps.
Playfair Display
Body text would look like this in Source Sans.
Playfair Display + Source Sans
Elegant serif + clean sans-serif. Great for blogs and magazines.
Space Grotesk
Body text would look like this in Inter.
Space Grotesk + Inter
Geometric, techy vibe. Perfect for SaaS and tech products.
DM Sans
Body text would look like this in DM Sans.
DM Sans + DM Sans
Friendly, rounded. Great for consumer apps.
Popular Google Fonts
Typography Rules of Thumb
Text Decoration & Transform
These utilities change how text looks without changing the font itself. Great for emphasis, labels, and styling links.
Click here to learn more
underlineBest for: Links and clickable text
$49.99 now $29.99
line-throughBest for: Old prices, removed items
new feature
uppercaseBest for: Labels, badges, buttons
HELLO WORLD
lowercaseBest for: Normalizing user input
welcome to the app
capitalizeBest for: Titles, names, headings
Remove default link style
no-underlineBest for: Styled links and buttons
Text Truncation & Clamping
When text is too long for a card or list item, you can cut it off with an ellipsis (...) instead of letting it overflow. This keeps your layout clean.
Single-Line Truncation
Cuts text off at one line with "..." at the end. Perfect for titles and names.
This is a really long product title that would normally wrap to the next line and break the layout of your card component
truncate
Multi-Line Clamping
Shows 2-3 lines, then cuts off. Great for descriptions and previews.
line-clamp-2 or line-clamp-3
Responsive Typography
Text should be smaller on phones and bigger on desktops. Tailwind makes this easy with responsive prefixes: just add the screen size before any text class.
Hero heading example:
Build Something Amazing
text-2xl
sm:text-3xl
md:text-4xl
lg:text-5xl
Section heading example:
Getting Started with Your Project
text-lg
sm:text-xl
md:text-2xl
How the prefixes work:
(none)All screens
< 640px
sm:Small+
640px+
md:Medium+
768px+
lg:Large+
1024px+
Web Font Loading
Fonts need to be downloaded before they can be displayed. Here's what you need to know to keep your site fast and looking great. Use our Font Picker to browse pairings.
“Add [font name] from Google Fonts to my project. Use the variable font version if available. Set font-display to swap for fast loading. Only load the weights I actually need: 400 for body text and 700 for headings. Set it as the default font for the whole site.”
Common Typography Mistakes
Watch out for these common issues that make text harder to read and sites look unprofessional.
HTML Text Elements
Every text element on a webpage has a specific tag. Knowing the names helps you tell AI exactly what you want.
h1Page Titleh2Section Titleh3Sub-sectionh4Card Titleh5Small Headingh6Label HeadingUse only one h1 per page (the main title). h2 for major sections, h3 for sub-sections inside those. Don't skip levels.
pThis is a normal paragraph. Most of your content uses this tag.strongBold text: use for important words or emphasis.emItalic text: use for emphasis, titles, or foreign words.smallSmall text: captions, footnotes, fine print.aLink text: clickable text that goes somewhere.codeInline code: for technical terms or code snippets.blockquote"A quote from someone else."ul: Unordered (bullet) list
- First item
- Second item
- Third item
ol: Ordered (numbered) list
- Step one
- Step two
- Step three
Prompt This
Copy-paste these prompts into your AI tool to apply what you just learned.
“Set up a typography system for my app using [font name] for headings and [font name] for body text. Include sizes for h1-h4, body, small text, and captions. Use consistent line heights and letter spacing.”
“Import and apply Google Fonts to my Next.js project. Use [heading font] for all headings and [body font] for paragraph text. Make sure the fonts load efficiently and have proper fallbacks.”
“My page text is hard to read. Fix the typography: make body text at least 16px, set line height to 1.5 for paragraphs, limit line width to about 65 characters, and add clear visual hierarchy between headings and body text.”
Frequently Asked Questions
How many fonts should I use on my site?
Two is the sweet spot, one for headings and one for body text. Using more than two fonts makes your site look cluttered. Some great sites use just one font family and vary the weight (bold, regular, light) for contrast.
What's the difference between serif and sans-serif?
Serif fonts have small decorative strokes at the ends of letters (like Times New Roman). Sans-serif fonts are clean and simple (like Arial or Inter). Sans-serif is the default choice for most websites because it's easier to read on screens.
What font size should I use for body text?
16px is the standard minimum for body text on the web. Anything smaller is hard to read on phones. For headings, 24-48px works well depending on the importance. Let your AI tool set up a consistent size scale.