CSS Units

Last updated: 2026-09-13

CSS Units

CSS units express lengths, angles, times and other quantities. They split into absolute, relative and viewport-based families.

Absolute Length

CSS UnitsDescription
pxPixels: 1px is one device pixel (CSS reference pixel).
ptPoints: 1pt = 1/72 of an inch.
inInches: 1in = 96px = 2.54cm.
cmCentimeters.
mmMillimeters.

Relative Length

CSS UnitsDescription
emRelative to the font-size of the element.
remRelative to the font-size of the root element.
exRelative to the x-height of the element's font.
chRelative to the width of the '0' (zero) glyph.

Viewport Units

CSS UnitsDescription
vw1% of the viewport width.
vh1% of the viewport height.
vmin1% of the smaller viewport dimension.
vmax1% of the larger viewport dimension.

Percentage

CSS UnitsDescription
%Relative to another value (parent size, property context).

Angle

CSS UnitsDescription
degDegrees: a full circle is 360deg.
radRadians: a full circle is 2πrad.
turnTurns: a full circle is 1turn.

Time

CSS UnitsDescription
sSeconds.
msMilliseconds (1000ms = 1s).

Global Keywords

CSS UnitsDescription
initialSets a property to its initial (default) value.
inheritTakes the computed value from the parent.
unsetActs as inherit for inherited props, initial otherwise.
Web-Tutorial.com

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.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