Max Design

Exciting, engaging websites

  • Home
  • About
  • News
  • Articles
  • Training
  • CSS

Naming id’s with numbers

April 10, 2008 by Russ Weakley

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.

http://www.w3.org/TR/html4/struct/global.html#adef-id

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 (“.”).

http://www.w3.org/TR/html4/types.html#type-name

CS – The value is case-sensitive (i.e., user agents interpret “a” and “A” differently).

http://www.w3.org/TR/html4/types.html#case-sensitive

Filed Under: Articles

Contact us

  • Facebook
  • GitHub
  • LinkedIn
  • Twitter
© 2016 Max Design

Copyright © 2021 · Parallax Pro Theme on Genesis Framework · WordPress · Log in