页面锚定失败Visual Studio 2010 HTML验证

时间:2022-12-25 02:46:48

I have a few <a name="something"></a> entries in my html page to enable page anchors; Visual Studio 2010 (with either HTML 4.01 or HTML 5 target) underlines name attribute and shows warning "Element 'name' is obsolete or nonstandard".

在我的html页面中,我有一些条目来启用页面锚点;Visual Studio 2010(以HTML 4.01或HTML 5为目标)强调name属性并显示警告“元素'name'已过时或不标准”。

Am I doing anything wrong? Is in-page anchoring deprecated?

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

1 个解决方案

#1


8  

Page anchors should now be done with ID attributes.

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

This is something that has been obsoleted in the draft for HTML 5:

这在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属性。如果存在的属性,它的值不能为空字符串,必须既不等于任何ID的元素的值的子树以外的其他元素的ID,如果任何,也不等于价值的任何其他名称属性的元素在元素的子树。如果存在此属性且元素有ID,则属性的值必须等于元素的ID。应该使用id属性。

The name attribute is actually valid HTML 4.01, so I am not sure what Visual Studio is doing there (possibly not applying the correct validation).

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

#1


8  

Page anchors should now be done with ID attributes.

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

This is something that has been obsoleted in the draft for HTML 5:

这在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属性。如果存在的属性,它的值不能为空字符串,必须既不等于任何ID的元素的值的子树以外的其他元素的ID,如果任何,也不等于价值的任何其他名称属性的元素在元素的子树。如果存在此属性且元素有ID,则属性的值必须等于元素的ID。应该使用id属性。

The name attribute is actually valid HTML 4.01, so I am not sure what Visual Studio is doing there (possibly not applying the correct validation).

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