Seven ways to fill text with colour: a gradient headline, one gradient word inside a plain sentence, an animated flowing gradient, letters filled with stripes, a conic rainbow, gradient text with a solid offset shadow and a link whose gradient sweeps in on hover.
The core technique: a gradient background clipped to the text with background-clip: text and a transparent text colour. A solid colour is set first as a fallback, and both gradient stops are dark enough to pass contrast on white.
Only the key word gets the gradient, inside an otherwise plain white headline, which is usually more effective than colouring the whole line. The word is wrapped in a span so the effect stays a styling choice.
View code
<h3 class="gt2">Build sites that <span>convert</span>.</h3>
The gradient inside the letters drifts sideways because the clipped background is wider than the text and its position animates. It stops for reduced motion, and the colours stay light enough to read on dark at every moment.
Big letters filled with diagonal stripes from a repeating gradient instead of a smooth blend. Any background, including an image, can be clipped to text this way; keep the letters large and heavy so the fill shows.
A conic gradient clipped to the text gives a colour-wheel effect, each letter catching different hues around the centre. Conic gradients clip to text exactly like linear ones, and these pastel stops stay readable on dark.
text-shadow shows through transparent gradient text, so a drop shadow needs another way: a dark copy of the word from attr(data-t) sits behind it, offset by a few pixels. The result is a bold, poster-like headline.
A link whose text is plain dark at rest and fills with a gradient sweeping from the left when hovered or focused, by transitioning the size of a clipped gradient layer over a solid one. The resting state stays calm and readable.
View code
<a class="gt7" href="#case">Read the case study</a>
Set a gradient as the background, clip it to the text with background-clip: text (plus the -webkit- version) and make the text colour transparent. Wrap it in @supports with a solid colour fallback.
Contrast at both ends
Every colour in the gradient must contrast with the page. On white, use darker stops; on dark pages, use lighter pastel stops.
Shadows need a copy
text-shadow shows through transparent text and muddies the gradient. For a shadow, place a solid copy of the word behind it with attr().
Emphasise, do not decorate everything
A single gradient word usually lands harder than a whole gradient paragraph, which is also harder to read.
Frequently asked questions
Is gradient text accessible?
Yes. It is still real text; just check the contrast of each colour.
Can I select and copy it?
Yes, selection and copying work normally.
Does it work in every browser?
background-clip: text works in all current browsers with the -webkit- prefix.