Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

George Anagnostopoulos
3,436 Pointscss selectors
difference between child selector and descendant selector
descendant selector example :
ul li {
color:blue;
}
child selector example :
ul > li { color:blue; }
applied on an html file, both have the same effect. What is that that differentiates them ?
5 Answers

James Barnett
39,199 PointsTo add to @Sam's already excellent answer ...
div li
div > ul

samiff
31,206 PointsThe first one is selecting all li elements in a ul, the second one is selecting any li element that is directly/immediately descended from a parent ul element only. Using the second rule, try wrapping one of the li elements in a span tag and see what happens.

George Anagnostopoulos
3,436 Pointsoh, i see. i get it now. thanks a lot , I appreciate it !

George Anagnostopoulos
3,436 PointsThank you @james ! The visual explanation helped out.

James Barnett
39,199 Points@George - Your very welcome, those visual aids are courtesy of selectutorial