Welcome to the Treehouse Community
Looking to learn something new?
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,109 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.