Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

http

xml

apache

svg

Several times I have opened SVG files located on various sites through a browser, and they were displayed as images.
Now, I copy this same SVG, I upload it to a remote host, and both Google Chrome and Firefox render XML code.
How do browsers determine whether to show an image or XML code?

like image 398
sabof Avatar asked Feb 16 '12 23:02

sabof


1 Answers

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.

like image 85
oabarca Avatar answered Sep 21 '22 16:09

oabarca