On 17 Oct 2003 13:49:54 -0700, Michel wrote:
Basically, what is it that classes can do that IDs can't?
The formidable Brian already explained the essentials. I just wanted
to add that the question is not quite right... ids and classes are two
different things -- it's like asking "what can a color do that an
address can't?" (both of a house, for example).
Ids are unique (within a page) identifiers of elements. Classes are
groups of elements -- elements that have something in common.
It may happen that you look at a document and you see only one single
instance of a class. But maybe that class gets used multiple times in
other documents that use the same stylesheet, or there were multiple
instances and modifications removed all but one, or the designer
planned for the future and saw the possibility of later modifications
introducing multiple instances.
Or maybe the designer simply decided that in this case, the associated
style was not a feature of _one_ unique element, but something that
could be a feature of a class of elements -- no matter whether there
actually are multiple instances of that class in the document.