liveBook · Manning

Em

As explained in Math for Web Design

em is a CSS relative length unit whose value is based on the computed font size of the relevant element.

The em unit expresses a CSS length relative to the current element’s computed font size. For font-size itself, nested em values multiply through the inheritance chain, so the browser converts each result to pixels before rendering. section 3.1.1 section 3.4.4

Calculate a nested em value by multiplying the base size by every inherited multiplier:

  • computed size = base size × multiplier₁ × multiplier₂ × … × multiplierₙ section 3.1.2
  • Deep nesting can produce unexpectedly large or small text because each font-size multiplier compounds with the previous result. section 3.4.4

Nested headings

With a 16px root, main at 1.25em becomes 20px. A direct h2 at 2em becomes 40px, while an article at 1.75em makes its nested h2 70px. Replacing h2’s value with 2rem makes both headings 32px because rem references the root. section 3.4.5

How Math for Web Design covers it

How deep it goes
Explains conversion, inheritance multiplication, formulas, and worked heading calculations, while deferring broader CSS rendering details.
Examples
Uses nested parent-and-child text, compounded headings, pixel calculations, and em-based media-query breakpoints.
What you can do after
Apply em calculations to predict rendered sizes and diagnose unexpected growth in nested typography.
How it connects
Connects em to CSS inheritance, computed values, rem units, media queries, and responsive design.

Also explained in

Compare how 4 books explain em →

Related concepts

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