--- title: slug: Web/CSS/length-percentage translation_of: Web/CSS/length-percentage ---
{{CSSRef}}

The <length-percentage> CSS data type represents a value that can be either a {{Cssxref("length")}} or a {{Cssxref("percentage")}}.
The <length-percentage> CSS数据类型表示一个值,该值可以是<length>或<percentage>。

Syntax

Refer to the documentation for {{Cssxref("length")}} and {{Cssxref("percentage")}} for details of the individual syntaxes allowed by this type.

Use 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 {{cssxref("calc", "calc()")}} expression. Therefore, all of the following values are acceptable for {{cssxref("width")}}:

width: 200px;
width: 20%;
width: calc(100% - 200px);

Specifications

Specification Status Comment
{{SpecName('CSS4 Values', '#mixed-percentages', '<length-percentage>')}} {{Spec2('CSS4 Values')}}
{{SpecName('CSS3 Values', '#mixed-percentages', '<length-percentage>')}} {{Spec2('CSS3 Values')}} Defines <length-percentage>. Adds calc()

Browser compatibility

{{Compat("css.types.length-percentage")}}