When should I use a class and When should I use an ID?

Posted on

From css-discuss.incutio.com

This is a common question on css-discuss and other lists. The key thing to know is that IDs identify a specific element and therefore must be unique on the page – you can only use a specific ID once per document. Many browsers do not enforce this rule but it is a basic rule of > HTML > / > XHTML > and should be observed. Classes mark elements as members of a group and can be used multiple times, so if you want to define a style which will be applied to multiple elements you should use a class instead.