Use relative units in CSS for resizable content

Using relative units improves accessibility by ensuring that text and content does not overlap when zooming web pages or changing the base font size.

Status
accepted
Date
Contributors
Adam Varn, Andrew Berry, Aubrey Sambor, Chris DeLuca, Claire Ristow, Javier Reartes, John Kaeser, Kat Shaw, Pauline Judge
Topics
front-end css

Decision

Use relative length units (such as rem) for all applicable properties.

Exceptions

Absolute length units should be used for the following properties, instead of relative ones.

  • border
  • border-radius
  • box-shadow
  • outline
  • Any decorative property where it is unexpected for it to scale with the type size.

A unitless value should be used for line-height.

Consequences

Pages will be more accessible as fonts will respect browser preferences and font sizes will not compound with each other. The same is true for content with other relative units.

Additional Resources

Search Decisions