CSS units reference — px, rem, em, vw, dvh, cqi and more with a size preview

Type a unit or a type such as viewport and the reference lists the matching CSS units with their category, what they are relative to and a short example, and draws bars in your own browser so you can compare real sizes.

Live demo · real result from this tool
Showing43 of 43 units

Table

UnitCategoryMeaningExample
pxAbsolute lengthCSS pixel — 1/96 of an inch (a reference pixel, not a device pixel).1px = 0.75pt
cmAbsolute lengthCentimetre.1cm = 37.8px
mmAbsolute lengthMillimetre.1mm = 3.78px
QAbsolute lengthQuarter-millimetre.4Q = 1mm
inAbsolute lengthInch.1in = 96px = 2.54cm
ptAbsolute lengthPoint, 1/72 of an inch (print).12pt = 16px
pcAbsolute lengthPica, 12 points.1pc = 16px
emFont-relativeThe element's font size (for font-size itself: the parent's).2em = twice the font size
remFont-relativeThe root element's font size.1rem = 16px by default
exFont-relativex-height of the font.≈ 0.5em in many fonts
rexFont-relativex-height of the root font.
chFont-relativeAdvance width of the "0" glyph — handy for text measure.max-width: 65ch
rchFont-relativech of the root font.
capFont-relativeCap height of the font.
icFont-relativeAdvance of the CJK "水" glyph.
lhFont-relativeComputed line-height of the element.margin-block: 1lh
rlhFont-relativeLine-height of the root element.
vwViewport1% of the viewport width.100vw = full width (includes the scrollbar)
vhViewport1% of the viewport height.On mobile, use dvh/svh to avoid toolbar jumps
vminViewport1% of the smaller of width and height.
vmaxViewport1% of the larger of width and height.
viViewport1% of the viewport in the inline direction.
vbViewport1% of the viewport in the block direction.
svh / svwViewportSmall viewport: with browser toolbars shown.min-height: 100svh
lvh / lvwViewportLarge viewport: with toolbars hidden.
dvh / dvwViewportDynamic viewport: tracks toolbars as they appear and disappear.height: 100dvh
cqwContainer1% of the query container's width.font-size: 5cqw
cqhContainer1% of the query container's height.
cqiContainer1% of the container's inline size.
cqbContainer1% of the container's block size.
cqmin / cqmaxContainerSmaller / larger of cqi and cqb.
%RelativePercentage of a reference value (usually the parent's size).width: 50%
frGridA fraction of the free space in a grid container.grid-template-columns: 1fr 2fr
degAngleDegrees; a full circle is 360deg.rotate(45deg)
radAngleRadians; a full circle is 2π rad.1rad ≈ 57.3deg
gradAngleGradians; a full circle is 400grad.
turnAngleTurns; a full circle is 1turn.rotate(0.25turn) = 90deg
sTimeSeconds.transition: 0.3s
msTimeMilliseconds.300ms = 0.3s
Hz / kHzFrequencyHertz (aural CSS; rarely used).
dppx / xResolutionDots per CSS pixel; 1x = 96dpi.@media (min-resolution: 2x)
dpiResolutionDots per inch.96dpi = 1dppx
dpcmResolutionDots per centimetre.

43 rows — scroll inside the table, or download the CSV.

Preview

Processed on your device — nothing is uploaded.

How to use the CSS units reference

  1. Type in Filter: a unit (rem, dvh), a category (viewport, container, angle, time) or a word from the meaning (toolbar, root).
  2. Read the Unit, Category, Meaning and Example columns. “Showing” gives the count out of 43.
  3. Scroll to the Preview. Its bars use 96px, 1in, 2.54cm, 72pt, 6em, 6rem, 12ch, 50% and 20vw, drawn by your browser at its current zoom and window size.
  4. Download the table as css-units.csv if you want it for a style guide.

What it does and when to use it

CSS has grown well beyond px and %. Newer units fix real layout problems: dvh for full-height mobile screens, ch for readable line lengths, container units for components that adapt to their slot, and lh for spacing that follows the line height. This reference collects them in one table with a one-line meaning and a sample declaration. Use it when you review a stylesheet with an unfamiliar unit, choose a unit for a new design token, or explain to a teammate why 100vh jumps on phones.

To build a fluid size that moves between two limits, use the CSS Clamp Generator. For breakpoints, the Media Query Generator writes the @media rules.

How it works

The table is a fixed list based on CSS Values and Units Level 4, plus fr from CSS Grid and the container query units. It is grouped into absolute lengths, font-relative lengths, viewport units, container units, percentages, fr, angles, times, frequency and resolution. The filter keeps rows where every word you type appears in some cell. The preview is plain HTML, so the bars show how your own browser resolves each unit right now; resize the window and the 20vw bar changes, while the 1in bar does not.

Worked examples

Root-relative type. Filter rem:

rem | Font-relative | The root element's font size. | 1rem = 16px by default

16px is the default root size in browsers; users can change it, which is why rem respects their setting.

All viewport units. Filter viewport returns Showing: 9 of 43 units: vw, vh, vmin, vmax, vi, vb and the small, large and dynamic pairs.

Mobile full height. Filter dvh returns dvh / dvw | Viewport | Dynamic viewport: tracks toolbars as they appear and disappear. | height: 100dvh.

Limits and tips

  • Browser support differs for the newest units, such as rlh, rex, rch and cap; check support before you depend on them.
  • 96px, 1in, 2.54cm and 72pt are the same length by definition, but none of them is guaranteed to measure an inch on a real screen.
  • For quick px to rem sums, use the PX to REM Converter.

Frequently asked questions

Should I use rem or em?
Use rem for sizes that should follow the user's base font setting but stay the same across components, such as spacing and type scales. Use em when a size should grow with its own element's font size, such as padding inside a button.
Is 1px one screen pixel?
No. A CSS pixel is defined as 1/96 of an inch, a reference pixel. On a high-density screen one CSS pixel covers several device pixels.
Why is 100vh too tall on my phone?
On many mobile browsers vh uses the large viewport, measured with the toolbars hidden. Use 100dvh to follow the toolbars as they appear, or 100svh for the size with toolbars shown.
What are cqi and cqw?
Container query units. They are a percentage of the nearest ancestor that is a size container (container-type set), not of the viewport, so a card can scale its text to its own width.
Can I convert between units here?
No, it is a reference. For px to rem maths, use the PX to REM Converter. Relative units depend on context, so only absolute units have fixed ratios.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close