0

I want to set a background to parent element if it has an item with 'open' class item with css. Main goal is add a background color the parent element.

For example:

<div class='parent'>
    <span class='title'>title</span>
    <span class='arrow open'>I should have a blue background!</span>
</div>
anil
  • 31
  • 6
  • 1
    A parents style can't be based on its children in CSS (excluding a few very specific situations, but they aren't relevant here) – DBS May 09 '22 at 14:00
  • 1
    The easiest way would be to add the `open` class to the parent so you just have you use `.parent.open{}`. Also, you can check [this answer](https://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector) – Cédric May 09 '22 at 14:01

0 Answers0