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

Re: Selectors 4 and Variables

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Fri, 30 Sep 2011 17:03:37 -0700
Message-ID: <CAAWBYDDZV7BKYU=pCjphevQFS3YG25gWnHUhs37gNjncRqHWBA@mail.gmail.com>
To: Daniel Glazman <daniel.glazman@disruptive-innovations.com>
Cc: "www-style@w3.org" <www-style@w3.org>
On Thu, Sep 29, 2011 at 11:35 PM, Daniel Glazman
<daniel.glazman@disruptive-innovations.com> wrote:
> Hi there,
> Both Selectors 4 and Variables now use the $ to represent something.
> I think this is wrong and will lead to CSS maintainance issues
> for web authors since a textual search for $p inside a style sheet will
> retrieve not only the definitions/calls to variable p but also the
> selectors having for subject a p. If this case will be probably be rare
> - but real - in the html world, it could be bigger in the xml one.
> I don't want to see that happen.
> I really have the gut feeling we should use different char descriptors
> here. Long, really long ago, I proposed to use !. I still think this is
> the best option, something very visual meaning an emphasis on the
> corresponding simple selector.

I thought it was generally agreed long ago that the best approach was
to use :has() rather than a marker in the selector.  It's more general
and allows more types of things to be expressed.

Basically, the subject indicator is exactly equivalent to a :has()
pseudo limited to the end of the selector:

foo $bar baz {...} == foo bar:has(baz) {...}

However, :has() can be placed anywhere in the selector, and so allows
more powerful selections:

label:has(:checked) + section > p {...}

This also has the nice benefit of not using up the $ (or any other
glyph) inside of selectors.

Received on Saturday, 1 October 2011 00:04:24 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:05 UTC