CSS Units Reference

Every CSS length unit with use cases and 2026 additions.

By Λ · Updated May 18, 2026

Absolute Units

Fixed sizes that do not scale with anything. Use sparingly; they fight responsive design.

UnitDefinitionWhen to use
pxPixels (1px = 1/96in on screen)Borders, fine details, sometimes margins. Most common absolute unit.
ptPoints (1pt = 1/72in)Print stylesheets only.
in / cm / mmInches / centimeters / millimetersPrint stylesheets only.
pcPicas (1pc = 12pt)Print typography. Rarely used in web.
QQuarter-millimetersVery precise print. Almost never used.

Font-relative Units

Sizes relative to a font measurement. Scale with user preferences when paired with rem.

emRelative to current element's font-size. 1em = parent font-size in most cases.
remRelative to ROOT element's font-size (usually 16px). The right default for most sizing.
exHeight of lowercase 'x' in current font. Rare.
chWidth of '0' (zero) character in current font. Useful for content width: max-width: 65ch for readable line length.
capCap height (uppercase letter height) of current font. 2023+ unit.
icWidth of CJK water ideograph. For non-Latin typography.
lhLine-height of current element. 2022+ unit.
rlhLine-height of root element. 2022+ unit.

Viewport Units

Sizes relative to the viewport. The 2022 addition of dvh/svh/lvh fixed the mobile-browser-toolbar problem.

vw1% of viewport width
vh1% of viewport height (originally; on mobile this can jump when toolbar shows/hides)
vmin1% of viewport's smaller dimension
vmax1% of viewport's larger dimension
dvh / dvwDynamic viewport. Updates as mobile toolbar shows/hides. The 2026 default.
svh / svwSmall viewport (toolbar visible). Use for elements that must always fit.
lvh / lvwLarge viewport (toolbar hidden). Maximum size of viewport.
dvi / svi / lviInline equivalents (logical, respects writing-mode).
dvb / svb / lvbBlock equivalents.

Grid units

frFraction of remaining space in CSS Grid. 1fr 2fr = 1:2 ratio of available space.
minmax(min, max)Function for flexible grid tracks. minmax(200px, 1fr).

Other

%Percentage of containing block. Meaning depends on property: width=container width, font-size=parent font-size, etc.
deg / rad / turn / gradAngle units. 1turn = 360deg.
s / msTime units for animations and transitions.
Hz / kHzFrequency units (for speech CSS, rare).
dpi / dpcm / dppxResolution units, mainly for media queries.

Recipes I use daily

Last updated