Halfway Nowhere

A Question for the Coders

August 14
 

I’ve always been curious about the difference between “class” and “id” in HTML.

One of my coworkers tried to explain to me why it was important to use “id” when there would be only one instance of a given object on a page, but I don’t think I was really able to process the explanation.

My question was largely based around the fact that you have invalid HTML code if you use the same “id” multiple times on a given page, but there are no problems if you use only one “class” on the page … in practice, I end up using #element_name and .element_name as I’m pretty sure they should be used, but I still don’t really get why everything can’t just be a “class.”

Does the fact that a given element has an “id” make it more important? Does making everything a “class” break something?

Loading...