CSS Unit Rulebook

All 63 CSS units in seven groups. Each one has its formula, an example, where it helps, where it bites and what browsers support it.

Your device, right now

Measured in this browser window. It updates when you resize, zoom or rotate.

Root font size (1rem)
…
1vw
…
1vh
…
1svh (small viewport)
…
1lvh (large viewport)
…
1dvh (dynamic viewport)
…
1ch (body font)
…
Device pixel ratio
…
Scrollbar width
…
Safe area (top, right, bottom, left)
…

Try it

Two experiments. Each runs in a frame, and inside a frame the viewport and the root font size belong to the frame, so every unit does exactly what it does in a real page.

Width: what follows what?

Make the frame narrower or wider. Viewport units follow the frame. The container unit follows the box inside it.

420px

vw, svw, lvw and dvw agree here. Browser toolbars mostly change the height of a phone's viewport, not its width, so the variants part ways only in the vertical direction. Both bars sit in the narrower inner box. 50% measures that box. 50cqw still measures the container.

Open this demo on its own page

The same experiment as a table
Resolved sizes at three frame widths (default 16px root size)
ValueFrame 320pxFrame 768pxFrame 1280px
50vw, 50svw, 50lvw, 50dvw160px384px640px
50cqw130px178px178px
50%70px98.8px98.8px

Font size: what follows the reader's setting?

Change the default font size, the way a reader does in browser settings. Watch which units move.

16px (100%)

Page zoom scales px too. This setting is different: it is the default size a reader picks in browser settings, and px text ignores it.

Open this demo on its own page

The same experiment as a table
Resolved text sizes at three default font sizes
ValueDefault 12pxDefault 16pxDefault 24px
font-size: 16px16px16px16px
font-size: 1rem12px16px24px
font-size: 1em (parent 1.25rem)15px20px30px
font-size: 1.2em × 3 levels20.74px27.65px41.47px

Absolute 7 units

Fixed lengths tied to the CSS pixel by constant ratios.

Reference The CSS pixel

px

The CSS pixel: the anchor that the other absolute units are measured in.

Safe to useBaseline: widely available

  • Chrome 1+
  • Edge 12+
  • Firefox 1+
  • Safari 1+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome1+
Chrome Android18+
Edge12+
Firefox1+
Firefox Android4+
Safari1+
Safari iOS1+

Formula 1px = 1/96in

What changes it

Moves with
  • page zoom
Stays put under
  • the reader's text size
  • the window size
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

Hairlines, shadows and the box around a fixed bitmap: details that should hold still while the text around them scales.

Watch out

A CSS pixel is not a screen pixel. On a 2x display one px covers 2×2 device pixels, and page zoom changes that ratio too. Text in px still grows with page zoom, but it ignores the default font size set in browser settings.

Example The text moves to rem and follows the reader; the hairline stays in px and holds still.

Before

.card {
  font-size: 14px;
  border: 1px solid;
}

After

.card {
  font-size: 0.875rem;
  border: 1px solid;
}

Full page for pxMDN (opens in a new tab)Specification (opens in a new tab)

pt

The typographic point: 1/72 of an inch, which is 1.333…px on screen.

Safe to useBaseline: widely available

  • Chrome 1+
  • Edge 12+
  • Firefox 1+
  • Safari 1+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome1+
Chrome Android18+
Edge12+
Firefox1+
Firefox Android4+
Safari1+
Safari iOS1+

Formula 1pt = 1/72in = 4/3px

What changes it

Moves with
  • page zoom
Stays put under
  • the reader's text size
  • the window size
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

Print stylesheets, where the sizes on the page are the sizes the designer quoted.

Watch out

Points sound physical, but on a screen they are not. 12pt is exactly 16px everywhere, whatever the real size of the display.

Example On screen 9pt is 12px at any reader setting. On paper 11pt is 11 points of type.

Before

.legal {
  font-size: 9pt;
}

After

@media print {
  body { font-size: 11pt; }
}

Full page for ptMDN (opens in a new tab)Specification (opens in a new tab)

pc

The pica: 12 points, which makes it exactly 16px.

Safe to useBaseline: widely available

  • Chrome 1+
  • Edge 12+
  • Firefox 1+
  • Safari 1+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome1+
Chrome Android18+
Edge12+
Firefox1+
Firefox Android4+
Safari1+
Safari iOS1+

Formula 1pc = 12pt = 1/6in = 16px

What changes it

Moves with
  • page zoom
Stays put under
  • the reader's text size
  • the window size
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

A print layout on a pica grid, such as column widths copied from a newspaper template.

Watch out

pc and pt are easy to mix up in one rule, and the arithmetic hides: 3pc + 4pt is 53.33px.

Example 20pc is 320px: 20 × 16px.
.column {
  inline-size: 20pc;
}

Full page for pcMDN (opens in a new tab)Specification (opens in a new tab)

in

The inch: 96px, 2.54cm, 72pt.

Safe to useBaseline: widely available

  • Chrome 1+
  • Edge 12+
  • Firefox 1+
  • Safari 1+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome1+
Chrome Android18+
Edge12+
Firefox1+
Firefox Android4+
Safari1+
Safari iOS1+

Formula 1in = 96px = 2.54cm = 72pt = 6pc

What changes it

Moves with
  • page zoom
Stays put under
  • the reader's text size
  • the window size
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

@page margins and the other print sizes that the rest of the sheet is derived from.

Watch out

Nothing on screen is measured with a ruler. The browser does not know how large the display really is, so 1in always draws as 96 CSS px. Only paper output makes the unit physical.

Example On screen 3in is 288 CSS pixels of unknown physical size. On paper the margin is a real inch.

Before

.ruler {
  inline-size: 3in;
}

After

@page {
  margin: 0.75in;
}

Full page for inMDN (opens in a new tab)Specification (opens in a new tab)

cm

The centimeter: 1/2.54 of an inch, about 37.8px.

Safe to useBaseline: widely available

  • Chrome 1+
  • Edge 12+
  • Firefox 1+
  • Safari 1+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome1+
Chrome Android18+
Edge12+
Firefox1+
Firefox Android4+
Safari1+
Safari iOS1+

Formula 1cm = 96px / 2.54 ≈ 37.795px

What changes it

Moves with
  • page zoom
Stays put under
  • the reader's text size
  • the window size
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

Print styles written in metric: A4 margins, label sheets, posters.

Watch out

A CSS centimeter is a ratio, not a measurement. A 5cm box on a phone is not five centimeters wide to the eye. Check physical sizes in print preview or a PDF, never on the screen.

Example A label meant to print at 5 by 3 centimeters.
.label {
  inline-size: 5cm;
  block-size: 3cm;
}

Full page for cmMDN (opens in a new tab)Specification (opens in a new tab)

mm

The millimeter: a tenth of a centimeter, about 3.78px.

