Absolute length units represent a physical measurement when the physical properties of the output medium are known, such as for print layout. This is done by anchoring one of the units to a physical unit and then defining the others relative to it. The anchoring is done differently for low-resolution devices, such as screens, versus high-resolution devices, such as printers.
For low-dpi devices, the unit px
represents the physical reference pixel; other units are defined relative to it. Thus, 1in
is defined as 96px
, which equals 72pt
. The consequence of this definition is that on such devices, dimensions described in inches (in
), centimeters (cm
), or millimeters (mm
) don't necessarily match the size of the physical unit with the same name.
For high-dpi devices, inches (in
), centimeters (cm
), and millimeters (mm
) are the same as their physical counterparts. Therefore, the px
unit is defined relative to them (1/96 of 1in
).
Note: Many users increase their user agent's default font size to make text more legible. Absolute lengths can cause accessibility problems because they are fixed and do not scale according to user settings. For this reason, prefer relative lengths (such as em
or rem
) when setting font-size
.
-
px
-
One pixel. For screen displays, it traditionally represents one device pixel (dot). However, for printers and high-resolution screens, one CSS pixel implies multiple device pixels. 1px
= 1in / 96
.
-
cm
-
One centimeter. 1cm
= 96px / 2.54
.
-
mm
-
One millimeter. 1mm
= 1cm / 10
.
-
Q
-
One quarter of a millimeter. 1Q
= 1cm / 40
.
-
in
-
One inch. 1in
= 2.54cm
= 96px
.
-
pc
-
One pica. 1pc
= 12pt
= 1in / 6
.
-
pt
-
One point. 1pt
= 1in / 72
.