Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
The :nth-of-type pseudo-class targets an element based on its position within a parent, but only if it’s a specific type of element.
Quick Reference
Using :nth-of-type
This selector targets the 4th div inside the parent, no matter what type of child elements come before it:
div:nth-of-type(4) {
background: #52bab3;
color: white;
}
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
Kirt Perez
7,374 Points1 Answer
-
Nabil Nazeer
5,271 PointsHow would we use these selectors if we had anchor elements nested inside list element?
Posted by Nabil NazeerNabil Nazeer
5,271 Points1 Answer
-
Suzanne Roys
3,170 PointsUsing classes/IDs vs. nth of type/nth child selectors, etc
Posted by Suzanne RoysSuzanne Roys
3,170 Points2 Answers
-
Trent Christofferson
18,846 Points1 Answer
-
Learning coding
Front End Web Development Techdegree Student 9,937 Points2 Answers
-
Sardor Latipov
5,609 Points4 Answers
-
Nick Prodromou
12,824 Points2 Answers
-
Iulia Copaci
5,039 Points4 Answers
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up