Safe to useBaseline: widely available

  • Chrome 1+
  • Edge 12+
  • Firefox 1+
  • Safari 1+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome1+
Chrome Android18+
Edge12+
Firefox1+
Firefox Android4+
Safari1+
Safari iOS1+

Formula 1mm = 1/10cm ≈ 3.7795px

What changes it

Moves with
  • page zoom
Stays put under
  • the reader's text size
  • the window size
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

Fine print dimensions: bleeds, safe zones, label gutters.

Watch out

Millimeters in screen CSS look precise but are not. They turn into fractional pixels: 0.1mm is 0.378px, thinner than one pixel on a 1x display.

Example A 3mm safe zone inside a printed sheet.
.sheet {
  padding: 3mm;
}

Full page for mmMDN (opens in a new tab)Specification (opens in a new tab)

Q

The quarter-millimeter, a unit taken from Japanese phototypesetting.

Safe to useBaseline: widely available

  • Chrome 63+
  • Edge 79+
  • Firefox 49+
  • Safari 13.1+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome63+
Chrome Android63+
Edge79+
Firefox49+
Firefox Android49+
Safari13.1+
Safari iOS13.4+

Formula 1Q = 1/40cm = 0.25mm ≈ 0.945px

What changes it

Moves with
  • page zoom
Stays put under
  • the reader's text size
  • the window size
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

Type sizes carried over from Japanese print specifications, which quote them in Q.

Watch out

Support arrived late. Safari added Q in 13.1 (iOS 13.4), so older iPhones and Macs drop any declaration that uses it.

Example 14Q is 3.5mm, about 13.2px.
.caption {
  font-size: 14Q;
}

Full page for QMDN (opens in a new tab)Specification (opens in a new tab)

Font-relative 12 units

Lengths measured from a font, so they follow the text.

Reference Font size and glyph metrics

em

The font size of the element it is used on. Inside font-size itself, the font size of its parent.

Safe to useBaseline: widely available

  • Chrome 1+
  • Edge 12+
  • Firefox 1+
  • Safari 1+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome1+
Chrome Android18+
Edge12+
Firefox1+
Firefox Android4+
Safari1+
Safari iOS1+

Formula 1em = the font-size of the element; in font-size itself, the parent's

What changes it

Moves with
  • the reader's text size
  • page zoom
Stays put under
  • the window size
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

Padding, gaps and borders inside a component that sets its own font-size, and media query breakpoints.

Watch out

em compounds. In font-size it multiplies the parent's size, so a list nested three levels deep at 1.2em ends up 1.728 times the base size.

Example Padding in em: raise the badge's font-size and the padding grows in step.

Before

.badge {
  font-size: 0.75rem;
  padding: 3px 6px;
}

After

.badge {
  font-size: 0.75rem;
  padding: 0.2em 0.5em;
}

Full page for emMDN (opens in a new tab)Specification (opens in a new tab)

rem

A size measured from the font size set on the page's html element.

Safe to useBaseline: widely available

  • Chrome 4+
  • Edge 12+
  • Firefox 3.6+
  • Safari 5+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome4+
Chrome Android18+
Edge12+
Firefox3.6+
Firefox Android4+
Safari5+
Safari iOS4+

Formula 1rem = font-size of :root (16px unless the reader changed the browser default)

What changes it

Moves with
  • the reader's text size
  • page zoom
Stays put under
  • the window size
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

Type sizes and the spacing between blocks, so that one browser setting scales the whole page.

Watch out

Setting the root size in pixels (say, 16px on html) switches off the reader's preference: rem then stays at 16px whatever the browser setting says. Leave the root alone or use a percentage.

Example No root size in px, and the heading follows the reader's setting along with its margin.

Before

html { font-size: 16px; }
h1 {
  font-size: 32px;
  margin-block-end: 24px;
}

After

h1 {
  font-size: 2rem;
  margin-block-end: 1.5rem;
}

Full page for remMDN (opens in a new tab)Specification (opens in a new tab)

ch

The width of the zero digit in the current font.

Safe to useBaseline: widely available

  • Chrome 27+
  • Edge 12+
  • Firefox 1+
  • Safari 7+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome27+
Chrome Android27+
Edge12+
Firefox1+
Firefox Android4+
Safari7+
Safari iOS7+

Formula 1ch = advance width of "0" in the element's font (0.5em if it cannot be measured)

What changes it

Moves with
  • the reader's text size
  • page zoom
  • the font in use
Stays put under
  • the window size
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

The measure of a text column, and inputs for a known number of digits.

Watch out

In IBM Plex Sans, the font of this site, a line 65ch wide held about 87 characters of English prose: zeros are wider than most letters. The number to write depends on the font, and changes when the font does.

Example A measure that follows the font instead of a pixel count. Tune the number in the real font.

Before

.story {
  max-inline-size: 720px;
}

After

.story {
  max-inline-size: 65ch;
}

Full page for chMDN (opens in a new tab)Specification (opens in a new tab)

rch

The zero-digit width, measured in the font of the root element.

Use with a fallbackBaseline: newly available since January 2026

  • Chrome 111+
  • Edge 111+
  • Firefox 147+
  • Safari 17.2+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome111+
Chrome Android111+
Edge111+
Firefox147+
Firefox Android147+
Safari17.2+
Safari iOS17.2+

Formula 1rch = the value of ch on the root element

What changes it

Moves with
  • the reader's text size
  • page zoom
  • the font in use
Stays put under
  • the window size
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

A line length that must stay the same when a component switches to another font family.

Watch out

In a heading set larger than the body, 60rch is narrower than 60ch by exactly the ratio of the two font sizes, because rch still counts the body's zero. Browsers without rch drop the declaration, so write the ch line first.

Example ch is the fallback where rch is missing.
.story {
  max-inline-size: 65ch;
}
@supports (width: 1rch) {
  .story { max-inline-size: 65rch; }
}

Full page for rchMDN (opens in a new tab)Specification (opens in a new tab)

ex

How tall a lowercase x is in the current font.

Safe to useBaseline: widely available

  • Chrome 1+
  • Edge 12+
  • Firefox 1+
  • Safari 1+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome1+
Chrome Android18+
Edge12+
Firefox1+
Firefox Android4+
Safari1+
Safari iOS1+

Formula 1ex = x-height of the element's font (0.5em if it cannot be determined, as the specification has it)

What changes it

Moves with
  • the reader's text size
  • page zoom
  • the font in use
Stays put under
  • the window size
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

An inline mark that should stop where the lowercase letters stop.

Watch out

At one font-size the x-height differs from font to font, so 1ex is a poor bridge across a font stack. If the intended font fails to load, every ex value changes with the fallback.

Example An icon as tall as two lowercase letters.
.inline-icon {
  inline-size: 2ex;
  block-size: 2ex;
}

Full page for exMDN (opens in a new tab)Specification (opens in a new tab)

rex

How tall a lowercase x is in the font set on the root element.

