问题
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?
回答1:
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)
来源:https://stackoverflow.com/questions/18222991/can-i-use-an-anchor-id-starting-with-a-number-in-html5