Andy Budd asks for parent selectors in “What I Want From CSS3 – Part 2“.
If you’re an exprienced CSS author, there is no doubt you have had a few “if only” moments when you’ve needed to affect a parent based on its children. You’re not alone. It looks like people have been asking for reverse inheritance since the dawn of CSS. In the comments of Andy’s post Mike Davidson mentions it’s been a problem for CSS Working Groups in the past. Indeed, I came to find the debate is long-standing.
At its core, we have to remember, the C in CSS stands for Cascade. So it stands to reason why there would be so much push-back on something that is inherently opposite. Still, if we were to go
down this path, an interesting question in my mind is how would you deal with specificity in this case. For instance…
a > b b < c
Who would win? Once you start asking these questions, you get more questions and you find that the answers aren’t as simple is they might seem. The more you dig, the easier it is to see why parent selectors are a problem for implementors and why we’re still asking for them.