Use with a fallbackBaseline: newly available since January 2026

  • Chrome 111+
  • Edge 111+
  • Firefox 147+
  • Safari 17.2+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome111+
Chrome Android111+
Edge111+
Firefox147+
Firefox Android147+
Safari17.2+
Safari iOS17.2+

Formula 1rex = the value of ex on the root element

What changes it

Moves with
  • the reader's text size
  • page zoom
  • the font in use
Stays put under
  • the window size
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

Small marks that must share one height across components set in different fonts.

Watch out

Where the unit is unknown the browser throws the declaration away. Write a rem value first and the rex line after it, so older browsers keep the first one.

Example Browsers without rex keep the first line.
.icon {
  block-size: 1rem;
  block-size: 2rex;
}

Full page for rexMDN (opens in a new tab)Specification (opens in a new tab)

cap

How tall the capital letters are in the current font.

Safe to useBaseline: widely available

  • Chrome 118+
  • Edge 118+
  • Firefox 97+
  • Safari 17.2+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome118+
Chrome Android118+
Edge118+
Firefox97+
Firefox Android97+
Safari17.2+
Safari iOS17.2+

Formula 1cap = cap height of the element's font (the ascent of the font if it cannot be determined, as the specification has it)

What changes it

Moves with
  • the reader's text size
  • page zoom
  • the font in use
Stays put under
  • the window size
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

An icon or box that should be exactly as tall as the capitals of its label.

Watch out

Cap height belongs to the font, so changing the font changes every cap value. A browser without the unit drops the declaration, so give the property a fallback line before the cap one.

Example 1em overshoots the capitals by the ascender room; 1cap stops where they stop.

Before

.btn svg {
  block-size: 1em;
}

After

.btn svg {
  block-size: 1cap;
}

Full page for capMDN (opens in a new tab)Specification (opens in a new tab)

rcap

Capital-letter height as the root element's font draws it.

Use with a fallbackBaseline: newly available since January 2026

  • Chrome 118+
  • Edge 118+
  • Firefox 147+
  • Safari 17.2+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome118+
Chrome Android118+
Edge118+
Firefox147+
Firefox Android147+
Safari17.2+
Safari iOS17.2+

Formula 1rcap = the value of cap on the root element

What changes it

Moves with
  • the reader's text size
  • page zoom
  • the font in use
Stays put under
  • the window size
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

One icon height for the whole page, tied to the capitals of the main font.

Watch out

rcap reads the font of the root, so a component set in another font still gets the capital height of the page, not its own. Where the unit is missing the declaration is dropped, so put a rem line before it.

Example The rem line is the fallback.
.logo {
  block-size: 1.5rem;
  block-size: 2rcap;
}

Full page for rcapMDN (opens in a new tab)Specification (opens in a new tab)

ic

The width of the CJK water ideograph (水) in the current font.

Safe to useBaseline: widely available

  • Chrome 106+
  • Edge 106+
  • Firefox 97+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome106+
Chrome Android106+
Edge106+
Firefox97+
Firefox Android97+
Safari15.4+
Safari iOS15.4+

Formula 1ic = advance of 水 (U+6C34) in the element's font (1em if it cannot be measured)

What changes it

Moves with
  • the reader's text size
  • page zoom
  • the font in use
Stays put under
  • the window size
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

Line lengths and indents counted in ideographs in Chinese, Japanese or Korean text.

Watch out

A font without CJK glyphs cannot measure the ideograph, and the unit falls back to 1em. Two different Latin fonts then report the same ic.

Example ch counts Latin zeros; ic counts ideographs, so the line holds about forty of them.

Before

.note {
  max-inline-size: 40ch;
}

After

.note {
  max-inline-size: 40ic;
}

Full page for icMDN (opens in a new tab)Specification (opens in a new tab)

ric

The width of the ideograph 水, taken from the font set on the root element.

Use with a fallbackBaseline: newly available since January 2026

  • Chrome 111+
  • Edge 111+
  • Firefox 147+
  • Safari 17.2+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome111+
Chrome Android111+
Edge111+
Firefox147+
Firefox Android147+
Safari17.2+
Safari iOS17.2+

Formula 1ric = the value of ic on the root element

What changes it

Moves with
  • the reader's text size
  • page zoom
  • the font in use
Stays put under
  • the window size
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

A CJK grid that holds across components, including ones set in a Latin-only font.

Watch out

Like ic it needs a 水 glyph, here in the root font, and falls back to the root's 1em without one. Where the unit is unsupported the declaration is ignored, so write an em line before it.

Example The em line serves browsers without ric.
.note {
  max-inline-size: 40em;
  max-inline-size: 40ric;
}

Full page for ricMDN (opens in a new tab)Specification (opens in a new tab)

lh

The line height of the element it is used on.

Safe to useBaseline: widely available

  • Chrome 109+
  • Edge 109+
  • Firefox 120+
  • Safari 16.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome109+
Chrome Android109+
Edge109+
Firefox120+
Firefox Android120+
Safari16.4+
Safari iOS16.4+

Formula 1lh = used line-height of the element

What changes it

Moves with
  • the reader's text size
  • page zoom
Stays put under
  • the window size
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

Gaps and heights counted in the element's own lines: margin-block: 1lh, min-block-size: 4lh.

Watch out

With line-height: normal, 1lh depends on the font's own metrics, and a line can grow taller than line-height when tall inline content sits in it, so 3lh is not always three rendered lines.

Example One blank line in whatever font and size the paragraph uses, instead of a number that fits one size.

Before

p + p {
  margin-block-start: 24px;
}

After

p + p {
  margin-block-start: 1lh;
}

Full page for lhMDN (opens in a new tab)Specification (opens in a new tab)

rlh

The line height set on the root element, shared by the whole page.

Safe to useBaseline: widely available

  • Chrome 111+
  • Edge 111+
  • Firefox 120+
  • Safari 16.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome111+
Chrome Android111+
Edge111+
Firefox120+
Firefox Android120+
Safari16.4+
Safari iOS16.4+

Formula 1rlh = used line-height of :root

What changes it

Moves with
  • the reader's text size
  • page zoom
Stays put under
  • the window size
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

Page-wide vertical rhythm: section spacing in whole lines of body text.

Watch out

It tracks the root's line height, so a component with bigger text will not get taller gaps from it. Good for page rhythm, wrong for spacing inside a component.

Example Section padding is two lines of body text.
section {
  padding-block: 2rlh;
}

Full page for rlhMDN (opens in a new tab)Specification (opens in a new tab)

Percentage 1 unit

A share of some other value. Which value depends on the property.

Reference Another value

%

A share of some other value. Which value depends on the property.

Safe to useBaseline: widely available

  • Chrome 1+
  • Edge 12+
  • Firefox 1+
  • Safari 1+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome1+
