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

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.

Thanks!

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!