CSS Units

14/05/2025

CSS provides several units for formatting the size of text on a page. All of them can be used without any restrictions on the use of units.

CSS UnitPixel Equivalent (px)Best Use Area
px1 pxFrequently used in web design.
pt1 pt ≈ 1.33 pxUsed in print designs.
pc1 pc ≈ 16 pxUsed in print designs (large-scale prints).
em1 em = Top font size
2 em = Top font size x 2
Used for flexible designs, dependent on a parent element.
rem1 rem = Font size of the page
2 rem = Font size of the page x 2
Used for proportional designs, depends on the font size of the page (html).
in1 in = 96 pxUsed in physical printing.
cm1 cm ≈ 37.8 pxUsed in physical printing.
mm1 mm ≈ 3.78 pxUsed in physical printing.

Physical units such as px, pt, pc, in, cm, and mm are fixed values. However, em and rem are variables and change according to the font size of the element to which they are attached.

Because browsers’ default font-size is 16px, 1em and 1rem are generally considered 16px. However, if font-size: 20px; is set on the <html> element, 1rem = 20px.

Measurements may vary physically on the print medium because screen resolution and DPI (dots per inch) may differ.

Px (Pixel)

It corresponds to one physical pixel on the screen and is a fixed value.

p {
  font-size: 18px;
}

Example

Lorem ipsum dolor sit amet

Pt (Point)

In designs intended for print, it is often used for printer outputs.

p {
  font-size: 12pt;
}

Example:

Lorem ipsum.

Pc (Pica)

It is used for printing and typography, especially preferred for large-scale print designs.

p {
  font-size: 2pc;
}

Example:

Lorem ipsum.

Em

The size of the element to which the CSS property is added may vary depending on the parent element’s size.

div {
  font-size: 16px;
}

p {
  font-size: 1.5em;
}

Example:

Lorem ipsum.

Rem

It is adjusted according to the page root (HTML) font size.

html {
  font-size: 16px;
}

p {
  font-size: 1.25rem; /* 16px * 1.25 = 20px */
}

Example:

Lorem ipsum dolor sit amet

In (Inch)

Used to indicate physical dimensions in designs for printing.

p {
  font-size: 1in;
}

Example:

Lorem ipsum dolor sit amet

Cm (Centimeter) or mm (Millimeter)

Cm (centimeter) and mm (millimeter) are also physical measurement units used for printing.

.cm {
  font-size: 2cm;
}

.mm {
  font-size: 10mm;
}

Example:

cm: Lorem ipsum dolor sit amet

mm: Lorem ipsum dolor sit amet