To fill text with a colour gradient instead of a single colour, you paint the gradient as the element’s background and then cut the background down to the shape of the letters. It takes three CSS lines and no images, and the text stays real text that can be selected, copied and read by screen readers and search engines.
.gradient-text { background: linear-gradient(to bottom right,#f27990, #332b75); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } What each line does:
background: linear-gradient(to bottom right, #f27990, #332b75) paints a gradient across the element’s box, from pink in the top-left corner to dark purple in the bottom-right corner. You can add more colours, separated by commas, or change the direction, for example to right. -webkit-background-clip: text clips the background to the text, so the gradient is only painted where there are letters. -webkit-text-fill-color: transparent makes the letters themselves transparent, so the gradient behind them shows through. Without it, the normal text colour would cover the gradient. To use it, add the class to any element, for example <h2 class="gradient-text">. The live example below uses the same three rules under the class name gradt, with slightly different colours (#f27370 to #442b75).
...