W3C home > Mailing lists > Public > www-style@w3.org > January 2010

Re: [css3-selectors] Grouping

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Fri, 8 Jan 2010 09:19:14 -0600
Message-ID: <dd0fbad1001080719s6edf6e54s47d261114423d6a5@mail.gmail.com>
To: Nikita Popov <privat@ni-po.com>
Cc: www-style list <www-style@w3.org>
On Fri, Jan 8, 2010 at 7:55 AM, Nikita Popov <privat@ni-po.com> wrote:
> Often several elements on a page have similar style. So you want to group
> them in one rule.
> The only possibility to do this, is the ",". The disadvantage is, that you
> often need to repeat large parts of the rule, but only small parts change.
>
> An Example: My body-Elements gets a class, containing the actual page, e.g.
> class="add". Now I want to give all input, textarea and select elements on
> this page, that are in two different divs some styling:
>
> .add #authors input, .add #authors select, .add #authors textarea,
> .add #publications input, .add #publications select, .add #publications
> textarea
> {
> ...
> }
>
> Not very nice.
> It would be much more convenient to group parts, that aren't changing:
> .add
> (#authors input, #authors select, #authors textarea,
> #publications input, #publications select, #publications textarea)
> {
> ...
> }
>
> Or even
> .add (#authors, #publications) (input, select, textarea)
> {
> ...
> }
>
> The code gets shorter and more readable.

I've asked for this before, under the :any() pseudoclass.  It works
just as you have it - that last rule would be written as ".add
:any(#authors,#publications) :any(input,select,textarea)".  It's
really a necessity for many cases where you end up with a
combinatorial explosion of selectors - this one selector replaces six
nearly identical ones.

Implementors have agreed that it's basically just syntax sugar, and
wouldn't require any special mechanics or cause performance
regressions.  It's just not in a draft yet, is all.

~TJ
Received on Friday, 8 January 2010 15:19:46 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:23 GMT