Skip to main content
HTML Validation

Bad value “” for attribute “name” on element “a”: An ID must not be the empty string.

About This HTML Issue

Empty name attributes on <a> are invalid; an anchor’s name/id must be a non-empty unique identifier.

Historically, the name attribute on <a> was used to create fragment targets (e.g., <a name="top"></a>). In HTML5/living standard, fragment navigation should use the id attribute instead. The name attribute on <a> is obsolete for this purpose, and an empty string is never allowed for identifiers.

Use id with a non-empty value to create link targets, and point to them with href="#idValue". If you keep name for legacy reasons, it must still be non-empty and match the HTML syntax for valid IDs. Avoid adding empty attributes like name="" or id="". Also ensure uniqueness of each id in the document.

HTML Examples

Example causing the validator error

<!doctype html>
<html lang="en">
  <head>
    <title>Anchor name error</title>
  </head>
  <body>
    <a name=""></a>
    <a href="#"></a>
  </body>
</html>

Corrected example using id (recommended)

<!doctype html>
<html lang="en">
  <head>
    <title>Anchor id fix</title>
  </head>
  <body>
    <a id="top"></a>
    <a href="#top">Back to top</a>
  </body>
</html>

Last reviewed: August 18, 2025

Was this guide helpful?

Find issues like this automatically

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

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