CSS | Length Data Type
Length is the measurement of distance followed by a length unit. There is no space between the number and unit. It can be positive or negative. The length unit is optional after 0. There are two types of length units which are absolute and relative. Lengths are used in many CSS properties, such as padding, border-width, font-size, text-shadow, width, height, and margins.
It takes number followed by a unit of length as a parameter.
Note: No space should be given between the number and its unit.
Example 1: The following example demonstrates the use of length as value using CSS.
Example 2: The following example demonstrates the length as a value for margins of a div element.
- Google Chrome
- Internet Explorer