Detect browser support for CSS-animated SVG

I am playing around with CSS-animated SVG elements and came across the problem that even though all technologies, which are used, are supported by some browsers the combination is not, i.e. CSS-animated DIVs work but SVG elements don't. I am wondering if there is a way to detect if a browser is capable of animating SVG elements using CSS.

Here is a jsFiddle with an example. It works in the latest versions of Chrome, Firefox and Safari. But when opening it with e.g. Firefox 5 only the div rotates while the rect doesn't.


You can add an event listener to check for the completion of an animation iteration, and within the corresponding event handler set a flag like supportsSVGKeyFramedAnimatedProps = true (if the iteration never completes then it is not animating).

elem.addEventListener('animationiteration', eventHandler, false)

This would allow you to 'fall forward' to your SVG animation, instead of providing a fallback.

I am wondering if there is a way to detect if a browser is capable of animating SVG elements using CSS

Simple Answer: Yes you can as stated by @jhpratt.

You can detect if a browser supports CSS-Functionality with only CSS. The @supports CSS at-rule lets you specify declarations that depend on a browser's support for one or more specific CSS features. This is called a feature query.


@supports (display: flex) {
  div {
    display: flex;
@supports not (display: flex) {
  div {
    float: right;

MDN Link:

Long Answer:

You will always have some cross-browser issues. The problem you have encountered is bothering every Webdeveloper. Still there are ways to get around with this Browser-Support-Problem:

1. You can check "can I use" for compatibility:

Link: It is recommend to look up any functionality which is questionable like animations.

2. Use an autoprefixer in your workflow:

With the help of an autoprefixer you don't have to worry most of the time about using CSS with a prefix like -moz-, -webkit-, etc. This tiny helper will do the trick for you, you can even tell some autoprefixers which browsers you want to support.

3. User 3rd - Party libraries:

There are many libraries out there which you can use to detect the browser and version. If you want to be sure that your animation is secure to use, you can simply use the provided animation from the libraries and of course look the compatibility up before on their respective websites.

Some Big Names:

there are many more, jsut search the world wide web.

4. Use CSS Hacks to detect specific Browsers:

It is possible to use so called CSS-Hacks. They are specific CSS calls, which only apply on certain browsers.

Some examples:

Internet Explorer/Edge 8 only: @media \0screen {}

firefox ≥ 3.6 only: @media screen and (-moz-images-in-menus:0) {}

Opera ≤ 9.27 AND Safari 2: html:first-child .selector {}

You can look up more Browserhacks here:


It is possible to detect specific browsers, but it is not possible to detect if the brwoser is supporting the given feature with only CSS. That is why you will always have some hard times with browser support.

Hope this helps. Regards

I believe that the SMIL animations detections in modernizr should do it.

I'm using it in a pretty involved set of css/SVG chart animations. Just wrap a fallback in the following tag:

.no-smil{    }

I haven't done exactly what you're looking for, but something similar (providing an animated clip-path as defined by SVG when the browser supports it and falling back when it doesn't). You can use media queries looking for pixel ratios to determine if a broswer is moz or webkit and provide the fallback animation outside the media query and provide the preferred animation in media queries that indicate a browser that will support it.

//fallback animation here

@media (-webkit-min-device-pixel-ratio: 0) {
  // webkit animation here 

As for older versions of Firefox? I don't know how to do that in CSS, but I'm not sure going back more than a few versions of Firefox or Chrome is a common use case.

Need Your Help

Gradle Warning: missing groovy return statement

android groovy gradle android-gradle build.gradle

I'm having the following warning in my gradle build file