Visual Studio doesn't like on-page anchor tags:
Validation (XHTML 1.0 Transitional): Attribute 'name' is considered outdated. A newer construct is recommended.
I'm using name
attributes in this way…
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd" xml:lang="en">
...
<body>
...
<p>On this page…</p>
<ul>
<li><a href="#one">Section One</a></li>
...
</ul>
...
<h2><a name="one">Section One</a></h2>
...
</body>
</html>
Is there really a more-modern way of doing this? Or is Visual Studio full of crap?
An anchor name is the value of either the name or id attribute when used in the context of anchors. Anchor names must observe the following rules: Uniqueness: Anchor names must be unique within a document. Anchor names that differ only in case may not appear in the same document.
The name attribute is used to create a named anchor. When using named anchors you can create links to a specific section on a page, instead of letting your viewer scroll around to find what he/she is looking for.
The <a> tag (anchor tag) in HTML is used to create a hyperlink on the webpage. This hyperlink is used to link the webpage to other web pages or some section of the same web page. It's either used to provide an absolute reference or a relative reference as its “href” value.
The <a> tag defines a hyperlink, which is used to link from one page to another. The most important attribute of the <a> element is the href attribute, which indicates the link's destination.
You should use the id
attribute instead. Works the same way, and you don't need an artifical <a name=...>
, but simply
<h2 id="one">Section One</h2>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With