1. Home
  2. Computing & Technology
  3. Web Design / HTML

How to Choose ID and Class Names

By Jennifer Kyrnin, About.com

CSS does not allow class and id names to start with a number or other non-alphabetical character. The only exception to this is if you use an escape character - which many browsers don't support.

You should always start your class and id names with a alphabetic character (not a number or a non-alpha character).

Also, keep in mind that while XHTML is case-sensitive, you cannot have two ids in the same document that are different only in case. For example:

#TextColor { color : #000; }
#textcolor { color : #f00; }

Would not be valid in the same document.

More Web Design / HTML Quick Tips

Explore Web Design / HTML

More from About.com

  1. Home
  2. Computing & Technology
  3. Web Design / HTML

©2008 About.com, a part of The New York Times Company.

All rights reserved.