In 2024, we can do this cross-browser, with no vendor prefixes!
p {
background-image: linear-gradient(red, blue);
color: transparent;
background-clip: text;
}
Some things to note:
- A lot of the old examples use
-webkit-text-fill-colorrather thancolor. The two are actually functionally identicial[1] (and both supporttransparent!),-webkit-text-fill-colorjust takes precidence. The reason this was used in old examples was because it provided a graceful fallback for non-webkit browsers --- any non-webkit browser that ignored the gradient or clip instructions would also ignore the-webkit-text-fill-colorinstruction, meaning that you wouldn't be left with transparent text on unsupported browsers. I guess this is a problem with this cross browser implementation, in that that we can't do a fallback like this, but it'll really only be a problem for really old browsers like IE11. background-clipis now standards tracked and implemented in all browsers. However, it took Chrome a long time to support thetextclip option on the non-vendor prefixed one, with this only coming in Chrome 120, released mid 2023! As such, using bothbackground-clip: text(for e.g. Firefox) and-webkit-background-clip: textwas the best solution until just very recently, and you might still need both unless you're only targeting ultra-modern browser versions.
CSS Gradient
cssgradient.io βΊ blog βΊ css-gradient-text
CSS Gradient Text β CSS Gradient
Add eye-catching gradient effects to your website text using pure CSS. Learn how to create vibrant, image-free text gradients with step-by-step syntax examples and tips.
css text gradient - Stack Overflow
I've had a little look around and can't find anything about this. If I have a paragraph of text, is there a way, maybe with CSS3 to gradually change the colour of the text as it goes down to the pa... More on stackoverflow.com
Gradient not working when there's a background color
You need to use -webkit- before that gradient and the background-clip. You also need to use -webkit-text-fill-color, instead of color. CSS: #maintitle { background: -webkit-linear-gradient(90deg, red, blue); -webkit-background-clip: text; -webkit-text-fill-color: transparent; display: inline-block; } Codepen: https://codepen.io/andybeckmann/pen/NWXWRmq?editors=1100 Resource: https://cssgradient.io/blog/css-gradient-text/ More on reddit.com
Buttons with gradient border and cut corners.
You'd be able to do something like this with an SVG
More on reddit.comPure CSS3 text color gradient - Is it possible?
Short answer: no. Use pngs, or realize that your design will never look the same in all browsers.
Build a solid foundation and use things like text gradients as frosting for people who have browsers that support these kinds of pretty add ons.
More on reddit.comVideos
00:48
CSS Tip - Gradient Text Effect #shorts - YouTube
08:01
How to Create CSS Text Gradients - YouTube
05:56
How to Create Simple Text Gradient Animation using HTML & CSS - ...
05:02
Create Amazing Gradient Text Animation Using HTML CSS | Step by ...
00:52
Gradient text with CSS | CSS Tip of the Day #shorts - YouTube
00:46
How to add gradient color on Text with CSS? #shorts - YouTube
Top answer 1 of 7
54
In 2024, we can do this cross-browser, with no vendor prefixes!
p {
background-image: linear-gradient(red, blue);
color: transparent;
background-clip: text;
}
Some things to note:
- A lot of the old examples use
-webkit-text-fill-colorrather thancolor. The two are actually functionally identicial[1] (and both supporttransparent!),-webkit-text-fill-colorjust takes precidence. The reason this was used in old examples was because it provided a graceful fallback for non-webkit browsers --- any non-webkit browser that ignored the gradient or clip instructions would also ignore the-webkit-text-fill-colorinstruction, meaning that you wouldn't be left with transparent text on unsupported browsers. I guess this is a problem with this cross browser implementation, in that that we can't do a fallback like this, but it'll really only be a problem for really old browsers like IE11. background-clipis now standards tracked and implemented in all browsers. However, it took Chrome a long time to support thetextclip option on the non-vendor prefixed one, with this only coming in Chrome 120, released mid 2023! As such, using bothbackground-clip: text(for e.g. Firefox) and-webkit-background-clip: textwas the best solution until just very recently, and you might still need both unless you're only targeting ultra-modern browser versions.
2 of 7
21
You can do it using CSS but it will only work in webkit browsers (Chrome and Safari):
p {
background: linear-gradient(red, blue);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
}
<p>blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah</p>
Fossheim
fossheim.io βΊ writing βΊ posts βΊ css-text-gradient
How to add a gradient overlay to text with CSS by Sarah L. Fossheim
We can do this by adding a background-color property to the text as well. .gradient-text { background-color: #f3ec78; background-image: linear-gradient(45deg, #f3ec78, #af4261); background-size: 100%; -webkit-background-clip: text; -moz-background-clip: text; -webkit-text-fill-color: transparent; -moz-text-fill-color: transparent; }
DEV Community
dev.to βΊ learnwithparam βΊ gradient-text-style-using-css-11ka
Gradient text style using CSS - DEV Community
April 14, 2019 - .gradient-text { // set the background color background: linear-gradient(to right, #ff8a00 0%, #da1b60 100%); // background color masked along the text and clip away the rest -webkit-background-clip: text; // make fill color to transparent so that masked background color will be shown -webkit-text-fill-color: transparent; }
CSS Gradient
cssgradient.io
CSS Gradient β Generator, Maker, and Background
As a free CSS gradient generator tool, this website lets you create a colorful gradient background for your website, blog, or social media profile.
W3Schools
w3schools.com βΊ css βΊ css3_gradients.asp
CSS Gradients
The CSS gradient functions let you display smooth transitions between two or more colors within an element.
Prismic
prismic.io βΊ blog βΊ css-hover-effects
CSS Hover Effects: 40 Engaging Animations To Try
December 11, 2024 - This animation creates an "explosive" effect when the element is hovered over. It works with the ::before and ::after pseudo-elements, which produces the radial gradient effect and scale up and rotate on hover. This animation creates a unique hover effect where underlines appear above and below the text when the user hovers over it.
CodyHouse
codyhouse.co βΊ nuggets βΊ text-gradients
Text Gradients in CSS | CodyHouse
November 24, 2020 - .text-gradient { /* π show a solid color in older browsers (e.g., IE11) */ color: darkblue; } /* π show the text gradient in modern browsers */ @supports (--css: variables) { .text-gradient { background: linear-gradient(to right, darkblue, darkorchid); color: transparent; -webkit-background-clip: text; background-clip: text; } }
DEV Community
dev.to βΊ fossheim βΊ how-to-add-a-gradient-overlay-to-text-with-css-2f99
How to add a gradient overlay to text with CSS - DEV Community
January 19, 2020 - We can do this by adding a background-color property to the text as well. .gradient-text { background-color: #f3ec78; background-image: linear-gradient(45deg, #f3ec78, #af4261); background-size: 100%; -webkit-background-clip: text; -moz-background-clip: text; -webkit-text-fill-color: transparent; -moz-text-fill-color: transparent; }