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
Aaron Machado598 Points
Conventions for the use of classes vs id's
Hi, I'm wondering about the conventions for the use of classes vs id's. For example in this video a class is used for the unordered list "Contact-Info" nevertheless I don't see any other possible use of this class in our webpage other than specifically "contact-info". So if this style is going to be used just one time in one particular specific element shouldn't we use an id instead of a class?
Philip Cox14,818 Points
Avery Kachline10,458 Points
Kevin Korte28,148 Points
CSS specificity becomes another issues. A single ID will have more specificity than numerous classes. This can cause issues. Classes in general are more extendable as well. You may not ever see the need to use a class on another element, but as a freebee you could later. You can also be more modular with your classes, have multiple, reusable classes make up and element. I don't use IDs that much, unless I want to be 100% sure I target that one and only element. And example as mentioned might be with jQuery, or maybe a form selection.