javascript - 实际上是否有官方的 w3c 声明声明用户代理实际上必须返回 uppcase 元素的标签名称?

标签 javascript html

我觉得奇怪的是,当我们执行 element.tagName 时,所有浏览器(Chrome/FF/IE/Safari/Opera)始终以大写形式返回标签​​名称。

是否真的有官方的 w3c 声明声明用户代理实际上必须以大写形式返回标签​​名称?

最佳答案

您正在寻找 DOM Level-2 :

tagName of type DOMString, readonly
The name of the element.
[...]
Note that this is case-preserving in XML, as are all of the operations of the DOM. The HTML DOM returns the tagName of an HTML element in the canonical uppercase form, regardless of the case in the source HTML document.

因此 e.tagName 对于 HTML 应该总是是大写的,但是对于 XML 来说大小写会与源文档相匹配。

关于javascript - 实际上是否有官方的 w3c 声明声明用户代理实际上必须返回 uppcase 元素的标签名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6894561/

相关文章:

javascript - Twitter Bootstrap 导航下拉菜单未扩展到 div 之外

javascript - Angular Material 按钮高度

javascript - 在两个功能之间进行选择的建议

html - 在单独的行上获取 div 中的链接

javascript - 使用js和html5 canvas元素的径向图表

Javascript 使语句动态化

javascript - 无法打开 jQueryUI 对话框

html - 在 JSP 页面中呈现未转义的 HTML

javascript - 如何检测单个字母并修改它们的外观/CSS

php - 如何修复我的脚本 : UPDATE user pass (php mysql) (no errors but something not working)