W3C home > Mailing lists > Public > www-style@w3.org > June 2013

Re: Reducing Selector Verbosity

From: Sebastian Zartner <sebastianzartner@gmail.com>
Date: Wed, 12 Jun 2013 01:13:29 +0200
Message-ID: <CAERejNbpnh0DvdxvXa+psSpGP7=vtkR1-6x1LgNoeUPknGo00g@mail.gmail.com>
To: Tom Wardrop <tom@tomwardrop.com>
Cc: "www-style@w3.org" <www-style@w3.org>
This is already covered by the :matches() pseudo-class[1].

And also already implemented in browsers as :-<vendor>-any()pseudo-class[2].

Sebastian

[1] http://dev.w3.org/csswg/selectors4/#matches
[2] https://developer.mozilla.org/en-US/docs/Web/CSS/:any


On 12 June 2013 00:42, Tom Wardrop <tom@tomwardrop.com> wrote:

> Hi All,
>
> I'm wondering if there's been any active discussion on reducing the
> verbosity of CSS selectors. Look at any stylesheet, and you'll likely see a
> lot of repetition in selectors, e.g.
>
> h1 > a, h2 > a, h3 > a, h4 > a, ... {
>     color: black;
> }
>
>
> Another common pattern is this one:
>
> #navigation { }
> #navigation a { }
> #navigation a:link { }
> ...
>
> #navigation > ul > li > ul {}
>
>
> There's a couple of simple and logical ways to handles these cases. For
> the first case, a parenthesis-based grouping syntax would work well, while
> for the second case, sub-selectors would do an equally good job. Examples...
>
> (h1, h2, h3, h4, h5, h6) > a {
>     blah: bleh;
> }
>
> #navigation {
>     a {
>         :link {
>
>         }
>     }
> }
>
>
> I guess such a change would be akin to introducing variables. It increases
> the complexity of the stylesheet markup, but I personally think it's
> overdue. Look at the complexity of CSS3 and the latest drafts compared to
> CSS1. We're adding more and more functionality, which as we use it,
> increases the verbosity of our stylesheets. I think CSS needs to facilitate
> this blow-out in new functionality by providing new constructs to
> reduce repetition and lighten up stylesheets. One could perhaps even make
> an argument on bandwidth.
>
> Thoughts before I continue any further?
>
>
Received on Tuesday, 11 June 2013 23:14:20 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:12 UTC