Naming id’s with numbers
I was recently sent this question:
I am trying to apply a div to a page and it will not show when I use the name “420wide” but it will if I use “wide420″. Why is this? Is this rule documented somewhere?
The simple answer is that the ID name must be unique in a document and it must begin with a letter - not a number.
You can find out more in the W3C’s HTML specification relating to the id attribute:
id = name [CS]
This attribute assigns a name to an element. This name must be unique in a document.
There are two associated links with this info:
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens (”-”), underscores (”_”), colons (”:”), and periods (”.”).
CS - The value is case-sensitive (i.e., user agents interpret “a” and “A” differently).


April 10th, 2008
9:08 am
Permalink
It never ceases to amaze me how many people don’t know these fundamental rules (especially the fact that id’s must be unique per page) when they have always been clearly defined at w3c.
April 10th, 2008
9:12 am
Permalink
thank you for this Article
Great Point
April 10th, 2008
2:52 pm
Permalink
ok, new checklist item to add my development process. Thanks for this.
April 11th, 2008
4:42 am
Permalink
I already noticed that, but I haven’t consulted the reference to check it. And reading this made me remember that experience.
Thanks for remembering me of this.
April 11th, 2008
12:21 pm
Permalink
Well rb not everyone knows the rules like you, a lot of designers are learning as they go and you cannot expect them to know. But its good that you…
Thanks for the tip Russ, as I know myself I have made this mistake and im sure many others have as well….
April 11th, 2008
12:37 pm
Permalink
ABC of CSS!
Basics are more important than anything!
April 13th, 2008
11:00 am
Permalink
[…] Algo que deberías saber: Cuando trabajes con XHTML/CSS las id’s deben empezar con una letra (A-Z / a-z) y no un número. El segundo caracter si puede ser un número (un guión, un punto, etc.). En caso de que esta regla no sea respestada, no se reconocerá la id. […]
April 13th, 2008
7:58 pm
Permalink
Thanks for this “mise au point”