Reputation: 4431
I have a graphics.svg
file having following code:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="400" height="110">
<rect width="400" height="110" style="fill:rgb(0,0,255);" />
</svg>
If I open that file from web-browser(Firefox, Chromium), the vector image is not displayed. Instead, the file is displayed in XML format:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<svg width="400" height="110">
<rect width="400" height="110" style="fill:rgb(0,0,255);"/>
</svg>
Is this because the svg file should be embedded in html file to be displayed properly?
Upvotes: 18
Views: 44362
Reputation: 124229
You are missing the namespace declaration.
You need to add xmlns="http://www.w3.org/2000/svg"
as an attribute of the root <svg>
element and while you're there you might as well add xmlns:xlink="http://www.w3.org/1999/xlink"
too.
There are some more complete authoring guidelines here which you might want to peruse.
Upvotes: 7
Reputation: 944321
No, it is because you have failed to specify the namespace for the svg
element with
xmlns="http://www.w3.org/2000/svg"
Upvotes: 25