CSS Measures of Length

We have frequent need to specify lengths or distances. Examples: font size, line spacing, paragraph indentation, position of a graphic, and many more. The following definition list shows the CSS measures of length.

The relative measures, em and ex, refer to the parent of the element. For example, if we have an h1 heading within the body of our code, a size for h1 of 1.6em would mean 1.6 times the size of the current body font. Changing the size of the body font would also change the size of the h1 heading, which is what we want. Specifying font-size as 160% would have the same effect.

in
inch
cm
centimeter; 1 inch = 2.54 cm
mm
millimeter; 1 inch = 25.4 mm
pt
point: 1/72 of an inch
pc
pica; 1 pica = 12 points = 1/6 of an inch
em
the font size of the current (parent) font
ex
the x-height of the current (parent) font
px
1 pixel on the current display device