Opening a SVG in a browser renders XML code instead of image Opening a SVG in a browser renders XML code instead of image xml xml

Opening a SVG in a browser renders XML code instead of image


As for your last question: How do browsers determine whether to show an image or XML code?

The answer lies in XML namespace. The XML namespace specified in an XML tag tells the user agent how to handle the tags. So if you have an <svg> without attribute xmlns="http://www.w3.org/2000/svg" then the browser will show text not the SVG rendered vector graphics.


You have to configure your server to send you svg files with Content-Type: image/svg+xml header. Here is an example on how to do this with Apache.