CSSApril 2026·12 min read

The Complete Guide to CSS Gradients

CSS gradients let you create smooth transitions between two or more colors without using images. They render as backgrounds, are infinitely scalable, and load faster than any image file. This guide covers everything from basic linear gradients to advanced layering techniques.

🌈
Try the Gradient Builder
Build and preview CSS gradients visually — free, no signup
DG
Derek Giordano
Designer & Developer
In this guide
01What Are CSS Gradients?02Linear Gradients03Radial Gradients04Conic Gradients05Color Stops & Positioning06Repeating Gradients07Gradient Text Effects08Layering Multiple Gradients09Performance Considerations10Real-World Examples11Browser Support
⚡ Key Takeaways
  • Master CSS gradients: linear, radial, and conic.
  • What Are CSS Gradients?.
  • Covers linear gradients.
  • Covers radial gradients.
  • Covers conic gradients.

What Are CSS Gradients?

A CSS gradient is a special type of image generated by the browser. Instead of loading a file from a server, gradients are created on the fly using mathematical functions that blend colors together. You can use them anywhere you'd use a background image: on divs, buttons, text, borders, and even pseudo-elements.

There are three types of CSS gradients, each producing a different visual effect. Linear gradients blend colors along a straight line. Radial gradients spread outward from a center point in a circular or elliptical shape. Conic gradients sweep colors around a center point like a color wheel.

Because gradients are rendered by the browser rather than downloaded as files, they're resolution-independent and scale perfectly on any screen — from a 4K monitor to a Retina mobile display. They also reduce HTTP requests, which can improve page load times compared to background images.

Linear Gradients

Linear gradients are the most commonly used gradient type. They create a smooth color transition along a straight line — by default from top to bottom.

💡 Tip
Always include -webkit-backdrop-filter alongside backdrop-filter for Safari support. Without the prefix, the effect is invisible to roughly 25% of mobile users.

Basic syntax

The simplest linear gradient requires just two colors. The browser blends them evenly from top to bottom:

