Most of a web page is text, so good typography does more for how a site feels than almost anything else. The good news: a handful of CSS properties cover the essentials, and small tweaks to size and spacing make a surprisingly big difference to readability.
1Font family and size
font-family sets the typeface. You give a stack — a list of fallbacks — so if the first font isn't available, the browser tries the next, ending with a generic family:
font-family: 'Inter', system-ui, sans-serif;
The generic families are serif (with little feet, like Times), sans-serif (clean, like Arial), and monospace (fixed-width, like code).
Sizing text: px vs rem
px— a fixed pixel size (font-size: 16px). Simple and predictable.rem— relative to the page's base size (1remusually equals 16px,1.5remequals 24px). Preferred for body text because it respects the user's chosen browser font size — an accessibility win.
font-familytakes a stack of fallbacks ending in a generic family (serif/sans-serif/monospace).pxis fixed;remscales with the user's base size and is preferred for body text.- Keep body text at least 16px (1rem) for readability.
2Weight, spacing, alignment — and web fonts
A few more properties polish your text:
font-weight—normal,bold, or numbers100–900.line-height— space between lines.1.5–1.6is comfortable for body text; cramped lines are tiring to read.text-align—left,center,right,justify.text-decoration— e.g.underline, ornoneto remove link underlines.letter-spacing— fine-tune the gaps between letters.
Web fonts
To use a font most computers don't have (like a Google Font), link it in your HTML head, then name it in font-family:
<link href="https://fonts.googleapis.com/css2?family=Inter" rel="stylesheet">
/* then in CSS */
body { font-family: 'Inter', sans-serif; }font-weight(normal/bold or 100–900),line-height(1.5–1.6 for body),text-alignandletter-spacingpolish text.- Load a web font by linking it, then naming it in
font-family. - Limit web fonts (two families is plenty) to keep pages fast.
★ Practical: style a readable article
In any playground, style a short article so that:
- Body text is
1remwithline-heightof about1.6. - The
<h1>uses a larger size and a heavierfont-weight. - A
.leadintro paragraph is slightly larger and a softer colour. - Try a Google web font, falling back to a generic family in the stack.
Ready to test yourself?
Take the short quiz. Score 60% or more to mark this lesson complete.
Start the quiz →💡 Log in to save your progress and earn the certificate.