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

Why not use ".phone a " instead of "contact-info li.phone a" as selector in css ?

Add iconography video in how to create a website track....

3 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,863 Points

Hey there Smith and Ramon,

It could work here, but it could also cause problems if this logic was used in a different project. Ramon is correct is looking at the specificity of the selector. The way Nick does it, we know that it has to be a list inside .contact-info and that list item has the class of .phone and then its anchor tag.

Now, with just .phone a, we are just going to target an anchor inside of a class of .phone. All's good until you have your phone number somewhere else (on another page) that has the same class. Now both (even though you only wanted the one) would be styled with that rule. I would use the class .phone, anywhere I had a phone number. In my CSS, I would have a rule for just .phone, with specific styles.

So, you see, with just .phone a, I am not able to style just the one specific anchor without affecting all the other places I may have an anchor inside of a class with that name.

Specificity is a great tool, and while sometimes it seems like a lot of extra typing, it helps with readability, but most importantly, you won't style something you didn't mean to.

Keep Coding! :)

:dizzy:

Maybe it's not specific enough. Could you post what video are you talking about?

Hmmm, i think you're right. It should work with .phone a.