W3C home > Mailing lists > Public > www-style@w3.org > September 2014

Re: [selectors] :nth-child(An+B of selector) with a pseudo element

From: Henrik Andersson <henke@henke37.cjb.net>
Date: Wed, 17 Sep 2014 20:00:24 +0200
Message-ID: <5419CC38.6020905@henke37.cjb.net>
To: Benjamin Poulain <bpoulain@apple.com>, www-style list <www-style@w3.org>
Benjamin Poulain skrev:
> Hi,
>
> Currently, :nth-child() does not restrict pseudo-elements like :not() does. Shouldn’t it have the same restrictions?
>
> For example:
>     :nth-child(2n of ::after)
>     :nth-child(2n+1 of ::first-letter)
> do not make much sense.
>
> Benjamin
>
>
I don't see how this is nonsense. Very unlikely and probably tricky to
setup, yes, but not nonsense.

I do not see why a pseudoelement can't contain a real element. There are
two kinds of pseudo elements as far as I know: grouping ones and
generating ones. Both should be able to have real elements as children.

This html snippet exemplifies one such scenario.

<p>A cat <img src="cat.jpg"> with a tail <img src="tail.jpg"></p>

The images would be clear child elements of a ::first-line pseudo
element, assuming that the line hasn't been broken during the layout.

Similarly, I do not see why a content generating pseudoelement can't
introduce an entire subtree. In fact, the option to specify an URI for
the "content" property seems to imply that might already be possible by
simply specifying an URI pointing to a resource with a document tree of
its own. I have not tried this.

Please clarify if pseudo elements are forbidden from containing child
elements.
Received on Wednesday, 17 September 2014 18:00:56 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:46 UTC