在一个项目上工作,几乎完成了,只是整理了HTML,我发现你不是真的被允许有一个只是一个数字的ID,@H_301_2@
< a> attribute “id” has invalid value “567” The attribute ID is of type ID. As described above,it should begin with a letter and have no spaces
Good <a id="567" href="/index.html"> Good <a id="n567" href="/index.html">
我可以通过我的代码,并添加一个字母,然后剥离它,当该值用于我的jQuery,但它会搞乱我真的不需要.
有没有理由我不应该使用数字作为ID?
解决方法
这就是规范说的.
@H_301_2@
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 (“.”).
好消息是,HTML 5 specification更宽松:
@H_301_2@The id
attribute specifies its element’s unique identifier (ID). 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.