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.

Design HTML Email Design Coding HTML Email Building Common Design Patterns

When do you use class and when do you use ID when defining the table, tr, and td?

Sometimes for his td's he uses class and other times he uses id's. Is there any particular reason? I know that in CSS the IDs are usually for one-time elements where as classes are for repeaters... I'm just confused as to why he switches in here when they all seem to be one-time elements.


Perhaps he is using classes because there is some future use for it? There is no difference really. For one time elements, you can still use classes. The world won't burn.

1 Answer

IDs are unique which means that an element can only have one ID and each page can only have one element with that ID. Classes, on the other hand, can be used for multiple elements and you can use multiple classes on the same element.

Hope this helps!