Chrome Android18+
Edge12+
Firefox1+
Firefox Android4+
Safari1+
Safari iOS1+

Formula N% = N/100 × the reference value of the property

What changes it

Moves with
  • page zoom
Stays put under
  • the reader's text size
  • the window size
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

And whatever moves the property's own reference: the parent's width, the element's box, the inherited font size.

Reach for it when

Widths that share a parent, and translate() or border-radius, which take their percentage of the element's own box.

Watch out

In a box 400px wide, padding-block: 10% is 40px whatever the height of the box. In horizontal text, padding and margin take their percentage from the width on all four sides.

Example 5% of the container's width, not of its height.
.story-head {
  padding-block: 5%;
}

Full page for %MDN (opens in a new tab)Specification (opens in a new tab)

Viewport 24 units

Shares of the window, with three extra readings for phones whose toolbars come and go.

Reference The viewport

vw

1% of the viewport's width.

Safe to useBaseline: widely available

  • Chrome 20+
  • Edge 12+
  • Firefox 19+
  • Safari 6+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome20+
Chrome Android25+
Edge12+
Firefox19+
Firefox Android19+
Safari6+
Safari iOS6+

Formula 1vw = 1/100 of the viewport width

What changes it

Moves with
  • the window size
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

Fluid type with a rem term inside clamp(), and full-bleed bands that ignore their parent.

Watch out

100vw includes the room a classic vertical scrollbar takes, so a block of that width is wider than the room left and the page scrolls sideways. Overlay scrollbars take no room, so the bug can hide on one machine and show on another.

Example The rem terms follow zoom and the reader's default size, the vw term does not. In a 1280px window, zooming to 200% enlarges this text 1.33 times, not 2.

Before

h1 {
  font-size: 4vw;
}

After

h1 {
  font-size: clamp(1.5rem, 1rem + 2.5vw, 3rem);
}

Full page for vwMDN (opens in a new tab)Specification (opens in a new tab)

vh

1% of the viewport's height.

Safe to useBaseline: widely available

  • Chrome 20+
  • Edge 12+
  • Firefox 19+
  • Safari 6+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome20+
Chrome Android25+
Edge12+
Firefox19+
Firefox Android19+
Safari6+
Safari iOS6+

Formula 1vh = 1/100 of the viewport height (the large viewport)

What changes it

Moves with
  • the window size
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

Full-height panels and height floors on desktop, where no toolbar comes and goes.

Watch out

Plain vh follows the large viewport, the size with retractable toolbars pulled away. Where a browser has such toolbars, a 100vh block is taller than the visible area while they are shown, so its bottom edge sits under them.

Example Under a 60px header, a 100vh section makes the page 60px taller than the window. Take the header off.

Before

.opening {
  min-block-size: 100vh;
}

After

.opening {
  min-block-size: calc(100vh - var(--header));
}

Full page for vhMDN (opens in a new tab)Specification (opens in a new tab)

vi

A hundredth of the viewport along the inline axis, the direction text runs in.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1vi = 1/100 of the viewport size in the inline direction

What changes it

Moves with
  • the window size
  • the writing mode
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars

Reach for it when

Layouts that must work in horizontal and vertical writing modes.

Watch out

MDN and the summary table in the specification take the axis from the writing-mode of the root, while the definition of vi says the box's own. Chromium 156, Firefox 157 and WebKit 27.2, measured on this site, follow the definition: the element that carries the unit, set there or inherited. The readings agree until an element overrides writing-mode, so test that case in each browser you support. Right-to-left direction changes nothing in either reading, only a vertical writing-mode does.

Example Resolves like 40vw in horizontal text and like 40vh in vertical text.
.column {
  inline-size: 40vi;
}

Full page for viMDN (opens in a new tab)Specification (opens in a new tab)

vb

A hundredth of the viewport along the block axis, the direction lines stack in.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1vb = 1/100 of the viewport size in the block direction

What changes it

Moves with
  • the window size
  • the writing mode
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars

Reach for it when

Panels and rails sized along the flow direction, for pages that may switch to vertical text.

Watch out

In horizontal writing it equals vh, so mistakes stay hidden until a page switches to vertical text. Like vh it follows the large viewport, so toolbars can cover its end. Whose writing-mode picks the axis is the question described under vi: the root's in MDN, the element's in the definition and in all three engines measured there.

Example As tall as the viewport in the direction text stacks.
.rail {
  block-size: 100vb;
}

Full page for vbMDN (opens in a new tab)Specification (opens in a new tab)

vmin

A hundredth of the shorter side of the window.

Safe to useBaseline: widely available

  • Chrome 26+
  • Edge 12+
  • Firefox 19+
  • Safari 7+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome26+
Chrome Android26+
Edge12+
Firefox19+
Firefox Android19+
Safari7+
Safari iOS7+

Formula 1vmin = 1% of min(viewport width, viewport height)

What changes it

Moves with
  • the window size
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

A square or circle that must fit the window whichever way it is turned.

Watch out

A window can get wider without changing the value: 10vmin stays 80px from 1000px to 2560px wide at 800px tall, because only the shorter side counts.

Example In a wide, short window 70vw is taller than the window; 70vmin fits either way.

Before

.dial {
  inline-size: 70vw;
  aspect-ratio: 1;
}

After

.dial {
  inline-size: 70vmin;
  aspect-ratio: 1;
}

Full page for vminMDN (opens in a new tab)Specification (opens in a new tab)

vmax

A hundredth of the longer side of the window.

Safe to useBaseline: widely available

  • Chrome 26+
  • Edge 16+
  • Firefox 19+
  • Safari 7+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome26+
Chrome Android26+
Edge16+
Firefox19+
Firefox Android19+
Safari7+
Safari iOS7+

Formula 1vmax = 1% of max(viewport width, viewport height)

What changes it

Moves with
  • the window size
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

A background shape that must reach every edge of the window.

Watch out

A block of 100vmax is longer than the window in its shorter direction (1280px against 800px in a 1280 by 800 window), so it scrolls or overflows unless a parent clips it.

Example A circle 1.5 times as wide as the window's longer side, enough to reach the corners of a window of any shape. It overflows on purpose, so clip it.
.glow {
  inline-size: 150vmax;
  aspect-ratio: 1;
  border-radius: 50%;
}

Full page for vmaxMDN (opens in a new tab)Specification (opens in a new tab)

svw

The small viewport's width in hundredths: the window with browser toolbars shown.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1svw = 1/100 of the width when browser toolbars are fully shown

What changes it

Moves with
  • the window size
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

The width half of a box sized from the small viewport on both axes, next to svh.

Watch out

Browsers that do not know the unit drop the declaration. Put a vw line before the svw one.

Example Older browsers keep the vw line.
.banner {
  inline-size: 50vw;
  inline-size: 50svw;
}

Full page for svwMDN (opens in a new tab)Specification (opens in a new tab)

svh