background: linear-gradient(#FF6B6B, #FFA62E);
linear-gradient(#FF6B6B, #FFA62E)

Changing direction

You can control the gradient direction using angle values or keyword directions. An angle of 0deg points upward, 90deg points right, 180deg points down (the default), and 270deg points left. You can also use keywords like to right, to bottom left, etc.

/* Using angles */ background: linear-gradient(135deg, #0575E6, #00F2FE); /* Using keywords */ background: linear-gradient(to right, #A18CD1, #FBC2EB);
135deg — diagonal from top-left

Multi-stop linear gradients

You're not limited to two colors. Add as many color stops as you want to create complex, multi-toned blends. The browser distributes stops evenly unless you specify positions:

background: linear-gradient( 135deg, #FF6B6B 0%, #FFA62E 25%, #43E97B 50%, #0575E6 75%, #A18CD1 100% );
Five-stop rainbow gradient

Hard color stops

When two adjacent color stops share the same position, you get a sharp edge instead of a smooth blend. This technique is useful for creating stripes and geometric patterns:

background: linear-gradient( #FF6B6B 0%, #FF6B6B 33%, #FFA62E 33%, #FFA62E 66%, #43E97B 66%, #43E97B 100% );
Hard stops — stripe effect

Radial Gradients

Radial gradients radiate outward from a central point, creating a circular or elliptical color blend. They're commonly used for spotlight effects, glowing buttons, and decorative backgrounds.

⚠ Warning
On iOS Safari, backdrop-filter inside a position: fixed element can cause severe scroll performance issues. Test thoroughly on real iOS devices.

Basic radial syntax

background: radial-gradient(circle, #FF6B6B, #0A0A0F);
radial-gradient(circle, #FF6B6B, #0A0A0F)

Shape and size

Radial gradients accept a shape keyword — circle or ellipse (the default). You can also control how far the gradient extends using size keywords: closest-side, farthest-corner, or explicit pixel/percentage values.

/* Ellipse positioned at top-left */ background: radial-gradient( ellipse at top left, #A18CD1 0%, #0A0A0F 70% );
Ellipse at top left

Conic Gradients

Conic gradients transition colors around a center point, like slices of a pie chart. They were the last gradient type to gain widespread browser support, and they unlock some unique visual effects that aren't possible with linear or radial gradients.

background: conic-gradient( from 0deg, #FF6B6B, #FFA62E, #F7D94E, #43E97B, #0575E6, #A18CD1, #FF6B6B );
Color wheel using conic-gradient

Conic gradients are especially useful for creating pie charts, color wheels, progress rings, and decorative border effects. You can combine them with border-radius: 50% to create circular patterns.

Color Stops & Positioning

Color stops are the individual colors in a gradient and their positions along the gradient line. Understanding how to place them precisely gives you fine control over the blending behavior.

When you don't specify positions, colors are distributed evenly. The first color defaults to 0% and the last to 100%. But you can place any stop at a specific percentage or length value:

/* Most of the gradient is coral, with a fast transition to orange at the end */ background: linear-gradient( #FF6B6B 0%, #FF6B6B 70%, #FFA62E 100% );

You can also use the two-value syntax to define both the start and end position of a single color, which is a shorthand for hard stops:

/* Equivalent hard-stop shorthand */ background: linear-gradient( #FF6B6B 0% 50%, #FFA62E 50% 100% );

Color hints (midpoints)

A color hint is a plain percentage value placed between two color stops. It shifts the midpoint of the transition — the point where the blend is 50/50 between the two colors. This lets you create asymmetric fades:

background: linear-gradient(#FF6B6B, 25%, #0575E6); /* Midpoint shifted to 25% instead of default 50% */

Repeating Gradients

CSS provides repeating versions of all three gradient types: repeating-linear-gradient, repeating-radial-gradient, and repeating-conic-gradient. They tile the gradient pattern to fill the element.

/* Diagonal stripes */ background: repeating-linear-gradient( 45deg, #FF6B6B 0px, #FF6B6B 10px, transparent 10px, transparent 20px );
Repeating diagonal stripes

Repeating gradients are excellent for creating striped backgrounds, progress indicators, and decorative patterns. The key is defining color stops with explicit length values (like pixels) rather than percentages — this way the pattern tiles at a fixed size regardless of the element's dimensions.

Gradient Text Effects

You can apply gradients directly to text using a combination of background-clip and transparent text color. This technique is widely used for headings and hero text:

h1 { background: linear-gradient(135deg, #FF6B6B, #FFA62E); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

This works because the gradient is applied as a background, then clipped to only show through the text shape. The text color is set to transparent so the gradient shows through. Note that you need the -webkit- prefixed versions for full cross-browser support.

Layering Multiple Gradients

Since gradients are treated as background images in CSS, you can stack multiple gradients on a single element using comma separation. This opens up possibilities for complex patterns and effects:

background: linear-gradient(45deg, rgba(0,255,209,0.3), transparent 50%), linear-gradient(135deg, rgba(5,117,230,0.3), transparent 50%), linear-gradient(225deg, rgba(0,255,209,0.3), transparent 50%), #0A0A0F;
Three layered gradients

When layering gradients, use semi-transparent colors (via rgba or hsla) so the layers below remain visible. The first gradient in the list renders on top.

Performance Considerations

CSS gradients are generally very performant since they're rendered by the GPU. However, there are a few things to keep in mind for optimal performance.

Avoid animating gradient properties directly — this forces the browser to repaint on every frame. Instead, animate the element's transform or opacity while keeping the gradient static. If you need an animated gradient effect, animate background-position on an oversized gradient using background-size: 200% 200%.

Extremely complex gradients with many stops on large elements can cause slow paints on lower-end devices. Test on real hardware if you're stacking multiple gradients with many stops. In most cases, gradients with up to 5-6 stops perform identically to 2-stop gradients.

Real-World Examples

Frosted glass card background

background: linear-gradient( 135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100% ); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.1);

Combining a subtle gradient with backdrop-filter creates the popular glassmorphism effect — a translucent surface with a blurred background.

Animated gradient button

.btn { background: linear-gradient(135deg, #FF6B6B, #FFA62E); background-size: 200% 200%; transition: background-position 0.5s ease; } .btn:hover { background-position: 100% 100%; }

This creates a button whose gradient shifts on hover — a smooth, eye-catching interaction that requires no JavaScript.

Gradient border

.card { border: 2px solid transparent; background-image: linear-gradient(#0A0A0F, #0A0A0F), linear-gradient(135deg, #FF6B6B, #A18CD1); background-origin: border-box; background-clip: padding-box, border-box; }

The double-background technique lets you create gradient borders on any element. The first background covers the padding area with a solid color, while the second gradient shows through the transparent border.

Browser Support

Linear and radial gradients have excellent support across all modern browsers. They've been supported without prefixes since approximately 2015. Conic gradients achieved full cross-browser support more recently, with all major browsers now supporting them. Repeating variants have the same support as their non-repeating counterparts.

For legacy browser support, you can provide a solid color fallback before the gradient declaration. Browsers that don't understand the gradient syntax will use the solid color instead:

background: #00FFD1; /* Fallback */ background: linear-gradient(135deg, #FF6B6B, #FFA62E);
Build gradients visually

Use the Ultimate Design Tools Gradient Builder to create linear, radial, and conic gradients with a visual editor. Drag color stops, adjust angles, and copy the CSS with one click.

⚡ Open Gradient Builder
DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.
📚 References & Further Reading
⚡ Try the free Mesh Gradient Generator →
⚡ Try the free Particle Background Generator →