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.

CSS How to Make a Website Adding Pages to a Website Build the Contact Page

Why does Nick use "class" for items which appear just once?

One says "use ID if you only ever use one of these elements, use class if there's more than one instance of it".

But I got confused over this stage in particular because Nick uses class for all these list items on the contact page (phone, email). Why is that? They just appear once on that very page...

Are there other reasons to use class over id?

1 Answer

Wayne Priestley
Wayne Priestley
19,567 Points

Hi Katsumi,

An ID has more specificity than a Class, so really you should use it rather than a class if its appropriate, but its mostly down to what you prefer.
Unless you think that you may need to use that specific styling elsewhere in you code in the future. If thats the case then using a class will result in less code being written.

Hope this helps.