CSS font-family & font-size
- type
- property
- applies to
- any element containing text
- inherits
- yes
- common values
- system-ui, sans-serif, 16px, 1rem
Where it goes
Usually set once on body and passed down to everything. Override only where a specific tag really needs to differ.
Example
body {
font-family: system-ui, sans-serif;
font-size: 16px;
}Common mistakes
- Listing one font with no general fallback like sans-serif at the end. If that font fails to load, the browser picks something unpredictable.
- Setting every font-size in px. That ignores a reader's own text-size setting. rem scales with it.