DEV Community

loading...

Easy way to make text gradient color css

Nikhil Chandra Roy
Front-End Web Developer with JavaScript, ReactJs and Backend Python(Django)
・1 min read

I was browsing a website and got the point to make a text gradient color, it's just a simple post.

for HTML text

<h1> Hello World </h1>

Enter fullscreen mode Exit fullscreen mode

and CSS

h1{
  background: linear-gradient(red 30%, green, blue) center/cover no-repeat;
  color: white;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

Enter fullscreen mode Exit fullscreen mode

2 new css property is

-webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
Enter fullscreen mode Exit fullscreen mode

Thanks.

Discussion (0)

Forem Open with the Forem app