Skip to main content

Pausing the animation of <svg> elements can affect child <svg> elements differently in different browsers

Consider the following SVG, which contains two animated rectangles:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="100" id="outer">
  <rect width="0" height="10" fill="black">
    <animate attributeName="width" values="0;10;0" dur="20s"/>
  </rect>

  <svg id="inner">
    <rect width="0" height="5" fill="red">
      <animate attributeName="width" values="0;10;0" dur="7s"/>
    </rect>
  </svg>
</svg>

Suppose you pause animations in the outer SVG with JavaScript, e.g.:

document.querySelector("svg#outer").pauseAnimations();

What happens next depends on the browser.