Numbers & units

The numeric value types and the units that go with them: plain numbers and percentages, distances, angles, durations, resolutions and the grid's fr. Any of them can also be computed with calc() and the other math functions. Colours are under Colors; positions and shapes under Images, shapes & positions.

Numbers

<number>

A real number, with or without a fractional part, and optionally signed: 1, 0.5, -2, .75. Scientific notation such as 1e3 is also allowed.

DefinitionA sequence of digits, optionally with a sign, a decimal point and an exponent
Used byline-height, opacity, flex, scale, zoom
SupportChrome 1 · Firefox 1 · Safari 1
Scientific notation: Chrome 43 · Firefox 29 · Safari 10.1
Speccss-values-4

A property may restrict the range, written in its grammar as <number [0,∞]> for a non-negative number. A unitless line-height is a <number> that multiplies the font size, and is inherited as the factor rather than as a fixed length.

<integer>

A whole number, positive, negative or zero, with no fractional part: 3, -1, 0.

Syntax<number-token>
Used byz-index, order, column-count, counter-increment, grid line numbers in grid-column
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-values-4

The grammar means a number token that has no decimal point and no exponent. 1.0 is a <number>, not an <integer>, so z-index: 1.0 is invalid.

<percentage>

A number followed by %, standing for a fraction of some reference value. Each property says what its percentages refer to, such as the containing block's width or the element's own font size.

DefinitionA <number> immediately followed by %
Used byMost sizes through <length-percentage>; on its own in opacity, scale and font-width
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-values-4

<ratio>

Two non-negative numbers separated by a slash, most often an aspect ratio of width to height. If the second number is left out it is taken as 1.

Syntax<number [0,∞]> [ / <number [0,∞]> ]?
Used byaspect-ratio, and the aspect-ratio media feature
SupportChrome 3 · Firefox 3.5 · Safari 5
Speccss-values-4
aspect-ratio: 16 / 9;
aspect-ratio: 1; /* the same as 1 / 1 */
A widescreen box and a square.

<dimension>

The general name for a number with a unit attached, such as 12px or 90deg. It is not used directly in property grammars; it is the shared form behind <length>, <angle>, <time>, <resolution> and <flex>.

DefinitionA <number> immediately followed by a unit identifier, with no space between them
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-values-4

Unit names are case-insensitive, so 10PX is the same as 10px.

Distance

<length>

A distance: a number followed by one of the length units below. A length of zero may be written without a unit; any other bare number is not a length.

DefinitionA <dimension> whose unit is a length unit, or the bare number 0
Used bywidth, margin, padding, border-width, font-size, gap, and most other sizes and offsets
SupportChrome 1 · Firefox 1 · Safari 1 (later units are listed below)
Speccss-values-4
UnitEqualsSupport
Absolute
pxOne CSS pixel, 1/96 of an inch. Not tied to device pixels.All browsers
cmOne centimetre (about 37.8px).All browsers
mmOne millimetre, 1/10 of a centimetre.All browsers
QA quarter-millimetre, 1/40 of a centimetre.Chrome 63 · Firefox 49 · Safari 13.1
inOne inch, 96px or 2.54cm.All browsers
ptOne point, 1/72 of an inch.All browsers
pcOne pica, 12pt or 1/6 of an inch.All browsers
Font-relative
emThe element's computed font size. In font-size itself, the parent's font size.All browsers
remThe root element's font size.Chrome 4 · Firefox 3.6 · Safari 5
exThe x-height of the element's first available font.All browsers
rexex measured on the root element.Chrome 111 · Firefox 147 · Safari 17.2
chThe advance width of the digit 0 in the element's font.Chrome 27 · Firefox 1 · Safari 7
rchch measured on the root element.Chrome 111 · Firefox 147 · Safari 17.2
capThe cap height: the height of capital letters in the element's font.Chrome 118 · Firefox 97 · Safari 17.2
rcapcap measured on the root element.Chrome 118 · Firefox 147 · Safari 17.2
icThe advance of the CJK ideograph 水 in the element's font, a full-width character cell.Chrome 106 · Firefox 97 · Safari 15.4
ricic measured on the root element.Chrome 111 · Firefox 147 · Safari 17.2
lhThe element's computed line-height.Chrome 109 · Firefox 120 · Safari 16.4
rlhThe root element's line-height.Chrome 111 · Firefox 120 · Safari 16.4
Viewport
vw, vh1% of the viewport's width or height.Chrome 20 · Firefox 19 · Safari 6
vmin, vmax1% of the viewport's smaller or larger dimension.Chrome 26 · Firefox 19 · Safari 7
vi, vb1% of the viewport in the root element's inline or block axis.Chrome 108 · Firefox 101 · Safari 15.4
svw, svh, svi, svb, svmin, svmaxThe same, measured on the small viewport: the size with the browser's expanding toolbars shown.Chrome 108 · Firefox 101 · Safari 15.4
lvw, lvh, lvi, lvb, lvmin, lvmaxThe same, measured on the large viewport: the size with those toolbars retracted.Chrome 108 · Firefox 101 · Safari 15.4
dvw, dvh, dvi, dvb, dvmin, dvmaxThe same, measured on the dynamic viewport, which changes as the toolbars show and hide.Chrome 108 · Firefox 101 · Safari 15.4
Container query
cqw, cqh1% of the nearest query container's width or height.Chrome 105 · Firefox 110 · Safari 16
cqi, cqb1% of the query container's inline or block size.Chrome 105 · Firefox 110 · Safari 16
cqmin, cqmaxThe smaller or larger of cqi and cqb.Chrome 105 · Firefox 110 · Safari 16

