CSS Repeating Text β Pattern Backgrounds, Marquees & Text Effects
Sometimes you don't want a tool to generate repeated text β you want the browser to render the repetition for you. CSS can tile text into pattern walls, stripe it with repeating gradients, outline it with text-stroke, and scroll it in seamless marquees, all without a single line of JavaScript. This guide covers the five techniques working developers actually use, with copy-paste code for each, plus the accessibility and performance rules that separate a slick effect from a broken page.
Quick Summary
Five CSS techniques cover nearly every repeating-text design: (1) repeating-linear-gradient for striped backgrounds, (2) background-clip: text for gradient-filled lettering, (3) -webkit-text-stroke for outlined pattern type, (4) CSS keyframe animations for seamless marquees, and (5) SVG <textPath> for text on curves. All are pure CSS (plus a little SVG), work in every modern browser, and stay lightweight β the main risks are accessibility (motion, contrast) and overuse, both covered in the checklist below.
Technique 1: Repeating Stripes With repeating-linear-gradient
The simplest repeating pattern β hard-stop colour bands, no images needed:
.stripes {
background: repeating-linear-gradient(
45deg,
#1a1a2e,
#1a1a2e 20px,
#16213e 20px,
#16213e 40px
);
}
The trick is the double colour stops: each colour declares a start and end position, which creates a hard edge instead of a blend. Change the angle and stop distances to control the stripe direction and rhythm.
Technique 2: Gradient-Filled Text With background-clip
Fill the letterforms themselves with a repeating gradient:
.gradient-text {
background: repeating-linear-gradient(
90deg,
#ff6b6b 0 15px,
#4ecdc4 15px 30px
);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
color: transparent lets the background show through the glyphs. Always provide a solid-colour fallback for older browsers β declare a normal color first (for example color: #ff6b6b;) before the transparent declaration, so unsupported browsers still show readable text.
Technique 3: Outlined Pattern Type With text-stroke
Hollow display type is the backbone of typography pattern walls:
.outline-text {
color: transparent;
-webkit-text-stroke: 1px #ffffff;
}
Despite the -webkit- prefix, this works in all modern browsers (Chrome, Edge, Firefox, Safari). Use it for oversized background words at low opacity β decorative, not body copy, because outlined text at small sizes hurts readability.
Technique 4: Seamless Marquee Rows
The classic scrolling text band, done with one keyframe animation. Duplicate the text span twice inside the track so the loop has no gap:
<div class="marquee">
<div class="marquee-track">
<span>SALE β’ SALE β’ SALE β’ </span>
<span>SALE β’ SALE β’ SALE β’ </span>
</div>
</div>
.marquee {
overflow: hidden;
white-space: nowrap;
}
.marquee-track {
display: inline-flex;
animation: marquee 15s linear infinite;
}
@keyframes marquee {
from { transform: translateX(0); }
to { transform: translateX(-50%); }
}
Translating exactly -50% of the doubled track is what makes the loop seamless β the second copy slides into the first copy's position. Adjust the duration for speed; keep it slow enough to read.
Technique 5: Text on a Path With SVG
When the repetition needs to follow a curve, SVG's <textPath> is the right tool:
<svg viewBox="0 0 300 100">
<defs>
<path id="curve" d="M10,60 Q80,10 150,60 T290,60" fill="none"/>
</defs>
<text>
<textPath href="#curve">REPEAT β’ REPEAT β’ REPEAT β’</textPath>
</text>
</svg>
This renders real, selectable text along the path β better than a rotated image, and it scales cleanly at any size.
Accessibility & Performance Checklist
- Respect reduced motion. Pause or disable marquees for users who ask for it:
@media (prefers-reduced-motion: reduce) { .marquee-track { animation: none; } } - Mark decorative repetition as decorative. Background text walls should carry
aria-hidden="true"so screen readers don't announce "SALE SALE SALE" fifty times. - Keep contrast legal. Outlined or low-opacity background type must not carry information β real content needs full contrast against its background.
- Don't animate layout properties.
transformandopacityare compositor-friendly; animatingwidth,leftorfont-sizeforces repaints and janks on low-end phones. - Mind the paint cost. Huge outlined text walls are cheap; dozens of animated gradient-text layers are not. Profile on a mid-range Android before shipping.
Common Mistakes to Avoid
- Marquee with a visible jump: the track content must be duplicated exactly twice and translated exactly -50% β any other ratio shows a seam.
- Forgetting the background-clip fallback: without a solid
colorfallback, unsupported browsers render invisible text. - Using outlined text for body copy: text-stroke below ~24px degrades readability fast; reserve it for display sizes.
- Infinite animations everywhere: two marquees in one viewport is a design; five is a migraine. Animate one element, keep the rest still.
- Faking patterns with spaced-out letters: use real CSS repetition instead of pasting "S A L E" with manual spaces β it's unmaintainable and breaks screen readers.
Frequently Asked Questions
How do I make text repeat infinitely across a page?
For a scrolling band, use the marquee technique above (doubled track, translateX -50%). For a static tiled background of words, repeat a text element in a CSS grid, or generate the repeated string with a text repeater and style the block.
Is -webkit-text-stroke safe to use in 2026?
Yes. Despite the vendor prefix, it's supported in all modern browsers including Firefox. It's the standard way to do outlined text.
Why does my marquee show a gap when it loops?
The two halves of the track aren't identical, or the translation isn't exactly -50%. Both spans must contain the same content (including trailing spacing), and the keyframe must move precisely half the track width.
Can I animate background-clip text?
Animating the background-position of the gradient works and is reasonably cheap. Animating the text itself with transforms is cheaper still β prefer moving the element over repainting the fill.
How do I make repeating text responsive?
Size display type in viewport units (vw) or clamp() so pattern walls scale with the screen, and reduce or disable marquees on small screens where they crowd the layout.
Related Guides & Tools
- How to Repeat Text Online β generate the repeated string, then style it with CSS
- Invisible Blank Text β Unicode spaces and blank characters for layout tricks
- Text Repeater β generate any repeated string for your markup