ID’s Cannot Start With a Number

Avatar of Chris Coyier
Chris Coyier on (Updated on )

Tempted to use something like “1800number_box” for a ID? Don’t. Because it won’t work. Class identifiers are allowed to start with a number, but ID identifiers are not.

That is all.

BUT

If you have already existing HTML using it that way that you absolutely can’t change, you can access it with:

[id='1800number_box'] {
 /* does work */
}

#1800number_box {
  /* doesn't work */
}

/* Or, you can "escape" the number, which looks funky but works: */
#\31 800number_box {
  /* does work */
}
/* See: http://mothereff.in/css-escapes */