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

Structural Pseudo-classes in Advanced Selectors

Help needed for task 4 of quiz please "Create a new rule that selects the last 3 list items only. Set the font size to 30px."

My code

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

I would be grateful for any help. Started these tutorials yesterday and have loved them

Cheers Stumped

7 Answers

Guil Hernandez
STAFF
Guil Hernandez
Treehouse Teacher

@Dave - li:nth-last-child(-n+3) is correct. However, the font size value should be font-size: 30px –– you had font: 30px.

li:nth-child(n+5) also works, but if more list items are added, it changes things. That's why using li:nth-last-child is more efficient.

Check this out for a cool visual http://www.nealgrosskopf.com/tech/resources/80/

Experiment with different combinations and it shows you what is selected.

James Barnett
James Barnett
39,199 Points

This is the coolest tool I've seen for nth-child, it's like a visual nth-child calculator.

mind blown

James Barnett
James Barnett
39,199 Points

A great tool to double check your selector is SelectORacle it will explain in plain english what a selector is doing.

cheers Robert that worked onwards and upwards

Yay teamwork! :D

Robert Cate
Robert Cate
7,911 Points

No problem. I literally just finished that quiz before your post.

Robert Cate
Robert Cate
7,911 Points

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