我可以使用以HTML5中的数字开头的锚ID吗? [英] Can I use an anchor ID starting with a number in HTML5?

查看:159
本文介绍了我可以使用以HTML5中的数字开头的锚ID吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用以HTML5中的数字开头的锚ID吗?

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

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

有人告诉我这不是NO。但它似乎在IE9,Firefox和Chrome中运行良好。那么,是什么给出了?

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

推荐答案

是的,这在HTML5中完全有效。

Yes, this is perfectly valid in HTML5.


3.2.3.1 id 属性



id 属性指定其元素的唯一标识符(ID) [DOM]

该值在所有 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.


注意:对于ID可以采取的形式没有其他限制;特别是, ID可以只包含数字,以数字开头,以下划线开头,仅包含标点符号等。

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 (重点补充)

这篇关于我可以使用以HTML5中的数字开头的锚ID吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