Table of Contents

CSS - (Length) Unit

What is the unit in CSS ?

The unit in CSS is the second element of a length that defines the type of the length number.

Example:

The recommended unit scales are:

Type

There are two types of length units:

When the physical properties of the output medium are

Relative

Relative length units specify a length relative to another length property. Style sheets that use relative units will more easily scale from one medium to another (e.g., from a computer display to a laser printer).

Relative units are:

More … CSS - Relative Sizing (Length)

Absolute

Absolute length units are only useful when the physical properties of the output medium are known. The absolute units are:

Example(s):

h1 { margin: 0.5in }      /* inches  */
h2 { line-height: 3cm }   /* centimeters */
h3 { word-spacing: 4mm }  /* millimeters */
h4 { font-size: 12pt }    /* points */
h4 { font-size: 1pc }     /* picas */

In cases where the used length cannot be supported, user agents must approximate it in the actual value.

Documentation / Reference