A hundredth of the visible height with browser toolbars fully shown.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1svh = 1/100 of the height when browser toolbars are expanded

What changes it

Moves with
  • the window size
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

A first screen whose button must stay visible while the toolbars are shown.

Watch out

svh is the smallest of the three heights. When the toolbars retract, 100svh stops short of the bottom edge of the screen and a strip behind it shows.

Example Fits the screen even while the toolbars are visible. The vh line stays for browsers without svh.

Before

.opening {
  min-block-size: 100vh;
}

After

.opening {
  min-block-size: 100vh;
  min-block-size: 100svh;
}

Full page for svhMDN (opens in a new tab)Specification (opens in a new tab)

svi

One percent of the small viewport, measured the way a line of text runs.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1svi = 1/100 of the small viewport in the inline direction

What changes it

Moves with
  • the window size
  • the writing mode
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars

Reach for it when

A column that fits the small viewport along its lines, in code shared between writing modes.

Watch out

Put vertical text on html and svi measures the height, in both readings. Writing-mode on a child is where the readings part: MDN and the summary table ignore it, the definition and Chromium follow it. See vi for the measurement.

Example Lines run top to bottom, so the column is 90% of the small viewport height.
html {
  writing-mode: vertical-rl;
}
.column {
  inline-size: 90svi;
}

Full page for sviMDN (opens in a new tab)Specification (opens in a new tab)

svb

One percent of the small viewport, measured across the stack of lines.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1svb = 1/100 of the small viewport in the block direction

What changes it

Moves with
  • the window size
  • the writing mode
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars

Reach for it when

A block that never exceeds the visible area, in any writing mode.

Watch out

In horizontal text svb equals svh and has its limits: once the toolbars retract, 100svb no longer fills the screen.

Example Lines stack from right to left, so the shelf is as wide as the small viewport.
html {
  writing-mode: vertical-rl;
}
.shelf {
  block-size: 100svb;
}

Full page for svbMDN (opens in a new tab)Specification (opens in a new tab)

svmin

A hundredth of the shorter side with browser toolbars shown.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1svmin = 1% of min(svw, svh)

What changes it

Moves with
  • the window size
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

A shape that fits the screen with every toolbar showing.

Watch out

svmin differs from vmin only in a window wider than tall. There the shorter side is the height, and the small height sits below the large one that plain vmin follows.

Example Fits even with the toolbars out.
.dial {
  inline-size: 70svmin;
  aspect-ratio: 1;
}

Full page for svminMDN (opens in a new tab)Specification (opens in a new tab)

svmax

A hundredth of the longer side with browser toolbars shown.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1svmax = 1% of max(svw, svh)

What changes it

Moves with
  • the window size
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

A cover for the small viewport, with its overflow clipped on purpose.

Watch out

A square of 100svmax is longer than the window in its shorter direction. Clip it or let it overflow on purpose.

Example A backdrop that covers the small viewport either way up.
.backdrop {
  inline-size: 100svmax;
  aspect-ratio: 1;
}

Full page for svmaxMDN (opens in a new tab)Specification (opens in a new tab)

lvw

The large viewport's width in hundredths: the window with browser toolbars retracted.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1lvw = 1/100 of the width when browser toolbars are retracted

What changes it

Moves with
  • the window size
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

The width half of a full-bleed pair with lvh, written so both read the same way.

Watch out

Plain vw is already defined as the large viewport (see vh), so lvw adds no new behavior. Use it only to make that choice explicit.

Example Ninety percent of the largest viewport width.
.wide {
  inline-size: 90lvw;
}

Full page for lvwMDN (opens in a new tab)Specification (opens in a new tab)

lvh

A hundredth of the visible height with browser toolbars fully retracted.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1lvh = 1/100 of the height when browser toolbars are retracted

What changes it

Moves with
  • the window size
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

Backgrounds and opening art that should fill the screen once the toolbars retract.

Watch out

lvh is what 100vh already means: plain vh is defined to follow the large viewport, and in Chromium 156 on a desktop 50vh and 50lvh measured the same. Swapping one for the other changes nothing, it only states your intent.

Example Covers the screen even after the toolbars retract.
.scenery {
  min-block-size: 100lvh;
}

Full page for lvhMDN (opens in a new tab)Specification (opens in a new tab)

lvi

One percent of the large viewport, measured along the line direction.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1lvi = 1/100 of the large viewport in the inline direction

What changes it

Moves with
  • the window size
  • the writing mode
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars

Reach for it when

A full-bleed length along the lines, for components shared between writing modes.

Watch out

Its axis follows the writing-mode of the root in MDN and of the element in the definition and in the three engines measured for vi. A column of 100lvi is as tall as the large viewport, so while the toolbars are shown it runs under them.

Example The column is as long as the largest viewport height.
html {
  writing-mode: vertical-rl;
}
.column {
  inline-size: 100lvi;
}

Full page for lviMDN (opens in a new tab)Specification (opens in a new tab)

lvb

One percent of the large viewport, measured in the direction lines pile up.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1lvb = 1/100 of the large viewport in the block direction

What changes it

Moves with
  • the window size
  • the writing mode
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars

Reach for it when

A full-bleed backdrop described without naming a side of the screen.

Watch out

In horizontal text lvb is lvh, which is also what plain vh already means.

Example Covers the large viewport whichever way text runs.
.cover {
  min-block-size: 100lvb;
}

Full page for lvbMDN (opens in a new tab)Specification (opens in a new tab)

lvmin

A hundredth of the shorter side with browser toolbars retracted.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1lvmin = 1% of min(lvw, lvh)

What changes it

Moves with
  • the window size
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

A badge or dial checked against the largest size it can reach.

Watch out

lvmin ignores the toolbars: it is the same whether they are shown or hidden. In a window wider than tall it is the large height, so a square of 100lvmin is taller than the visible area while the toolbars are shown.

Example A square badge sized from the large viewport.
.badge {
  inline-size: 40lvmin;
  aspect-ratio: 1;
}

Full page for lvminMDN (opens in a new tab)Specification (opens in a new tab)

lvmax

A hundredth of the longer side with browser toolbars retracted.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1lvmax = 1% of max(lvw, lvh)

What changes it

Moves with
  • the window size
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

A cover layer for the large viewport in either orientation.

Watch out

Sized this way a shape overshoots the window along its shorter side unless the window is square, so clip it or let it overflow on purpose.

Example Overshoots the large viewport on purpose.
.wash {
  inline-size: 110lvmax;
  aspect-ratio: 1;
}

Full page for lvmaxMDN (opens in a new tab)Specification (opens in a new tab)

dvw

A hundredth of the visible width, as it is at this moment.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1dvw = 1/100 of the current visible width

What changes it

Moves with
  • the window size
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

Reach for it when

Keeping both axes in the dynamic family when a formula also holds dvh.

Watch out

Choosing it for a width is not expected to change anything. The toolbar problem lives in the height, so dvh is where this family matters.

