{"id":140,"date":"2026-10-18T21:10:29","date_gmt":"2026-10-18T21:10:29","guid":{"rendered":"https:\/\/refracttools.com\/blog\/?p=140"},"modified":"2026-10-18T21:10:29","modified_gmt":"2026-10-18T21:10:29","slug":"css-gradient-text","status":"publish","type":"post","link":"https:\/\/refracttools.com\/blog\/css-techniques\/css-gradient-text\/","title":{"rendered":"CSS gradient text, outline and glow effects"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">To make gradient text in CSS, set a gradient as the element&#8217;s background, clip the background to the letters with <code>background-clip: text<\/code>, and make the text fill transparent so the gradient shows through. The same idea gives you image-filled and animated gradient text, while <code>-webkit-text-stroke<\/code> makes outline text and <code>text-shadow<\/code> makes glows and long shadows. The text stays real, selectable and readable by screen readers and search engines.<\/p>\n\n\n\n<div class=\"wp-block-group is-style-refract-takeaways is-layout-constrained wp-block-group-is-layout-constrained\">\n<h3 class=\"wp-block-heading\">Key takeaways<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Gradient text = gradient background + <code>background-clip: text<\/code> + transparent text fill.<\/li>\n\n\n<li>Include the <code>-webkit-<\/code> lines; they are still needed in Safari and harmless elsewhere.<\/li>\n\n\n<li>Give a solid colour fallback inside <code>@supports<\/code>, so text never disappears.<\/li>\n\n\n<li>Keep effects for short, large headings and check the contrast of the lightest colour.<\/li>\n<\/ul>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">How do you make gradient text in CSS?<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>.gradient-text {\n  color: #7b5cff; \/* fallback if clipping isn't supported *\/\n}\n\n@supports (background-clip: text) or (-webkit-background-clip: text) {\n  .gradient-text {\n    background: linear-gradient(90deg, #ff7a59, #7b5cff);\n    -webkit-background-clip: text;\n            background-clip: text;\n    -webkit-text-fill-color: transparent;\n            color: transparent;\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>-webkit-text-fill-color<\/code> overrides any colour set by your theme or page builder, which is the most common reason gradient text shows as a solid block. The <code>@supports<\/code> wrapper means a browser that can&#8217;t clip the background shows plain coloured text instead of invisible text.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Gradient text that wraps onto two lines<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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 <code>display: inline-block<\/code> to treat the heading as one box, or <code>box-decoration-break: clone<\/code> (with its <code>-webkit-<\/code> version) to repeat the full gradient on every line.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Which CSS text effects can you make?<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><div class=\"table-scroll\" tabindex=\"0\" role=\"region\" aria-label=\"Scrollable table\"><table><thead><tr><th>Effect<\/th><th>Main property<\/th><th>Works best for<\/th><\/tr><\/thead><tbody><tr><td>Gradient<\/td><td><code>background-clip: text<\/code><\/td><td>Hero headings, brand words<\/td><\/tr><tr><td>Animated gradient<\/td><td><code>background-size<\/code> + animated <code>background-position<\/code><\/td><td>One highlighted word, used sparingly<\/td><\/tr><tr><td>Outline<\/td><td><code>-webkit-text-stroke<\/code><\/td><td>Very large display type<\/td><\/tr><tr><td>Glow \/ neon<\/td><td>Stacked <code>text-shadow<\/code><\/td><td>Dark backgrounds, playful brands<\/td><\/tr><tr><td>Image fill<\/td><td><code>background-image<\/code> + <code>background-clip: text<\/code><\/td><td>Thick, heavy fonts at large sizes<\/td><\/tr><tr><td>Long shadow<\/td><td>Many offset <code>text-shadow<\/code> layers<\/td><td>Retro and poster styles<\/td><\/tr><\/tbody><\/table><\/div><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Animated gradient text<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>.gradient-text--animated {\n  background-size: 200% auto;\n  animation: shine 4s linear infinite;\n}\n\n@keyframes shine {\n  to { background-position: 200% center; }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .gradient-text--animated { animation: none; }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Outline and glow text<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>.outline-text {\n  -webkit-text-stroke: 2px #ffffff;\n  color: transparent;\n}\n\n.glow-text {\n  color: #fff;\n  text-shadow: 0 0 6px #7df0d4, 0 0 18px #2f8cff;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>-webkit-text-stroke<\/code> 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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Image-filled text<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.image-text {\n  background: url(\"texture.webp\") center \/ cover;\n  -webkit-background-clip: text;\n          background-clip: text;\n  -webkit-text-fill-color: transparent;\n  font-weight: 900;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Long shadow text<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A long shadow is a stack of <code>text-shadow<\/code> 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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why not use an image of the styled text?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A PNG of a styled headline can&#8217;t be read by screen readers without alt text, isn&#8217;t indexed as a heading by search engines, doesn&#8217;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.<\/p>\n\n\n<aside class=\"tool-card tool-card--inline\"><span class=\"swatch\" style=\"background:linear-gradient(90deg,#ff8a5c,#7a5cff,#5ce1c6)\" aria-hidden=\"true\"><\/span><div class=\"tool-card__body\"><p class=\"tool-card__eyebrow\">Free tool<\/p><p class=\"tool-card__name\">CSS text effects generator<\/p><p class=\"tool-card__blurb\">Gradient, outline, glow and image-filled text for any heading.<\/p><\/div><a class=\"btn primary\" href=\"https:\/\/refracttools.com\/css-text-effects\/\">Try it free <span aria-hidden=\"true\">\u2192<\/span><\/a><\/aside>\n\n\n\n<h2 class=\"wp-block-heading\">Are CSS text effects accessible?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Check the lightest and darkest stops<\/strong> against the background with a <a href=\"https:\/\/refracttools.com\/contrast-checker\/\">contrast checker<\/a>. Large text needs at least 3:1 for WCAG AA; see our guide to <a href=\"\/blog\/ui-design\/wcag-contrast-ratio\/\">contrast ratios<\/a>.<\/li>\n\n\n<li><strong>Keep effects for headings.<\/strong> Never apply them to paragraphs or form labels.<\/li>\n\n\n<li><strong>Turn animation off<\/strong> for people who prefer reduced motion, as in the code above.<\/li>\n\n\n<li><strong>Check it in high contrast mode<\/strong>, where Windows may override colours; the fallback colour keeps the text visible.<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-group is-style-refract-callout is-layout-constrained wp-block-group-is-layout-constrained\">\n<p class=\"wp-block-paragraph\"><strong>Page builders:<\/strong> 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&#8217;s colour setting if the gradient doesn&#8217;t appear.<\/p>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Using text effects in WordPress and page builders<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Page builders let you set a heading colour and a basic shadow, but not gradient, outline or image-filled text. The <a href=\"https:\/\/refracttools.com\/css-text-effects\/\">CSS text effects generator<\/a> has a &#8220;Paste into&#8221; 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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Try it<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Open the <a href=\"https:\/\/refracttools.com\/css-text-effects\/\">CSS text effects generator<\/a>, 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 <a href=\"https:\/\/refracttools.com\/css-gradient-generator\/\">CSS gradient generator<\/a> gives finer control over angles and stops.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Last checked: October 2026.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Sources: <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/background-clip\" rel=\"noopener\" target=\"_blank\">MDN: background-clip<\/a>, <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/-webkit-text-stroke\" rel=\"noopener\" target=\"_blank\">MDN: -webkit-text-stroke<\/a>, <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/box-decoration-break\" rel=\"noopener\" target=\"_blank\">MDN: box-decoration-break<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Gradient text, outline text, glows, image fills and long shadows, all in CSS. The code for each, how to stop gradient text showing as a solid block, and how to keep it readable.<\/p>\n","protected":false},"author":1,"featured_media":139,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_refract_tool":"css-text-effects","footnotes":""},"categories":[8],"tags":[4,49,47],"class_list":["post-140","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-css-techniques","tag-css-generators","tag-gradients","tag-typography"],"_links":{"self":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/comments?post=140"}],"version-history":[{"count":1,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/140\/revisions"}],"predecessor-version":[{"id":168,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/140\/revisions\/168"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/media\/139"}],"wp:attachment":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/media?parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/categories?post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/tags?post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}