[thelist] CSS id or class?

David.Cantrell at Gunter.AF.mil David.Cantrell at Gunter.AF.mil
Thu Aug 1 09:51:01 CDT 2002


In the thread "I've found a great use for <span>", Simon Willison stated he
uses IDs on his elements for styling purposes.

My question is, when is it more appropriate to use ID vs class, and
vice-versa?

I would think ID is supposed to be unique in the document, though I may be
wrong here. I used to use IDs a lot more, but for the past couple years have
used class almost exclusively. I know ID comes into play with DHTML, so you
may want to make sections of your code (nav links, etc) available for future
scripting, but is there any other reason for choosing ID over class or the
other way around?

What scenarios call for either or both?

Thanks,
-dave



More information about the thelist mailing list