0

I have a menu like:

<nav>
    <ul>
        <li><a href="index.php">Home</a></li>
        <li><a href="forum.php">Community</a>
            <ul>
                <li><a href="forum.php">Forum</a></li>
            </ul>
        </li>               
        <li><a>Account Management</a></li>
    </ul>
</nav>

I'm using the following to style the 'Community' link:

nav ul li:nth-child(2) a 

But that also styles the 'Forum' link which I don't want.

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Kryptix
  • 129
  • 1
  • 6

1 Answers1

2

You will need to add some child selectors, otherwise your selector will ignore nesting levels and always select any a elements that's nested within your second li:

nav > ul > li:nth-child(2) > a

See this other answer for an illustration of the child selector.

Community
  • 1
  • 1
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356