51

I have the following <img> tag in a static HTML document.

<img src="foo.gif" alt="This is an animated gif image, but it does not move"/>

After I set its src attribute to point to a .gif file (i.e. foo.gif), the GIF appears as a static (or non-moving) image. How do I animate the GIF?

nbro
  • 15,395
  • 32
  • 113
  • 196
MaryBaker
  • 667
  • 1
  • 5
  • 8
  • 4
    This should work by default, can you provide an example? – Alessio Jul 11 '16 at 14:29
  • this may help? http://stackoverflow.com/questions/5818003/stop-a-gif-animation-onload-on-mouseover-start-the-activation – George G Jul 11 '16 at 14:29
  • 1
    Excuse me, are you shure your source GIF is animated, or it is in default format (gif89a)? Do some google and find an animated gif just for testing purposes. It seems your gif is not ok. Best. – statosdotcom Jul 11 '16 at 14:31

3 Answers3

65

By default browser always plays animated gifs, and you can't change that behavior. If the gif image does not animate there can be 2 ways to look: something wrong with the browser, something wrong with the image. Then to exclude the first variant just check trusted image in your browser (run snippet below, this gif definitely animated and works in all browsers).

Your code looks OK. Can you check if this snippet is animated for you?
If YES, then something is bad with your gif, if NO something is wrong with your browser.

<img src="https://i.stack.imgur.com/SBv4T.gif" alt="this slowpoke moves"  width="250" />
Iurii Tkachenko
  • 3,106
  • 29
  • 34
4

Agreed with Yuri Tkachenko's answer.

I wanna point this out.

It's a pretty specific scenario. BUT it happens.

When you copy a gif before its loaded fully in some site like google images. it just gives the preview image address of that gif. Which is clearly not a gif.

So, make sure it ends with .gif extension

Dummy
  • 47
  • 3
3

try

<img src="https://cdn.glitch.com/0e4d1ff3-5897-47c5-9711-d026c01539b8%2Fbddfd6e4434f42662b009295c9bab86e.gif?v=1573157191712" alt="this slowpoke moves"  width="250" alt="404 image"/>

and switch the src with your source. If the alt pops up, try a different url. If it doesn't work, restart your computer or switch your browser.

Dukk
  • 106
  • 7