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

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

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 16 Oct 2012 11:25:21 -0700
Message-ID: <CAAWBYDDAeriz-bfHxC_M=y5yHMuVy+NmC+_V7esctXM1skQMbA@mail.gmail.com>
To: Lea Verou <lea@w3.org>
Cc: www-style list <www-style@w3.org>
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 GMT

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