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

Re: [selectors] Are really arbitrary selectors allowed in :not()?

From: Florian Rivoal <florian@rivoal.net>
Date: Tue, 20 Jan 2015 17:54:17 +0100
Cc: Benjamin Poulain <benjamin@webkit.org>, www-style list <www-style@w3.org>
Message-Id: <C0DDB0CA-DFA9-4029-82E4-691E53A6C81C@rivoal.net>
To: Sebastian Zartner <sebastianzartner@gmail.com>

> On 20 Jan 2015, at 17:36, Sebastian Zartner <sebastianzartner@gmail.com> wrote:
>> span:not(div > .someclass) matches any span that does not have a class "someclass" and is not under a div.
> So an equivalent to :not(div) > span:not(.someclass).

Not equivalent selectors, although they end up matching the same thing.

"span:not(div > .someclass)"       requires the span not to have .someclass and not to be the child of a div.

":not(div) > span:not(.someclass)" requires the span not to have .someclass and to be the child of something that is not a div. 

A span that's not the child of anything would match the first one, but not the second. That can't happen in html, since a span will at least be the child of 'body', so they end up being equivalent, but only indirectly.

 - Florian
Received on Tuesday, 20 January 2015 16:54:43 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:51:56 UTC