CSS length

You are Here:

CSS length

CSS length represents a distance value.

Lengths can be used in many CSS properties, such as padding, margin, font-size, width, height, etc.

The following tables provide a list of all CSS length values.

Absolute Length Units

LengthExpansionConvert to pxExample
pxpixel1 px = 1 pxRun
cmcentimetre1 cm = 38 pxRun
mmmillimetre1 mm = 3.8 pxRun
ininch1 in = 96 pxRun
pcpica1 pc = 16 pxRun
ptpoint1 pt = 1.3 pxRun

Viewport Percentage Length

vhhundredths of the viewport heightRun
vwhundredths of the viewport widthRun
vminhundredths of whichever is minimum, the viewport width or height.Run
vmaxhundredths of whichever is maximum, the viewport width or height.Run

Relative Length Units

chRelative to width of the "0" (zero), i.e. if body font-size:16 then the relative font-size is 10pxRun
emRelative to the font-size of the element, i.e. if body font-size:5 then the relative font-size is 15px (when em is 3)Run
exRelative to the x-height of the current font. For example, 1ex ≈ 0.5em in many fonts.Run
remRelative to font-size of the root element (typically <html>).Run


Hi Developers, we almost covered 98.7% of CSS Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in CSS.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author