We need the -webkit- prefix so Internet Explorer doesn't render a background for us. The -webkit-conic-gradient property doesn't actually exist.
Why are the gradient angles different to the gradient generator?īecause the -webkit-linear-gradient property takes its angles a little bit differently to linear-gradient.
This allows IE to gracefully fall back to just rendering the text. Unfortunately Internet Explorer does not support this property at all, so instead of setting the background to linear-gradient and the color to transparent, we set the background to -webkit-linear-gradient and the -webkit-text-fill-color to transparent. Goodbye.Although background-clip: text is currently not officially supported, it's actually fairly well supported (over 95%) when using the -webkit prefix. This is some old example code, let’s get rid of it.ĭot gradient dash text would be like this.Īnd now that we've defined this class, we can just use it every time we want to have this gradient text effect, directly in our HTML. Then, we can customize the colors and change the gradient, going from cyan to magenta.Īnd of course, if you have something against using inline styling, or need to reuse the effect throughout your site more than one time, you can define a class in the CSS. Pasting inside the “style” definition does immediately deliver the expected results. I'm gonna first copy the three necessary CSS statements from the example on the CSS tricks website.
#Css text gradient code
So I'm going to open the code editor and just try to add some inline style to demonstrate how this can happen. Let’s make it more peculiar by adding the gradient text effect to the heading. We're going to create a new Live Canvas page draft.
#Css text gradient how to
So let's have a look at how to do things in practice.
So green light! These properties are safe to use, and the effect will work fine even on mobile devices. If you have a look at the “Can I use” website, you can see that the “text-fill” property is actually supported pretty well on all browsers except Internet Explorer, which is quite dead anyway.Īnd also the “background clip” property has great support as well. So the first question would be: Can those properties be safely used? Unless you’re a CSS ninja, you may never have heard of them. We have the “background” property, where a gradient is defined.īut the magic happens with the last two properties, the ones with the webkit prefix: webkit text fill and webkit text stroke. Let’s just ignore the “font-size” property which is not important for the effect. And this one is also ten years old - but still relevant! I really recommend you reading his articles. We're gonna see this by having a look at an article on CSS tricks, a fantastic website, which actually is one of the best resources to learn cool CSS and HTML stuff.īy the way, Chris Coyier is one of those names you can’t ignore if you are passionate about websites and programming. So gradient text is possible on the web combining three simple CSS properties. You may already have seen this effect a number of times - it’s quite popular nowadays on many websites.īefore we get started, just a little bit about the theory. So we're going to try to replicate something that looks like this. In this short video, we're going to have a look at how we can achieve some gradient text effect and how to use it in LiveCanvas. The linear-gradient CSS function takes two color values: ff8a00 (the orange) DD4C4F (the red) And it’s supposed to spread from 0 to 100 evenly, as specified in the CSS: (to right, ff8a00 0, DD4C4F 100) So we want this on the text element: Notice how the two colors are evenly applied.