Web Design / HTML

  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.

Explore Web Design / HTML

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Web Design / HTML

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

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

All rights reserved.