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.

Alternatives

Alternative ways to create graphics. These are not applicative to our objective but are listed here for completeness.

Test of Object Tag

SVG inserted via <object> tag. PNG used as backup.

Must include width and height in <object> tag to avoid scroll bars with Chrome.

SVG Button

Displayed as PNG.

  • 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.
  • IE 9: ?.

Test of Image Tag

SVG inserted via <img>.

Note: no interactivity: attribute onmousedown won't work, style hover won't work.

Alt: SVG Button.
  • Firefox 4.0: works... well that's what I read; this page crashes the current Minefield (does not work with earlier versions).
  • Chrome 6.0: works.
  • Opera 10.61: works.
  • IE 8: fails, no SVG support.
  • IE 9: ?.

Test of Inline SVG

SVG inserted directly (HTML5 or XHTML).

Note that XHTML requires xmlns attribute for SVG and XLINK.

SVG
  • Firefox 4.0: works for HTML and XHTML.
  • Chrome 6.0: fails for HTML (requires HTML5 parser), works for XHTML.
  • Opera 10.61: fails for HTML (requires HTML5 parser), works for XHTML.
  • IE 8: fails, no support for SVG.
  • IE 9: ?.