css-size-units

CSS Various Size Units

Many CSS properties take "length" values, such as width, margin, padding, font-size, etc. CSS supports a number of measurements units, including absolute units such as inches, centimeters, points, and so on, as well as relative measures units such as percentages and em units.

Absolute Lengths

   The absolute length units are fixed and a length expressed in any of these will appear as exactly that size. Absolute length units are not recommended for use on screen, because screen sizes vary so much. However, they can be used if the output medium is known, such as for print layout.

Unit Meaning
cm centimeters
mm millimeters
in inches
pt points

Relative Lengths

   Relative length units specify a length relative to another length property. Relative length units scales better between different rendering mediums.

Unit Meaning
em Relative to font-size of element (2em means 2 times of actual font-size)
rem Relative to font-size to root element.
% Relative to Parent element.