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 Going Further with Attribute Selectors and Pseudo-Classes :only-child and :empty

Stephen Drake
Stephen Drake
784 Points

:only child confused

I don't understand why it didn't add font size and color when we targeted <span> element which was the only child of ul. I only added a checkmark

2 Answers

Steven Parker
Steven Parker
231,236 Points

If you're following the video, the <span> is not a child of the <ul>, but it is the only child of the <li>. So the CSS rule should apply to it. If you accidentally made the <span> a child of the <ul>, it would then be a sibling of all the <li>'s, and so the rule would not apply to it. But that's also not proper HTML syntax, since a <ul> should only have <li>'s as direct children.

If you're having a different experience, take a look at this video about making a snapshot of your workspace and sharing the link to it so we can check it out.