html - 页面 anchor 未通过 Visual Studio 2010 HTML 验证

标签 html anchor

我有几个<a name="something"></a>我的 html 页面中的条目以启用页面 anchor ; Visual Studio 2010(带有 HTML 4.01 或 HTML 5 目标)下划线 name属性并显示警告“元素‘名称’已过时或非标准”。

我做错了什么吗?页内锚定是否已弃用?

最佳答案

页面 anchor 现在应该使用 ID 属性完成。

这是已经obsoleted in the draft for HTML 5的东西:

Authors should not specify the name attribute on a elements. If the attribute is present, its value must not be the empty string and must neither be equal to the value of any of the IDs in the element's home subtree other than the element's own ID, if any, nor be equal to the value of any of the other name attributes on a elements in the element's home subtree. If this attribute is present and the element has an ID, then the attribute's value must be equal to the element's ID. In earlier versions of the language, this attribute was intended as a way to specify possible targets for fragment identifiers in URLs. The id attribute should be used instead.

name 属性实际上是有效的 HTML 4.01,所以我不确定 Visual Studio 在那里做了什么(可能没有应用正确的验证)。

关于html - 页面 anchor 未通过 Visual Studio 2010 HTML 验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7533856/

相关文章:

javascript - 如果 div 为空则移除类

python - BeautifulSoup: 'lxml' 和 'html.parser' 以及 'html5lib' 解析器有什么区别?

javascript - 如何获取转到另一个页面上的特定 div 的链接

html - 是否允许 figcaption 成为 HTML5 中 <a> 标签的子标签?

Javascript - 出于设计原因添加 anchor

jquery - 如何阻止 anchor 链接跳转到页面的另一个区域

javascript - 动画摇摆不定与 jquery

javascript - 元素转换时不会触发 Mouseleave 事件

php - 如何从选择框中选择多个选项

javascript - 如何使用 javascript 将 rel ="nofollow"添加到与我的域无关的所有外部链接?