# Re: Previous-sibling combinator

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Fri, 17 Aug 2012 09:58:58 -0700
Message-ID: <CAAWBYDAp=gFiFEsm1sX1EB3Sd6-eACs7Dhy5pDYH88+ioZJuNw@mail.gmail.com>
To: Greg Houston <gregory.houston@gmail.com>
Cc: "Kang-Hao (Kenny) Lu" <kanghaol@oupeng.com>, "Marat Tanalin | tanalin.com" <mtanalin@yandex.ru>, WWW Style <www-style@w3.org>
```On Thu, Aug 16, 2012 at 9:54 PM, Greg Houston <gregory.houston@gmail.com> wrote:
> I think the exclamation point was put in the wrong place. It would be
> better to simply reverse a directional selector. Not only is it much
> easier to write but it makes a little more sense where we generally
> think of the exclamation point as meaning "not", like != (not equal).
> Not UL doesn't make binary sense, but !+ (not next) makes a bit more
> sense for previous.
>
> :matches(!UL + P) > LI
> vs.
> P !+ UL > LI
>
> :matches(!UL ~ P) > LI
> vs.
> P !~ UL > LI
>
> :matches(!UL > P) > LI
> vs.
> P !> UL > LI
>
> :matches(!UL P) > LI
> vs.
> P ! UL > LI
>
> Not sure If I am writing this one correctly using nested :matches...
> :matches(!panel > :matches(!header > :matches(!.float-right > .btn))) > footer
> vs.
> .btn !> .float-right !> header !> .panel > footer

this here:

The ! doesn't "reverse a combinator", though it can look like that in
some cases.  It just changes which part of the selector is used to
return a value.

Your last example can be more easily written as:

:matches(!.panel > header > .float-right > .btn) > footer

~TJ
```
Received on Friday, 17 August 2012 16:59:46 UTC

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