Re: [css4-background] More relaxed box-shadow grammar

On Thu, Oct 11, 2012 at 6:32 PM, Lea Verou <lea@w3.org> wrote:
> 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>?

You're right, that's pretty weird.  I support this grammar relaxation.

> 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>

I guess we *could*, but it wouldn't buy us much.  If all of the
lengths are 0, you simply don't have a shadow at all.

We *could* allow you to omit the second length, but it doesn't seem to
be worth very much.  How often is a shadow just projected up/down?
Potentially more useful is to assume that, if the second length is
omitted, it's *the same* as the first length.  That's a much more
common case in my experience.

~TJ

Received on Tuesday, 16 October 2012 18:26:11 UTC