CSS Absolute and Relative Units

Several CSS properties like height, width, margin, font-size etc. requires length values. To express these lengths, CSS supports two types of units namely, absolute and relative.

Absolute length units are static irrespective of the screen size and hence are used when the output display size is known, like the print layout.

Relative length units are specified with respect to another length property. These are the most used ones as they adjust accordingly with the different rendering mediums.

The unit needs to be specified with the length value without any whitespace between them. However, value ‘0’ is an exception.

Negative lengths are also acceptable for some CSS properties.

Here is the complete list of measuring units in CSS –

1 CSS Absolute Units

[table id=13 /]

2 CSS Relative Units

[table id=14 /]