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

[css-syntax] Do not require digits after decimal point for number tokens

From: Lea Verou <lea@verou.me>
Date: Tue, 29 Jul 2014 22:20:00 +0300
Message-Id: <E9C84174-B476-4C2F-A049-550015A788D6@verou.me>
To: www-style list <www-style@w3.org>
Iím not sure if this is even feasible at this point, but in case it is, here goes:

My proposal is to allow decimal points without digits after them so that CSS like the following is valid:

font-size: 1.em;
line-height: 1.;

It would still change the type to "number", just step 4 of [1] would be reworded to "If the next input code point is U+002E FULL STOP (.), then:"

The reasoning is that currently there are many tools around that let authors edit CSS code and see the result in real time, including (but not limited to) browser debuggers. When the author is editing non integer lengths (e.g. from 2.5px to 2.9px), it usually goes like this (| denotes the caret):

2.5px|
2.5|px
2.|px
2.9|px

Instead of being able to observe the result of their changes, all they see is a flash, since the 3rd step makes the value invalid, then it jumps back to 2.9px. It sounds trivial, but itís encountered so frequently that itís incredibly annoying.
Not allowing such numbers is also inconsistent with Ecmascript, where numbers like 5. are perfectly valid.

~ Lea

[1]: http://www.w3.org/TR/css3-syntax/#consume-a-number0
Received on Tuesday, 29 July 2014 19:20:24 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:23 UTC