decorative banner

About relative, absolute, and percentage units


    There are two types of length units: relative and absolute. Relative units specify a length relative to another length property. Style sheets that use relative units will scale more easily from one output medium to another (for example, from a computer display to a laser printer). Relative units may also reduce the differences in font size that occur when a page is viewed on different platforms.

    The following relative units are supported:

    • pixel is relative to the resolution of the computer display. This unit is best for reducing size display differences between browsers on Windows and Mac OS.
    • em represents the height of the style item's font.
    • ex represents the Height of the letter x.
    • % Percentage values are always relative to another value--for example, a length unit.
    • Keywords such as XX-small through X-large specify font size relative to the parent element.

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

    The following absolute length units are supported:

    • Inch (in) is equivalent to 2.54 centimeters.
    • Centimeters (cm).
    • Millimeters (mm).
    • Point (pt) is equivalent to 1/72 of an inch.
    • Pica (pc) is equivalent to 12 points.

    Some properties allow negative length units, but this may complicate the formatting and there may be browser-specific limitations.