December 4, 2026
To make an infinite marquee in pure CSS, place two identical copies of your content side by side in one track and animate the
track from translateX(0) to translateX(-50%) on a linear, infinite loop. At the end of the loop the
second copy sits exactly where the first began, so the restart cannot be seen. No JavaScript is needed.
What is the code?
<div class="marquee">
<div class="track">
<ul><li>Design</li><li>Motion</li><li>Code</li></ul>
<ul aria-hidden="true"><li>Design</li><li>Motion</li><li>Code</li></ul>
</div>
</div>
.marquee { overflow: hidden; }
.track { display: flex; width: max-content; animation: slide 20s linear infinite; }
.track ul {
display: flex; gap: 3rem;
padding: 0 3rem 0 0; /* the same space as the gap, after the last item */
margin: 0; list-style: none;
}
@keyframes slide { to { transform: translateX(-50%); } }
.marquee:hover .track,
.marquee:focus-within .track { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
.track { animation: none; }
}
Why does it jump at the loop point?
Minus 50 percent only lines up if both copies are exactly the same width. The gap property puts space between
items but not after the last one, so each copy ends up one gap short and the loop skips by that amount. The
padding-right in the code above adds the missing space to each copy. Check this first whenever a marquee
twitches.
What if the content is shorter than the screen?
Two copies of a short list leave an empty stretch on a wide monitor. Repeat the items inside each copy until one copy is at least as wide as the widest screen you care about. A few lines of JavaScript can clone items to fit, which is what the Library element does for you.
How do I fade the edges?
.marquee {
mask-image: linear-gradient(to right, transparent, #000 10%, #000 90%, transparent);
}
A mask fades the content itself, so it works over any background, where a gradient overlay only works over a flat colour.
What about screen readers?
Mark the second copy aria-hidden="true" so the list is not read twice. If the marquee contains links, make sure
the duplicates cannot be reached with the Tab key either, for example with the inert attribute.
Which finished marquees can I copy?
| Element | What it does |
|---|---|
| Marquee ticker | Endless horizontal text that pauses on hover, with speed, gap and direction controls. |
| Double ticker band | Two stacked bands of repeated words sliding past at different speeds. |
| Edge fade logo strip | A row of word-marks that slides past endlessly and fades out at both edges. |
| Marquee hover menu | Menu rows where a coloured band slides in from the edge the pointer entered. |
All are free in the Enrichr Library, with a live demo, copyable code and a pen on CodePen.
Where to go next
- Scroll animations without a library.
- What to do with animations when a visitor asks for reduced motion.
- Animated SVG background patterns.
FAQ
Can I still use the marquee tag?
The <marquee> element is deprecated. Browsers still draw it, but it cannot be paused or styled well and may be removed. A CSS animation does the same job properly.
Why does my CSS marquee jump when it loops?
The two halves are not the same width. The usual cause is a flex gap between items with no matching space after the last item of each copy. Add the same space as padding at the end of each copy.
How do I pause a CSS marquee on hover?
Set animation-play-state: paused on the moving track when the wrapper is hovered or contains focus.
How do I control the speed?
With the animation duration. The track moves half its own width per loop, so longer content needs a longer duration to keep the same speed.