CSS text-transform / letter-spacing
- type
- properties
- applies to
- text
- inherits
- yes
- common values
- uppercase | capitalize | none; 0.05em, 1px, -0.02em
Where it goes
On the text or a parent. Both pass down. A common pair: text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px for a small label or a nav link.
Example
.eyebrow {
text-transform: uppercase;
letter-spacing: 0.08em;
font-size: 12px;
}
h1 { letter-spacing: -0.02em; }Common mistakes
- Typing the text in capitals in the HTML instead. A screen reader (software that reads the page aloud) may spell all-caps words letter by letter, and CSS cannot undo it. Lowercase in HTML, uppercase in CSS.
- Using px for letter-spacing on text that changes size. 2px is loose on 12px text and invisible on 48px. em scales with the text.
- Adding spacing to capitals and forgetting it also lands after the last letter. Centered labels drift right. A matching negative margin-right fixes it.