CSS gradients create color transitions with code, no images needed. They're lightweight, scale without losing quality, and work for backgrounds, buttons and cards. If you'd rather adjust colors visually, the CSS gradient generator lets you pick the type, angle and stops, then copy the code.
What is a CSS gradient
A gradient is a gradual transition between two or more colors. In CSS it's generated with functions used as a background image (background-image or background), so you don't need files: it's all code the browser draws.
Linear gradient (linear-gradient)
The most common: colors flow in a straight line, in one direction.
background: linear-gradient(to right, #3b82f6, #8b5cf6);
- Direction: you can use words (
to right,to bottom) or an angle (90deg,45deg).0degis upward,90degto the right. - Multiple colors: add as many as you want separated by commas.
background: linear-gradient(45deg, #f59e0b, #ef4444, #8b5cf6);
Radial gradient (radial-gradient)
Colors radiate from a central point outward, in a circle or ellipse.
background: radial-gradient(circle, #3b82f6, #1e293b);
Useful for light spots, vignettes or backgrounds with depth. You can control the shape (circle/ellipse) and the center position (at top left).
Conic gradient (conic-gradient)
Colors rotate around a point, like clock hands. Perfect for color wheels, pie charts or circular effects.
background: conic-gradient(from 0deg, #ef4444, #f59e0b, #10b981, #ef4444);
Color stops
You can control where each color happens by adding a percentage:
background: linear-gradient(to right, #3b82f6 0%, #3b82f6 40%, #8b5cf6 100%);
Here blue takes the first 40% and then transitions. If you put two colors at the same position, you create a hard transition (solid bands instead of a gradient).
Transparency in gradients
Use colors with alpha (rgba or 8-digit HEX) for gradients that fade out, ideal for overlaying text on images:
background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
Practical tips
- Soften with nearby colors in hue for elegant gradients; very opposite colors can look harsh.
- Gradients on text: use
background-clip: textwith the text color set to transparent so the gradient shows through:
background: linear-gradient(90deg, #3b82f6, #8b5cf6);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
- Performance: gradients are lightweight, but animating a background forces the browser to repaint it on every frame. Where you can, animate
opacityortransforminstead. More detail in CSS animations and performance.
Frequently asked questions
Do gradients work in all browsers? linear-gradient and radial-gradient have been widely supported for many years. conic-gradient works from Chrome 69, Firefox 83 and Safari 12.1 (MDN). If you need older browsers, declare a solid color first as a fallback: background: #3b82f6; followed by the gradient.
Can I animate a gradient? Not directly in an efficient way; the usual trick is animating the background-position of a large gradient.
How many colors can I use? As many as you want, but 2-4 usually suffices for a clean result. The generator allows from 2 to 6 stops.
Is my data uploaded? No. The generator calculates the CSS in your browser and sends nothing to a server.
Create linear, radial and conic gradients visually with the free CSS gradient generator and copy the code instantly.