W3C home > Mailing lists > Public > www-style@w3.org > April 2013

Re: [selectors4] siblings and pseudo-elements

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 4 Apr 2013 08:46:09 -0700
Message-ID: <CAAWBYDDpjqGePhrOE0UTA1ANfp6ebf50MccNL6B=Assn=Cho=w@mail.gmail.com>
To: Dario De Bastiani <dario.debastiani@gmail.com>
Cc: www-style list <www-style@w3.org>
On Fri, Mar 22, 2013 at 6:22 AM, Dario De Bastiani
<dario.debastiani@gmail.com> wrote:
> Hi,
>
> this is the first email I send to a w3c list - I read the instructions but
> if I am doing anything wrong please do tell me.
>
> I'd like to suggest 2 additions to selectors level 4:
>
>  1) *previous-sibling* and *preceding-sibling* combinators.
> These would be complementary to the next-sibling and following-sibling
> combinators.
> I have tried to search the archives for any discussion that could shed light
> on why they have never been implemented, but couldn't find anything
> relevant.
>
> One use case for these could be labels preceding inputs that need to be
> styled differently than those afterwards.
>
> *sibling* and *neighboring-siblings* combinators could also be added as
> syntactic sugar in place of `preceding-sibling, following-sibling` and
> `previous-sibling, next-sibling`.

This is now handled by the subject indicator
<http://dev.w3.org/csswg/selectors/#subject>, which lets you
arbitrarily "reverse" selectors without adding new combinators.
Rather than saying ".two - .one" (using an earlier suggestion for the
- sign as the "previous sibling" combinator), just write "!.one +
.two".  The exact syntax for this is still in the air.

>  2) allow more than a single ::before and ::after pseudo-element.
> This could look something like *::before(x)*, with x as a number and
> ::before(0) being the same as ::before.
> ::before(1) would create a new pseudo-element after ::before(0), and so on.
>
> The main problem I see with limiting the number of pseudo-elements, is that
> sometimes they are both already used up: see for example [this float
> clearing technique](http://nicolasgallagher.com/micro-clearfix-hack/).
> Using code like that currently makes adding further styling via a new
> pseudo-element impossible.

Yes, we're discussing this, and have some ideas for it in the
Pseudo-Elements draft: http://dev.w3.org/csswg/css-pseudo/

~TJ
Received on Thursday, 4 April 2013 15:47:03 UTC

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