Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript using nth-child(1) on a anchor Re: using nth-child(1) on a anchor

#72876
Chris Coyier
Keymaster

I’ll bet you a nickel:

#home nav ul li:nth-child(1) a {
background-position:bottom;
}

The CSS infers a list. It’s the list items which have multiple siblings within the list. The anchors are within the list items, so :nth-child see’s all of them as the first child of list items (the “counters” reset when you move down a DOM level).