Are SVG parameters such as 'xmlns' and 'version' needed? Are SVG parameters such as 'xmlns' and 'version' needed? xml xml

Are SVG parameters such as 'xmlns' and 'version' needed?


The xmlns="http://www.w3.org/2000/svg" attribute is:

  • Required for image/svg+xml files. 1
  • Optional for inlined <svg>. 2

The xmlns:xlink="http://www.w3.org/1999/xlink" attribute is:

  • Required for image/svg+xml files with xlink: attributes. 1
  • Optional for inlined <svg> with xlink: attributes. 2

The version="1.1" attribute is:

  • Recommended to comply with image/svg+xml files standards. 3
  • Apparently ignored by every user agent. 4
  • Removed in SVG 2. 5

1 Internationalized Resource Identifiers (RFC3987)
2 Since HTML5
3 Extensible Markup Language (XML) 1.0
4 Probably until the release of further major versions.
5 SVG 2, W3C Candidate Recommendation, 07 August 2018


All user agents (browsers) ignore the version attribute, so you can always drop that.

If you embed your SVG inline in a HTML page and serve that page as text/html then xmlns attributes are not required. Embedding SVG inline in HTML documents is a fairly recent innovation that came along as part of HTML5.

If however you serve your page as image/svg+xml or application/xhtml+xml or any other MIME type that causes the user agent to use an XML parser then the xmlns attributes are required. This was the only way to do things until recently so there is a lot of content served like this.


I'd like to add to both answers, but I have no points, I'm adding a new answer.In recent tests on Chrome (Version 63.0.3239.132 (Official Build) (64-bit Windows)), I have found that:

  1. For inline SVG that is directly entered into the HTML file, via text editor or javascript and elm.innerHTML, the xmlns attributes are not necessary, as stated in the other two answers.
  2. But for inline SVG that is loaded via javascript and AJAX, there are two options:
    • Use xhr.responseText and elm.innerHTML. This does not require the xmlns.
    • Use xhr.responseXML.documentElement and elm.appendChild() or elm.insertBefore(). This method of creating the inline SVG produces half-baked results without the basic SVG namespace being declared, as in xmlns="http://www.w3.org/2000/svg". The <svg> loads into the HTML, but document-level functions, such as getElementById() are not recognized on the <svg> element. I assume that this is because it uses the XMLHttpRequest XML parser outside of the HTML.