Play Gif image in HTML with infinite loop

Looping is encoded into the GIF itself, not the img tag. Open the GIF in an image editor and change the mode to loop, or use a different GIF. The loop attribute is an invalid, deprecated attribute only meant to work when the src is a video.


As mentioned it is encoded into the GIF but you can change it with tools like photoshop for this:

  • Open your file in Photoshop
  • Go to File and click Save For Web
  • At the very bottom of the save dialog, you will see the Animation section, which should no longer be greyed out
  • Choose forever and save it.