On phones, 100vh is the large viewport and can run under the address bar; 100svh always fits, and 100dvh tracks the bar as it moves. Container units fall back to the small viewport units when there is no eligible container. See container-type.

min-height: 100svh;
max-width: 65ch;
padding-block: 1lh;
A full-screen section that never hides under the toolbar, a readable measure, and padding of one line.

<length-percentage>

Either a <length> or a <percentage>, or a calc() that mixes the two, such as calc(100% - 2rem). The percentage resolves against whatever the property names.

Syntax[ <length> | <percentage> ]
Used bywidth, margin-top, padding-top, inset, gap, border-radius
SupportChrome 1 · Firefox 1 · Safari 1
Speccss-values-4

Angle & time

<angle>

A rotation or direction: a number followed by an angle unit. Positive angles turn clockwise. Some places, such as gradient angles, also accept a unitless 0.

DefinitionA <dimension> whose unit is an angle unit
Used byrotate, rotate() and skew(), linear-gradient(), hue-rotate(), hues in colour functions, font-style: oblique
SupportChrome 2 · Firefox 3.6 · Safari 4
turn: Chrome 2 · Firefox 13 · Safari 4
Speccss-values-4
UnitEquals
degDegrees; a full circle is 360deg.
gradGradians; a full circle is 400grad.
radRadians; a full circle is 2π, about 6.2832rad.
turnTurns; a full circle is 1turn.

<angle-percentage>

Either an <angle> or a <percentage> of a full turn, as used by the colour stops of a conic gradient.

Syntax[ <angle> | <percentage> ]
Used byColour-stop positions in conic-gradient() and repeating-conic-gradient()
SupportChrome 2 · Firefox 3.6 · Safari 4
Speccss-values-4

<time>

A duration or delay: a number followed by s (seconds) or ms (milliseconds). The unit is required, even for zero, so write 0s.

DefinitionA <dimension> whose unit is s or ms
Used bytransition-duration, transition-delay, animation-duration, animation-delay, interest-delay
SupportChrome 1 · Firefox 4 · Safari 3.1
Speccss-values-4
UnitEquals
sSeconds.
msMilliseconds; 1000ms is 1s.

Durations cannot be negative. A negative delay is allowed and starts the animation part-way through.

Resolution & flex

<resolution>

The pixel density of an output device or an image: how many dots fit into a given length.

DefinitionA <dimension> whose unit is a resolution unit
Used byThe resolution media feature, and the density descriptors of image-set()
SupportChrome 29 · Firefox 8 · Safari 16
dppx: Chrome 29 · Firefox 16 · Safari 16
x: Chrome 68 · Firefox 62 · Safari 16
Speccss-values-4
UnitEquals
dpiDots per inch.
dpcmDots per centimetre.
dppxDots per CSS pixel. 1dppx is 96dpi.
xAnother name for dppx.
@media (resolution >= 2x) { … }
Styles for high-density screens.

<flex>

A fraction of the free space in a grid container, written with the fr unit. After fixed and content-sized tracks are laid out, the leftover space is shared among the flexible tracks in proportion to their fr values.

DefinitionA <dimension> with the unit fr
Used bygrid-template-columns, grid-template-rows, grid-auto-columns, grid-auto-rows, and minmax() as its maximum
SupportChrome 29 · Firefox 40 · Safari 10.1
Speccss-grid-2

A <flex> is not a <length>: it cannot be mixed with other units inside calc().

grid-template-columns: 200px 1fr 2fr;
A fixed sidebar, then the rest split one third to two thirds.