Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,650 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.