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

What's the difference between assigning an "id" versus a "class"?

They seem to both be types of alt tags.

2 Answers

Sam Gord
Sam Gord
14,084 Points

adding to what Dave said above, i have to say that there are priorities in styling elements with id or class. id has higher priority than class, means that if u style an element using its id, it will be override the style u give that element using its class .

This was very helpful. Thank you!

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

The key difference is that an id is unique (can be assigned to only one element) on the page, while many elements can be assigned the same class.

Also, elements can only have 1 id, while they can have many classes.

Thank you!