Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use an anchor ID starting with a number in HTML5?

Can I use an anchor ID starting with a number in HTML5?

<a id="1" class="anchor"></a>

I was told this was a NO NO. But it seems to work fine in IE9, Firefox and Chrome. So, what gives?

like image 970
user2063873 Avatar asked Aug 14 '13 04:08

user2063873


1 Answers

Yes, this is perfectly valid in HTML5.

3.2.3.1 The id attribute

The id attribute specifies its element's unique identifier (ID). [DOM]

The value must be unique amongst all the IDs in the element's home subtree and must contain at least one character. The value must not contain any space characters.

Note: There are no other restrictions on what form an ID can take; in particular, IDs can consist of just digits, start with a digit, start with an underscore, consist of just punctuation, etc.

http://www.w3.org/TR/html5/dom.html#the-id-attribute (emphasis added)

like image 189
Matt Ball Avatar answered Sep 16 '22 15:09

Matt Ball