How to make a text marquee banner using just CSS
In February 2025 an interior designer's portfolio site needed a band of large text sliding across the home page, the kind of thing that used to be a <marquee> tag. The site is Statamic with Tailwind and Alpine, but the marquee itself is plain CSS in the block's own partial. No library, no JavaScript, no timer.
I've reused the pattern since, and the second time I added two things the first version should have had. Here's the whole thing, then what changed.
The block
The Replicator set is three fields: text, a link_field and a new_window toggle. The partial renders the text ten times into a list, then renders the same list a second time with aria-hidden="true" (the link branch is left out here, it's the same shape):
<div class="marquee py-8 font-bold text-lg md:text-xl uppercase">
<ul class="marquee__content">
{{ loop from="1" to="10" }}
<li>{{ text }}</li>
{{ /loop }}
</ul>
<ul class="marquee__content" aria-hidden="true">
{{ loop from="1" to="10" }}
<li>{{ text }}</li>
{{ /loop }}
</ul>
</div>
The duplicate list is the whole trick. A screen reader hears the phrase ten times from the first list, which is already more than it needs, and never hears the second. Sighted users see one continuous ribbon.
The CSS
This is the version from the first commit, with a 30 second loop:
.marquee {
--gap: 1rem;
display: flex;
overflow: hidden;
user-select: none;
gap: var(--gap);
}
.marquee__content {
flex-shrink: 0;
display: flex;
justify-content: space-around;
min-width: 100%;
gap: var(--gap);
animation: scroll 30s linear infinite;
}
@keyframes scroll {
from { transform: translateX(0); }
to { transform: translateX(calc(-100% - var(--gap))); }
}
Each track is at least as wide as the container and is not allowed to shrink, so the two tracks sit side by side in a flex row with a gap between them, and the container clips the overflow. The animation slides every track left by exactly its own width plus that gap. At the end of one cycle the second track is sitting precisely where the first one started, so the jump back to zero is invisible.
Two details carry the illusion. calc(-100% - var(--gap)) has to include the gap; leave it off and you get a small stutter every cycle, which is the bug in most marquees I see. And the timing function has to be linear; the default ease makes the ribbon speed up and slow down once per loop, which reads as a hiccup.
The ten copies exist because min-width: 100% only guarantees the track is as wide as the container. With a short phrase and space-around, one copy would be a single word floating in the middle. Ten of a short phrase has been enough on every screen I've needed it on.
Speed
The 30 second loop was fine for uppercase text at text-xl. In May 2026 the site was re-skinned with Playfair italic at text-4xl on phones and text-7xl on desktop, a hairline border top and bottom, a ยท after each item and a 2.5rem gap. I bumped the duration to 60 seconds in that commit, and the next day to 140. The commit message says why: readable now rather than a moving sign.
The rule I took from that is that duration is the wrong unit to think in. The same 30 seconds is three times faster in pixels per second once the text is three times wider. Large display type wants to crawl.
Pause and reduced motion
In July 2026 I built the same structure on another client site, a row of icon chips that scrolls inside an open accordion panel. Same two lists, same aria-hidden on the second, same keyframe, the newer Tailwind's utilities in place of the class names. Two things were new:
.engagement-marquee:hover .engagement-marquee__content {
animation-play-state: paused;
}
@media (prefers-reduced-motion: reduce) {
.engagement-marquee {
overflow-x: auto;
}
.engagement-marquee__content {
animation: none;
}
.engagement-marquee__content[aria-hidden='true'] {
display: none;
}
}
Pausing on hover lets someone actually read the thing. The reduced-motion block stops the animation, hides the duplicate track so the content isn't doubled, and lets the container scroll sideways so nothing is cut off. It's seven lines.
The first site shipped without those seven lines, and as I write this it still runs without them. Seventeen months of a looping animation for anyone who asked their OS not to show one. That is the part of this post I'd rather not be writing.
When CSS is the wrong tool
Same month, same site, a strip of client logos. I wanted it to scroll continuously and still be draggable. A CSS marquee can't be dragged, so that one is Swiper with autoplay.delay: 0, speed: 4000 and pauseOnMouseEnter, plus one override, because Swiper eases each step by default and a continuous loop with easing reads as glide-and-pause:
.brands-slider .swiper-wrapper {
transition-timing-function: linear !important;
}
The short version: if nobody touches it, two lists and a keyframe. If they drag it, a slider with linear timing. Either way, write the reduced-motion rule the same day, not seventeen months later.