1

is it possible in CSS or Stylus to apply style to an element if it has certain child class?

doing this for example:

.par > .chld
    background-color:red

Will color the child, but I need to color the parent

How can I do that?

iLemming
  • 34,477
  • 60
  • 195
  • 309
  • possible duplicate of [Is there a CSS parent selector?](http://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector) – showdev Dec 03 '14 at 00:31
  • As @alex mentions, there's no ascending CSS selector. Usually, if you find a need for this, you're going about something wrong. – marked-down Dec 03 '14 at 00:40

1 Answers1

3

You can't do that because CSS can't do that, unfortunately.

CSS has no ascending selectors (yet).

If you look at the CSS4 working draft, you can see a :has() selector has been proposed.

alex
  • 479,566
  • 201
  • 878
  • 984