To make gradient text in CSS, set a gradient as the element’s background, clip the background to the letters with background-clip: text, and make the text fill transparent so the gradient shows through. The same idea gives you image-filled and animated gradient text, while -webkit-text-stroke makes outline text and text-shadow makes glows and long shadows. The text stays real, selectable and readable by screen readers and search engines.
Key takeaways
- Gradient text = gradient background +
background-clip: text+ transparent text fill. - Include the
-webkit-lines; they are still needed in Safari and harmless elsewhere. - Give a solid colour fallback inside
@supports, so text never disappears. - Keep effects for short, large headings and check the contrast of the lightest colour.
How do you make gradient text in CSS?
.gradient-text {
color: #7b5cff; /* fallback if clipping isn't supported */
}
@supports (background-clip: text) or (-webkit-background-clip: text) {
.gradient-text {
background: linear-gradient(90deg, #ff7a59, #7b5cff);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
color: transparent;
}
}
-webkit-text-fill-color overrides any colour set by your theme or page builder, which is the most common reason gradient text shows as a solid block. The @supports wrapper means a browser that can’t clip the background shows plain coloured text instead of invisible text.
Gradient text that wraps onto two lines
On an inline element, the gradient is stretched across the whole run of text, so a heading that wraps can show only half the gradient on each line. Use display: inline-block to treat the heading as one box, or box-decoration-break: clone (with its -webkit- version) to repeat the full gradient on every line.
Which CSS text effects can you make?
| Effect | Main property | Works best for |
|---|---|---|
| Gradient | background-clip: text | Hero headings, brand words |
| Animated gradient | background-size + animated background-position | One highlighted word, used sparingly |
| Outline | -webkit-text-stroke | Very large display type |
| Glow / neon | Stacked text-shadow | Dark backgrounds, playful brands |
| Image fill | background-image + background-clip: text | Thick, heavy fonts at large sizes |
| Long shadow | Many offset text-shadow layers | Retro and poster styles |
Animated gradient text
.gradient-text--animated {
background-size: 200% auto;
animation: shine 4s linear infinite;
}
@keyframes shine {
to { background-position: 200% center; }
}
@media (prefers-reduced-motion: reduce) {
.gradient-text--animated { animation: none; }
}
Outline and glow text
.outline-text {
-webkit-text-stroke: 2px #ffffff;
color: transparent;
}
.glow-text {
color: #fff;
text-shadow: 0 0 6px #7df0d4, 0 0 18px #2f8cff;
}
-webkit-text-stroke is non-standard but supported in all current browsers. The stroke is centred on the letter edges, so thin fonts can lose their inner shapes; use a bold weight and a large size.
Image-filled text
Swap the gradient for a photo and the letters become windows onto the image. It works best with a very heavy font at a large size, so enough of the picture shows through each letter to be recognisable. Pick a busy, textured image such as foliage, water or a city at night; a portrait just looks like random patches.
.image-text {
background: url("texture.webp") center / cover;
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
font-weight: 900;
}
Long shadow text
A long shadow is a stack of text-shadow layers, each offset one pixel further than the last, which builds a solid diagonal block behind the letters. Twenty to forty layers is typical. Each layer is drawn separately, so very long shadows on many headings can slow down scrolling on low-powered phones. A generator saves typing them all out.
Why not use an image of the styled text?
A PNG of a styled headline can’t be read by screen readers without alt text, isn’t indexed as a heading by search engines, doesn’t reflow on small screens, blurs when zoomed and has to be re-exported every time the wording changes. CSS effects avoid all of that, and they weigh a few hundred bytes.
Are CSS text effects accessible?
The text itself is fine: it is still real text, so screen readers read it and search engines index it, unlike text baked into an image. The risk is visual. A gradient from dark blue to pale yellow might pass contrast at one end and fail at the other, and an outline or glow can blur letter shapes at small sizes.
- Check the lightest and darkest stops against the background with a contrast checker. Large text needs at least 3:1 for WCAG AA; see our guide to contrast ratios.
- Keep effects for headings. Never apply them to paragraphs or form labels.
- Turn animation off for people who prefer reduced motion, as in the code above.
- Check it in high contrast mode, where Windows may override colours; the fallback colour keeps the text visible.
Page builders: If your theme or builder sets a heading colour, gradient text can still look solid in the editor preview. Check the live page, and clear the builder’s colour setting if the gradient doesn’t appear.
Using text effects in WordPress and page builders
Page builders let you set a heading colour and a basic shadow, but not gradient, outline or image-filled text. The CSS text effects generator has a “Paste into” menu that rewrites the CSS to target the heading inside Elementor, Divi, Bricks, Breakdance or a WordPress Heading block, with steps for where to paste it. Your heading stays editable in the builder.
Try it
Open the CSS text effects generator, type your own words, pick an effect and set the colours, then preview it on light and dark backgrounds before copying. For the gradient itself, the CSS gradient generator gives finer control over angles and stops.
Last checked: October 2026.
Sources: MDN: background-clip, MDN: -webkit-text-stroke, MDN: box-decoration-break.


