- From: Amelia Bellamy-Royds via GitHub <sysbot+gh@w3.org>
- Date: Tue, 03 Dec 2019 00:15:51 +0000
- To: public-css-archive@w3.org
AmeliaBR has just created a new issue for https://github.com/w3c/csswg-drafts: == [css-values] Clarify that calc(0) is never a length == Inspired by [this twitter thread](https://twitter.com/simevidas/status/1201624926823813125), where some people I'd consider very informed CSS devs were suprised to discover that calc expressions evaluating to zero are invalid as lengths. I couldn't find a good spec reference to point to as a authoritative explanation. There are two relevant sections of CSS Values, but they don't currently cross-link in a useful way. "[Real Numbers: the `<number>` type](https://drafts.csswg.org/css-values/#numbers)" states: > The value `<zero>` represents a literal number with the value 0. Expressions that merely evaluate to a `<number>` with the value 0 (for example, `calc(0)`) do not match `<zero>`; only literal `<number-token>`s do. However, the `<zero>` production is not referenced anywhere other than that paragraph. "[Distance Units: the `<length>` type](https://drafts.csswg.org/css-values/#lengths)" states > For zero lengths the unit identifier is optional (i.e. can be syntactically represented as the `<number>` 0). (…and then goes on to talk about how interpretation as a number takes precedence if the property accepts either number and length.) But nothing about "Expressions that merely evaluate" to zero. The official specification of the "`calc(0)` is not a length" rule would come from the [calculation type-checking rules](https://drafts.csswg.org/css-values/#calc-type-checking), but those are rather long and convoluted and not something most authors would read. A more prominent note in the number/length sections would be helpful, either making use of the `<zero>` type or getting rid of it. Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4554 using your GitHub account
Received on Tuesday, 3 December 2019 00:15:52 UTC