Skip to content

Commit 9c0e4fe

Browse files
committed
Editorial tweaks to calc()
1 parent 066a357 commit 9c0e4fe

2 files changed

Lines changed: 59 additions & 38 deletions

File tree

css3-values/Overview.html

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ <h2 class="no-num no-toc" id=contents>Table of contents</h2>
278278
<li><a href="#functional-notation"><span class=secno>9. </span> Functional
279279
Notations</a>
280280
<ul class=toc>
281-
<li><a href="#calc"><span class=secno>9.1. </span> Calculations:
282-
&lsquo;<code class=css>calc()</code>&rsquo;, &lsquo;<code
281+
<li><a href="#calc"><span class=secno>9.1. </span> Mathematical
282+
Expressions: &lsquo;<code class=css>calc()</code>&rsquo;, &lsquo;<code
283283
class=css>min()</code>&rsquo; and &lsquo;<code
284284
class=css>max()</code>&rsquo;</a>
285285

@@ -782,11 +782,11 @@ <h3 id=percentages><span class=secno>4.3. </span> Percentages: the
782782
&lsquo;<a href="#percentage-value"><code
783783
class=css>&lt;percentage&gt;</code></a>&rsquo; type</h3>
784784

785-
<p>A percentage value is denoted by <dfn
785+
<p>A <dfn id=percentage>percentage</dfn> value is denoted by <dfn
786786
id=percentage-value><code>&lt;percentage&gt;</code></dfn>, consists of a
787787
<a href="#number-value"><i>&lt;number&gt;</i></a> immediately followed by
788788
a percent sign &lsquo;<code class=css>%</code>&rsquo;. It corresponds to
789-
the <code>PERCENTAGE</code> token in the <a
789+
the <a href="#percentage"><code>PERCENTAGE</code></a> token in the <a
790790
href="http://www.w3.org/TR/CSS21/syndata.html#tokenization">grammar</a>.
791791

792792
<p>Percentage values are always relative to another value, for example a
@@ -1297,15 +1297,19 @@ <h2 id=functional-notation><span class=secno>9. </span> Functional
12971297
<!-- -->content: counter(list-item) ". ";
12981298
<!-- -->width: calc(50% - 2em);</pre>
12991299

1300-
<h3 id=calc><span class=secno>9.1. </span> Calculations: &lsquo;<a
1301-
href="#calc0"><code class=css>calc()</code></a>&rsquo;, &lsquo;<a
1302-
href="#min"><code class=css>min()</code></a>&rsquo; and &lsquo;<a
1303-
href="#max"><code class=css>max()</code></a>&rsquo;</h3>
1300+
<h3 id=calc><span class=secno>9.1. </span> Mathematical Expressions:
1301+
&lsquo;<a href="#calc0"><code class=css>calc()</code></a>&rsquo;,
1302+
&lsquo;<a href="#min"><code class=css>min()</code></a>&rsquo; and
1303+
&lsquo;<a href="#max"><code class=css>max()</code></a>&rsquo;</h3>
13041304

13051305
<p>The <dfn id=calc0>calc()</dfn>, <dfn id=min>min()</dfn>, and <dfn
1306-
id=max>max()</dfn> functions allow mathematical expressions to be used as
1307-
component values. They can be used wherever <a
1308-
href="#length-value"><code>&lt;length&gt;</code></a>, <a
1306+
id=max>max()</dfn> functions allow mathematical expressions with addition
1307+
(&lsquo;<code class=css>+</code>&rsquo;), subtraction (&lsquo;<code
1308+
class=css>-</code>&rsquo;), multiplication (&lsquo;<code
1309+
class=css>*</code>&rsquo;), division (&lsquo;<code
1310+
class=css>/</code>&rsquo;), and modulus (&lsquo;<code
1311+
class=css>mod</code>&rsquo;) to be used as component values. They can be
1312+
used wherever <a href="#length-value"><code>&lt;length&gt;</code></a>, <a
13091313
href="#frequency-value"><code>&lt;frequency&gt;</code></a>, <a
13101314
href="#angle-value"><code>&lt;angle&gt;</code></a>, <a
13111315
href="#time-value"><code>&lt;time&gt;</code></a>, or <a
@@ -1337,6 +1341,9 @@ <h3 id=calc><span class=secno>9.1. </span> Calculations: &lsquo;<a
13371341
<pre>.box { width: min(10% + 20px, 300px) }</pre>
13381342
</div>
13391343

1344+
<p class=issue>Add less trivial examples, particularly involving parens or
1345+
nesting.
1346+
13401347
<p>The expression language of these functions is described by the grammar
13411348
and prose below.
13421349

