Add a pause control to an animated web banner

Give readers a way to stop a looping banner while they use the rest of the page.

Multi-format design4 min read

A banner that loops beside an article can keep moving for as long as someone reads. If you own the page and the banner, give the reader a visible way to stop it without holding a pointer or keyboard focus in place.

Start with the actual placement

Suppose a banner starts on page load, runs a seven-second animation and repeats indefinitely beside an article. Its movement starts automatically, lasts more than five seconds and appears alongside other content. Under WCAG 2.2 success criterion 2.2.2, provide a mechanism to pause, stop or hide it unless the movement is essential to the activity. An advertising animation is not automatically essential just because it is part of the creative.

The duration of one cycle is not the whole duration: a three-second animation repeated indefinitely keeps moving beyond five seconds. Conversely, a static banner has no motion to pause. A sequence that truly stops within five seconds does not trigger the moving-content branch of this criterion on duration alone; check the actual exported playback and any other applicable requirements. Auto-updating information has a separate branch with no five-second exception. Flashing also has separate limits.

Make the control part of the page

Place a clearly named Pause animation button next to the banner or at the top of the page. Use a real HTML button with a visible focus indicator and enough contrast. It must work with keyboard as well as pointer input; the banner's destination link and the pause button need separate interactive targets. The W3C control technique describes this pattern; it is one sufficient technique, not the only possible implementation.

On activation, freeze every moving layer of that banner and change the control to Play animation. Keep it stopped when the reader moves focus away, scrolls, or uses the rest of the page. A hover-only or focus-only pause is not enough: it makes the reader keep the pointer or focus on the banner instead of reading. Restart only on an explicit play action. For this non-live creative, resuming from the frozen frame preserves context; a stop-and-reset approach can also work if the stopped frame keeps the message understandable.

For a CSS animation, the developer can toggle a paused state on the banner and apply animation-play-state: paused to each animated element. A CSS switch alone will not stop a video, an animated GIF, a canvas loop or a separately running script: each needs its own stop mechanism, or a static replacement. Keep essential offer text readable in the paused frame and make sure the control's accessible name reflects its next action.

Try a seven-second loop

Save this as banner.html. With normal motion, the dot moves for seven seconds in each direction. Pause it with the keyboard, move focus away and wait longer than seven seconds. The dot should stay in place while the offer link still works. With reduced motion, the dot stays still and the same offer remains visible.

HTML
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>20% off mugs on orders of $50 or more</title>
<style>
  .art { display: inline-block; color: #284e78; animation: slide 7s ease-in-out infinite alternate; }
  @keyframes slide { from { transform: translateX(0); } to { transform: translateX(32px); } }
  .stopped .art { animation-play-state: paused; }
  @media (prefers-reduced-motion: reduce) {
    .art { animation: none; }
    #motion { display: none; }
  }
</style>
<section id="banner">
  <span class="art" aria-hidden="true">●</span>
  <p>20% off mugs on orders of $50 or more</p>
  <a href="#terms">Offer details</a>
</section>
<button id="motion" type="button">Pause animation</button>
<p id="terms">Sample offer. Replace these terms and the destination before publishing.</p>
<script>
  const banner = document.getElementById("banner");
  const button = document.getElementById("motion");
  button.addEventListener("click", () => {
    const stopped = banner.classList.toggle("stopped");
    button.textContent = stopped ? "Play animation" : "Pause animation";
  });
</script>
</html>

Check the finished placement

  1. Load the actual page and let the seven-second loop run. Find the pause control without hovering over the banner.
  2. Reach it with Tab, confirm focus is visible, and activate it with Enter or Space. All banner motion should stop.
  3. Tab away and read or scroll for longer than a cycle. Nothing should restart by itself. Activate Play and confirm motion resumes; the banner link should still work separately.
  4. Repeat at a narrow viewport and with a screen reader: the control must remain visible, reachable and named for the action it performs.

Also test the page with the operating system's reduced-motion preference. Serving a static or reduced-motion version respects that preference, but it is a separate adaptation: a reader who has not set it still needs a pause mechanism when the criterion applies.

When you cannot control the host

A third-party placement may accept only a finished image or impose its own player and controls. Confirm the host's actual capabilities and creative specification before promising an in-page pause. If the placement cannot expose a usable control, supply a static creative or a version that genuinely stops within the allowed duration for the moving-content case, and have the page owner assess the complete placement. A looping GIF does not acquire a pause button merely because one is drawn into its pixels. A static or short creative still needs its message, destination and any other applicable accessibility checks reviewed.

Marketing workflow
All guides
Add a pause control to an animated web banner | Formatry Media — Formatry