Table of Contents
Units of Measure
—the ways we describe size, scale,
and proportion in CSS
Units of measure are how we express how big something should be
— not as exact numbers, but as relationships.
Each unit carries a different mental model.
When we choose a unit,
we choose how the element should behave as the environment changes.
Units are not syntax.
They are intent.
Absolute Units
fixed, unmoving, precise
px— a fixed pixel; stable, predictable, not responsive
Use when you want something to stay the same size everywhere.
Relative Units
scaling with context, typography, or the viewport
em— relative to the element’s own font sizerem— relative to the root font size%— relative to the parent’s size
Use when you want elements to scale with typography or structure.
Viewport Units
responsive to the size of the screen
vw— 1% of the viewport widthvh— 1% of the viewport height
Use when you want elements to adapt fluidly to screen size.
Fractional Units
for grid layouts
fr— a share of the available space in a grid
Use when you want proportional distribution without math.
Why Units of Measure matter when working with AI
AI can generate correct CSS
but still miss the intention behind a unit.
When we name the unit, we tell AI:
- whether the size should stay fixed or scale
- whether it should follow typography or layout
- whether it should respond to the viewport
- whether proportions matter more than exact numbers
Units are how we express behavior,
not just size.
