CSS gradients are rendered by the browser rather than downloaded, so they scale to any size with no file to fetch and no pixelation. For backgrounds, buttons and overlays they are strictly better than an image.
How to use the Gradient Generator
- Choose linear or radial
- Pick your colours and adjust the direction
- Move the colour stops to control where the transition happens
- Copy the generated CSS
Linear and radial
Linear gradients run along a straight line. The direction comes first — an angle (135deg) or a keyword (to bottom right). 0deg points up, 90deg points right.
background: linear-gradient(135deg, #7c6cff, #38bdf8);Radial gradients spread outward from a point, useful for spotlights and soft background glows.
background: radial-gradient(circle at 30% 40%, #7c6cff, transparent);Colour stops let you control where each colour sits: linear-gradient(90deg, red 0%, yellow 30%, blue 100%) compresses the red-to-yellow transition into the first third.
Why gradients sometimes look muddy
Browsers interpolate in sRGB, which can route a transition through an unexpectedly grey midpoint. Blue to yellow is the classic offender — the midpoint comes out a dull grey rather than green.
Two practical fixes. Add an intermediate colour stop to steer the path through a hue you actually want. Or use colours that are near each other on the colour wheel, which avoids long interpolation paths entirely and generally looks more professional.
The other common problem is banding — visible stripes instead of a smooth blend, most noticeable on large areas with subtle colour changes. Greater contrast between the stops, or a very subtle noise overlay, both help.
Conic gradients and the third type
CSS supports three gradient functions, and the third is the least used and often the right one.
conic-gradient() sweeps colour around a centre point rather than along a line or outwards from a point. That makes it the natural way to build things that are otherwise fiddly: a pie chart in pure CSS, a colour wheel, a progress ring, or a subtle angular sheen on a card.
A pie chart is a single declaration — conic-gradient(#7c6cff 0 40%, #38bdf8 40% 75%, #34d399 75% 100%) gives three segments with no SVG and no JavaScript.
All three accept a repeating variant. repeating-linear-gradient() produces stripes, hazard tape and graph-paper backgrounds; repeating-conic-gradient() produces a checkerboard or a starburst. These replace a surprising number of background images.
Worth knowing: a gradient is an image in CSS terms, so it goes in background-image and can be layered with other backgrounds, comma separated. It cannot go in background-color, which is why a gradient declared there silently does nothing.
Gradient techniques that are not backgrounds
Because a gradient is an image, it works anywhere an image does — which enables several effects that look like they need a graphics tool.
Gradient text. Apply the gradient as a background, clip it to the glyphs, and make the text transparent:
background: linear-gradient(135deg, #7c6cff, #38bdf8); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
Keep a solid color declared first as a fallback, and check contrast against the background at both ends of the gradient rather than just one.
Gradient borders. border-image works but disallows rounded corners. The usual approach layers two backgrounds with different background-clip values, or places a gradient-filled pseudo-element behind the element.
Fading an edge. A gradient from the background colour to transparent, overlaid on the bottom of a scrollable area, produces the fade that signals more content below.
Masking. Used as a mask-image, a gradient fades any element — including an image or a video — without altering the asset itself.
Frequently asked questions
Are CSS gradients better than image backgrounds?
For solid colour transitions, yes — no HTTP request, no file size, infinitely scalable, and trivially themeable. Images remain necessary for photographic or complex textured backgrounds.
Why does my gradient look grey in the middle?
sRGB interpolation can pass through a desaturated midpoint, especially between complementary colours. Add an intermediate colour stop to steer the transition.
How do I apply a gradient to text?
Set the gradient as the background, then apply background-clip: text and color: transparent. Include the -webkit- prefixed properties for wider support.
Can I animate a gradient?
Not the colour stops directly — they are not animatable. The standard workaround is to make the background larger than the element and animate background-position, which produces a smooth moving effect.