CSS units express lengths, angles, times and other quantities. They split into absolute, relative and viewport-based families.
Absolute Length
CSS Units
Description
px
Pixels: 1px is one device pixel (CSS reference pixel).
pt
Points: 1pt = 1/72 of an inch.
in
Inches: 1in = 96px = 2.54cm.
cm
Centimeters.
mm
Millimeters.
Relative Length
CSS Units
Description
em
Relative to the font-size of the element.
rem
Relative to the font-size of the root element.
ex
Relative to the x-height of the element's font.
ch
Relative to the width of the '0' (zero) glyph.
Viewport Units
CSS Units
Description
vw
1% of the viewport width.
vh
1% of the viewport height.
vmin
1% of the smaller viewport dimension.
vmax
1% of the larger viewport dimension.
Percentage
CSS Units
Description
%
Relative to another value (parent size, property context).
Angle
CSS Units
Description
deg
Degrees: a full circle is 360deg.
rad
Radians: a full circle is 2πrad.
turn
Turns: a full circle is 1turn.
Time
CSS Units
Description
s
Seconds.
ms
Milliseconds (1000ms = 1s).
Global Keywords
CSS Units
Description
initial
Sets a property to its initial (default) value.
inherit
Takes the computed value from the parent.
unset
Acts as inherit for inherited props, initial otherwise.
Web-Tutorial Tech Team
A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.