Why does my SVG animation not work?
An SVG animation is the quietest failure in front-end development. Nothing throws, nothing appears in the console, no build step complains — the graphic simply sits still. That silence happens because SMIL and CSS animations are declarative: the browser ignores instructions it cannot satisfy and keeps rendering the static first frame. Below are the seven causes behind virtually every "my SVG animation is not working" report, in the order they are quickest to check.
1. The animation has no duration
This is the number-one answer to "why does my SVG animation not work?" In SMIL, the dur attribute defaults to indefinite, which does not mean "a long time" — it means the animation never advances on its own. An <animate> or <animateTransform> without dur waits forever for an external beginElement() call that usually never comes, so the graphic renders its base state and stops.
The fix is a single explicit duration such as dur="2s". The same trap exists in CSS, where omitting the time value from the animation shorthand leaves animation-duration at its default of 0s: the keyframes run and finish instantly, which is visually identical to not running at all. A time unit is mandatory — animation: spin 1.6s linear infinite works, animation: spin linear infinite does not.
2. The animation is outside its target
A SMIL element must either be a child of the element it animates, or point at one with href="#id" (or the legacy xlink:href). When an <animate> is moved during refactoring and ends up as a direct child of <svg> or of a sibling group, it has no target and becomes a silent no-op. Equally common is an href="#logo" pointing at an id that was renamed or deleted — the reference resolves to nothing and the browser drops the animation.
Fix it by moving the element back inside its target, or by restoring the referenced id. If you intentionally want an event-driven animation, keep the target relationship intact and use a trigger such as begin="go.click" instead of leaving the element orphaned.
3. The keyframes name does not match
CSS animations fail by string equality. If your rule says animation: pulse 2s infinite but the file defines @keyframes pulses — a plural, a typo, a case mismatch — the property has no timeline to play and the element renders un-animated. The stylesheet is still perfectly valid, so there is no warning. This bug appears constantly after find-and-replace edits and when keyframes are copied between files without their definitions.
Search the file for the exact identifier used in animation-name (or the shorthand) and make sure a matching @keyframes block exists, character for character. Vendor-prefixed duplicates such as @-webkit-keyframes count as separate blocks; modern engines accept the unprefixed form, but some older WebKit builds need both names aligned.
4. The CSS selector matches nothing
Even a perfectly written keyframes block does nothing if its selector finds no elements. In SVG this usually means a class that exists in the HTML version of an icon but not in the exported SVG, or an id that changed during optimization. The rule is dead code: valid syntax, zero targets, zero motion. A variant of this is the scoping problem where a selector works on a demo page but the same markup embedded elsewhere inherits a different cascade and the rule loses specificity.
Run the selector against the actual SVG document — not the page around it — and confirm it returns the elements you expect. The checker performs that query directly against the parsed XML and flags any animated rule with zero matches as a warning.
5. keyTimes and values disagree
Fine-grained SMIL timing uses parallel lists: values="20;40;20" describes three keyframe values, and keyTimes="0;0.5;1" describes when each one is reached. The two lists must contain the same number of entries. If they do not — a classic copy-paste artifact — the browser discards the timing function entirely, which can freeze the element or snap it to the final value. The same rule applies to keySplines, which must have one spline per interval between keyTimes.
Count semicolons: n values need n keyTimes, and n − 1 splines. Note that calcMode="paced" is the exception — it computes its own pacing and ignores keyTimes — so a mismatch under paced timing is not an error, but it is under every other mode.
6. The embedding method blocks the animation
Here is the most confusing variant: the SVG animates when opened directly or viewed in the checker, but stays still on the production page. The file is fine — its container is the problem. An <img src="tick.svg"> renders SVG in a restricted, secure context: SMIL and CSS animations keep playing, but any <script>, inline onclick handler or external resource is blocked. Inline SVG in the markup runs everything. A strict Content-Security-Policy can additionally strip inline <style> blocks, which silently removes CSS keyframes even from an inlined file.
Identify which engine your animation uses, then choose an embedding method that allows it. This is a deep enough topic that it has its own guide: SVG animation not working in an img tag explains the full embedding matrix and how to restructure a scripted file into declarative animation.
7. Scripts, handlers and sanitizers
Animation driven by requestAnimationFrame, setInterval or a library such as GSAP is real animation, but it depends on executing JavaScript. Beyond the <img> restriction above, many CMS pipelines, email clients and security sanitizers remove <script> tags and on* attributes from uploaded SVGs — again without telling you. External href references to remote files fail the same way in offline or locked-down embeds, and can leak visitor IP addresses when they do load.
If the graphic must survive arbitrary pipelines, rebuild the motion declaratively in SMIL or CSS. The trade-offs between those two engines are mapped out in SMIL vs CSS animation for SVG.
- Does every SMIL element have an explicit
dur, and every CSS rule a time value? - Is each animation a child of its target, or does its
href="#id"resolve? - Does the
animation-namestring match an@keyframesblock exactly? - Does each animated selector match at least one element in the SVG itself?
- Do
values,keyTimesandkeySplineshave consistent counts? - Is the embedding method (
img, inline,object, background) allowed to run this engine? - Will a sanitizer or CSP remove the scripts, handlers or inline styles the motion needs?
Diagnose it in seconds instead of guessing
Every rule above is encoded in the SVG Animation Checker: drop the file or paste its markup and the parser reads the raw XML, lists each animation with its target and timing, and reports the exact failure — missing duration, orphaned target, unmatched keyframes, dead selectors and keyTimes mismatches all get their own diagnostic with a plain-English explanation. The live preview plays in an isolated iframe with replay, pause and quarter-speed controls, so a one-frame glitch becomes visible too. Nothing is uploaded; all analysis runs in your browser.
If you are building success-state artwork rather than debugging, the animated check mark gallery ships six hand-built ticks (SMIL, CSS and a GIF fallback) that pass every rule in this guide — open any of them in the checker with one click to see a clean report.