Kirsty Marks
Kirsty Marks

Reputation: 483

Removing Border with Last and Nth child Not Working

www.pureelysium.com/Pure/index.html

Hi there

i tried removing the last both by using both the n-th child and the last-child like so

nav ul li a.last-child {border-right: none;}

I also tried

nav ul li:nth-child(n+3) {
border: 0;
}

Im stumped! Can anyone advise why this wouldnt work?

Upvotes: 0

Views: 1593

Answers (1)

MarcinJuraszek
MarcinJuraszek

Reputation: 125630

Your last-child syntax is incorrect. Should be:

nav ul li a:last-child {border-right: none;}

However, it won't work in your case. You have to use that one:

nav ul li:last-child a {border-right: none;}

last-child, nth-child and similar works always in context of parent, so nav ul li a:last-child looks for <a> that is the last child of it's parent: <li> in your case. But you'd like to select <a> within the last <li>. That's why you have to put :list-child after li, not the a.

Upvotes: 3

Related Questions