DEV Community

Ed is Taking Note
Ed is Taking Note

Posted on • Updated on

[CSS trick] Create a Linear Gradient Text

  1. Set a linear gradient background for the text.
  2. Set -webkit-background-clip to text.
  3. Set the original text color to transparent.

Example:

.some-text {
  background-image: linear-gradient(to right, red, orange, yellow, green, blue, purple);
  -webkit-background-clip: text;
  color: transparent;
} 
Enter fullscreen mode Exit fullscreen mode

Result:
Image description

Discussion (1)

Collapse
andrewbaisden profile image
Andrew Baisden

Cool snippet.