W3C home > Mailing lists > Public > www-style@w3.org > March 2011

Re: [css3-selectors] Allowing pseudo-classes on pseudo-elements

From: Bert Bos <bert@w3.org>
Date: Fri, 11 Mar 2011 17:26:18 +0100
Message-Id: <2383D50C-2578-4F58-9D2F-F086FA02BA04@w3.org>
To: W3C style mailing list mailing list <www-style@w3.org>
On Mar 10, 2011, at 01:34, Sylvain Galineau wrote:

> Current selector syntax does not allow a pseudo-class to qualify a pseudo-element i.e. E::first-line:hover will not match when the first line of E is hovered.
[...]
> I wanted to inquire as to the reasons for this limitation, as well as the possibility of lifting it in a future version of CSS Selectors.

It is simply that it doesn't make sense to apply a pseudo-classes to a pseudo-element for any of the pseudo-classes and pseudo-elements currently defined. It's not impossible that certain future pseudo-classes and -elements *can* be combined. (On the other hand, given that we have so many already that cannot be combined, maybe we discovered a pattern that is worth keeping, if only for usability reasons?)

E.g., the purpose of ':active', ':hover', ':focus', ':visited' and ':link' is to show that something is happening, going to happen, could happen, or has recently happened. But, with a pseudo-element, nothing is ever going to happen, because it can have neither an HREF attribute nor any form-related attributes, nor indeed any other semantics, because such semantics can only be in the source document, not in CSS.

Similarly, ':nth-child' and its cousins make no sense for pseudo-elements, because pseudo-elements, by definition, aren't in the document tree.

Even among the pseudo-classes and pseudo-elements of css3-ui there doesn't seem to be any useful pair. At best such a pair would simply have the same meaning as with the pseudo-class *before* the pseudo-element.

> [1] http://dev.w3.org/csswg/css3-grid-align/
> [2] http://dev.w3.org/csswg/css3-ui/#pseudo-elements
> [3] http://www.webkit.org/blog/363/styling-scrollbars/



Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos                               W3C/ERCIM
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France
Received on Friday, 11 March 2011 16:26:47 GMT

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