Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
- :first-child and :last-child 4:15
- :first-child and :last-child Challenge 2 objectives
- :only-child and :empty 4:58
- Substring Matching Attribute Selectors - "Begins With" and "Ends With" 8:19
- Substring Matching Attribute Selectors - "Contains" 6:44
- Substring Matching Attribute Selectors Challenge 3 objectives
- Element States Pseudo-Classes 6:20
- Structural and Element States Pseudo-Classes Review 5 questions

- 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
Besides being able to target first and last child elements with pseudo-classes, the browser can also target only child elements and empty elements.
Quick Reference
Using :only-child and :empty
To target a span
that is the only child element in a parent div
, we can write:
div span:only-child {
font-size: .5em;
}
To target all elements that have no child content, we can write:
:empty {
background: red;
}
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
Stephen Drake
784 Points2 Answers
-
Yoko Iseki
Front End Web Development Techdegree Student 7,524 Points2 Answers
-
Eddie Harmon
17,094 Points1 Answer
-
Jake Almendarez
Front End Web Development Techdegree Student 4,250 Points2 Answers
-
Sam Weeks
Front End Web Development Techdegree Student 16,699 Points3 Answers
-
Adam Duffy
4,466 Points:only-child psuedo class not displaying properly in Chrome.
Posted by Adam DuffyAdam Duffy
4,466 Points2 Answers
-
James King
5,529 Points1 Answer
-
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,638 Points1 Answer
-
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,638 Points1 Answer
-
bobdeei
8,575 Points1 Answer
-
Luca Di Pinto
8,051 Points2 Answers
-
Ross Alejandro Bendal
8,993 Points2 Answers
-
Malcolm Stretten
3,814 Points7 Answers
-
Francis N
10,376 Pointsmany people are concerned that chrome doesnt support :only-child but in the video, Guil is using Chrome....
Posted by Francis NFrancis N
10,376 Points6 Answers
-
PLUS
Dennis Marquez
Courses Plus Student 2,791 Points3 Answers
-
Sean Flanagan
33,236 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