liveBook · Manning

Rem

As explained in Architecting Accessibility

A rem unit is a relative CSS length unit whose value is based on the root element's font size.

The CSS rem unit sizes text relative to the root element’s font size. Keeping the root at the browser default lets user font-size preferences take effect; 1rem is usually 16px, though the default can vary. section 4.4.1 section 4.3

Scale text with the root

Set the root to 100%, then size body text at 1rem and an h1 at 2rem. These sizes scale proportionally when users increase their root font size. By contrast, fixed pixel values are generally less adaptable to user preferences. section 4.4.1 section 4.3

:root { font-size: 100%; } #A
body { font-size: 1rem; } #B
h1 { font-size: 2rem; } #C

Use this CSS pattern to keep the root at the browser default and size text with rem. section 4.4.1

How Architecting Accessibility covers it

How deep it goes
Defines rem relative to the root font size, explains scaling, and contrasts fixed-pixel sizing with CSS examples.
Examples
Shows root sizing at 100%, body text at 1rem, an h1 at 2rem, and fixed-pixel alternatives.
What it assumes
Explains the browser-default root font size and rem sizing without requiring a custom root size.
What you can do after
Apply rem sizing in CSS to support user font preferences and proportional text scaling.
How it connects
Connects rem with relative units, pixel units, root font size, text scaling, and browser zoom.

Also explained in

Compare how 7 books explain rem →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Architecting Accessibility. The section links point to the parts of the book it draws on.