SVG: When to use xmlns and version attributes

The xmlns attribute is required for SVG files but optional for inlined SVGs. The version attribute is always optional.

Table of contents

The xmlns attribute

  • The xmlns and xmlns:xlink attributes are optional for inlined SVGs in HTML.

  • The xmlns attribute is required for SVG files and SVGs in CSS, e.g.:

    background-image: url(
    'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg">...</svg>'
    );
  • The xmlns:xlink attribute is required for SVG files with xlink: attributes. Similarly for SVGs in CSS.

The version attribute

The version attribute is ignored and thus always optional. Plus it's deprecated since SVG 2.

Source

Are SVG parameters such as 'xmlns' and 'version' needed? on Stack Overflow