Skip to content
TheChatArchiveThe Chat Archive
Qwenqwen3-235b-a22b-no-thinking· Alibaba (Qwen)Hugging Face LMArena Human Preference 140K

Generate animated image through html code

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Mistralmistral-small-3.1-24b-instruct-2503’s answer.
  1. User

    Generate animated image through html code

  2. Qwen Assistant

    To generate an animated image using HTML, you typically use either:

    1. Animated GIFs (simplest method),
    2. CSS animations on images,
    3. JavaScript-based animation, or
    4. Canvas-based animation.

    ✅ Option 1: Use an Animated GIF (Easiest)

    If the animation is already available as a GIF, just embed it in your HTML:

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>Animated Image</title>
    </head>
    <body>
    
      <h2>My Animated Image</h2>
      <img src="https://media.giphy.com/media/your-animated-gif.gif" alt="Animated GIF">
    
    </body>
    </html>
    

    Replace the src URL with the path to your animated GIF file or link.


    ✅ Option 2: CSS Animation on a Static Image

    You can animate a static image using CSS keyframes. For example, rotating an image:

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>CSS Animated Image</title>
      <style>
        .rotate {
          width: 200px;
          animation: spin 4s linear infinite;
        }
    
        @keyframes spin {
          from { transform: rotate(0deg); }
          to { transform: rotate(360deg); }
        }
      </style>
    </head>
    <body>
    
      <h2>Rotating Image</h2>
      <img class="rotate" src="your-image.png" alt="Rotating Image">
    
    </body>
    </html>
    

    ✅ Option 3: JavaScript Animation (Basic Example)

    Use JavaScript for more dynamic behavior like moving an image across the screen:

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>JS Animated Image</title>
      <style>
        #box {
          position: relative;
          left: 0px;
          transition: left 0.1s linear;
        }
      </style>
    </head>
    <body>
    
      <h2>Moving Image</h2>
      <img id="box" src="your-image.png" alt="Moving Image" style="width:100px;">
    
      <script>
        let pos = 0;
        const box = document.getElementById("box");
    
        setInterval(() => {
          pos += 5;
          if (pos > window.innerWidth - 100) pos = 0;
          box.style.left = pos + "px";
        }, 30);
      </script>
    
    </body>
    </html>
    

    ✅ Option 4: Canvas-Based Animation

    For full control over pixel-level animation (e.g., sprite sheets):

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>Canvas Animation</title>
    </head>
    <body>
    
    <canvas id="myCanvas" width="400" height="300"></canvas>
    
    <script>
      const canvas = document.getElementById("myCanvas");
      const ctx = canvas.getContext("2d");
    
      let x = 0;
    
      function draw() {
        ctx.clearRect(0, 0, canvas.width, canvas.height);
        ctx.beginPath();
        ctx.arc(x, 150, 30, 0, Math.PI * 2);
        ctx.fillStyle = "blue";
        ctx.fill();
        x += 2;
        if (x > canvas.width) x = 0;
        requestAnimationFrame(draw);
      }
    
      draw();
    </script>
    
    </body>
    </html>
    

    Summary

    MethodUse Case
    GIFPre-made looping animations
    CSSSimple effects like rotation, scaling, fading
    JSDynamic movement and logic-driven animation
    CanvasFull custom drawing and game-style animation

    Let me know which kind of animation you're trying to create, and I can tailor the code!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.