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
andxmlns: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>...</svg>);
-
The
xmlns:xlink
attribute is required for SVG files withxlink:
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