play & pause gif animations

baccyflap.com is part of the PixScape webring; it was eligible because of my tiny ideas webcomic, which includes some animated comics. The ringmaster asked me to provide an option to disable those animations to accomodate people who are sensitive to excessive motion. There are a few readymade JavaScript solutions available, but none of them work if the user has JavaScript disabled in their browser; they either get the still or the animation, period. And so, as per usual, plug-and-play solutions awaken a rage in me that can only be extinguished by finding an alternative, pure HTML/CSS solution.

So here's my solution, which you can also see on the comic page linked above. A still image (data-still.gif) transforms into an an animated image (data-animated.gif) on click.

a still image of actor Brent Spiner in pale green makeup as Data in Star Trek TNG a short clip of actor Brent Spiner in pale green makeup as Data in Star Trek TNG, making quizzical and amused facial expressions

Click the image, and the animation will appear; click it again, and it will go back to the still image. No JavaScript, no nonsense. Here's a full example page:

<html>
<head>
<title>page title</title>
<style>
summary.gifstop{list-style:none}
[open] summary.gifstop {margin-bottom:-120px;opacity:0%}
</style>
</head>
<body>

<details>
<img src="data-animated.gif" alt="a still image of actor Brent Spiner in pale green makeup as Data in Star Trek TNG">
<summary class="gifstop">
<img src="data-still.gif" alt="a short clip of actor Brent Spiner in pale green makeup as Data in Star Trek TNG, making quizzical and amused facial expressions">
</summary>
</details>

</body>
</html>
Mind that -120px: it's the image's height. I tried for a universal solution but couldn't come up with one and since I didn't need it for my purposes, I've left it like this for now. If you want to use this hack for multiple images of different sizes, you need to make a class for each of them, with the height included where that -120px is in my example. Fiddly, but it works.