# Attribute “xmlns:rdf” not allowed here.

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

The `xmlns:rdf` attribute declares the RDF namespace that SVG editors use for the metadata block in a drawing, and HTML doesn't allow prefixed namespace declarations on `<svg>` or any other element.

Inkscape SVG files, such as those saved by Inkscape 0.92, declare `xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"` on the root `<svg>` element, next to `xmlns:dc` and `xmlns:cc`. RDF (Resource Description Framework) is the W3C model for describing things as statements, and the `rdf:` namespace holds its core terms. Inkscape uses them to build the `<metadata>` block. `<rdf:RDF>` wraps the description, `rdf:about=""` says it is about this file, and `rdf:resource` gives a property a URI as its value, such as the Dublin Core type `StillImage`. The title and format are Dublin Core (`dc:`) terms, and the license is a Creative Commons (`cc:`) one. In a standalone `.svg` file, which is XML, all of this is valid.

Inline the file in an HTML page and the block stops being RDF. The HTML parser doesn't process namespace declarations, so `xmlns:rdf` is a plain attribute with a colon in its name, and the validator reports it on `<svg>`, on `<html>` and on any other element. The elements lose their namespace too. `<rdf:RDF>` becomes an SVG element named `rdf:rdf`, which the validator reports as a completely-unknown element, along with every element nested in it.

Delete `xmlns:rdf` together with the `<metadata>` block. Removing only the declaration leaves all those unknown-element errors in place. Nothing in the block is drawn, so the image doesn't change. The same export usually declares `xmlns:dc`, `xmlns:cc`, `xmlns:sodipodi` and `xmlns:inkscape` too. Each gets its own message, and they all go in the same cleanup.

If the page needs machine-readable facts about the image, such as who made it or what license it has, describe it in JSON-LD instead. A `<script type="application/ld+json">` block with a schema.org `ImageObject` can hold `creator` and `license`, and its `contentUrl` points at the image file, for example the original `.svg` with its metadata intact. Google's image metadata documentation asks for `contentUrl` plus at least one of `creator`, `creditText`, `copyrightNotice` or `license`.

On `<html>`, `xmlns:rdf` is a leftover from XHTML+RDFa 1.0, which declared prefixes with `xmlns:`. RDFa 1.1 uses the `prefix` attribute instead, and `rdf` is one of its predefined prefixes, so you can delete the declaration without adding anything in its place.

To keep the declaration out of inlined SVGs, run them through SVGO first. Its default preset includes `removeEditorsNSData`, whose list of editor namespaces contains RDF, and `removeMetadata`, which drops the `<metadata>` block.

## Invalid example

```html
<svg xmlns="http://www.w3.org/2000/svg"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  width="240" height="160" viewBox="0 0 240 160">
  <metadata>
    <rdf:RDF>
      <rdf:Description rdf:about="">
        <dc:title>Route map</dc:title>
        <dc:creator>Jane Doe</dc:creator>
        <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
      </rdf:Description>
    </rdf:RDF>
  </metadata>
  <path d="M20 140L120 20L220 140" fill="none" stroke="currentColor" stroke-width="4" />
</svg>
```

## Valid example

```html
<svg width="240" height="160" viewBox="0 0 240 160" role="img">
  <title>Route map</title>
  <path d="M20 140L120 20L220 140" fill="none" stroke="currentColor" stroke-width="4" />
</svg>

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "ImageObject",
  "contentUrl": "https://example.com/images/route-map.svg",
  "name": "Route map",
  "creator": { "@type": "Person", "name": "Jane Doe" },
  "license": "https://creativecommons.org/licenses/by/4.0/"
}
</script>
```
