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

[CSS4 Selectors] :has() (was Re: [CSSWG] ... F2F Kyoto]

From: Alan Gresley <alan@css-class.com>
Date: Sat, 11 Jun 2011 23:37:02 +1000
Message-ID: <4DF36F7E.8030602@css-class.com>
To: Brian Kardell <bkardell@gmail.com>
CC: John Jansen <John.Jansen@microsoft.com>, fantasai <fantasai.lists@inkedblade.net>, "www-style@w3.org" <www-style@w3.org>
On 11/06/2011 10:38 PM, Brian Kardell wrote:
> I have read through the wiki and the discussions surrounding
> subject/matches/has and I can't seem to find where ! is introduced.  In any
> case, I ran this privately past 5 designers and 2 programmers who are very
> good with CSS and without fail all eight of us had the same reaction as
> Opera voiced "that means not".  There was also unanimous agreement that
> has() as presented by Ian and implemented in jQuery for some time (with the
> addition of supporting rhs combinator), despite a smattering of limitations
> is both infinitely more intuitive/readable and fulfills the vast majority of
> their real world needs.
> It is also easy to implement and has the advantage that it already has shown
> its practical worth and is used by a large community.
> As I said, I read fantasai's comments on this, and I understand the
> objections on a larger "matches", but :has() seems like low hanging fruit
> that accomplishes a lot even if it could also be written with a matches() or
> some symbol notation.  Even if the later has much expressive power, I would
> personally willingly trade a certain amount of whatever that is for simple
> intuitiveness and readability.

So that I am clear in what :has() does. If I wanted to style any 
list-item <li> that does not have anchor links <a>, could use this selector?

ul:has(a) li { ... }

Could either of these work?

ul:has(a) { ... }

ul:has(li > a) { ... }

ul:has(a:hover) { ... }

CSS has never worked like that before.

Alan Gresley
Received on Saturday, 11 June 2011 13:37:37 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:50:02 UTC