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

Re: Previous-sibling combinator

From: Marat Tanalin | tanalin.com <mtanalin@yandex.ru>
Date: Sat, 28 Jan 2012 03:15:16 +0400
To: Tab Atkins Jr. <jackalmage@gmail.com>
Cc: www-style@w3.org
Message-Id: <133161327706116@web5.yandex.ru>
28.01.2012, 03:08, "Tab Atkins Jr." <jackalmage@gmail.com>:
> On Fri, Jan 27, 2012 at 3:05 PM, Marat Tanalin | tanalin.com
> <mtanalin@yandex.ru> wrote:
>
>> šHello.
>>
>> šIt would be nice to have combinator to select previous sibling.
>>
>> šš šP - UL {
>> šš š š š/* Styles for UL element which is
>> šš š š š š previous sibling of P element. */
>> šš š}
>>
>> šThe "-" combinator is functionally similar to existing "+" combinator, but selects previous-sibling element instead of next-sibling one.
>>
>> šSo in result we would have "+" to move forward, and "-" to move backward (like element.nextSibling and element.previousSibling in DOM, respectively).
>
> This is already possible with Selectors 4, using the normal sibling
> combinator and the subject indicator:
>
> !ul + p { ... }
>
> ~TJ

And how would you write following selector using subject indicator?

    P - UL > LI {...}
Received on Friday, 27 January 2012 23:15:48 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:49 GMT