How when I hover on the <li>
I can select my <a>
element ?
a ul:hover {
color: red;
}
<a href="#">Link</a>
<ul>
<li>Element 1</li>
<li>Element 2</li>
</ul>
For those browsers which support :has you can use:
<style>
a:has(+ ul li:hover) {
background: red;
}
</style>
<a href="#">Link</a>
<ul>
<li>Element 1</li>
<li>Element 2</li>
</ul>
However, check on caniuse.com that there is enough support for your use case - Edge/Chrome/Safari support it but Firefox requires a flag to be set.