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

Xavier Avery
Xavier Avery
8,059 Points

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

Create a new rule that targets the 3rd list item only. Set the background color to the HEX value FF6347.

i put li:nth-child(3){background: FF6347}

whats wrong????

Xavier Avery
Xavier Avery
8,059 Points

oh i had to put a # sign before the FF6347 like so #FF6347

Xavier Avery
Xavier Avery
8,059 Points

well I'm trying to get past task 3 now and can't...any help

1 Answer

Jacob Miranda
Jacob Miranda
19,392 Points

Here's what I did. Please don't just copy and paste, try to understand the argument. -n tells the browser to start from the bottom of the list and +4 will tell it to start from the fourth child from the bottom. You just have to think about which direction you're going, where you want to start, and which ones you want to select.

The argument should be in the form of (an+b), where a is the starting child(number) and b is the pattern. So +2 would be every other child and +3 would be every third child.

ul li:nth-child(-n+4) {
font-weight: bold;
}
Xavier Avery
Xavier Avery
8,059 Points

u know what i wasn't reading the question right...i was thinking item four only but thanks and i understand it...