Example Both sides follow the visible area.
.panel {
  inline-size: 80dvw;
  block-size: 80dvh;
}

Full page for dvwMDN (opens in a new tab)Specification (opens in a new tab)

dvh

A hundredth of the visible height, following the toolbars as they show and hide.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1dvh = 1/100 of the currently visible height

What changes it

Moves with
  • the window size
  • phone toolbars
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • the writing mode

Reach for it when

A chat composer or a sheet that must end exactly where the visible area ends.

Watch out

A box in dvh is resized each time the toolbars move, in the middle of a scroll. Whether the on-screen keyboard counts as a toolbar is up to the browser; this site has not measured it on a phone.

Example Ends where the visible area ends as the toolbars come and go; 100vh reaches under them.

Before

.thread {
  block-size: 100vh;
}

After

.thread {
  block-size: 100dvh;
}

Full page for dvhMDN (opens in a new tab)Specification (opens in a new tab)

dvi

A hundredth of what is visible right now, measured along the text's own run.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1dvi = 1/100 of the current viewport in the inline direction

What changes it

Moves with
  • the window size
  • phone toolbars
  • the writing mode
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container

Reach for it when

A column that follows the visible height as the toolbars move, in vertical text.

Watch out

In vertical text dvi measures the height, so it follows the toolbars when they take height, which dvw does not.

Example The column follows the visible height as the toolbars come and go.
html {
  writing-mode: vertical-rl;
}
.column {
  inline-size: 100dvi;
}

Full page for dviMDN (opens in a new tab)Specification (opens in a new tab)

dvb

A hundredth of what is visible right now, measured where lines stack.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1dvb = 1/100 of the current viewport in the block direction

What changes it

Moves with
  • the window size
  • phone toolbars
  • the writing mode
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container

Reach for it when

A full-screen sheet in a page that may switch between horizontal and vertical text.

Watch out

In horizontal text it equals dvh and moves with the toolbars exactly as dvh does.

Example Fills the visible area in the flow direction.
.sheet {
  block-size: 100dvb;
}

Full page for dvbMDN (opens in a new tab)Specification (opens in a new tab)

dvmin

A hundredth of the shorter side that is visible right now.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1dvmin = 1% of min(dvw, dvh)

What changes it

Moves with
  • the window size
  • phone toolbars
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • the writing mode

Reach for it when

A shape that must fit the visible area at each moment.

Watch out

In a window wider than tall dvmin is the dynamic height, so it moves whenever the toolbars show or hide.

Example Fits the visible area at each moment.
.dial {
  inline-size: 60dvmin;
  aspect-ratio: 1;
}

Full page for dvminMDN (opens in a new tab)Specification (opens in a new tab)

dvmax

A hundredth of the longer side that is visible right now.

Safe to useBaseline: widely available

  • Chrome 108+
  • Edge 108+
  • Firefox 101+
  • Safari 15.4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome108+
Chrome Android108+
Edge108+
Firefox101+
Firefox Android101+
Safari15.4+
Safari iOS15.4+

Formula 1dvmax = 1% of max(dvw, dvh)

What changes it

Moves with
  • the window size
  • phone toolbars
Stays put under
  • the reader's text size
  • page zoom
  • the font in use
  • the query container
  • the writing mode

Reach for it when

A cover shape that follows the visible area as the toolbars move.

Watch out

In a window taller than wide the larger side is the height, so the shape grows and shrinks with the toolbars.

Example Tracks the visible area as the toolbars move.
.wash {
  inline-size: 100dvmax;
  aspect-ratio: 1;
}

Full page for dvmaxMDN (opens in a new tab)Specification (opens in a new tab)

Container 6 units

Lengths measured from the box a component lives in, not from the window.

Reference The nearest query container

cqw

One percent of the nearest query container's width.

Safe to useBaseline: widely available

  • Chrome 105+
  • Edge 105+
  • Firefox 110+
  • Safari 16+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome105+
Chrome Android105+
Edge105+
Firefox110+
Firefox Android110+
Safari16+
Safari iOS16+

Formula 1cqw = 1/100 of the nearest container's width

What changes it

Moves with
  • page zoom
  • the query container
Stays put under
  • the reader's text size
  • the window size
  • the font in use
  • phone toolbars
  • the writing mode

Reach for it when

Components dropped into slots of different widths: sidebars, grids, dialogs.

Watch out

In a 1280px window, 10cqw with no container-type anywhere above it came to 128px, the same as 10svw, and nothing warned about it.

Example Without the container-type line the heading follows the window; with it, the wrapper.

Before

.card h2 {
  font-size: clamp(1.25rem, 6cqw, 3rem);
}

After

.card-wrap {
  container-type: inline-size;
}
.card h2 {
  font-size: clamp(1.25rem, 6cqw, 3rem);
}

Full page for cqwMDN (opens in a new tab)Specification (opens in a new tab)

cqh

One percent of the nearest query container's height.

Safe to useBaseline: widely available

  • Chrome 105+
  • Edge 105+
  • Firefox 110+
  • Safari 16+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome105+
Chrome Android105+
Edge105+
Firefox110+
Firefox Android110+
Safari16+
Safari iOS16+

Formula 1cqh = 1/100 of the nearest container's height

What changes it

Moves with
  • page zoom
  • the query container
Stays put under
  • the reader's text size
  • the window size
  • the font in use
  • phone toolbars
  • the writing mode

Reach for it when

Fixed-height widgets such as dashboard tiles and chart panels.

Watch out

container-type: size is the only setting that lets the height be queried, and it also cuts the box off from its children's height. Give the container a block-size, or it measures 0px and so does everything in cqh.

Example A size container with no height of its own is 0px tall, and so is the chart. The block-size line fixes both.

Before

.panel {
  container-type: size;
}
.panel .chart {
  block-size: 80cqh;
}

After

.panel {
  container-type: size;
  block-size: 20rem;
}
.panel .chart {
  block-size: 80cqh;
}

Full page for cqhMDN (opens in a new tab)Specification (opens in a new tab)

cqi

One percent of the container's inline size, the direction text runs along.

Safe to useBaseline: widely available

  • Chrome 105+
  • Edge 105+
  • Firefox 110+
  • Safari 16+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome105+
Chrome Android105+
Edge105+
Firefox110+
Firefox Android110+
Safari16+
Safari iOS16+

Formula 1cqi = 1/100 of the nearest container's inline size

What changes it

Moves with
  • page zoom
  • the query container
  • the writing mode
Stays put under
  • the reader's text size
  • the window size
  • the font in use
  • phone toolbars

Reach for it when

The default choice for component type, gaps and widths, in any writing mode.

Watch out

An element with container-type is a container for its descendants only. Its own cqi values look further up, to the next container, or to the small viewport.

Example The heading scales with the card it sits in, not with the window.

Before

.card h2 {
  font-size: 6vw;
}

