How can I select the link elements of only the parent <ul> from a list like this?
<ul>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a>
<ul>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>
</li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
So in css ul li a, but not ul li ul li a
Thanks
But you would need to set a class on the root ul if you specifically want to target the outermost ul:
Then it’s:
Another way of making sure you only have the root li elements:
It looks kludgy, but it should do the trick