It looks like ids and classes are the exact same thing and have the same functionality
Look again.
id
specifically identifies an element. Each element can have no more than one id
and each id
must be unique throughout the DOM.
class
describes an element in a more generic way, associating it logically with other elements of the same class
. An element can have many classes, and the same class can be used many times throughout the DOM.
ids are used just to show the coder/designer that they are only changing one item in those other similar items... Is that true?
No, that's not true at all. id
s uniquely identify (hence "id") elements. They can be used by a developer or a designer to target a specific element for some purpose (altering it, styling it, observing it, and so on).
The fact that the person is selecting an id
does guarantee that they are targeting only one element (assuming that element exists, otherwise zero elements) as long as the document is well-formed (doesn't break the rule of not re-using id
values, in which case the code is incorrect and behavior is undefined).
Conversely, when selecting based on a class
value, any number of elements may be selected. So any developer and/or designer (or any other role) would bear that in mind and not assume that there's only one element.