Skip to content

Commit ad244f3

Browse files
committed
[css-values-4] Define the concept of calculation contexts more formally. #11204
1 parent e15b289 commit ad244f3

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

css-values-4/Overview.bs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4531,6 +4531,38 @@ Type Checking</h3>
45314531
might become valid in Quirks Mode
45324532
(and have its result interpreted as a ''px'' length).
45334533

4534+
<h4 id='calc-context'>
4535+
Calculation Contexts</h4>
4536+
4537+
Numeric values can be interpreted in various <dfn export>calculation contexts</dfn>,
4538+
depending on where they are used,
4539+
which defines how <<percentage>> values resolve,
4540+
etc.
4541+
4542+
<p class=example>
4543+
For example, in 'top', a <<percentage>> value
4544+
is resolved against the size of the containing block,
4545+
making it act as a <<length>>.
4546+
A single property can define multiple [=calculation contexts=];
4547+
for example, in 'background-size'
4548+
one value resolves <<percentages>> against the width of the [=background sizing area=]
4549+
while the other resolves them against the height.
4550+
4551+
[=Math functions=] always inherit the [=calculation context=] from wherever they're used.
4552+
That is, in ''top: calc(25% + 50px)'',
4553+
the <<percentage>> is resolved <em>as normal</em> for 'top',
4554+
as if ''top: 25%'' were specified
4555+
(and then has ''50px'' added to its value).
4556+
4557+
Unless otherwise defined,
4558+
all other functions <strong>do not inherit a [=calculation context=]</strong>,
4559+
and instead define their own [=calculation contexts=]
4560+
for their numeric arguments.
4561+
For example, in ''top: anchor(25%)'',
4562+
the <<percentage>> in the ''anchor()'' function
4563+
is instead defined to resolve in a completely different manner
4564+
(against the height of the default anchor element).
4565+
45344566
<h4 id='calc-ieee'>
45354567
Infinities, NaN, and Signed Zero</h4>
45364568

0 commit comments

Comments
 (0)