Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page anchors fail Visual Studio 2010 HTML validation

Tags:

html

anchor

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".

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

like image 988
Andrey Avatar asked Feb 23 '23 21:02

Andrey


1 Answers

Page anchors should now be done with ID attributes.

This is something that has been 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.

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).

like image 163
Oded Avatar answered Mar 11 '23 00:03

Oded