treehouse : what would you like to learn today?
Web Design Web Development iOS Development

ID’s Cannot Start With a Number

Published by Chris Coyier

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 code 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 */
}
View Comments

Comments

  1. I just spent 1 hour figuring why #1Col #content wasn’t working…
    Thanks for the tip!

  2. well is there any scientific reason behind this or its just a rull as you said “That is all.” please let me know if you have a link to this

    regards
    Surja

  3. Any idea if they can start with an underscore? validator.w3.org isn’t throwing any errors, but I’m still not 100% sure.

This comment thread is closed. If you have important information to share, you can always contact me.