Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS CSS Foundations Advanced Selectors Pseudo-Classes: :nth-child

Ariel Vainer
Ariel Vainer
7,042 Points

What is the correct sintax if I want to use the nth-child in two different lists?

Hi,

If I have 2 ul, how can I target them separately? I want them to have different values. How can I make the difference between both of them?

Thank you!!

Ariel Vainer
Ariel Vainer
7,042 Points

class or id before? li:nth-child Or there is a simpler way?

2 Answers

Hi Ariel,

Simply use a "class" for your two ul. Maybe use .listOne and .listTwo then you can target them separately.

Hope this helps.

Chris Shaw
Chris Shaw
26,676 Points

Hi Ariel,

If you want both lists to see the same CSS when using nth-child then a class is the best way to go about, just be sure the class comes after your initial CSS for your lists otherwise the styles won't overwrite anything your doing within nth-child.

Hope that helps.