Font Stack & Sizing
body {
font-family: 'Inter Variable', Inter, system-ui, -apple-system, sans-serif;
font-size: 1rem;
line-height: 1.6;
}
h1 {
font-family: 'Space Grotesk Variable', 'Space Grotesk', sans-serif;
font-weight: 700;
font-size: clamp(1.75rem, 1.4rem + 2vw, 3rem);
}
code {
font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
}
The generic family at the end of font-family is the fallback if none of the named fonts are available — never omit it.
A resilient font stack, and sizing that scales with the reader's own settings.
- font-family
- A prioritized list ending in a generic family (sans-serif, serif, monospace)
- font-size
- rem ties size to the root font size, which respects the user's browser zoom
- line-height
- A unitless number scales with font-size; a px value does not
- font-weight
- 100–900; variable fonts accept any value in between, not just the named steps
Text Overflow & Wrapping
h1 {
text-wrap: balance;
}
p {
text-wrap: pretty;
}
.single-line-truncate {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.multi-line-clamp {
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
Truncating, balancing, and clamping text without cutting off mid-word.
- text-wrap: balance
- Evens out line lengths — best on short headings, not body copy
- text-wrap: pretty
- Avoids stranding a single word alone on the last line
- text-overflow: ellipsis
- Needs overflow: hidden and white-space: nowrap to have any effect
- -webkit-line-clamp
- Truncates after N lines — still needs the -webkit- prefix everywhere