CSS gradient text is a visual effect where text characters display a color gradient instead of a single solid color. Instead of plain black or blue text, you can create text that transitions smoothly from one color to another -- or through multiple colors -- using pure CSS. No images, no JavaScript, no external dependencies.
This technique has become increasingly popular in modern web design, especially for hero headlines, landing pages, brand typography, and dark-mode interfaces. Companies like Apple, Stripe, Vercel, and Linear use gradient text prominently in their marketing sites.
The CSS gradient text technique relies on three key properties working together:
.gradient-text {
background: linear-gradient(90deg, #ff6b6b, #4ecdc4);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
Here is what each property does:
| Property | Purpose |
|---|---|
background | Applies a gradient as the element's background |
-webkit-background-clip: text | Clips the background to the text shape only |
-webkit-text-fill-color: transparent | Makes text color transparent so gradient shows through |
background-clip: text | Standard property (include alongside -webkit- prefix) |
The background-clip: text property originated as a WebKit extension. While it is now part of the CSS specification and supported by all modern browsers, the -webkit- prefix is still needed for full compatibility. Always include both the prefixed and standard versions.
You can use color: transparent instead of -webkit-text-fill-color: transparent. However, -webkit-text-fill-color has higher specificity and is more reliable for gradient text:
/* Using color: transparent */
.gradient-text {
background: linear-gradient(90deg, #ff6b6b, #4ecdc4);
-webkit-background-clip: text;
color: transparent;
background-clip: text;
}
/* Preferred: -webkit-text-fill-color */
.gradient-text {
background: linear-gradient(90deg, #ff6b6b, #4ecdc4);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
Linear gradients are the most common type for gradient text. They transition colors along a straight line at a specified angle or direction.
/* Left to right gradient */
.heading {
background: linear-gradient(to right, #667eea, #764ba2);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
/* Angled gradient */
.heading-angled {
background: linear-gradient(135deg, #f093fb, #f5576c);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
Linear gradients support both keyword directions and degree angles:
/* Keyword directions */
background: linear-gradient(to right, ...); /* 90deg */
background: linear-gradient(to left, ...); /* 270deg */
background: linear-gradient(to bottom, ...); /* 180deg (default) */
background: linear-gradient(to top, ...); /* 0deg */
background: linear-gradient(to bottom right, ...); /* 135deg */
/* Degree angles */
background: linear-gradient(0deg, ...); /* bottom to top */
background: linear-gradient(45deg, ...); /* diagonal */
background: linear-gradient(90deg, ...); /* left to right */
background: linear-gradient(180deg, ...); /* top to bottom */
Control where each color starts and ends using percentage positions:
.precise-gradient {
background: linear-gradient(
90deg,
#ff6b6b 0%,
#feca57 30%,
#4ecdc4 70%,
#667eea 100%
);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
Radial gradients radiate from a center point outward, creating circular or elliptical gradient effects on text.
.radial-text {
background: radial-gradient(circle, #ff6b6b, #4ecdc4);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
/* Positioned radial gradient */
.radial-offset {
background: radial-gradient(circle at top left, #667eea, #764ba2);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
/* Elliptical */
.elliptical-text {
background: radial-gradient(ellipse at center, #f093fb, #f5576c);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
Linear gradients work best for horizontal text flows where you want color to transition across the text. Radial gradients create a spotlight or focal point effect, drawing attention to the center of the text. For most heading use cases, linear gradients are more predictable and visually balanced.
CSS gradients support unlimited color stops, allowing you to create rainbow effects, brand-specific multi-color gradients, or subtle multi-tone text.
/* Three-color gradient */
.three-color {
background: linear-gradient(90deg, #ff6b6b, #feca57, #4ecdc4);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
/* Rainbow text */
.rainbow {
background: linear-gradient(
90deg,
#ff0000, #ff8000, #ffff00,
#00ff00, #0080ff, #8000ff
);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
/* Subtle two-tone */
.subtle {
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
Create sharp transitions between colors by placing two color stops at the same position:
.hard-stop {
background: linear-gradient(
90deg,
#ff6b6b 0%, #ff6b6b 33%,
#feca57 33%, #feca57 66%,
#4ecdc4 66%, #4ecdc4 100%
);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
The direction of the gradient dramatically affects how it appears on text. Horizontal gradients work well for single-line text, while vertical gradients suit multi-line headings.
/* Horizontal: best for single-line headings */
.horizontal {
background: linear-gradient(to right, #ff6b6b, #4ecdc4);
}
/* Vertical: best for multi-line text */
.vertical {
background: linear-gradient(to bottom, #667eea, #764ba2);
}
/* Diagonal: creates dynamic visual flow */
.diagonal {
background: linear-gradient(to bottom right, #f093fb, #f5576c);
}
/* Each needs background-clip and text-fill-color */
Use degree values for precise directional control. 0deg points upward, 90deg points right, and values rotate clockwise:
.custom-angle {
background: linear-gradient(127deg, #00f260, #0575e6);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
You can animate gradient text by changing background-position or background-size with CSS keyframe animations.
@keyframes gradient-shift {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
.animated-gradient {
background: linear-gradient(
-45deg,
#ee7752, #e73c7e, #23a6d5, #23d5ab
);
background-size: 300% 300%;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
animation: gradient-shift 6s ease infinite;
}
Create gradient text that changes on hover:
.gradient-hover {
background: linear-gradient(90deg, #667eea, #764ba2);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
transition: background 0.3s ease;
}
.gradient-hover:hover {
background: linear-gradient(90deg, #f093fb, #f5576c);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
Animating background-position is not GPU-accelerated and triggers paint operations. For smooth performance, keep animated gradient text to hero sections or small elements. Avoid animating gradient text on many elements simultaneously. Consider using will-change: background-position for optimization.
Gradient text should scale responsively. Use relative font sizes and consider how the gradient appears at different viewport widths.
.responsive-gradient {
background: linear-gradient(90deg, #ff6b6b, #4ecdc4);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
font-size: clamp(2rem, 5vw, 4.5rem);
font-weight: 800;
line-height: 1.1;
}
/* Adjust gradient direction for mobile */
@media (max-width: 640px) {
.responsive-gradient {
background: linear-gradient(to bottom, #ff6b6b, #4ecdc4);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
}
The clamp() function is ideal for gradient text headings because it provides a smooth size range between minimum and maximum values. This ensures the gradient looks good at all viewport sizes without requiring multiple media queries.
While gradient text is visually appealing, accessibility requires careful consideration:
Ensure sufficient contrast between every color in your gradient and the background. The entire gradient range must meet WCAG contrast requirements (4.5:1 for normal text, 3:1 for large text). Avoid light gradients on light backgrounds or dark gradients on dark backgrounds.
/* Good: sufficient contrast on white background */
.accessible {
background: linear-gradient(90deg, #1a1a2e, #0f3460);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
/* Bad: low contrast on white background */
.inaccessible {
background: linear-gradient(90deg, #feca57, #f0f0f0);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
Always provide a solid color fallback for browsers or contexts that do not support gradient text:
.gradient-with-fallback {
color: #667eea; /* Fallback solid color */
background: linear-gradient(90deg, #667eea, #764ba2);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
Screen readers read the actual text content and are unaffected by gradient styling. The gradient is purely visual. No additional ARIA attributes are needed for gradient text.
color property as a fallback./* Mistake: forgetting background-clip */
.broken {
background: linear-gradient(90deg, #ff6b6b, #4ecdc4);
color: transparent;
/* Missing: -webkit-background-clip: text; */
/* Result: invisible text with gradient background behind */
}
/* Mistake: using on inline elements without display */
span.gradient {
background: linear-gradient(90deg, #ff6b6b, #4ecdc4);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
/* May need: display: inline-block; for proper rendering */
}
CSS gradient text is supported in all modern browsers:
The -webkit- prefix is still recommended alongside the standard background-clip: text for maximum compatibility. This is one of the few cases where the WebKit prefix is still practically required in 2026.
Our free CSS Gradient Text Generator lets you create gradient text effects visually and export production-ready CSS code.
Design beautiful gradient text effects visually with our free generator. Choose colors, set direction, customize font, and copy production-ready CSS code -- all in your browser.
Try the Gradient Text GeneratorMaster linear, radial, and conic gradients with color stops and effects.
Master box shadows: offset, blur, spread, inset, multiple shadows, and performance.
Master color format conversion between HEX, RGB, HSL, and HSV.