logo
Page Affairs

Editing and Web Design

CSS authors have long desired a ‘parent selector’—that is, a selector for styling one element that contains another. There has thus been a lot of excitement over the ‘subject indicator’ (a.k.a. parent selector) in the CSS Selectors Level 4 specification—which seems to suggest that a parent selector will be coming soon to CSS. But will it really be coming?

It seems that this excitement is misplaced. In a recent interview on The Web Ahead (Episode 58, about 32 minutes in), Lea Verou points out that all is not as it seems with the parent selector.

The catch is that there are actually two Selectors Level 4 profiles, known as ‘fast’ and ‘complete’. Those in the fast profile are the ones likely to be implemented in CSS, while those in the complete profile can only be used in JavaScript:

The complete profile is appropriate for contexts which aren’t extremely performance sensitive. For example, implementations of the Selectors API specification … should use the ‘complete’ profile.

Source

Lea Verou points out that browser makers are not keen to implement the parent selector (for performance reasons) and it has thus been relegated to the complete profile … meaning that it will never be usable except with JavaScript.

That’s a bummer indeed. Given the amazing things browsers can do these days, it seems weird they can’t handle something like this. Hopefully the browser vendors will change their minds on this, but I’m not going to hold my breath.

© Page Affairs, 2008–2024