Simple Rules for Great Web Typography

Simple Rules for Great Web Typography

Updated by Andy Feliciotti

Most of a website is text. If the text is hard to read, people leave, no matter how nice the rest of the design is.

I wrote the first version of this post in 2013 after reading Typographic Web Design by Laura Franz. The rules in it still hold up. What changed is CSS, which now handles a lot of the fiddly parts for you.

In this post, I’ll go through the rules I actually use, with the CSS for each, and some AI prompts you can paste into ChatGPT, Claude or Cursor to check and fix the type on your own site. Let’s get into it.

The Quick Version

Since you’re likely here for the CSS, here’s a starting point that follows every rule below. Swap in your own fonts and colors:

:root {
  font-family: "Your Body Font", system-ui, sans-serif;
}

body {
  font-size: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem); /* 17px on phones, up to 19px */
  line-height: 1.6;
  color: #2f3a31;
  background: #f6f3ea;
}

.content {
  max-width: 50ch; /* about 65 to 75 characters per line */
  margin-inline: auto;
  padding-inline: 16px;
}

p {
  margin: 0 0 1.1em;
  text-wrap: pretty;
}

h1, h2, h3 {
  color: #16251a;
  line-height: 1.15;
  margin: 1.6em 0 0.5em;
  text-wrap: balance;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.375rem; }

