Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

cm — CSS centimeter

cm is an absolute CSS length unit representing centimeters. The fixed relationship is 2.54cm = 96px, but this does not guarantee agreement with a physical ruler on screen.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

<number>cm

cm is a unit of the <length> type. Write it immediately after a number without whitespace, for example 2.54cm. It can be used wherever a property accepts a length; whether negative values are allowed depends on the property.

Absolute units have fixed ratios: 1cm = 10mm, and 2.54cm = 1in = 96px. Unlike em or vw, cm does not depend on the font size or viewport size.

“Absolute” does not guarantee a physical centimeter on screen. When the CSS pixel is the anchor, physical units can differ from real-world measurements. cm is especially useful when output conditions are known, such as printing; print scaling can change the final size.

In the example, width: 2.54cm corresponds to 96px in CSS, not necessarily 96 device pixels. Check the width in developer tools rather than measuring the screen with a ruler.

Examples

<!doctype html>
<meta charset="utf-8">
<title>cm</title>
<style>
  #sample {
    width: 2.54cm;
    height: 1cm;
    background: navy;
  }
</style>
<div id="sample"></div>

Result

Expected CSS width: 96px.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources