<length-percentage>
Quick Summary for <length-percentage>
The
<length-percentage>
CSS data type represents a value that can be either a <length>
or a <percentage>
.
Code Usage for <length-percentage>
<p>You can use percentages and lengths in so many places.</p>
More Details for <length-percentage>
<length-percentage>
The <length-percentage>
CSS data type represents a value that can be either a <length>
or a <percentage>
.
Syntax
Refer to the documentation for <length>
and <percentage>
for details of the individual syntaxes allowed by this type.
Examples
length-percentage examples
The following simple example demonstrates several properties that use <length-percentage>
values.
<p>You can use percentages and lengths in so many places.</p>
CSS p { /* length-percentage examples */ width: 75%; height: 200px; margin: 3rem; padding: 1%; border-radius: 10px 10%; font-size: 250%; line-height: 1.5em; /* length examples */ text-shadow: 1px 1px 1px red; border: 5px solid red; letter-spacing: 3px; /* percentage example */ text-size-adjust: 20%; }
ResultUse in calc()
Where a <length-percentage>
is specified as an allowable type, this means that the percentage resolves to a length and therefore can be used in a calc()
expression. Therefore, all of the following values are acceptable for width
:
width: 200px; width: 20%; width: calc(100% - 200px);
Specifications
Specification |
---|
CSS Values and Units Module Level 5 # mixed-percentages |
See also
<percentage>
<length>
CSS Values and Units Last modified: Nov 21, 2021, by MDN contributors
Posted in
12:22 am, February 22, 2022
Add Comment
Other Items in CSS
rgb()
rgba()
:right
right
@right-bottom
:root
rotate
rotate()
rotate3d()
rotateX()
rotateY()
rotateZ()
row-gap
ruby-align
ruby-position
saturate()
scale
scale()
scale3d()
scaleX()
scaleY()
scaleZ()
:scope
scroll-behavior
scroll-margin
scroll-margin-block
scroll-margin-block-end
scroll-margin-block-start
scroll-margin-bottom
scroll-margin-inline
scroll-margin-inline-end
scroll-margin-inline-start
scroll-margin-left
scroll-margin-right
scroll-margin-top
scroll-padding
scroll-padding-block
scroll-padding-block-end
scroll-padding-block-start
scroll-padding-bottom
scroll-padding-inline
scroll-padding-inline-end
scroll-padding-inline-start
scroll-padding-left
scroll-padding-right
scroll-padding-top
scroll-snap-align
scroll-snap-stop
scroll-snap-type
@scroll-timeline