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

Lars Thorn
Lars Thorn
2,459 Points

Code challenge: Pseudo-Classes – :nth-child (Task 4)

Hello, on task number 4 I can't get through to the next stage.

The task says: "Finally, create a new rule that targets the last 3 list items only. Set the font size to 30px." http://teamtreehouse.com/library/pseudoclasses-nthchild

I have tried both:

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

and

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

But all I get is the following error: "Bummer! Check the selector in your CSS. Make sure you set font-size to 30px."

Thanks, Lars

4 Answers

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

Check your code, I just did this and it passed

Lars Thorn
Lars Thorn
2,459 Points

Ok, thanks Daniel. I retook the challenge and now it worked oddly enough.

Jacob Miranda
Jacob Miranda
19,392 Points

I don't believe you have to add last-child. Declaring the n as -n will reverse the order of the argument, making you start at the 3rd child from the bottom and go up.

branco design
branco design
5,120 Points
/* Write your CSS below */
li:nth-child(even) {
    color: white;
    background-color: black;
}

li:nth-child(3) {
    background-color: #FF6347;
}

li:nth-child(4n+1) 
{ font-weight: bold; }

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