W3C home > Mailing lists > Public > www-style@w3.org > December 2010

Re: [css3-values] unitless zero lengths inside 'calc()'

From: Brad Kemper <brad.kemper@gmail.com>
Date: Wed, 29 Dec 2010 10:41:05 -0800
Message-Id: <2976E7DA-EF90-478A-A31D-B7DCE2D2855A@gmail.com>
Cc: "L. David Baron" <dbaron@dbaron.org>, "www-style@w3.org" <www-style@w3.org>
To: "Tab Atkins Jr." <jackalmage@gmail.com>

On Dec 29, 2010, at 9:56 AM, "Tab Atkins Jr." <jackalmage@gmail.com> wrote:

> On Wed, Dec 29, 2010 at 9:41 AM, L. David Baron <dbaron@dbaron.org> wrote:
>> calc() expressions, defined in
>> http://dev.w3.org/csswg/css3-values/#the-calc-min-and-max-functions ,
>> do not allow unitless zero to be treated as a length, since the spec
>> says:
>>  # The context of the expression imposes a target type, which is
>>  # one of length, frequency, angle, time, or number. NUMBER tokens
>>  # are of type number. DIMENSION tokens have types of their units
>>  # (¡®cm¡¯ is length, ¡®deg¡¯ is angle etc.); any DIMENSION whose type
>>  # does not match the target type is not allowed and must be a
>>  # parse error.
>> I think this is a good thing; the only use cases for zero lengths
>> that I can think of are for the output of tools that might be
>> generating nonzero lengths, and in such cases the tool would
>> presumably be generating the unit anyway.
>> However, since this isn't explicitly stated, and it might trip up
>> authors or implementors, I think it would be good to add a note
>> (near the text above) that this means that '0' is never a dimension
>> inside calc(), even though it is allowed to be a length outside of a
>> calc() expression.
> Agreed on all points.  0 lengths aren't very useful in calc(),
> machines generating them will probably put a unit in anyway, and we
> should have an explicit note in the spec so people don't make
> assumptions based on how the grammar works elsewhere in the language.

What is the harm of having unitless zero allowed? The benefit is that authors would not need to remember a special exception to unitless zeros that can be applied everywhere else that lengths are accepted. 
Received on Wednesday, 29 December 2010 18:41:43 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:38:41 UTC