25

How do I know if my browser supports SVG 2.0?

(Apart from trying a feature that is supposed to work in SVG2 and realizing it's not working or that it works ...?)

user18490
  • 3,261
  • 4
  • 30
  • 51
  • 6
    Check your calendar. When it says 2018, your browser may support SVG 2. – Michael Mullany Sep 29 '14 at 06:21
  • 4
    2018-01-01 now, but.. it turns out that [SVG 2 is on life support](http://tavmjong.free.fr/svg2_status.html). – Yeti Jan 01 '18 at 10:18
  • 2
    Or perhaps "[after a near death experience, SVG 2 is back."](https://www.patreon.com/posts/svg-2-status-19078074) At least, this [Patreon page](https://www.patreon.com/tavmjong) seems to have some modest support and occasional [updates](https://www.patreon.com/posts/svg-2-update-20335982) and talk of[fallbacks](https://www.patreon.com/posts/svg-2-fallbacks-23506209) that work in conjunction with InkScape exports and browsers. – Weston C Jan 13 '19 at 22:26
  • 1
    [2020-02-16 Scalable Vector Graphics (SVG) 2 W3C Editor’s Draft](https://svgwg.org/svg2-draft/) – l --marc l Apr 24 '20 at 19:57

3 Answers3

13

From what I understand SVG 2.0 is still a work in progress with no full browser implementation.

For the more elusive features of SVG that may not be implemented by all browser you can check CanIUse to see if the feature is supported.

Schybo
  • 1,623
  • 1
  • 13
  • 12
13

Asking if a browser supports SVG 2 is like asking if a browser supports HTML5. It seems like a totally reasonable question, but it doesn't work like that.

The best we can do is test if a browser supports a feature, rather than a version of spec.

David Gilbertson
  • 3,667
  • 1
  • 20
  • 30
8

According to SVG 2.0 specification it may be something like

document.implementation.hasFeature("http://www.w3.org/TR/SVG2/feature#GraphicsAttribute", 2.0)

SVG 1.1 support you can check with hasFeature call

document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#SVG", 1.1)

EDIT: hasFeature is deprecated and removed from Web standards. It will return always true on modern browsers (DOM Spec).

Niko Ruotsalainen
  • 41,078
  • 4
  • 23
  • 29
  • 2
    I'm pretty sure SVG2/html will mandate that they all return true always no matter what the feature's level of implementation is as they have generally been completely useless. – Robert Longson Sep 28 '14 at 20:13
  • You are right. According to [Mozilla](https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation.hasFeature) "The latest version of the spec settled to force this method to always return true, except for SVG features, where the functionality was accurate and in use.". But I don't know which one is the case with SVG 2.0 features so my answer should not be the accepted one for the time being. – Niko Ruotsalainen Jan 10 '15 at 13:09
  • `document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#SVG", 5.1)` also returns true. No matter what version number you gives it. – AGamePlayer Jun 15 '18 at 03:50