W3C home > Mailing lists > Public > public-css-archive@w3.org > March 2017

[csswg-drafts] [css-values] note counter-intuitive interpretation of unitless 0 inside calc()

From: Michael Giuffrida via GitHub <sysbot+gh@w3.org>
Date: Fri, 17 Mar 2017 00:01:11 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-214872780-1489708870-sysbot+gh@w3.org>
mgiuffrida has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-values] note counter-intuitive interpretation of unitless 0 inside calc() ==
[Section 8.1.2 **`calc()` Type Checking](https://drafts.csswg.org/css-values-3/#calc-type-checking) does not explicitly indicate how a unitless `0` inside a `calc()` expression is treated. For example:

left: calc(0 - 5px);

It's not clear whether this expression is invalid. Inside `calc(()`, the types of arguments to the `-` operator must be compatible, and the rhs is of type `dimension<length>`. But what is the type of the lhs: `number` or `dimension<length>`?

Since section 5 says:

> for zero lengths the unit identifier is optional (i.e. can be syntactically represented as the `<number>` '0'

I would argue that interpreting `0` as being of type `dimension<length>` would be valid, and would be more in line with developer expectations. However, this was [discussed in 2010](https://lists.w3.org/Archives/Public/www-style/2010Dec/0479.html) with @tabatkins agreeing the `0` should cause a parse error. That's fine, but it would be helpful if the fact that `0` is never treated as a dimension inside `calc()` were explicitly noted in the spec (which was also agreed upon in that discussion).

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1114 using your GitHub account
Received on Friday, 17 March 2017 00:01:19 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:09 UTC