@@ -1350,22 +1357,26 @@ <h3 id=calc><span class=secno>9.1. </span> Calculations: &lsquo;<a
13501357
unit : ["+"|"-"]? [ NUMBER | DIMENSION | PERCENTAGE |
13511358
min | max | "(" S* sum S* ")" ];</pre>
13521359

1353-
<div class=note>
1354-
<p>Additionally, the following redefinition is made to the informative
1355-
grammar appearing in <a href="http://www.w3.org/TR/CSS2/grammar.html">CSS
1356-
2.1 Appendix G</a>:</p>
1360+
<p class=note>Note that the grammar requires spaces around binary
1361+
&lsquo;<code class=css>+</code>&rsquo; and &lsquo;<code
1362+
class=css>-</code>&rsquo; operators. The &lsquo;<code
1363+
class=css>*</code>&rsquo;, &lsquo;<code class=css>/</code>&rsquo;, and
1364+
&lsquo;<code class=css>mod</code>&rsquo; operators do not require spaces.
13571365

1358-
<pre>
1366+
<p>Additionally, the following redefinition is made to the informative
1367+
grammar appearing in <a href="http://www.w3.org/TR/CSS2/grammar.html">CSS
1368+
2.1 Appendix G</a>:
1369+
1370+
<pre>
13591371
term
13601372
: unary_operator?
13611373
[ NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S* | ANGLE S* |
13621374
TIME S* | FREQ S* ]
13631375
| STRING S* | IDENT S* | URI S* | hexcolor | function<ins> | math</ins>
13641376
;</pre>
1365-
</div>
13661377

1367-
<p>The expression has a <dfn id=resolved-type>resolved type</dfn>, which is
1368-
one of &lsquo;<code class=css>&lt;length></code>&rsquo;, &lsquo;<code
1378+
<p>A math expression has a <dfn id=resolved-type>resolved type</dfn>, which
1379+
is one of &lsquo;<code class=css>&lt;length></code>&rsquo;, &lsquo;<code
13691380
class=css>&lt;frequency></code>&rsquo;, &lsquo;<code
13701381
class=css>&lt;angle></code>&rsquo;, &lsquo;<code
13711382
class=css>&lt;time></code>&rsquo;, or &lsquo;<code
@@ -1381,9 +1392,10 @@ <h3 id=calc><span class=secno>9.1. </span> Calculations: &lsquo;<a
13811392
class=css>&lt;length></code>&rsquo;, &lsquo;<a href="#deg"><code
13821393
class=css>deg</code></a>&rsquo; is &lsquo;<code
13831394
class=css>&lt;angle></code>&rsquo;, etc.). If percentages are accepted in
1384-
the context in which the expression is placed, a <code>PERCENTAGE</code>
1385-
token has the type of the value that percentages are relative to;
1386-
otherwise, an expression containing percentages is invalid.
1395+
the context in which the expression is placed, a <a
1396+
href="#percentage"><code>PERCENTAGE</code></a> token has the type of the
1397+
value that percentages are relative to; otherwise, a math expression
1398+
containing percentages is invalid.
13871399

13881400
<p>Operators form sub-expressions, which gain types based on their
13891401
arguments. To make expressions simpler, operators have restrictions on the
@@ -1427,7 +1439,7 @@ <h3 id=calc><span class=secno>9.1. </span> Calculations: &lsquo;<a
14271439
</div>
14281440

14291441
<p>Given the complexities of width and height calculations on table cells
1430-
and table elements, expressions involving percentages for widths and
1442+
and table elements, math expressions involving percentages for widths and
14311443
heights on table columns, table column groups, table rows, table row
14321444
groups, and table cells in both auto and fixed layout tables MAY be
14331445
treated as if &lsquo;<code class=property>auto</code>&rsquo; had been
@@ -2309,6 +2321,9 @@ <h2 class=no-num id=index>Index</h2>
23092321
<li><a href="#number-value"><code>&lt;number&gt;</code></a>, <a
23102322
href="#number-value" title="&lt;number&gt;"><strong>4.2.</strong></a>
23112323

2324+
<li>percentage, <a href="#percentage"
2325+
title=percentage><strong>4.3.</strong></a>
2326+
23122327
<li><a href="#percentage-value"><code>&lt;percentage&gt;</code></a>, <a
23132328
href="#percentage-value"
23142329
title="&lt;percentage&gt;"><strong>4.3.</strong></a>

css3-values/Overview.src.html

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ <h3 id="numbers">
449449
<h3 id="percentages">
450450
Percentages: the ''&lt;percentage&gt;'' type</h3>
451451

