Unit of length


Unit of length

Unit of length that can be used in CSS

Unit Unit Name Explanation
Absolute length units
mm millimeter 10mm = 1cm
cm centimeter 1cm = 10mm
in inch 1in = 2.54cm
pt point 72pt = 1in
pc pica 1pc = 12pt
Relative length units
em em 1em = the current height of the font
ex x-height 1ex = the current height of the "x" character
px pixels 1px = one dot on the screen
Percentage unit
% percentage -

In CSS, some unit must be specified for length values. However, only when a value is zero, the unit can be omitted.


About "em"

1em is the current font size (It is based on "M" character). If the current font size is 14pt, 1em becomes 14pt.

1em = 14pt
2em = 28pt
0.5em = 7pt