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 How to Make a Website Adding Pages to a Website Add Iconography

Mike Zhu
Mike Zhu
1,840 Points

Questions about "class"

In this video, I have to add some style on the class "phone", which is under the parent class "contact-info". Therefore, we write like this: ".contactInfo li.phone". However, my question is, can we just write ".phone" instead of "contactInfo li.phone"

Hugo Paz
Hugo Paz
15,622 Points

You can. But since you are using a class, you might also use it somewhere else. So if you just use .phone, the rules will be applied to all elements with that class.

By using .contactInfo li.phone, you limit the rules to that specific element.

1 Answer

Jordan Jesse
Jordan Jesse
13,243 Points

Hi Mike,

If you have multiple items with the .phone class and you only want to style one that is a child of .contact-info, then you would need to target it as follows: .contact-info .phone. However, if you only have a single .phone class then you should be able to simply target .phone. Hope that helps.