0
<div class="header-wrapper">
    <div> 
        <nav>
           <ul>
               <li>
                 <a class="link" href="/">Link</a>
               </li>
           </ul>
        </nav>
    </div>
</div>

I want to change the background colour of the div with the class header-wrapper when hovering on the link. Can I do this with just css or scss?

a.link:hover {
.header-wrapper {
    background: red;
   }
}

And several more variations of this, parent selector in scss.

DumbDevGirl42069
  • 891
  • 5
  • 18
  • 47
  • nope, this is like parent-inception.- their question is "How do I select the
  • element that is a direct parent of the anchor element?" Also this question was asked 9 years ago - I'd prefer a cleaner solution - not using js if possible
  • – DumbDevGirl42069 Sep 16 '18 at 05:59
  • 1
    @Jessica: Perhaps that question should be revised to change "parent" to "ancestor" in general since most developers do incorrectly refer to distant ancestors as parents... in any case, it doesn't matter whether the element you want is a parent or a distant ancestor, there is no clean CSS solution for it. – BoltClock Sep 16 '18 at 06:11
  • Even so, the [answer](https://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector#answer-1014958) was updated this year. – msg Sep 16 '18 at 06:30