# Attribute “xmlns:X” not allowed here.

> Canonical HTML version: https://rocketvalidator.com/html-validation/attribute-xmlns-x-not-allowed-here
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

An attribute like `xmlns:news` or `xmlns:x` declares an XML namespace prefix, and HTML doesn't accept prefixed namespace declarations, except `xmlns:xlink` on SVG and MathML elements.

In XML, `xmlns:news="http://example.com/modules/news"` binds the prefix `news` to a namespace URI, so names like `news:item` can appear in the document. The HTML parser doesn't process namespace declarations. It keeps the declaration as a plain attribute with a colon in its name, and it lowercases that name, so `xmlns:Foo` in the source shows up as `xmlns:foo` in the message. The validator reports it the same way whatever the prefix is and whichever element carries it, `<html>` included. On HTML elements the only namespace attribute allowed is `xmlns`, with the exact value `http://www.w3.org/1999/xhtml`. Inline `<svg>` and `<math>` also accept `xmlns:xlink="http://www.w3.org/1999/xlink"`, and no other prefix.

Pages built with XSLT, as many CMS modules are, often carry these declarations on a `<div>` or on `<html>`. When an XSLT stylesheet writes out a literal element, it copies the namespace declarations in scope onto that element, except for the XSLT namespace itself and any prefix listed in `exclude-result-prefixes`. If you can edit the stylesheet, add the prefix to that list:

```xml
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:news="http://example.com/modules/news"
  exclude-result-prefixes="news">
```

Inline SVG pasted from Adobe Illustrator brings its own set: `xmlns:x`, `xmlns:i` and `xmlns:graph` on the root `<svg>`, pointing to Adobe's Extensibility, Illustrator and Graphs namespaces, and in older files `xmlns:a` for the Adobe SVG Viewer plugin. In the original `.svg` file the values are often entity references like `&ns_ai;`, defined in the file's DOCTYPE, so they don't resolve to anything once the markup sits inside an HTML page. Delete the declarations along with any attributes that use those prefixes, such as `i:extraneous="self"` on a `<g>`, which the validator reports as a separate error. If a build step inlines your SVGs, SVGO's `removeEditorsNSData` plugin, part of its default preset, removes Adobe's namespaces and the attributes that use them.

Browsers ignore these declarations in HTML, so removing them doesn't change how the page looks or works.

## Invalid example

```html
<div class="news-list" xmlns:news="http://example.com/modules/news">
  <p>Latest news</p>
</div>

<svg xmlns="http://www.w3.org/2000/svg"
  xmlns:x="http://ns.adobe.com/Extensibility/1.0/"
  xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/"
  xmlns:graph="http://ns.adobe.com/Graphs/1.0/"
  width="24" height="24" viewBox="0 0 24 24">
  <path d="M5 12l5 5L20 7" fill="none" stroke="currentColor" stroke-width="2" />
</svg>
```

## Valid example

```html
<div class="news-list">
  <p>Latest news</p>
</div>

<svg xmlns="http://www.w3.org/2000/svg"
  width="24" height="24" viewBox="0 0 24 24">
  <path d="M5 12l5 5L20 7" fill="none" stroke="currentColor" stroke-width="2" />
</svg>
```
