Skip to main content
HTML Validation

Bad value “X” for attribute “Y” on element “Z”: Not a valid XML 1.0 name.

About This HTML Issue

Why This Matters

While HTML5 is quite permissive with id values (allowing almost anything except spaces), elements within XML-based vocabularies like SVG and MathML are held to stricter rules. When these elements appear in your HTML document, their attributes must still conform to XML 1.0 naming conventions as defined by the relevant specification.

XML 1.0 names must follow these rules:

  • Must start with a letter (az, AZ) or an underscore (_)
  • Subsequent characters can be letters, digits (09), hyphens (-), underscores (_), and periods (.)
  • Cannot contain spaces, colons (outside of namespaced contexts), or special characters like @, #, $, !, etc.

This error typically appears when design tools (such as Figma, Illustrator, or Sketch) export SVG files with auto-generated id values that include spaces or other invalid characters. Browsers may still render the content, but relying on non-conformant names can cause problems with CSS selectors, JavaScript’s getElementById(), URL fragment references, and accessibility tools that depend on valid identifiers.

How to Fix It

  1. Remove spaces — replace them with hyphens or underscores, or use camelCase.
  2. Ensure the name starts with a letter or underscore — if it starts with a digit, prefix it with a letter or underscore.
  3. Strip out special characters — remove or replace characters like @, #, (, ), etc.
  4. Review exported SVG files — if you’re embedding SVGs from design tools, clean up the generated id values before adding them to your HTML.

Examples

Invalid: Space in the id value

The space in "Group 270" makes this an invalid XML 1.0 name:

<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  <g id="Group 270">
    <circle cx="50" cy="50" r="40" />
  </g>
</svg>

Invalid: Name starts with a digit

XML 1.0 names cannot begin with a number:

<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  <rect id="1st-rectangle" width="100" height="50" />
</svg>

Invalid: Special characters in the name

Characters like ( and ) are not allowed:

<svg viewBox="0 0 200 100" xmlns="http://www.w3.org/2000/svg">
  <path id="icon(home)" d="M10 80 L50 10 L90 80 Z" />
</svg>

Fixed: Valid XML 1.0 names

Replace spaces with hyphens, prefix digit-leading names with a letter, and remove special characters:

<svg viewBox="0 0 200 100" xmlns="http://www.w3.org/2000/svg">
  <g id="group-270">
    <circle cx="50" cy="50" r="40" />
  </g>
  <rect id="first-rectangle" width="100" height="50" />
  <path id="icon-home" d="M10 80 L50 10 L90 80 Z" />
</svg>

Tip: Cleaning up exported SVGs

Design tools often produce id values like "Frame 42", "Vector (Stroke)", or "123_layer". A quick find-and-replace workflow can fix these before they land in your codebase. You can also use tools like SVGO to optimize and clean up SVG output, including stripping or renaming invalid identifiers.

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.