Sub topic 14
Common pitfalls and exceptions
This chapter assumes you know the difference between kerning (per pair), tracking (per run of text), and word spacing, and that you can write basic CSS. It collects the mistakes that show up most often when you apply those controls.
Tracking out lowercase body text
Loose tracking on lowercase body text breaks up word shapes. Readers recognize words by their overall outline, and wide gaps make that harder. Keep body text at the font's default spacing, or change it by only a few hundredths of an em. Open up small all-caps labels instead, because capitals are designed to sit apart and benefit from the extra room.
Fixing the wrong problem
Tracking cannot repair a single bad pair. If "AV" looks tight but the rest of the line is fine, tracking the whole line loosens everything else too. Kern that pair, then adjust tracking last.
Trailing space in CSS
letter-spacing adds space after every character, including the last one. In centered text, buttons, and badges, the text looks shifted left by half the spacing value. Cancel the extra space with a negative margin of the same size.
.label {
text-transform: uppercase;
letter-spacing: 0.12em;
margin-right: -0.12em;
}Inheritance of em values
An em value is converted to an absolute length on the element where you declare it. Children inherit that length, not the em ratio. A heading inside the card below keeps the small body spacing even though its font is three times larger.
.card {
font-size: 1rem;
letter-spacing: 0.1em; /* 1.6px at a 16px root size */
}
.card h2 {
font-size: 3rem;
/* still 1.6px, which is only about 0.033em here */
}Set letter-spacing on the element that owns the font size, so the value scales with it.
Ligatures and tracked text
Browsers skip optional ligatures when letter-spacing is non-zero, but engines differ in the details. Disable ligatures explicitly on tracked text so the result is the same everywhere.
.tracked-caps {
text-transform: uppercase;
letter-spacing: 0.1em;
font-variant-ligatures: none;
}Exceptions where letter spacing is wrong
- Connected scripts. In Arabic and similar scripts, letters join each other. Adding letter spacing breaks the joins, so leave it at zero.
- Monospaced code. Every glyph has the same advance width by design, so tracking spoils the grid that columns rely on.
- Mixed fonts. Optical kerning in a design tool judges each font by its shapes. It can give inconsistent results on mixed-font lines, so check them by eye.
- Turning kerning off. Setting
font-kerning: noneis useful for comparisons. Leave it off in production text only if you have a specific reason.
| Pitfall | Symptom | Fix |
|---|---|---|
| Tracked lowercase body text | Words fall apart | Keep default spacing |
| Tracking to fix one pair | Rest of line too loose | Kern the pair |
| Trailing letter-spacing | Centered text sits off-center | Negative margin |
| em inherited as length | Large child text too tight | Declare on the element that owns the size |
| Ligatures vary | Different results across browsers | `font-variant-ligatures: none` |
Exercise
A centered all-caps button label with letter-spacing: 0.15em looks slightly shifted to the left. Why does this happen, and how do you correct it?
Show answer
letter-spacing adds space after every character, including the last, so the text box has an empty gap on its right side that pushes the visible letters left. Add margin-right: -0.15em (or equivalent padding) to cancel the trailing space.
Exercise
You set letter-spacing: 0.1em on .card (font size 1rem, 16px). An h2 inside is 3rem. What letter-spacing does the h2 use, and how would you make it scale with the heading?
Show answer
It inherits the computed length of 1.6px, not 0.1em of its own size. Declare letter-spacing: 0.1em (or another em value) on the h2 itself, so it is computed against the heading's font size.