CSS <length> Data Type
<length> data type denotes distance measurements using relative or absolute units.
<length> data type is a dimension, so it consists of a valid
number immediately followed by a unit identifier (with no space between the number and the unit identifier).
When you see
<length> (including the
>) anywhere in the CSS specifications, this refers to the fact that the value can be any valid length.
For example, the
font-size property accepts the following value types:
Which means that
<length> is one of the accepted types.
So you could do something like this:
Which will result in this:
<length> type can use any of the following units.
Relative length units specify a length relative to another length.
- Relative to the font size of the element. An
emis equal to the computed value of the font-size property of the element on which it is used.
- Relative to the used x-height of the first available font.
- Relative to the width of the "0" (ZERO, U+0030) glyph in the element's font.
- Relative to the font size of the root element (usually the
- Relative to 1% of the viewport's width.
- Relative to 1% of the viewport's height.
- Relative to 1% of the viewport's smaller dimension (i.e. equal to the smaller of
- Relative to 1% of the viewport's larger dimension (i.e. equal to the larger of
- Centimeters. 1cm is the equivalent of 96px/2.54.
- Millimeters. 1mm is the equivalent of 1/10th of 1cm
- Quarter-millimeters. 1q is the equivalent of 1/40th of 1cm.
- Inches. 1in = 2.54cm is the equivalent of 96px.
- Picas. 1pc is the equivalent of 1/6th of 1in.
- Points. 1pt is the equivalent of 1/72th of 1in.
- Pixels. 1px is the equivalent of 1/96th of 1in.
So the following are all examples of valid
<length>data type is defined in CSS Values and Units Module Level 3 (W3C Candidate Recommendation, 29 September 2016)
- It is also defined in the Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification (W3C Recommendation 07 June 2011)
- It is also defined in Cascading Style Sheets, level 1 (W3C Recommendation 17 Dec 1996)