CSS Reference ยท Units and Values
The cm, mm, in, pt, pc and Q units
Reference for CSS absolute length units cm, mm, Q, in, pt and pc: how they convert to pixels, why they are not true physical sizes on screens, and print use.
Absolute length units have fixed ratios to one another. Everything is tied to the CSS pixel: 1in is exactly 96px, and the other units are fractions of an inch. They never depend on fonts, parent boxes or the viewport.
They are named after real-world measures, but on a screen they are not real physical sizes. A 1cm box will not measure one centimeter on your monitor, because the browser cannot know your screen's true density. On paper, in print, the sizes are accurate, which is where these units belong.
@media print { body { margin: 2cm; font-size: 11pt; } }
Try it
All seven bars have the same length because they describe the same inch: 96 CSS pixels.
Syntax
<length> = <number>cm | <number>mm | <number>Q | <number>in
| <number>pt | <number>pc | <number>px
- Applies to: any property that accepts a
<length>. - Animatable: yes, as part of a length.
- Computed value: an absolute length in CSS pixels.
Values
| Unit | Definition | In CSS pixels |
|---|---|---|
in |
Inch | 96px |
cm |
Centimeter, 1/2.54 in | about 37.795px |
mm |
Millimeter, 1/10 cm | about 3.7795px |
Q |
Quarter-millimeter, 1/40 cm (the Q is uppercase) | about 0.9449px |
pt |
Point, 1/72 in | about 1.3333px |
pc |
Pica, 12pt = 1/6 in | 16px |
px |
CSS pixel, 1/96 in | 1px |
Usage notes
- Use them for print. In
@media print,ptis the usual unit for body text (10pt to 12pt) andcmormmfor margins. - Do not use them for screen layout. Pixel-based or relative units are better. A "real" centimeter on screen is a myth.
- Case rules. Unit names are case-insensitive except that
Qis conventionally uppercase;qalso works. - Fonts.
ptis still common in design tools and word processors, which is why designers sometimes request font sizes in points. On screens,12ptis16px. - Page size. The
@pagerule can set paper size with these units, for examplesize: 210mm 297mm. - Accessibility. Like
px, absolute units do not follow the user's default font size.
Browser support
Supported in every browser.