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

How to Choose ID and Class Names

By , About.com Guide

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

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

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

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

All rights reserved.