W3C home > Mailing lists > Public > www-style@w3.org > March 2008

[css3-values] Lengths and calc()

From: Christoph Päper <christoph.paeper@crissov.de>
Date: Wed, 12 Mar 2008 13:02:27 +0100
Message-Id: <6493AA96-E1F4-49D5-874D-3EE2C544BB27@crissov.de>
To: www-style Mailing List <www-style@w3.org>

In CSS3 Values and Units sections 3.4.1. and 3.7.4. should be  
harmonised, i.e. the former should use <atomic-length> instead of  
<length> or explicitely refer to the overwrite by 'calc()'.

3.4.1 Lengths
| The format of a length value (denoted by <length>) is a <number>  
immediately followed by a
| unit identifier (e.g., 'px', 'gd').

That is:

   <length> := <number> <length-unit>

3.7.4. The 'calc' function
| The calc(<expression>) function can be used wherever length values  
are allowed.

This <expression> is replaced by <length-expression> further on.

| The expression language is defined by 'length-expression' below:
|   <length> := calc( <length-expression> ) | <atomic-length>
|   <length-expression> := <length-additive-expression>
   ...
|   <atomic-length> := <number><length-unit>

Is the limitation of 'calc()' to lengths (i.e. no percentages,  
angles, times, frequencies and probably others) intentional?

I wonder if CSS could include railroad or syntax diagrams for those  
BNF parts, like JSON.org does.

   <atomic-length> := <number> <length-unit> | <zero>
   <number>        := <integer> | <real-number>
   <integer>       := <sign> <int>
   <sign>          := <positive-sign> | <negative-sign>
   <positive-sign> := '+' | ''   % implicit
   <negative-sign> := '-'
   <int>           := <digit> | <digit> <int>   % zero-padding allowed
   <digit>         := '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' |  
'8' | '9'
   <real-number>   := <integer> <float-part> | <sign> <float-part>    
% "-.5" legal
   <float-part>    := <decimal-separator> <int>
   <decimal-separator> := '.'
   <zero>          := '0'
   <non-negative-number>  := <non-negative-integer> | <non-negative- 
real>
   <non-negative-integer> := <positive-sign> <int>
   <non-negative-real>    := <non-negative-integer> <float-part> |  
<positive-sign> <float-part>
   <length-unit>   := <absolute-length-unit> | <relative-length-unit>  
| <percent>
   <absolute-length-unit> := 'mm' | 'cm' | 'pt' | 'pc' | 'in'   % all  
case-insensitive
   <relative-length-unit> := 'em' | 'ex' | 'px' | 'gd' | 'rem' | 'vw'  
| 'vh' | 'vm' | 'ch'
   <percent>       := '%'
   <angle>         := <number> <angle-unit>
   <angle-unit>    := 'deg' | 'grad' | 'rad' | 'turn'
   <time>          := <non-negative-number> <time-unit>
   <time-unit>     := 'ms' | 's'
   <frequency>     := <non-negative-number> <frequency-unit>
   <frequency-unit>:= 'Hz' | 'kHz'

Section 3.5 has "non-negative" in the title, but the definitions use  
<number> instead of <non-negative number>.

PS: How expensive is the addition of more ((absolute) length) units?  
I know the benefit is severely limited by lack of backwards  
compatibility, but for some (future) applications accuracy might be  
more important (e.g. for Didot points).
Received on Wednesday, 12 March 2008 12:12:56 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:02 GMT