a {
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

table {
  font-variant-numeric: tabular-nums;
}

Here’s why each part is there.

1. Use a Bigger Font Size Than You Think

Browsers default to 16px, and that’s the floor for body text, not the goal. For reading-heavy pages like blog posts, 17px to 20px is more comfortable on a laptop. This blog uses 19px.

Set sizes in rem instead of px where you can. rem follows the reader’s browser setting, so someone who bumped their default font size up still gets bigger text.

For headings, pick a scale instead of random sizes. Multiply each level by the same ratio, somewhere between 1.2 and 1.333. This blog is roughly 1.2, with a few sizes nudged by eye: 19px body, then 22, 26, 32 and 42px for h4 up to h1. Typescale lets you preview a ratio with your own font.

2. Keep Lines Between 45 and 75 Characters

This one makes the biggest difference. When a line runs past about 80 characters, your eye has trouble finding the start of the next line, and you end up rereading. The classic range from print typography is 45 to 75 characters, with about 66 as the sweet spot. WCAG’s highest accessibility level asks for no more than 80.

Here’s the same paragraph both ways:

The same paragraph at about 120 characters per line and at about 70 characters per line

On my blog, a typical line is around 70 characters. You get there by capping the width of your content:

.content { max-width: 50ch; }

One thing worth knowing: a lot of guides say max-width: 65ch gives you 65 characters. It doesn’t. A ch is the width of the “0” character, and most letters are narrower. In my test with the system font at 19px, 65ch fit about 90 characters per line. 50ch fit 65 to 76. Whatever font you use, set the width, then count the characters on a real line.

On phones the screen does this for you. Lines drop to about 35 to 45 characters at 17px, and that’s fine.

3. Give Lines Room With Line Height

Body text needs a line height of about 1.5 to 1.7. Below that, lines blur together. Above it, the text starts to feel like a list. I use 1.65 here.

Write it without a unit (line-height: 1.6, not 24px). A unitless value scales with the font size of each element, so it keeps working when you change sizes later.

Headings are the exception. Big text with body line height looks loose and disconnected, so headings get something tighter, like 1.1 to 1.25.

4. Space Paragraphs Less Than a Full Line

Paragraph spacing lets readers skim. A bottom margin of about 70% of your line height works well. With a 1.6 line height, that’s around 1.1em. This is the rule I learned from the book in 2013, and it’s still what this site uses.

Give headings more space above than below (margin: 1.6em 0 0.5em). That way each heading sits with the section it starts, instead of floating halfway between two.

5. Left-Align Body Text

Keep paragraphs left-aligned. Justified text looks tidy in print, where software hyphenates words and tunes the spacing. Browsers don’t do that by default, so justified paragraphs on the web get uneven gaps between words, and on a phone those gaps get huge.

Centered text is fine for a short heading or a one-line intro. For anything longer than two or three lines, it makes every line start in a different spot, which is hard to follow.

6. Make Sure the Text Has Enough Contrast

Light gray text on white looks clean in a mockup and is hard to read for a lot of people. WCAG’s minimum is a contrast ratio of 4.5:1 for body text and 3:1 for large text (about 24px, or 19px bold).

Some real numbers:

Text on background Ratio Passes for body text
#999999 on white 2.85:1 No
#767676 on white 4.54:1 Yes, barely
#2f3a31 on #f6f3ea (this blog) 10.69:1 Yes

You can check any pair with my contrast checker on ColorKit. Headings usually look best a step darker than body text, and pure black on pure white can feel harsh, so a very dark gray or a tinted dark color is a nice middle ground.

7. Pick One or Two Fonts That Fit the Content

There’s no one perfect font. Pick one that matches what the text is saying. Comic Sans gets a lot of hate, but for a kids’ daycare it fits. For a law firm, it doesn’t.

If you use two fonts, they should be different enough to tell apart but not fighting each other. A common pairing is a serif for headings and a sans serif for body text, or the other way around. If two fonts look almost the same, just use one in two weights. Google Fonts shows suggested pairings on each font’s page.

For body text, pick a font made for reading at small sizes. Display and handwritten fonts are fun for headings and logos, and tiring for paragraphs.

8. Load Fonts Without the Page Jumping

Custom fonts load after the page shows up. Without some care, the text either stays invisible for a second, or shows in a fallback font and then jumps when the real font arrives.

font-display: swap shows the fallback right away:

@font-face {
  font-family: "Your Body Font";
  src: url("/fonts/body.woff2") format("woff2");
  font-display: swap;
}

To stop the jump, tune the fallback font to take up the same space as your real font with size-adjust. This is what this site does with its body font:

@font-face {
  font-family: "Body Fallback";
  src: local("Arial");
  size-adjust: 102.95%;
  ascent-override: 94.1%;
  descent-override: 23.43%;
  line-gap-override: 0%;
}

:root {
  font-family: "Your Body Font", "Body Fallback", sans-serif;
}

You don’t have to work out those numbers by hand. Tools like Fontaine calculate them, and Next.js does it automatically when you load fonts with next/font. Also use woff2 files and only load the weights you actually use.

9. Fix Awkward Line Breaks With text-wrap

Two newer CSS properties fix things designers used to fix by hand:

  • text-wrap: balance evens out the lines of a heading, so you don’t get a long first line and one word hanging on the second. It works in Chrome, Firefox and Safari. It’s only for short text: Chrome stops balancing past 6 lines and Firefox past 10, so don’t bother putting it on paragraphs.
  • text-wrap: pretty avoids a single short word stranded on the last line of a paragraph. It works in Chrome and Safari. Firefox just wraps normally, so it’s safe to use now.

10. Sweat the Small Details

A few one-liners that make text feel more finished:

  • Underlines: text-underline-offset: 3px moves link underlines off the letters, so they don’t cut through descenders like “g” and “y”.
  • Letter spacing: leave body text alone. Big headings can look better slightly tighter, but scale it with the size instead of putting one value on everything. This blog uses -0.01em on h1 and h2 and the font’s own spacing on h3 and h4. I used -0.02em everywhere until recently, and the smaller headings looked crowded. Small all-caps labels go the other way and need a little extra, around 0.05em, so the letters don’t crowd.
  • Numbers: font-variant-numeric: tabular-nums makes every digit the same width. Use it in tables, prices and timers so numbers line up and don’t wiggle when they change.
  • Don’t fix text heights: readers with low vision often increase line height and letter spacing with browser extensions. WCAG says your layout should survive up to 1.5 line height, paragraph spacing of 2 times the font size, and extra letter and word spacing. If a box has a fixed height, the text will overflow it.

11. Watch for AI Template Patterns

AI site builders are fast, and they make a lot of the same choices. Once you’ve seen a few dozen AI-generated sites, you start spotting them right away, and so do your visitors, even if they couldn’t tell you why. Michal Malewicz wrote a good breakdown of these patterns, and it matches what I see. The ones to look for in your own type:

  • The default font. AI tools pick whatever shows up most in the code they learned from, so Inter, Geist and Poppins are everywhere. They’re good fonts. They just don’t say anything about you anymore. A less common free font, or a paid one, fixes this in one line.
  • Tight letter spacing on every heading. The same negative tracking on every size, every time. Tune it to your font instead (see rule 10).
  • A gradient on the second line of the headline. Usually on a bold sans serif, and usually on words that don’t need the emphasis.
  • One highlighted word in a short headline, often in a slanted serif. If a headline is under about a dozen words, it probably doesn’t need a highlight at all.

None of these are wrong on their own. It’s the combination that makes a site look like it took five minutes.

The bigger fix is the words. Write the real headings and copy first, at roughly the right sizes, before you pick fonts or colors. Malewicz calls this typeframing. If the copy is “Unlock seamless growth for your business”, no font is going to save it.

AI Prompts to Check and Fix Your Typography

AI coding tools are good at this kind of audit, because the rules are specific and they can read your CSS. Here are the prompts I’d use. They work in ChatGPT or Claude if you paste your CSS, or in Claude Code and Cursor where the AI can read your project directly.

Audit Your Current Typography

Review the typography in this site's CSS against these rules and list every problem you find, with the file, the selector and the fix:

- Body text (paragraphs and lists in the main content) is 16px minimum, ideally 17px to 20px, set in rem. Check smaller text like captions, notes and code blocks too.
- Lines of body text are 45 to 75 characters on desktop. Count characters on a rendered page if you can, since ch values usually fit more than you expect. Phones can go down to about 35.
- Body line height is unitless, 1.5 to 1.7. Headings are 1.1 to 1.25.
- Paragraph spacing is about 70% of the line height.
- Headings have more space above than below.
- Text contrast is at least 4.5:1, or 3:1 for text 24px and up. Calculate the actual ratio for each text color and its background, in light and dark mode. Include placeholder text.
- No more than two font families, not counting a monospace font for code.
- Fonts use woff2 and font-display: swap, with a fallback that limits layout shift.
- Headings use text-wrap: balance and paragraphs use text-wrap: pretty.
- No fixed heights on elements that contain text.
- Headings don't all share one tight letter-spacing value, and there's no gradient text or highlighted word in short headlines.

Don't change anything yet. Start with the problems that affect readability the most.

The “don’t change anything yet” line is on purpose. You’ll get a list to look over first, instead of a pile of edits to untangle.

I ran this prompt on this blog with Claude Code. It found 11 problems, ranked. The useful ones: comment form placeholder text at 3.01:1 contrast, paragraphs in comments spaced too tightly, a note box running about 81 characters per line, and every font size set in px. So I don’t fully follow my own rem rule yet. It also confirmed what was already fine, like 60 to 73 characters per line on desktop and 10.69:1 contrast for body text.

Set Up a Type System From Scratch

Set up the typography for this site in plain CSS (or Tailwind, if the project uses it).

Body font: [font name or "system font stack"]
Heading font: [font name or "same as body"]
Content type: [blog posts / docs / marketing site / web app]

Requirements:
- Body text 17px on phones, scaling to 19px on desktop with clamp(), in rem.
- Content width set so body lines are about 65 characters.
- A small heading scale (h1 to h4) with tighter line height than the body.
- Paragraph and heading spacing based on the line height.
- Link underlines with offset, and tabular numbers in tables.
- Font loading with font-display: swap and a size-adjusted fallback so the page doesn't shift.
- Light and dark text colors that pass WCAG AA contrast. Show the ratio for each.

Keep it in a single file with CSS variables, and explain any value that isn't obvious in a short comment.

Find a Font Pairing

Suggest 5 free font pairings from Google Fonts for [describe your site, like "a personal blog about web development with a friendly, playful feel"].

For each pairing, give:
- The heading font and the body font.
- One sentence on why they work together.
- Whether the body font holds up at 17px for long paragraphs.
- The weights I'd actually need, so I only load those.

Skip the fonts AI tools default to, like Inter, Geist, Poppins, Montserrat and Open Sans.

AI is decent at suggesting pairings and bad at seeing them, so open each suggestion in Google Fonts and look at a real paragraph before you pick.

Fix Layout Shift From Web Fonts

When this page loads, the text jumps when the custom font arrives. Fix it:

1. Find where fonts are loaded and make sure they use woff2 and font-display: swap.
2. Add a fallback @font-face using a local system font with size-adjust, ascent-override, descent-override and line-gap-override, so the fallback takes up the same space as the real font. Calculate the values from the font's metrics.
3. Preload only the font file used for body text above the fold.
4. Remove any font weights or styles the CSS never uses.

Keep the AI From Undoing It Later

Once your type looks right, the next AI-built page can quietly bring back a 15px font or a new font family. AI tools also lean on the same safe fonts, like Inter and Roboto, when you don’t tell them otherwise. Anthropic says as much in their own post on frontend design.

The fix is a rules file the AI reads every time. Claude Code reads CLAUDE.md, and Cursor, Codex and most other tools read AGENTS.md. Add a short section like this, with your own values:

## Typography

- Fonts: "Your Body Font" for body text, "Your Heading Font" for headings. Don't add other font families.
- Body text: 19px desktop, 17px mobile, line-height 1.6. Never smaller than 16px.
- Headings: 22, 26, 32 and 42px (h4 to h1), line-height 1.15, letter-spacing -0.01em on h1 and h2.
- Content width: 50ch (about 70 characters per line). Don't make text columns wider.
- Colors: body text and headings use the CSS variables in globals.css. New text colors need 4.5:1 contrast.
- Use the existing type styles before writing new ones.

Whatever the AI changes, look at the page afterward in a real browser, in both light and dark mode, on a phone. Typography is one of those things where the numbers can be right and it still looks a little off.

FAQs About Web Typography

What’s the best font size for body text on a website?

16px is the minimum. For long reading, 17px to 20px is more comfortable. Use rem units so the text respects the reader’s browser settings.

What’s the ideal line length for reading?

45 to 75 characters per line, with about 66 being the classic ideal. Cap your content width so lines stay in that range on desktop, then count a real line to check, since ch units usually fit more characters than you’d expect.

What line height should I use?

About 1.5 to 1.7 for body text, written without a unit. Headings look better tighter, around 1.1 to 1.25.

How many fonts should a website use?

One or two. A second font should be clearly different from the first, usually one for headings and one for body text. If you need more variety, use different weights of the same font.

Is Inter a bad font?

No. Inter is a great font for interfaces. The problem is that AI site builders and templates use it so often that it now reads as a default. If you keep it, pair it with a second font and set your own weights and letter spacing, so it doesn’t look like every other generated site.

Should I use px, em or rem for font sizes?

Use rem for font sizes so they follow the reader’s browser setting. Use em for spacing that should grow with the text, like paragraph margins. Plain px is fine for small things like borders and underline offsets.

Wrapping Up

None of these rules are strict. They’re starting points. Set them up, then read a few real pages of your site on a laptop and a phone, and adjust what feels off. If you’re working on colors too, my post on hex color opacity pairs well with this one.

    Slap a sticker on this post

    Comments

    Loading comments…