Great typography
Good typography is mostly restraint. A sensible scale, comfortable spacing and enough contrast beat any clever effect. A label, a table cell, a marketing headline and an article paragraph should not share one set of rules. Apply these principles when building or reviewing anything with text in it.
Match the project's styling system. Before suggesting or writing any fix, check how the codebase styles things and express every change in that system: Tailwind utilities in a Tailwind project, plain declarations in CSS, CSS Modules, styled-components or StyleX. The cheat sheet maps each declaration to its Tailwind equivalent. Never introduce a second styling approach just to apply a typography fix.
Quick Reference
| Category | When to use | Reference |
|---|
| Choosing fonts | Font categories, pairing, formats, typeface anatomy | choosing-fonts.md |
| Variable fonts & OpenType | Axes, weights, tabular numbers, stylistic sets | variable-fonts-and-opentype.md |
| Spacing & sizing | Type scale, line-height, letter-spacing, text trimming | spacing-and-sizing.md |
| Wrapping & punctuation | Measure, wrapping, truncation, smart punctuation, RTL | wrapping-and-punctuation.md |
| Details & accessibility | Underlines, selection, forms, decorative text, contrast | details-and-accessibility.md |
| CSS cheat sheet | Quick lookup of every property covered, with Tailwind equivalents | css-cheat-sheet.md |
Core Principles
1. Serve the Right Format
Use
(Brotli compression, broadly supported) on the web.
is a fallback only for very old browsers;
and
are raw desktop formats with no web compression. How the files are loaded is the project's own concern, this skill does not prescribe it.
2. Properties Over Raw Tags
When a CSS property exists, use it.
instead of
font-variation-settings: "wght" 650
,
font-optical-sizing: auto
instead of
,
font-variant-numeric: tabular-nums
instead of
font-feature-settings: "tnum" 1
. Properties keep working when a non-variable fallback renders. Reserve the raw-tag properties for custom axes (
) and niche features (
) that have no property of their own.
3. No Fake Weights
When a weight or style is not loaded, the browser synthesizes it. That is a safety mechanism, not a feature. Set
so missing files fail visibly instead of rendering a faked bold or italic.
4. Fewer Fonts, Sizes and Weights
Rarely use more than three fonts. Weight and size define hierarchy, but overusing them hurts readability quickly. Pair for contrast, not similarity: a serif headline with a sans body reads as deliberate, two near-identical sans-serifs read as a mistake.
5. Use a Type Scale with Semantic Names
Define a small set of sizes and deviate from it as little as possible. Hard-coded sizes without a system break down at scale. For solo projects, default names like
work fine as long as the usage rules are clear. On a team, name sizes by use (
), not by size, so the rules stay consistent.
6. Line-Height by Role
Headings tighter, around
. Body copy
to
. Prefer unitless values so line-height scales with the font size; fixed values like
do not.
7. Letter-Spacing by Size
Large headings often look better with slightly negative letter-spacing. Small uppercase labels need a little positive letter-spacing so letters do not feel crowded. Body copy at reading sizes needs neither.
8. Cap the Measure
Long lines make it hard for the eye to find the next line. Cap long-form text around 60–75 characters per line. Any unit works:
measures characters directly, and a pixel or rem cap is just as good — at a
body size the range lands roughly between
and
depending on the font, so Tailwind's
or
fit. What matters is that a cap exists and the resulting line length sits in range.
9. Wrap Deliberately
distributes text evenly across lines: use it on headings.
avoids leaving a single short word on the final line: use it on descriptions. Skip both in long-form text: browsers ignore
past a few lines anyway, and evening out a whole paragraph wastes space and makes it harder to read.
overflow-wrap: break-word
where long words, links or IDs could escape the container.
on labels and badges where a line break looks broken.
10. Tabular Numbers on Changing Values
Digits have different widths by default, so timers, counters and prices shift layout as they update. Apply
font-variant-numeric: tabular-nums
to any value that changes.
11. Truncate Without Losing Content
Single line:
with
and
. Multiple lines:
. Truncation hides content, so if the missing text matters, keep the full value reachable in a tooltip or expanded view.
12. Write Copy Naturally, Style with CSS
Store text in natural case and control presentation with
, so redesigns never require rewriting copy. Use smart punctuation: curly quotes in prose (straight quotes in code), an en dash for ranges like
, an em dash to set off a thought, the single ellipsis character,
to keep values like
together and
to control where long words may break.
13. Underlines from the Font
Default underlines sit wherever the browser decides. Pull position and thickness from the font's own metrics with
text-underline-position: from-font
and
text-decoration-thickness: from-font
, or tune manually with
text-decoration-thickness
,
and
.
draws the line dotted, dashed or wavy; a dotted underline is a common hint that a word carries extra information, like an abbreviation or a defined term. Unless the only thing animating is a color change, build the underline as a separate element instead of using
— color is the only part of a real underline that animates reliably.
14. Inputs at 16px on Mobile
iOS Safari zooms the whole page when an input's text is smaller than
. Keep input text at
on mobile viewports (
). Avoid the
viewport meta: Safari ignores it for pinch zoom, but every other browser honors it and blocks zooming, which fails WCAG.
15. Size and Contrast Floors
Body text
(the web default and the right reading size). UI text can go smaller:
for inputs and menus (inputs still need
on mobile, see principle 14),
for captions, rarely below
. WCAG AA:
contrast for regular text,
for large text (roughly
and up).
16. Font Smoothing on the Root
On macOS text renders heavier than intended. Apply
-webkit-font-smoothing: antialiased
and
-moz-osx-font-smoothing: grayscale
(both covered by Tailwind's
) once on the root layout so they cover all text.
17. Logical Properties for Direction
To support right-to-left content, use direction-agnostic properties:
instead of
,
instead of
. Set
so browsers pick the right quotes and hyphenation, and
where needed.
18. Style the Selection, Disable It Where It Distracts
is a subtle way to embed brand in the reading experience; keep the combination legible. Use
on button labels where copying is unlikely and selection feels distracting, and make sure
only grabs text the user expects to copy. In cross-platform apps that feel closer to native, disable selection for the interface and keep it only on content worth copying.
Review Output Format
Always present changes as a markdown table with Before and After columns. Include every change you made, not just a subset. Never list findings as separate "Before:" / "After:" lines outside of a table. Group changes by principle using a heading above each table, and keep each row focused on a single diff. Write every After snippet in the styling system the project already uses.
Example
Tabular numbers
| Before | After |
|---|
| on live price | <span className="tabular-nums">{price}</span>
|
font-feature-settings: "tnum" 1
| font-variant-numeric: tabular-nums
|
Line-height and measure
| Before | After |
|---|
| on body paragraph | (body needs –) |
| Full-width article column | (~65 characters per line at ) |
Rows should cite the specific file and property when it is not obvious from the snippet. If a principle was reviewed but nothing needed to change, omit that table entirely.
Common Mistakes
| Mistake | Fix |
|---|
| / served on the web | Convert to |
font-variation-settings: "wght"
for weight | (works with non-variable fallbacks) |
font-feature-settings: "tnum" 1
| font-variant-numeric: tabular-nums
|
| Browser-faked bold or italic | Load the file, set |
| Hard-coded one-off font sizes | Use the type scale |
| on scalable text | Unitless value () |
| Full-width paragraphs | Cap around 60–75 characters per line |
| Orphan on the last line of a paragraph | |
| Lopsided two-line heading | |
| Numbers cause layout shift | |
| Truncated text with no way to read it | Tooltip or expanded view for the full value |
| typed into copy | Natural case + |
| Justified text in an interface | ; reserve justify for specific editorial layouts |
| Underline cuts through descenders | text-decoration-skip-ink: auto
, metrics |
| Inputs below zoom on iOS | |
| in RTL-capable UI | |
| Selectable button labels in native-feel UI | , keep selection on real content |
| Extra-info hint with no visual cue | Dotted underline via text-decoration-style: dotted
|
| Tailwind classes dropped into a CSS-in-JS codebase (or the reverse) | Express the fix in the styling system the project already uses |
Review Checklist