I've got a nested unordered list in which I want to isolate some css rules so that they only apply to hyperlinked elements that are direct descendents of the parent UL element.
I don't want any of these rules to apply to anchors that are descendent elements.
For example, my markup is:
I only want the rules applied to the "Home", Contact Us, and "About Us" elements.HTML Code:<div class="menu nav"> <ul class="menu"> <li class="menu-item"><a href="#">Home</a></li> <li class="menu-item"><a href="contact-us">Contact Us</a></li> <li class="menu-item"><a href="about-us">About Us</a> <ul class="sub-menu"> <li class="menu-item"><a href="privacy-policy">Privacy Policy</a></li> <li class="menu-item"><a href="ftc-disclaimer">FTC “Disclaimer”</a></li> </ul> </li> </ul> </div>
Here's what I've tried, what am I missing?
.menu.nav ul.menu:first-child li a {//rules here}



Reply With Quote

With my method you also target the second level anchors. Force Flow's method should work.



Bookmarks