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 Selectors Advanced Selectors :nth-of-type

Learning coding
seal-mask
.a{fill-rule:evenodd;}techdegree
Learning coding
Front End Web Development Techdegree Student 9,937 Points

Why doesn't the 4child element get the #52bab3; background with white letters?

At 1.30 in the video the 4th child (a new heading) is targeted. Although the h1 isn't a div child, it's also a child of section. So it confuses a bit, why don't the background change to #52bab3; and the letters into white?

2 Answers

Steven Parker
Steven Parker
231,236 Points

Congratulations on resolving your own issue. :+1:

Yes, that's the difference between :nth-child and :nth-of-type.

Changjoon Song
seal-mask
.a{fill-rule:evenodd;}techdegree
Changjoon Song
Python Web Development Techdegree Student 8,092 Points

I have a similar question. Why didn't it target the h1 element when before switching over to "type". Does this mean, if h1 had been within <div>, it would be targeted?