liveBook · Manning

Absolute unit

As explained in Web Design Playground, Second Edition

An absolute CSS unit represents a fixed physical or reference dimension that does not scale with inherited or user-adjusted text size.

An absolute CSS unit gives a measurement a fixed size: a pixel stays a pixel. That sounds reassuring, but fixed sizing can ignore user-adjusted text sizes and make layouts rigid on different screens. section 7.6

Common absolute units include:

  • px (pixel): an absolute measurement equal to 1/96 of an inch. section 7.6
  • pt (point): an absolute measurement equal to 1/72 of an inch. section 7.6
  • Absolute values can override user text-size preferences, while relative units such as rem and percentages adapt to them. section 7.6

A fixed header versus a responsive header

With header { height: 64px; }, a larger default font can make the heading overflow its container and clip letter descenders. Changing the height to 4rem lets the header grow with the text. section 14.11

Table 7.1 Units of measurement for CSS properties (view table figure)

Unit

Name

Description

px

Pixel

An absolute measurement equal to 1/96 of an inch

pt

Point

An absolute measurement equal to 1/72 of an inch

em

Em

A relative measurement equal to the element’s default, inherited, or defined font size

rem

Root em

A relative measurement equal to the font size of the root element of the web page

vw

Viewport width

A relative measurement equal to 1/100 of the current width of the browser window

vh

Viewport height

A relative measurement equal to 1/100 of the current height of the browser window

Compare absolute units with em, rem, vw, and vh, whose sizes depend on inherited text, the root element, or the viewport. section 7.6

How Web Design Playground, Second Edition covers it

How deep it goes
Defines px and pt, explains user-preference and responsive-layout consequences, and stops short of detailed unit mechanics.
Examples
Demonstrates px and rem through a header whose fixed height clips enlarged text.
What it assumes
Assumes basic CSS property-and-value syntax while introducing measurement units and the root element from the fundamentals.
What you can do after
Evaluate fixed dimensions and replace them with responsive measurements when user text settings or screen sizes may vary.
How it connects
Contrasts absolute units with relative units, rem units, percentages, viewport units, and responsive web design.

Related concepts

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