Box model, units and text
Text and fonts
Goal: Style readable text with font, size, weight, line-height and alignment · 9 min
Good typography makes pages readable.
| property | purpose | example |
|---|---|---|
font-family | typeface, with fallbacks | font-family: "Open Sans", Arial, sans-serif; |
font-size | size | font-size: 1rem; |
font-weight | boldness | font-weight: 700; (bold) or 400 (normal) |
font-style | italic | font-style: italic; |
line-height | line spacing | line-height: 1.5; (unitless: times the font size) |
text-align | alignment | left, center, right, justify |
text-decoration | underline etc. | none, underline |
text-transform | case | uppercase, capitalize |
letter-spacing | tracking | 0.05em |
Font stacks list fallbacks in order, ending with a generic family (serif, sans-serif, monospace). The browser uses the first one that is installed or loaded. Names with spaces need quotes.
Readability rules of thumb: body text 16–18px (1rem or more), line-height 1.4–1.6, line length of about 45–75 characters (max-width: 65ch), enough contrast, and never use colour alone to carry meaning.
body { font-family: system-ui, sans-serif; line-height: 1.6; }
article { max-width: 65ch; }Worked example: A readable article
- Choose a font stack: system-ui, then sans-serif.
- Set font-size: 1.125rem and line-height: 1.6 for comfortable reading.
- Limit the line length with max-width: 65ch.
article {
font-family: system-ui, sans-serif;
font-size: 1.125rem;
line-height: 1.6;
max-width: 65ch;
}