After

.card h2 {
  font-size: clamp(1.5rem, 8cqi, 3rem);
}

Full page for cqiMDN (opens in a new tab)Specification (opens in a new tab)

cqb

One percent of the container's block size, the direction lines stack along.

Safe to useBaseline: widely available

  • Chrome 105+
  • Edge 105+
  • Firefox 110+
  • Safari 16+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome105+
Chrome Android105+
Edge105+
Firefox110+
Firefox Android110+
Safari16+
Safari iOS16+

Formula 1cqb = 1/100 of the nearest container's block size

What changes it

Moves with
  • page zoom
  • the query container
  • the writing mode
Stays put under
  • the reader's text size
  • the window size
  • the font in use
  • phone toolbars

Reach for it when

Heights inside fixed-height containers, in any writing mode.

Watch out

Inside an inline-size container nested in a size container 300px tall, 10cqb was 30px from the outer box while 10cqi came from the inner one. The two axes look up the tree separately.

Example Forty percent of the pane's block size.
.pane .thumb {
  block-size: 40cqb;
}

Full page for cqbMDN (opens in a new tab)Specification (opens in a new tab)

cqmin

One percent of whichever side of the container is shorter.

Safe to useBaseline: widely available

  • Chrome 105+
  • Edge 105+
  • Firefox 110+
  • Safari 16+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome105+
Chrome Android105+
Edge105+
Firefox110+
Firefox Android110+
Safari16+
Safari iOS16+

Formula 1cqmin = min(1cqi, 1cqb)

What changes it

Moves with
  • page zoom
  • the query container
  • the writing mode
Stays put under
  • the reader's text size
  • the window size
  • the font in use
  • phone toolbars

Reach for it when

Squares and icons that must fit the container in both directions.

Watch out

With container-type: inline-size the block axis is not measured, so cqb, and with it cqmin and cqmax, looks further up the tree or is replaced by the small viewport height. Use container-type: size for both axes.

Example A square that fits the tile either way.
.tile .glyph {
  inline-size: 50cqmin;
  aspect-ratio: 1;
}

Full page for cqminMDN (opens in a new tab)Specification (opens in a new tab)

cqmax

One percent of whichever side of the container is longer.

Safe to useBaseline: widely available

  • Chrome 105+
  • Edge 105+
  • Firefox 110+
  • Safari 16+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome105+
Chrome Android105+
Edge105+
Firefox110+
Firefox Android110+
Safari16+
Safari iOS16+

Formula 1cqmax = max(1cqi, 1cqb)

What changes it

Moves with
  • page zoom
  • the query container
  • the writing mode
Stays put under
  • the reader's text size
  • the window size
  • the font in use
  • phone toolbars

Reach for it when

Cover art inside a container that should reach every edge.

Watch out

It follows the larger side, so a shape sized with it overflows the smaller side. Clip the container with overflow if that is not intended.

Example Covers the tile whatever its shape.
.tile .wash {
  inline-size: 100cqmax;
  aspect-ratio: 1;
}

Full page for cqmaxMDN (opens in a new tab)Specification (opens in a new tab)

Flexible 1 unit

A share of the space left over in a grid track.

Reference Free space in a grid

fr

A share of the free space in a grid track.

Safe to useBaseline: widely available

  • Chrome 57+
  • Edge 16+
  • Firefox 52+
  • Safari 10.1+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome57+
Chrome Android57+
Edge16+
Firefox52+
Firefox Android52+
Safari10.1+
Safari iOS10.3+

Formula 1fr = one part of the space left after fixed tracks and gaps

What changes it

Moves with
  • page zoom
Stays put under
  • the reader's text size
  • the window size
  • the font in use
  • the query container
  • phone toolbars
  • the writing mode

And the free space of its own grid: every fixed track, gap and content minimum changes what is left to share.

Reach for it when

Grid columns that split the leftover width: a fixed sidebar next to a flexible main column.

Watch out

1fr has a hidden floor: the track never gets narrower than its content's smallest size, so a code block or a long URL widens the whole grid. minmax(0, 1fr) takes the floor away.

Example A fixed sidebar and a main column that may shrink below its content.

Before

.page-grid {
  display: grid;
  grid-template-columns: 14rem 1fr;
  gap: 1.5rem;
}

After

.page-grid {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: 1.5rem;
}

Full page for frMDN (opens in a new tab)Specification (opens in a new tab)

Special 12 units

Not lengths: angles, time, frequency and resolution.

Reference Its own type

deg

Degrees: a full turn is 360deg.

Safe to useBaseline: widely available

  • Chrome 2+
  • Edge 12+
  • Firefox 3.6+
  • Safari 4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome2+
Chrome Android18+
Edge12+
Firefox3.6+
Firefox Android4+
Safari4+
Safari iOS3.2+

Formula 360deg = 400grad = 2π rad = 1turn

Reach for it when

Rotations, gradient directions and hue angles that people read and edit by hand.

Watch out

A bare number is not an angle inside transform functions, except 0: rotate(45) is invalid and the whole declaration is dropped. Write rotate(45deg).

Example A bare number is dropped with the whole declaration; the unit makes it an angle.

Before

.arrow {
  rotate: 45;
}

After

.arrow {
  rotate: 45deg;
}

Full page for degMDN (opens in a new tab)Specification (opens in a new tab)

grad

Gradians: a full turn is 400grad, so a right angle is 100grad.

Safe to useBaseline: widely available

  • Chrome 2+
  • Edge 12+
  • Firefox 3.6+
  • Safari 4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome2+
Chrome Android18+
Edge12+
Firefox3.6+
Firefox Android4+
Safari4+
Safari iOS3.2+

Formula 400grad = 360deg = 1turn

Reach for it when

Angles that arrive in gradians from a survey plan or a GIS export.

Watch out

100grad is a right angle and 90deg is the same angle. Mixing the two in one stylesheet makes values hard to compare at a glance.

Example A quarter turn, the same as 90deg.
.pointer {
  rotate: 100grad;
}

Full page for gradMDN (opens in a new tab)Specification (opens in a new tab)

rad

Radians: a full turn is 2π, about 6.283rad.

Safe to useBaseline: widely available

  • Chrome 2+
  • Edge 12+
  • Firefox 3.6+
  • Safari 4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome2+
Chrome Android18+
Edge12+
Firefox3.6+
Firefox Android4+
Safari4+
Safari iOS3.2+

Formula 2π rad = 360deg = 1turn

Reach for it when

Angles computed in JavaScript with Math.sin and friends, or inside CSS trigonometry.

Watch out

CSS trigonometric functions read a plain number as radians: sin(1) means one radian, and sin(90deg) is the one that equals 1.

Example A quarter turn, about 90deg.
.needle {
  rotate: 1.5708rad;
}

Full page for radMDN (opens in a new tab)Specification (opens in a new tab)

turn

