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

Nico Bee
Nico Bee
814 Points

Missing something?

The instructions say, "Finally, create a new rule that targets the last 3 list items only. Set the font size to 30px."

My code:

li:nth-child(n+5) { font-size:30px; }

The hint says, "Check the selector in your CSS. Make sure you set font-size to 30px."

Am I missing something here?

I think you can use nth-last-child() to start your selector from the bottom up. Try li:nth-last-child(3)

4 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

It's got to be in your expression somewhere. I'm not clear on nth-child expressions yet but it looks like you're targetting the last 5 rather than the 3? What does the preview show you?

may be try this one: :nth-last-child()

sorry solw internet connection, didnt see jareds comment

Nico Bee
Nico Bee
814 Points

Hey, guys! I was stuck in a quiz for just the :nth-child section and hadn't gotten to :nth-last-child section yet so I don't think it would let me use that pesudo selector, although in the future I will. I think it may have been a glitch because I started a new page and copied and pasted the exact same code and it worked. I had walked away from it but all of your responses motivated me to try again sooner than I would've. Thanks for keeping me on my game :)

Try li:nth-last-child(-n+3) : counting from the bottom upward. If n = -3 -3+3=0 (The last Row) n=-2 -2+3=1 (second to last row), etc... nth-last-child is best in my option because if your list ever grows you can continue to select the last 3.