Skip to content

Commit 6fc145c

Browse files
committed
[css-values] Simplify the % section a bit.
1 parent b0592a2 commit 6fc145c

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

css-values/Overview.bs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -661,21 +661,13 @@ Percentages: the <<percentage>> type</h3>
661661
It corresponds to the <<percentage-token>> production
662662
in the <a href="http://www.w3.org/TR/css-syntax/">CSS Syntax Module</a> [[!CSS3SYN]].
663663

664-
Percentage values are always relative to another value,
664+
Percentage values are often relative to another value,
665665
for example a length.
666666
Each property that allows percentages also defines the value to which the percentage refers.
667667
The value may be that of another property for the same element,
668668
a property for an ancestor element,
669669
or a value of the formatting context
670670
(e.g., the width of a <a>containing block</a>).
671-
672-
<h4 id='dimension-percentage'>
673-
Percentages Relative to Other Values</h4>
674-
675-
In some cases, <<percentage>>s are interpreted relative to a <a>dimension</a> or <<number>>,
676-
such as a <<length>>.
677-
When this happens, <<percentage>>s and <a>dimensions</a>/<<number>>s can combined in ''calc()'' expressions.
678-
679671
While such "relative" percentages are often indicated in prose,
680672
they can also be indicated with an explicit grammar term,
681673
one for each basic <a>dimension</a> type:
@@ -696,6 +688,20 @@ Percentages Relative to Other Values</h4>
696688
:: Equivalent to <code class=prod>[ <<number>> | <<percentage>> ]</code>,
697689
where the <<percentage>> will resolve to a <<number>>.
698690

691+
<div class="example">
692+
For example, in the 'width' property <<percentage>> values are relative to the width of the containing block.
693+
If the containing block is ''1000px'' wide,
694+
then ''width: 500px;'' and ''width: 50%'' have the exact same behavior.
695+
This means that ''width: calc(500px + 50%);'' is allowed--
696+
it has the same behavior as ''width: calc(500px + 500px)'',
697+
which is an easy length+length calculation.
698+
699+
On the other hand, the second and third arguments of the ''hsl()'' function are bare <<percentage>>s,
700+
not relative to any other value.
701+
They cannot be combined with anything in ''calc()''
702+
(except themselves, in useless expressions like ''calc(10% + 20%)'').
703+
</div>
704+
699705
<h3 id='dimensions'>
700706
Numbers with Units: <a>dimensions</a></h3>
701707

0 commit comments

Comments
 (0)