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

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 UTC