Unit

CSS unit is a type of data with which we can define measurements, and it looks like this:

max-height: 150px;

Alternatively, it could also look like this:

transform: rotate(45deg);

There is no space between the number and the unit.

In most cases, the unit isn't required after the number 0 (zero).

There are several types of length units, such as described in the following explanations.

Relative length units

They are dependent on another element's length (usually, a parent element in the DOM) that relates directly to the element in question. When the other element's length changes, the length of the element in question maintains the defined proportion. In other words, there is no need to declare the length of the child element again.

Description

Relative ...

Get Web Developer's Reference Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.