Little Web Hut
(Cascading Style Sheets) CSS 2.1 Reference

Length Values

Length values are numbers followed by a unit identifier. Example: 15px. A list of unit identifiers is shown below. A plus sign (+) or minus sign (-) can precede the number to indicate the sign of the length value. Example: -1.5em. If the number zero is specified then the unit identifier is optional. Example: 0cm is the same as 0.

Some properties may restrict length values. There may be property values, for example, that only allow positive lengths.

Unit Identifiers:

  • The following are Relative Unit Identifiers.
    • em - The em unit is relative to the value of the font-size property. (Note: If the em unit is used to the set the font-size property itself, then the em unit is relative to the value of its parent font-size property). If the font-size property is set to 20 pixels, then 1em equals 20 pixels and 1.5em equals 30 pixels (1.5 times 20 pixels = 30 pixels).
    • ex - The ex unit is relative to the x-height (often the height of a lowercase x) of the current font. The current font size is the value of the font-size property. (Note: If the ex unit is used to the set the font-size property itself, then the ex unit is relative to the x-height of its parent font). If the font-size property is set to 20 pixels and the x-height is 10 pixels, then 1ex equals 10 pixels and 1.5ex equals 15 pixels (1.5 times 10 pixels = 15 pixels).
  • The following are Absolute Unit Identifiers.
    • in - Inches
    • cm - Centimeters
    • mm - Millimeters
    • pt - Points (equal to 1/72 inch)
    • pc - Picas (equal to 12pt)
    • px - Pixels