- From: Kornel Lesinski <kornel@ldreams.net>
- Date: Fri, 29 Jul 2005 20:40:23 +0000
- To: www-style@w3.org
On Fri, 29 Jul 2005 18:08:57 +0100, Christoph Päper
<christoph.paeper@tu-clausthal.de> wrote:
> 3.7.4. The 'calc' function
>
> Should we introduce mathematical expressions to calculate values?
>
> I think the majority of webdesigners would say yes. I'm undecided. I'm
> also not sure whether a generic 'calc()' or distinctive 'add()',
> 'sub()', 'mul()', 'div()', 'mod()', 'pow()' etc. functions were
> preferable.
I've implemented server-side CSS preprocessor and written few stylesheets
using math expressions and constants.
My suggestion for syntax is: shortest possible. calc() seems too much to
write. sub() might avoid confusion with minus and hyphenated identifiers,
but again - it's too verbose.
I suggest new syntax - expressions to be just in parentheses.
foo {width: (2px + 2em);}
This is compatible with CSS parsing rules and does not conflict with any
current syntax.
Formally it'd be (basing on CSS2.1 grammar appendix):
term
: unary_operator?
[ NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S* | ANGLE S* |
TIME S* | FREQ S* | function ]
| STRING S* | IDENT S* | URI S* | UNICODERANGE S* | hexcolor |
"(" S* term S* [ math_operator S* term S* ]* ")" S* /* added
mathematical expressions */
;
--
regards, Kornel Lesinski
Received on Monday, 1 August 2005 10:09:12 UTC