W3C home > Mailing lists > Public > www-style@w3.org > April 2014

[css-values] Revisiting calc() and whitespace

From: Simon Pieters <simonp@opera.com>
Date: Wed, 30 Apr 2014 18:42:43 +0200
To: "www-style@w3.org" <www-style@w3.org>
Message-ID: <op.xe411h0ridj3kv@simons-mbp>
I'd like to reopen the issue of whitespace around + and - in calc(). I  
think the current situation is hostile for authors and we can do better.  
In my opinion, we should make things that look OK be OK and things that  
don't, aren't.

Currently the following are valid:

calc(1px + +1px)
calc(1px + 1px)

but this are not:

calc(1px + + 1px);
calc(1px +1px);

(I wouldn't be able to explain it to a Web author keeping a straight face  
and avoid #WTFCSS tweets why it's like this.)

I propose that we make the following changes:

* In css-syntax, while tokenizing a dimension, we exclude "-" from being a  
valid character in the unit.
* In css-syntax, we store whether "+" or "-" was used in the token. (This  
is technically already stored in the "representation".)
* We remove all whitespace restrictions in calc() (currently calc(1px+  
1px) is not allowed but it parses OK).
* We define that the "+" or "-" delim in calc() must be omitted if the  
next value is a <number-token>/<percentage-token>/<dimension-token> with  
"+"/"-" set.

This would make it valid to use exactly one +/- with any whitespace  
around, as far as I can tell.

Previously stated concerns against:
* This wouldn't help with keywords if we are going to add keywords in the  
future (e.g. calc(auto-1em)).
   - Rebuttal: I don't see why that has to cripple calc() with dimensions.  
Saying that keywords can contain dashes and so have to be followed by a  
space seems sane to me.

Open issues:
* Should calc(+ 1px) be valid?

-- 
Simon Pieters
Opera Software
Received on Wednesday, 30 April 2014 16:43:15 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 30 April 2014 16:43:18 UTC