Skip to main content
HTML Validation

The “name” attribute is never allowed on the “a” element.

About This HTML Issue

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

Older versions of HTML used <a name="section1"> to create anchor targets within a page. HTML5 dropped this approach. The id attribute on any element now serves the same purpose, and it works on <a> tags as well as <div>, <section>, <h2>, or any other element. Fragment links like href="#section1" will scroll to whatever element has id="section1", regardless of element type.

The name attribute is still valid on elements like <input>, <form>, <meta>, and <map>, where it has a distinct function. On <a>, though, it has no valid use in modern HTML.

Invalid example

<a name="about">About us</a>

<p>Read more in our <a href="#about">about section</a>.</p>

Valid example

<h2 id="about">About us</h2>

<p>Read more in our <a href="#about">about section</a>.</p>

If the anchor wraps content that has no better semantic element, a <span> or <div> with an id works fine:

<span id="about">About us</span>

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?
🌍 Trusted by teams worldwide

Validate at scale.
Ship accessible websites, faster.

Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.

Scheduled Reports
API Access
Open Source Standards
$7 / 7 days

Pro Trial

Full Pro access. Cancel anytime.

Start Pro Trial →

Join teams across 40+ countries