The goal: use SVG wherever possible, falling back to a PNG (or SVG
plug-in) when necessary. In particular, IE prior to 9 should use a
PNG or SVG plug-in. IE9 (and Safari?) should use SVG except when
the SVG includes filters.
XHTML is supported by modern browsers but not by IE (before 9?). It
requires closing tags and use of name spaces. HTML5 is only supported
at the moment by Firefox 4 and IE9.
This is a work in progress.
Note: I don't have access to the IE9 previews.
SVG Support Issues
Support issues can be divided into two categories:
feature detection and fallbacks.
Feature Detection
hasFeature
The "modern" way to implement feature detection is to use the
"hasFeature" query, which can be done via JavaScript or inside a
<switch> SVG tag. It doesn't appear to be possible to use in
HTML or XHTML directly.
The "hasFeature" query has problems since the browsers don't agree
on the exact criteria for returning true. Firefox is very
strict and thus returns false for requiredFeatures =
"http://www.w3.org/TR/SVG11/feature#BasicFilter" even though it
has rather good filter support.
Modernizr (www.modernizr.com)
Does not include svg filter support detection out of box but can
be added. This however would be no better than "hasFeature"
since Firefox would still report that it lacks filter support.
<object> tag
The <object> tag is a form of feature detection since if
the <object> is not rendered, the content wrapped by the
tag is exposed. This content can be a PNG. It is not clear in
which cases this works. In particular, IE uses a non-standard set
of attributes, requiring an IE test(?). (Also IE6 doesn't handle
the fallback gracefully, adding extra junk.) It also appears
that many browsers will only use the first child tag for the
fallback.
Browser Tests
Not recommended for many reasons... but maybe necessary.
Fallbacks
Fallbacks can be divided into two types:
static images (e.g. PNG) or using SVG
plug-ins.
Static Images
PNG fallback from <object> tag.
SVG Plug-ins
Plug-ins face the same problem of feature detection.
Google Chrome Frame:
Add <meta http-equiv="X-UA-Compatible" content="chrome=1">.
Test by adding cf: (gcf:http://test.site.com).
SVG inserted via <object> tag.
PNG used as backup.
Must include width and height in <object> tag to avoid
scroll bars with Chrome.
Firefox 4.0: works (SVG shown).
Chrome 6.0: works (SVG shown). Background not transparent.
Opera 10.61: works (SVG shown).
IE 8: "works" (PNG shown, if not in compatibility mode;
Adobe SVG plug-in will not be used).
IE 9: ?.
Test of Embed Tag
SVG inserted via <embed> tag.
Content between start and end tag is only hidden in XHTML. An error
message will be displayed by Opera and Chrome if content not
displayed by tag.
Not valid HTML 4 or XHTML 1 or any previous
versions of the standards! But supported by most browsers. Will be
part of HTML5 (since everybody is supporting it anyway). Intended
for content that needs a plug-in.
Must include width and height in <embed> to allocate
correct space with Chrome.
Firefox 4.0: works (SVG shown).
Chrome 6.0: works (SVG shown). Background not transparent.
Opera 10.61: works (SVG shown).
IE 8: works only with plug-in (e.g. Adobe).
IE 9: ?.
Test of IFrame Tag
SVG inserted via <iframe> tag.
PNG used as backup(?).
Must include width and height in <iframe> tag to avoid
scroll bars.
<iframe>, dropped from HTML 4.0 Strict and XHTML 1.0 Strict
in favor of the <object> tag, has resurfaced in HTML5 as a
way of "sandboxing" content from external sources.
Firefox 4.0: works (SVG shown).
Chrome 6.0: works (SVG shown). Background not transparent.
Opera 10.61: works (SVG shown).
IE 8: works if Adobe SVG Viewer installed [will prompt to install] (SVG shown). Background not transparent.