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 trialKevin Chin
869 PointsWhy don't I need to specify the unordered list after the class e.g. .contact-info ul{ in first step of this challenge?
If I add the ul after the class it is wrong and only accepts .contact-info. {
4 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi Clinton,
The challenge instructions state "Select the unordered list with the class contact-info..." So the ul
is with the class "contact-info". They're together.
That's describing html that looks like this:
<ul class="contact-info">
</ul>
You could select that ul
with the class name by itself, .contact-info
, or you could type qualify the selector and put ul in front like this, ul.contact-info
That means, "select a ul with a class of contact-info"
The selector that you tried, .contact-info ul
is a descendant selector. That's saying, "select a ul that is within another element that has a class of contact-info"
The html for that might look like this:
<div class="contact-info">
<ul>
</ul>
</div>
Here you can see that the ul has an ancestor with a class of "contact-info"
Devin Scheu
66,191 Pointsbecause the class is the ul, so if you use the class and the ul your pretty much saying ul ul, which is redundant.
Shawn Williams
Courses Plus Student 4,462 PointsThe only reason you would use
.contact-info ul {}
is if the contact-info class was actually being applied to a parent element. As Devin stated, since the class is applied to the actual ul element, then it is redundant to call both the class and the element in the selector.
Kevin Chin
869 PointsThanks Jason, Devin and Shawn for the very speedy and clear explanations. It really clarifies it for me and now makes complete sense why you wouldn't use ul. thanks again :-)