452-
<p>A percentage value is denoted by
452+
<p>A <dfn>percentage</dfn> value is denoted by
453453
<dfn id="percentage-value"><code>&lt;percentage&gt;</code></dfn>,
454454
consists of a <i>&lt;number&gt;</i> immediately followed by a percent
455455
sign ''%''. It corresponds to the <code>PERCENTAGE</code> token in the
@@ -865,11 +865,12 @@ <h2 id="functional-notation">
865865
<!-- -->width: calc(50% - 2em);</pre>
866866

867867
<h3 id="calc">
868-
Calculations: ''calc()'', ''min()'' and ''max()''</h3>
868+
Mathematical Expressions: ''calc()'', ''min()'' and ''max()''</h3>
869869

870870
<p>The <dfn>calc()</dfn>, <dfn>min()</dfn>, and <dfn>max()</dfn> functions
871-
allow mathematical expressions to be used as component values. They
872-
can be used wherever
871+
allow mathematical expressions with addition (''+''), subtraction (''-''),
872+
multiplication (''*''), division (''/''), and modulus (''mod'') to be used
873+
as component values. They can be used wherever
873874
<code>&lt;length&gt;</code>,
874875
<code>&lt;frequency&gt;</code>,
875876
<code>&lt;angle&gt;</code>,
@@ -903,6 +904,9 @@ <h3 id="calc">
903904
<pre>.box { width: min(10% + 20px, 300px) }</pre>
904905
</div>
905906

907+
<p class='issue'>Add less trivial examples, particularly involving parens
908+
or nesting.</p>
909+
906910

907911
<p>The expression language of these functions is described by
908912
the grammar and prose below.
@@ -917,21 +921,23 @@ <h3 id="calc">
917921
unit : ["+"|"-"]? [ NUMBER | DIMENSION | PERCENTAGE |
918922
min | max | "(" S* sum S* ")" ];</pre>
919923

920-
<div class='note'>
921-
<p>Additionally, the following redefinition is made to the informative
922-
grammar appearing in
923-
<a href="http://www.w3.org/TR/CSS2/grammar.html">CSS 2.1 Appendix G</a>:</p>
924+
<p class='note'>Note that the grammar requires spaces around binary ''+''
925+
and ''-'' operators. The ''*'', ''/'', and ''mod'' operators do not require
926+
spaces.</p>
924927

925-
<pre>
928+
<p>Additionally, the following redefinition is made to the informative
929+
grammar appearing in
930+
<a href="http://www.w3.org/TR/CSS2/grammar.html">CSS 2.1 Appendix G</a>:</p>
931+
932+
<pre>
926933
term
927934
: unary_operator?
928935
[ NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S* | ANGLE S* |
929936
TIME S* | FREQ S* ]
930937
| STRING S* | IDENT S* | URI S* | hexcolor | function<ins> | math</ins>
931938
;</pre>
932-
</div>
933939

934-
<p>The expression has a <dfn>resolved type</dfn>, which is one of
940+
<p>A math expression has a <dfn>resolved type</dfn>, which is one of
935941
''&lt;length>'', ''&lt;frequency>'', ''&lt;angle>'', ''&lt;time>'', or
936942
''&lt;number>''. The <i>resolved type</i> must be valid for where the
937943
expression is placed; otherwise, the expression is invalid.
@@ -941,7 +947,7 @@ <h3 id="calc">
941947
by its unit (''cm'' is ''&lt;length>'', ''deg'' is ''&lt;angle>'', etc.).
942948
If percentages are accepted in the context in which the expression
943949
is placed, a <code>PERCENTAGE</code> token has the type of the value that
944-
percentages are relative to; otherwise, an expression containing
950+
percentages are relative to; otherwise, a math expression containing
945951
percentages is invalid.</p>
946952

947953
<p>Operators form sub-expressions, which gain types based on their arguments.
@@ -981,9 +987,9 @@ <h3 id="calc">
981987
</div>
982988

983989
<p>Given the complexities of width and height calculations on table cells
984-
and table elements, expressions involving percentages for widths and heights
985-
on table columns, table column groups, table rows, table row groups, and
986-
table cells in both auto and fixed layout tables MAY be treated as if
990+
and table elements, math expressions involving percentages for widths and
991+
heights on table columns, table column groups, table rows, table row groups,
992+
and table cells in both auto and fixed layout tables MAY be treated as if
987993
'auto' had been specified.</p>
988994

989995
<h3 id="cycle">

0 commit comments

Comments
 (0)