1

I have the following HTML

<div class="class1">
    <div class="class2">
    <div class="class3 subclass1">
        Test
    </div>
</div>
</div>

and I need to add the CSS:

background-color: yellow;

to the div with class class1 that has a child div with class class3 subclass1. Cannot just add the CSS to the class1 as there could be more than one div with class of class1. Is that possible with just CSS?

TylerH
  • 19,065
  • 49
  • 65
  • 86
Coding Duchess
  • 5,487
  • 11
  • 75
  • 157

1 Answers1

0

There is no way to style of a parent using only CSS, you'll have to use JS.

https://snook.ca/archives/html_and_css/css-parent-selectors goes into a bit of detail on why this doesn't (and probably won't) exist.

nathan.medz
  • 1,417
  • 9
  • 19