—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.
fixed, unmoving, precise
px — a fixed pixel; stable, predictable, not responsiveUse when you want something to stay the same size everywhere.
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 sizeUse when you want elements to scale with typography or structure.
responsive to the size of the screen
vw — 1% of the viewport widthvh — 1% of the viewport heightUse when you want elements to adapt fluidly to screen size.
for grid layouts
fr — a share of the available space in a gridUse when you want proportional distribution without math.
AI can generate correct CSS
but still miss the intention behind a unit.
When we name the unit, we tell AI:
Units are how we express behavior,
not just size.