How to Make Text Gradient in CSS
Learn to create stunning gradient text effects using CSS background-clip. Step-by-step tutorial with live interactive demos.
What is CSS Text Gradient?
CSS text gradient is a technique that fills text with a gradient color blend instead of a solid color. It creates eye-catching typography using:
- background-clip: text - Clips the gradient to the text shape
- Transparent text color - Allows gradient to show through
- Linear or radial gradients - Multiple gradient types supported
- Animation ready - Can be animated for dynamic effects
Popular on landing pages, hero sections, and modern web designs to create visually striking headlines.
Gradient Text
Step-by-Step Tutorial
Follow these 5 simple steps to create gradient text. Click any code block to copy.
Create a Text Element
Start with any text element - headings work best since gradient effects are more visible on larger text.
Apply a Gradient Background
Add a linear-gradient (or radial-gradient) as the background. Choose colors that blend well together.
Clip Background to Text Shape
The magic happens here! background-clip: text clips the gradient to the text shape. Include the -webkit- prefix for Safari.
Make Text Transparent
Set color: transparent so the gradient shows through. Without this, the text color will cover the gradient.
Add Display Property
Add display: inline-block to ensure the gradient applies correctly. This prevents the background from extending beyond the text.
Live Interactive Demo
Customize your gradient text and copy the generated CSS.
Gradient Text
.gradient-text {
background: linear-gradient(90deg, #667eea, #f093fb);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
display: inline-block;
}Linear Gradient Text Examples
Popular linear gradient combinations for text. Click any example to try it in the demo above.
Radial Gradient Text Examples
Radial gradients create a circular color blend, perfect for unique text effects.
Cosmic
radial-gradient(circle, #667eea, #764ba2, #f093fb)Sunrise
radial-gradient(circle, #ffecd2, #fcb69f)Northern Lights
radial-gradient(ellipse, #00c6ff, #0072ff, #7c3aed)Golden Hour
radial-gradient(circle, #f093fb, #f5576c, #f093fb)Animated Gradient Text
Create eye-catching animated gradient text using CSS animations.
Animated Text
CSS Code
/* Animated Gradient Text */
.animated-gradient-text {
background: linear-gradient(
90deg,
#ff6b6b,
#feca57,
#48dbfb,
#ff9ff3,
#ff6b6b
);
background-size: 300% 100%;
-webkit-background-clip: text;
background-clip: text;
color: transparent;
animation: gradient-shift 3s ease infinite;
}
@keyframes gradient-shift {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}Tailwind CSS Text Gradient
Create gradient text easily with Tailwind CSS utility classes.
Gradient Text
from-purple-500 via-pink-500 to-red-500
Diagonal Gradient
bg-gradient-to-br from-green-400 to-blue-500
Multi-color
from-indigo-500 via-purple-500 to-pink-500
Tailwind Code
<!-- Tailwind CSS Text Gradient --> <h1 class="bg-gradient-to-r from-purple-500 via-pink-500 to-red-500 bg-clip-text text-transparent"> Gradient Text </h1> <!-- Different directions --> <p class="bg-gradient-to-br from-green-400 to-blue-500 bg-clip-text text-transparent"> Diagonal Gradient </p> <!-- Three color stops --> <p class="bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 bg-clip-text text-transparent"> Multi-color Gradient </p>
Browser Support
background-clip: text Browser Support
Text gradient using background-clip: text has excellent browser support:
Chrome
4+
Firefox
49+
Safari
5+ (prefix)
Edge
15+
Opera
15+
Always include -webkit-background-clip: text for Safari and older Chrome versions. Global browser support is over 97%.
Frequently Asked Questions
To create gradient text in CSS, apply a gradient background to your text element, then use background-clip: text (with -webkit-background-clip: text for Safari) and set the text color to transparent. This clips the gradient to the shape of the text, creating the gradient text effect.
The most common issues are: 1) Missing the -webkit- prefix for Safari/Chrome compatibility, 2) Not setting color: transparent so the gradient shows through, 3) The element needs display: inline-block or block for the background to apply properly. Make sure you have all three: background-clip: text, -webkit-background-clip: text, and color: transparent.
Yes! You can animate gradient text by using a larger background-size (like 200% or 300%) and animating the background-position property. This creates a smooth moving gradient effect. You can also animate using CSS @keyframes for more complex animations like color-shifting gradients.
In Tailwind CSS, use the classes: bg-gradient-to-r (or other directions), from-[color], to-[color], bg-clip-text, and text-transparent. For example: className="bg-gradient-to-r from-purple-500 to-pink-500 bg-clip-text text-transparent"
Yes, gradient text works in all modern browsers including Chrome, Firefox, Safari, Edge, and Opera. The -webkit-background-clip: text property is needed for Safari and older Chrome versions. The effect has excellent browser support as of 2024/2025 with over 97% global coverage.
More CSS Tutorials
Copy CSS from Website
Extract styles with 2 clicks
Center a Div (CSS)
Flexbox, Grid, and more
Center a Div (Tailwind)
Utility classes for centering
Convert CSS to Tailwind
CSS to utility classes
Glassmorphism Effect
Frosted glass UI style
Neumorphism Button
Soft UI button design
Responsive Navbar
Mobile-friendly navigation
Sticky Header
Fixed navigation on scroll
CSS Pagination
Page navigation styles
CSS Accordion
Expandable content sections
Dropdown Menu
Hover and click dropdowns
CSS Modal
Popup dialog boxes
Toast Notifications
Animated alert messages
Hamburger Menu
Animated menu icon
Animate Gradients
Moving gradient backgrounds
Skeleton Loader
Loading placeholder UI
Element Screenshot
Capture any element as image
Pick Color from Website
Eyedropper tool comparison
Identify Fonts
Find fonts on any website
Download All Images
Bulk save images from any site
Measure Elements
Page ruler and measurements
Extract Colors from Website
Get any color palette instantly
Dark Mode Toggle
CSS variables and localStorage
Responsive Grid
CSS Grid auto-fit and minmax
Center Text in CSS
text-align, Flexbox, and Grid
Make Text Bold
font-weight values explained
Add Shadow in CSS
box-shadow, text-shadow, drop-shadow
Round Corners in CSS
border-radius and pill shapes
Style File Input
Custom upload buttons
