typography

font-size

Sets the size of rendered text. Modern designs use rem for accessibility and clamp() for fluid typography that scales with the viewport.

font-size: <length> | <percentage> | <absolute-size> | <relative-size> | clamp(...)

Common values

Value Effect
1rem Root-relative size, respects user zoom
16px Fixed pixel size
1.125em Relative to parent's computed font size
clamp(1rem, 1vw + 1rem, 1.5rem) Fluid size with a min and max
smaller One step smaller than the parent

Examples

html { font-size: 100%; }

Respect user's default browser size

h1 { font-size: clamp(1.75rem, 3vw + 1rem, 3rem); }

Fluid heading that scales with viewport

small { font-size: .875rem; }

Slightly smaller supporting text

Gotcha

Using px prevents users from scaling text with browser zoom in some accessibility settings; prefer rem for body copy.

Related properties

← All CSS properties · CSS selectors · Grid vs Flexbox