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?
Yes, this is perfectly valid in HTML5.
3.2.3.1 The
id
attributeThe
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With