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?
name attributes are deprecated in XHTML 1.0 - you can use an id attribute in the same way though, see Fragment Identifiers in the HTML Compatibility Guidelines of the XHTML spec.
So you can simply use
But note that the 1.0 spec recommends playing it safe with something like this:
However, your fragment uses XHTML 1.1, where the name attribute has been entirely removed from
a
andmap
elements - so you can only use an id.You can also link on a section header :
Table of Contents
Source: http://www.w3.org/TR/REC-html40/struct/links.html
You should use the
id
attribute instead. Works the same way, and you don't need an artifical<a name=...>
, but simply