# Bad value “” for the attribute “xmlns” (only “http://www.w3.org/2000/svg” permitted here).

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-for-the-attribute-xmlns-only-http-www-w3-org-2000-svg-permitted-here
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `xmlns` attribute declares the XML namespace for an element. For SVG elements, the only permitted namespace is `"http://www.w3.org/2000/svg"`. When this attribute is present but set to an empty string (`""`) or any value other than the correct namespace, the W3C validator reports an error because the browser cannot properly associate the element with the SVG specification.

In HTML5 documents (served as `text/html`), the `xmlns` attribute on `<svg>` is actually **optional**. The HTML parser automatically associates `<svg>` elements with the correct SVG namespace without needing an explicit declaration. However, if you do include the `xmlns` attribute — for example, because your SVG was exported from a design tool or copied from an XML-based source — it **must** contain the exact value `"http://www.w3.org/2000/svg"`. An empty or incorrect value will cause a validation error and could lead to rendering issues in certain contexts.

This matters for several reasons:

- **Standards compliance**: The HTML specification explicitly restricts the allowed value for `xmlns` on SVG elements.
- **Browser compatibility**: While most modern browsers are forgiving in HTML mode, an incorrect namespace can cause problems when SVG content is used in XML contexts (such as XHTML or standalone `.svg` files).
- **Interoperability**: Tools and libraries that process your HTML may rely on the correct namespace to identify and manipulate SVG elements.

To fix this issue, you have two options:

1. **Set the correct value**: Replace the empty or incorrect `xmlns` value with `"http://www.w3.org/2000/svg"`.
2. **Remove the attribute entirely**: Since `xmlns` is optional in HTML5, simply removing it is often the cleanest solution.

## Examples

### Incorrect: empty `xmlns` attribute

This triggers the validation error because the namespace value is an empty string:

```html
<svg xmlns="" width="100" height="100">
  <circle cx="50" cy="50" r="40" fill="red" />
</svg>
```

### Incorrect: wrong namespace value

Any value other than the correct SVG namespace will also trigger this error:

```html
<svg xmlns="http://www.w3.org/2000/html" width="100" height="100">
  <circle cx="50" cy="50" r="40" fill="red" />
</svg>
```

### Fix: use the correct namespace

Set `xmlns` to the only permitted value:

```html
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
  <circle cx="50" cy="50" r="40" fill="red" />
</svg>
```

### Fix: remove the `xmlns` attribute

In an HTML5 document, you can omit `xmlns` altogether since the parser handles the namespace automatically:

```html
<svg width="100" height="100">
  <circle cx="50" cy="50" r="40" fill="red" />
</svg>
```

### Note on inline SVG from external sources

Design tools like Figma, Illustrator, or Inkscape often export SVG files with the `xmlns` attribute already set correctly. If you're copying SVG markup and the `xmlns` value gets accidentally cleared or corrupted during the process, either restore it to `"http://www.w3.org/2000/svg"` or remove it before embedding the SVG in your HTML. Both approaches will produce valid, working markup.
