Skip to content

Commit 55b3ec8

Browse files
committed
Clarifications to handling percentages in calc() due to <http://www.w3.org/mid/4FFB7960.3080700@csail.mit.edu>.
--HG-- extra : rebase_source : c77106c60b7bb17e791a3d576da6fda149446ad3
1 parent eaf81e1 commit 55b3ec8

4 files changed

Lines changed: 43 additions & 11 deletions

File tree

css3-values/Overview.html

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,10 +1368,20 @@ <h3 id=calc-notation><span class=secno>8.1. </span> Mathematical
13681368
class=css>calc()</code></a>’ expression is the expression with all
13691369
components computed, with all multiplication/division subexpressions
13701370
resolved, and with all addition/subtraction subexpressions resolved where
1371-
both sides are the same type. <span class=note> Thus, the computed value
1372-
of a ‘<a href="#calc"><code class=css>calc()</code></a>’ expression
1373-
can be represented as either a number or a tuple of a dimension and a
1374-
percentage. </span>
1371+
both sides are the same type. Where percentages are not resolved at
1372+
computed value, they are not resolved in ‘<a href="#calc"><code
1373+
class=css>calc()</code></a>’ expressions, e.g. ‘<code
1374+
class=css>height: calc(100% - 100% + 1em)</code>’ computes to ‘<code
1375+
class=css>height: calc(0% + 1em)</code>’, not to ‘<code
1376+
class=css>height: calc(1em)</code>’, and, due to containing a percentage
1377+
relative to the height of a containing block that depends on this
1378+
element's height, <a
1379+
href="http://www.w3.org/TR/CSS21/visudet.html#the-height-property">is
1380+
treated as ‘<code class=css>auto</code></a>. <a href="#CSS21"
1381+
rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a> <span class=note> Thus, the
1382+
computed value of a ‘<a href="#calc"><code
1383+
class=css>calc()</code></a>’ expression can be represented as either a
1384+
number or a tuple of a dimension and a percentage. </span>
13751385
<!-- http://lists.w3.org/Archives/Public/www-style/2010May/0001.html
13761386
This has notes on how we should handle things when calc() is extended to
13771387
handle unit mult/div. Related to this is <unit>mod<unit>, which can return
@@ -1474,12 +1484,12 @@ <h4 id=calc-syntax><span class=secno>8.1.1. </span> Syntax</h4>
14741484

14751485
<p> UAs must support ‘<a href="#calc"><code
14761486
class=css>calc()</code></a>’ expressions of at least 20 terms, where
1477-
each <a href="#number"><code class=css>number</code></a>’, ‘<a
1478-
href="#dimension"><code class=css>dimension</code></a>, or <a
1479-
href="#percentage"><code class=css>percentage</code></a> is a term. If
1480-
a ‘<a href="#calc"><code class=css>calc()</code></a>’ expression
1481-
contains more than the supported number of terms, it must be treated as if
1482-
it were invalid.
1487+
each <a href="#number"><code>NUMBER</code></a>, <a
1488+
href="#dimension"><code>DIMENSION</code></a>, or <a
1489+
href="#percentage"><code>PERCENTAGE</code></a> is a term. If a ‘<a
1490+
href="#calc"><code class=css>calc()</code></a>’ expression contains more
1491+
than the supported number of terms, it must be treated as if it were
1492+
invalid.
14831493

14841494
<h4 id=calc-type-checking><span class=secno>8.1.2. </span> Type Checking</h4>
14851495

css3-values/Overview.src.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,12 @@ <h3 id="calc-notation">
912912
with all components computed,
913913
with all multiplication/division subexpressions resolved,
914914
and with all addition/subtraction subexpressions resolved where both sides are the same type.
915+
Where percentages are not resolved at computed value,
916+
they are not resolved in ''calc()'' expressions,
917+
e.g. ''height: calc(100% - 100% + 1em)'' computes to ''height: calc(0% + 1em)'',
918+
not to ''height: calc(1em)'',
919+
and, due to containing a percentage relative to the height of a containing block that depends on this element's height,
920+
<a href="http://www.w3.org/TR/CSS21/visudet.html#the-height-property">is treated as ''auto''</a>. [[!CSS21]]
915921
<span class='note'>
916922
Thus, the computed value of a ''calc()'' expression can be represented
917923
as either a number
@@ -1017,7 +1023,7 @@ <h4 id='calc-syntax'>
10171023

10181024
<p>
10191025
UAs must support ''calc()'' expressions of at least 20 terms,
1020-
where each ''number'', ''dimension'', or ''percentage'' is a term.
1026+
where each <code>NUMBER</code>, <code>DIMENSION</code>, or <code>PERCENTAGE</code> is a term.
10211027
If a ''calc()'' expression contains more than the supported number of terms,
10221028
it must be treated as if it were invalid.
10231029

css3-values/issues-lc-2012.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,3 +329,12 @@ <h1>CSS Values and Units Level 3 Disposition of Comments</h1>
329329
Response: <a href="http://lists.w3.org/Archives/Public/www-style/2012Jul/0217.html">http://lists.w3.org/Archives/Public/www-style/2012Jul/0217.html</a>
330330
Closed: Partially Accepted
331331
</pre>
332+
<pre class="a" id="issue-38">
333+
Issue 38. <a href="#issue-38">#</a>
334+
Summary: Clarify whether percentages can be simplified away in calc()
335+
From: Kenny Lu
336+
Comment: http://www.w3.org/mid/4FFB7960.3080700@csail.mit.edu
337+
Response:
338+
Closed: Accepted
339+
</pre>
340+

css3-values/issues-lc-2012.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,10 @@ Comment: http://lists.w3.org/Archives/Public/www-style/2012Jul/0210.html
259259
Response: http://lists.w3.org/Archives/Public/www-style/2012Jul/0217.html
260260
Closed: Partially Accepted
261261
----
262+
Issue 38.
263+
Summary: Clarify whether percentages can be simplified away in calc()
264+
From: Kenny Lu
265+
Comment: http://www.w3.org/mid/4FFB7960.3080700@csail.mit.edu
266+
Response:
267+
Closed: Accepted
268+
----

0 commit comments

Comments
 (0)