19/07/2016

CSS Measurement Units

CSS supports different measurement units such as absolute units ( like inches, points, pixels etc) and relative units (like percentages, em etc.). These values will required when a designer need to specify the measurements in the CSS document like " font-size:15px " etc

Below is the list of different measurement units used in CSS -

Unit Description Example
% Specifies measurement in percentage of another relative value. p { line-height: 150%; }
cm Specifies measurement in centimeters p { margin-bottom: 5cm; }
em Specifies relative measurement for the height of a font in em spaces. Because an em unit is equivalent to the size of a given font, if you assign a font to 10pt, each "em" unit would be 10pt; thus, 2em would be 20pt. p { letter-spacing: 5em; }
ex Specifies a measurement relative to a font's x-height (determined by the height of the font's lowercase letter x.) p { line-height: 3ex; }
in Specifies a measurement in inches. p { word-spacing: .12in; }
mm Specifies a measurement in millimeters. p { word-spacing: 10mm; }
pc Specifies a measurement in picas (1 pica = 12 points) p { font-size: 10pc; }
pt Specifies a measurement in points (1 point = 1/72nd of an inch.) p { font-size: 18pt; }
px Specifies a measurement in screen pixels. p { font-size: 15px; }
vh 1% of viewport height. p { font-size: 3.0vh; }/td>
vw 1% of viewport width p { font-size: 5.9vw; }
vmin 1vw or 1vh, whichever is smaller p { font-size: 2vmin;}