One turn is a full rotation.

Safe to useBaseline: widely available

  • Chrome 2+
  • Edge 12+
  • Firefox 13+
  • Safari 4+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome2+
Chrome Android18+
Edge12+
Firefox13+
Firefox Android14+
Safari4+
Safari iOS3.2+

Formula 1turn = 360deg = 400grad = 2π rad

Reach for it when

Spinners, loops and simple fractions of a circle.

Watch out

Rotations beyond 1turn are valid and spin more than once in an animation: 2.5turn ends at half a turn after two full spins, but a static 2.5turn looks like 0.5turn.

Example A loop that ends where it began.
@keyframes spin {
  to { rotate: 1turn; }
}

Full page for turnMDN (opens in a new tab)Specification (opens in a new tab)

s

Seconds, the base unit of time in CSS.

Safe to useBaseline: widely available

  • Chrome 1+
  • Edge 12+
  • Firefox 4+
  • Safari 3.1+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome1+
Chrome Android18+
Edge12+
Firefox4+
Firefox Android4+
Safari3.1+
Safari iOS2+

Formula 1s = 1000ms

Reach for it when

Durations and delays counted in tenths of a second or more.

Watch out

Zero is not exempt: transition-duration: 0 is invalid, and 0s is the form that works.

Example A time without a unit is invalid and the whole transition is dropped. 0.4s works, and so does 400ms.

Before

.menu {
  transition: transform 400 ease-in-out;
}

After

.menu {
  transition: transform 0.4s ease-in-out;
}

Full page for sMDN (opens in a new tab)Specification (opens in a new tab)

ms

Milliseconds: a thousandth of a second.

Safe to useBaseline: widely available

  • Chrome 1+
  • Edge 12+
  • Firefox 4+
  • Safari 3.1+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome1+
Chrome Android18+
Edge12+
Firefox4+
Firefox Android4+
Safari3.1+
Safari iOS2+

Formula 1ms = 0.001s

Reach for it when

Short interface timings that you adjust in small steps.

Watch out

Scripts read durations back in seconds: in Chromium getComputedStyle reports a 300ms transition as 0.3s, so do not compare it with a string like "300ms".

Example A quick slide-in.
.toast {
  transition: transform 200ms ease-out;
}

Full page for msMDN (opens in a new tab)Specification (opens in a new tab)

Hz

Hertz, cycles per second, a unit for audio pitch in speech styling.

Not usableNo property accepts it in any main browser

Formula 1Hz = 1 cycle per second

Reach for it when

Reading the specification: the unit is defined there, next to the speech properties.

Watch out

Nothing visible happens. The unit exists for speech styling such as voice-pitch, which Chromium 156 rejects and MDN has no data for.

Example Valid by the speech module, rejected by Chromium 156.
.speaker {
  voice-pitch: 220Hz absolute;
}

Full page for Hz

kHz

Kilohertz: a thousand hertz.

Not usableNo property accepts it in any main browser

Formula 1kHz = 1000Hz

Reach for it when

Reading the specification, or writing a tool that must accept every unit CSS defines.

Watch out

Like Hz it changes no rendering: Chromium 156 accepts a frequency in no property.

Example The same pitch as 220Hz, equally rejected.
.speaker {
  voice-pitch: 0.22kHz absolute;
}

Full page for kHz

dpi

Dots per CSS inch.

Safe to useBaseline: widely available

  • Chrome 29+
  • Edge 12+
  • Firefox 8+
  • Safari 16+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome29+
Chrome Android29+
Edge12+
Firefox8+
Firefox Android8+
Safari16+
Safari iOS16+

Formula 1dpi = 1/96dppx

Reach for it when

Matching a figure that arrives in dpi, such as a print specification or an old min-resolution query.

Watch out

The inch here is the CSS inch of 96px, so dpi on a screen tells you nothing about the real pixel density of the panel.

Example Matches a device pixel ratio of 2 or more, the same screens as min-resolution: 2dppx.
@media (min-resolution: 192dpi) {
  .plate { background-image: url("plate-192dpi.png"); }
}

Full page for dpiMDN (opens in a new tab)Specification (opens in a new tab)

dpcm

Dots per centimeter.

Safe to useBaseline: widely available

  • Chrome 29+
  • Edge 12+
  • Firefox 8+
  • Safari 16+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome29+
Chrome Android29+
Edge12+
Firefox8+
Firefox Android8+
Safari16+
Safari iOS16+

Formula 1dpcm = 2.54dpi

Reach for it when

Resolution queries in projects that work in metric print units.

Watch out

It is a fixed ratio to dppx, not a measurement of the panel: 1dppx is about 37.8dpcm on every screen.

Example 113dpcm sits just under 3dppx (113.39dpcm), so a screen at 3x matches. 120dpcm would not.
@media (min-resolution: 113dpcm) {
  .map { background-image: url("map@3x.png"); }
}

Full page for dpcmMDN (opens in a new tab)Specification (opens in a new tab)

dppx

Dots per CSS pixel: the device pixel ratio.

Safe to useBaseline: widely available

  • Chrome 29+
  • Edge 12+
  • Firefox 16+
  • Safari 16+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome29+
Chrome Android29+
Edge12+
Firefox16+
Firefox Android16+
Safari16+
Safari iOS16+

Formula 1dppx = 96dpi = 1x

Reach for it when

min-resolution queries that serve sharper assets to dense screens.

Watch out

A query for exactly 2dppx matches only at a ratio of 2, not at 1.5 or 3, so use min-resolution. The ratio also moves with anything that changes device pixels per CSS pixel, so a resolution query does not prove the screen is dense.

Example An exact match misses ratios of 1.5 and 3; min-resolution catches every dense screen.

Before

@media (resolution: 2dppx) {
  .hero-art { background-image: url("hero-2x.webp"); }
}

After

@media (min-resolution: 2dppx) {
  .hero-art { background-image: url("hero-2x.webp"); }
}

Full page for dppxMDN (opens in a new tab)Specification (opens in a new tab)

x

The short form of dppx, mostly written next to images.

Safe to useBaseline: widely available

  • Chrome 68+
  • Edge 79+
  • Firefox 62+
  • Safari 16+
All browsers
First version with support, from MDN browser data
BrowserSince
Chrome68+
Chrome Android68+
Edge79+
Firefox62+
Firefox Android62+
Safari16+
Safari iOS16+

Formula 1x = 1dppx = 96dpi

Reach for it when

Density labels in image-set(), and short resolution values in media queries.

Watch out

x is a label for a density, not a multiplier. It does nothing in width or font-size, where Chromium 156 rejects it.

Example The browser chooses a file to suit the screen density.
.badge {
  background-image: image-set(
    url("badge.png") 1x,
    url("badge-2x.png") 2x,
    url("badge-3x.png") 3x
  );
}

Full page for xMDN (opens in a new tab)Specification (opens in a new tab)