Overview
A multicolor linear gradient clipped into live text via background-clip: text — a vivid spectrum sweeps through the glyphs without any per-letter spans or canvas tricks. A static fallback color renders for engines that do not support the property, so unsupported browsers see a solid (non-invisible) text instead of nothing.
When to use it
Reach for rainbow-clipped text on celebratory or “complete me” product surfaces — checkout completion, achievement unlock, pride banners. Skip it for utility chrome; the vivid spectrum reads as marketing, not information. Skip it for low-contrast surfaces — even moderate stops drop below WCAG AA against a busy background.
How it works
Set background-image on the text to a multi-stoplinear-gradient(90deg, red, orange, yellow, green, cyan, violet) with background-size: 200% 100% (oversized) so the gradient extends past the glyphs. Clip the background to the text shape with background-clip: text + -webkit-background-clip: text, then set color: transparent + -webkit-text-fill-color: transparent so the glyph fill comes from the clipped gradient. Animate background-position from 0% 50% to 100% 50% for a slow spectrum drift; the colors visible inside each glyph shift as the gradient slides under the clip.
Production gotchas
The @supports feature query is non-negotiable — omit it and Firefox versions without background-clip: text render the text invisible (transparent color + no clip = nothing). On Safari iOS the -webkit-text-fill-color prefix is still required alongside the unprefixed color: transparent. Saturated spectrum stops on a busy background can drop below WCAG AA contrast — verify the gradient against the surface at both rest and peak animation positions, not just one frame.
Accessibility
The text node is real DOM throughout — screen readers, copy-paste, and search engines all see the string normally. Under prefers-reduced-motion: reduce pause the gradient at a middle position so the text still reads as rainbow-clipped without the sliding motion. Provide a sufficiently-contrasting fallback color for @supports-less browsers.
References
Implementation depth
Rainbow text needs restraint in both palette and surface. Keep the phrase short, clip the gradient to real text, and use a solid fallback so unsupported browsers never render transparent invisible copy.
The gradient should support the content hierarchy. If every heading uses a rainbow treatment, no heading is special. Reduced motion should pin the gradient rather than animating color movement through body-sized text.