Skip to main content
HTML Validation

The “name” attribute on the “a” element is obsolete. Consider putting an “id” attribute on the nearest container instead.

About This HTML Issue

The name attribute on <a> elements is obsolete in HTML5 and should be replaced with the id attribute.

In older versions of HTML, the name attribute on anchor elements was used to create fragment identifiers — targets you could link to with #section-name in a URL. In HTML5, this approach has been deprecated in favor of the id attribute, which can be placed on any element, not just <a> tags.

Using id is more flexible because you can turn any element into a link target directly, without wrapping it in an anchor. The id attribute works the same way for fragment navigation: a link pointing to #section-name will scroll to the element with id="section-name".

HTML Examples

❌ Obsolete usage with name

<a name="about"></a>
<h2>About Us</h2>
<p>Welcome to our site.</p>

<a href="#about">Go to About</a>

✅ Fixed using id

<h2 id="about">About Us</h2>
<p>Welcome to our site.</p>

<a href="#about">Go to About</a>

The id attribute is placed directly on the <h2> heading, eliminating the need for an empty <a> tag entirely. The #about link works exactly the same way.

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?

Ready to validate your sites?
Start your free trial today.