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

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 90,845 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.