Marquee Ticker with Pause
Two rows scroll in opposite directions; hover or Pause stops them, and reduced motion shows a static list.
AI prompt
Build a two-row marquee of keyword pills (Motion, Layout, Typography, Colour, Depth, Light, Texture, Rhythm). The top row scrolls left at a slow constant speed (24 seconds per loop), the bottom row scrolls right (32 seconds). Duplicate each track for a seamless loop and mark the copy aria-hidden. Soft white fades on both edges. Pause on hover and focus-within, and provide a visible Pause/Play button with aria-pressed. Under prefers-reduced-motion stop all scrolling, wrap the pills into a static list and hide the button. Light minimal style, pills with 1 pixel border and 13 pixel text. Plain HTML, CSS and JavaScript (only for building the tracks and the button).About this pattern
Definition
A marquee is content that scrolls continuously in a loop, often used for logo strips, keywords and announcements. The row is duplicated so the loop restarts without a visible jump.
Purpose & UX principles
- Good for decorative, repeated content (client logos, topics); do not use it for essential information.
- Moving content that lasts more than five seconds needs a pause control (WCAG 2.2.2), and it should also pause on hover and focus.
- Duplicate the items for the loop and hide the copy from screen readers.
Interaction states
- Running, paused by hover, paused by button, reduced motion (static wrapping list).
Motion specification
- Linear translateX loop, 24s per cycle for the top row and 32s reverse for the bottom row.
- Reduced motion: no scrolling; items wrap in a static list and the pause button is hidden.
Responsive behaviour
- Speed is set in pixels per second, so very wide screens still look calm; edge fades soften the cut.
- Keep item height consistent and gaps equal.
Code
<div class="bx"><div class="mq" id="mq"></div><button id="pz" type="button" aria-pressed="false">Pause</button></div>:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
.bx{width:min(340px,100%);display:grid;gap:10px;justify-items:center}
.mq{width:100%;display:grid;gap:8px;overflow:hidden;-webkit-mask-image:linear-gradient(90deg,transparent,#000 12%,#000 88%,transparent);mask-image:linear-gradient(90deg,transparent,#000 12%,#000 88%,transparent)}
.row{display:flex;width:max-content;gap:8px;animation:mv var(--s,24s) linear infinite;animation-direction:var(--dir,normal)}
.mq:hover .row,.mq:focus-within .row,.mq.paused .row{animation-play-state:paused}
@keyframes mv{to{transform:translateX(calc(-50% - 4px))}}
.p{flex:none;height:30px;padding:0 14px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:13px;display:grid;place-items:center}
#pz{height:28px;padding:0 16px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:12px;cursor:pointer}
button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){.row{animation:none;flex-wrap:wrap;width:auto}.row .cp{display:none}#pz{display:none}.mq{-webkit-mask-image:none;mask-image:none}}const W=['Motion','Layout','Typography','Colour','Depth','Light','Texture','Rhythm'],mq=document.getElementById('mq'),pz=document.getElementById('pz');
[['24s','normal',W],['32s','reverse',W.slice().reverse()]].forEach(([s,d,w])=>{const r=document.createElement('div');r.className='row';r.style.setProperty('--s',s);r.style.setProperty('--dir',d);
[0,1].forEach(k=>w.forEach(t=>{const p=document.createElement('span');p.className='p'+(k?' cp':'');p.textContent=t;if(k)p.setAttribute('aria-hidden','true');r.append(p);}));mq.append(r);});
pz.addEventListener('click',()=>{const on=pz.getAttribute('aria-pressed')!=='true';pz.setAttribute('aria-pressed',String(on));pz.textContent=on?'Play':'Pause';mq.classList.toggle('paused',on);});One complete HTML file. Save it and open it in a browser.
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Marquee Ticker with Pause — demo</title>
<style>
:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
html,body{height:100%}body{background:var(--bg);color:var(--text);font:15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Inter,Roboto,sans-serif;-webkit-font-smoothing:antialiased}.stage{min-height:100%;display:grid;place-items:center;padding:24px}button,input,select,textarea{font-family:inherit}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
.bx{width:min(340px,100%);display:grid;gap:10px;justify-items:center}
.mq{width:100%;display:grid;gap:8px;overflow:hidden;-webkit-mask-image:linear-gradient(90deg,transparent,#000 12%,#000 88%,transparent);mask-image:linear-gradient(90deg,transparent,#000 12%,#000 88%,transparent)}
.row{display:flex;width:max-content;gap:8px;animation:mv var(--s,24s) linear infinite;animation-direction:var(--dir,normal)}
.mq:hover .row,.mq:focus-within .row,.mq.paused .row{animation-play-state:paused}
@keyframes mv{to{transform:translateX(calc(-50% - 4px))}}
.p{flex:none;height:30px;padding:0 14px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:13px;display:grid;place-items:center}
#pz{height:28px;padding:0 16px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:12px;cursor:pointer}
button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){.row{animation:none;flex-wrap:wrap;width:auto}.row .cp{display:none}#pz{display:none}.mq{-webkit-mask-image:none;mask-image:none}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="mq" id="mq"></div><button id="pz" type="button" aria-pressed="false">Pause</button></div>
</div>
<script>
const W=['Motion','Layout','Typography','Colour','Depth','Light','Texture','Rhythm'],mq=document.getElementById('mq'),pz=document.getElementById('pz');
[['24s','normal',W],['32s','reverse',W.slice().reverse()]].forEach(([s,d,w])=>{const r=document.createElement('div');r.className='row';r.style.setProperty('--s',s);r.style.setProperty('--dir',d);
[0,1].forEach(k=>w.forEach(t=>{const p=document.createElement('span');p.className='p'+(k?' cp':'');p.textContent=t;if(k)p.setAttribute('aria-hidden','true');r.append(p);}));mq.append(r);});
pz.addEventListener('click',()=>{const on=pz.getAttribute('aria-pressed')!=='true';pz.setAttribute('aria-pressed',String(on));pz.textContent=on?'Play':'Pause';mq.classList.toggle('paused',on);});
</script>
</body></html>