W3C home > Mailing lists > Public > www-style@w3.org > October 2012

[css4-background] More relaxed box-shadow grammar

From: Lea Verou <lea@w3.org>
Date: Fri, 12 Oct 2012 04:32:38 +0300
Message-Id: <4A6C0ECB-393E-4980-81A9-051AD1262BA7@w3.org>
To: www-style list <www-style@w3.org>
It always bugged me as an author that while these are perfectly legal:

box-shadow: inset 1px 2px 3px 4px black;
box-shadow: inset black 1px 2px 3px 4px;
box-shadow: 1px 2px 3px 4px black inset;
box-shadow: black 1px 2px 3px 4px inset;

These are not:

box-shadow: 1px 2px 3px 4px inset black;
box-shadow: black inset 1px 2px 3px 4px;

It seems entirely arbitrary and goes against one of the basic syntactic conventions of CSS: When disambiguation is possible, order of values doesn’t matter.

I propose the following grammar change:

<shadow> = inset? && <length>{2,4} && <color>?

In addition, why require at least two lengths? We can safely assume that if they are omitted, they are zero, which is on par with most CSS shorthands or shorthandy-style properties. Therefore, it could become this:

<shadow> = inset? && <length>{0,4} && <color>?

which (I think) can be simplified as:

<shadow> = inset || <length>{1,4} || <color>

Lea Verou
W3C developer relations
http://w3.org/people/all#leahttp://lea.verou.me ✿ @leaverou
Received on Friday, 12 October 2012 01:32:47 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:21:01 GMT