The Official XML Namespace URI for SVG
This article identifies the official XML namespace Uniform Resource Identifier (URI) required for standard Scalable Vector Graphics (SVG) documents. It explains what the URI is, why it is essential for rendering standalone graphic files, and how to implement it correctly within your code.
The Standard SVG Namespace URI
The official XML namespace URI for standard SVG documents defined by the World Wide Web Consortium (W3C) is:
http://www.w3.org/2000/svg
Even though modern web protocols prioritize HTTPS, the namespace
string itself is a fixed identifier and must use the exact
http:// prefix rather than https://.
How to Declare the Namespace
To declare the namespace in an SVG document, attach the
xmlns attribute to the root <svg>
element.
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">
<circle cx="50" cy="50" r="40" fill="blue" />
</svg>When the Namespace Is Required
The necessity of the SVG namespace depends on the context in which the graphic is served:
- Standalone SVG Files (
.svg): Mandatory. Image viewers, vector editors, and browsers using XML parsers rely onxmlns="http://www.w3.org/2000/svg"to recognize elements like<path>,<circle>, or<rect>as graphical nodes rather than generic XML tags. - XHTML Documents: Mandatory. Because XHTML enforces strict XML parsing rules, any embedded SVG elements must include the namespace attribute or inherit it from a parent wrapper.
- Inline HTML5: Optional. The HTML5 parser
automatically binds
<svg>elements to the SVG namespace without requiring an explicitxmlnsattribute. However, including it is considered best practice to maintain portability across formats.
Common Related Namespaces
When working with advanced or legacy SVG features, you may encounter secondary namespaces alongside the primary SVG URI:
- XLink Namespace (Legacy links and references):
xmlns:xlink="http://www.w3.org/1999/xlink"(largely superseded by standardhrefattributes in SVG 2). - HTML Integration:
xmlns:xhtml="http://www.w3.org/1999/xhtml"(used inside<foreignObject>elements to embed HTML content).