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 1 and above
- Edge 12 and above
- Internet Explorer 3 and above
- Firefox 1 and above
- Opera 3.5 and above
- Safari 1 and above