Typography is controlled by a family of font-* and text-* properties. Getting them right is most of what makes a page look polished and readable.
{
: , system-ui, sans-serif;
: ;
: ;
: italic;
: ;
: ;
}
font-family: "Inter", system-ui, -apple-system, sans-serif;
The browser tries each in order until one is available. Always end with a generic family (sans-serif, serif, monospace) so text renders even if custom fonts fail. system-ui uses the OS's native font (fast, no download).
.text {
text-align: center; /* left | right | center | justify */
text-decoration: underline;/* underline | line-through | none */
text-transform: uppercase; /* UPPERCASE | lowercase | Capitalize */
white-space: nowrap; /* prevent wrapping */
word-break: break-word; /* break long words/URLs */
}
line-height: 1.5; /* ✅ 1.5 × the element's font-size — scales correctly */
line-height: 24px; /* ⚠️ fixed — doesn't adapt if font-size changes */
A unitless line-height multiplies each element's own font-size, so it stays proportional when nested elements have different sizes — the recommended approach.
.truncate {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis; /* shows "..." when text is cut off */
}
Text properties drive readability and visual hierarchy — font-size/weight for emphasis, line-height (~1.5) for comfortable reading, fallback stacks for reliability, and text-overflow for clean truncation.
Good typography is the bulk of good-looking UI.