[css4-background] More relaxed box-shadow grammar

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 UTC