I have several SVG images I\'d like to layout on a page. Firefox and Chrome have given me no issues whatsoever, but Safari only seem to display the SVG image if and only if
The reason .xhtml
works in Safari and .html
doesn't is that Safari needs to treat the document as XML to allow embedded SVG. The latest versions of Firefox and Chrome use a HTML5 parser which allows SVG to be embedded in plain HTML documents, so they should work with both.
To have it render properly in Safari you need to set the content type to application/xhtml+xml
. Use this in your PHP file before you output any content:
<?php
header('Content-type: application/xhtml+xml');
?>
you can set your php config to process xhtml files.
In this example I'm assuming you're using apache on debian/ubuntu
you can look in the file /etc/apache2/mods-enabled/php5.conf
<IfModule mod_php5.c>
<FilesMatch "\.xhtml$">
SetHandler application/x-httpd-php
</FilesMatch>
</IfModule>
You may have this SetHandler directive in some other file if you're using a different webserver or distro or OS...
assuming you're on a unix box, just grep the /etc/apache or /etc/httpd directories
grep -Ri sethandler /etc/apache