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

Lars picture Lars · Aug 27, 2013 · Viewed 49.5k times · Source

In about half of the svg examples I see on the internet, the code is wrapped in plain simple <svg></svg> tags.

In the other half, the svg tags have lots of complicated attributes like this:

<svg 
  xmlns="http://www.w3.org/2000/svg" 
  version="1.1" 
  xmlns:xlink="http://www.w3.org/1999/xlink"> 

My question is: is it ok to use the simple svg tags? I've tried playing around with the complicated ones, and everything works fine at my end if I don't include them.

Answer

ncomputers picture ncomputers · Dec 13, 2015

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