liveBook · Manning

Relative unit

A relative unit is a CSS length unit whose value is determined in relation to a contextual reference, such as a font size, parent dimension, container, or viewport.

How 2 Manning books explain it

Architecting Accessibility

A relative measurement unit specifies a size in relation to another value, such as a parent dimension, root size, or viewport.

How it is used
Supports text resizing and zoom by sizing fonts, spacing, and containers relative to user or layout values.
How deep it goes
Explains em, rem, and percentages for fonts and spacing, then demonstrates rem-based sizing alongside fixed-pixel styling.
Examples
Contrasts rem-based root, body, and heading rules with fixed-pixel body and heading sizes.
What you can do after
Apply relative CSS units to size text and spacing while supporting user font preferences and adaptable containers.

Read how Architecting Accessibility explains relative unit →

Tiny CSS Projects

A relative unit is a CSS length unit whose computed size depends on another value, such as the element's font size.

How it is used
Scales typography, padding, and margins with text size while reserving fixed units for measurements that should not change.
How deep it goes
Explains relative sizing through blockquote and form examples, but does not develop unit computation internals.
Examples
Uses a styled blockquote and text-input form controls to contrast scalable spacing with a fixed border.
What you can do after
Build it from scratch by choosing relative units for text-dependent spacing and fixed units for invariant details.

Read how Tiny CSS Projects explains relative unit →

Also covered in

What to know first

Related concepts

Questions about relative unit

What is relative unit?

A relative unit is a CSS length unit whose value is determined in relation to a contextual reference, such as a font size, parent dimension, container, or viewport.

Which Manning books explain relative unit?

Architecting Accessibility and Tiny CSS Projects.

What should I know before learning relative unit?

Manning books that teach relative unit usually introduce rem first.

What is the difference between relative unit and absolute unit?

A relative unit is a CSS length unit whose value is determined in relation to a contextual reference, such as a font size, parent dimension, container, or viewport. An absolute CSS length unit has a fixed reference magnitude or defined relationship to physical or CSS reference lengths rather than depending on surrounding layout.

What kinds of relative unit are there?

Kinds of relative unit include rem.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.