How to use the CSS Gradient Generator
- 1
Choose linear or radial
Linear blends along a line at an angle; radial blends outward from the centre in a circle.
- 2
Pick colours and stop positions
Set up to three colours and slide each stop between 0% and 100% to decide where that colour is at full strength.
- 3
Try presets or randomise
Presets such as Sunset, Ocean and Night swap all three colours; the dice button also picks a random angle.
- 4
Copy the two lines
Copy the CSS: a solid colour line followed by the gradient line, ready for any background.
Features
Full-circle angle
Linear gradients accept any angle from 0° to 360°.
Adjustable stops
Every colour has its own position slider, so blends can be wide, narrow or sharp.
Six presets
Sunset, Ocean, Mint, Peach, Night and Lime are ready-made three-colour starting points.
Random button
Generates three random colours and a random angle when you need inspiration.
Solid fallback line
The first colour is written as a plain background before the gradient line.
Large live preview
The preview band updates instantly with every slider movement.
Who uses it — and for what
Hero sections
A soft branded backdrop behind a headline without loading an image.
Buttons and badges
Subtle top-to-bottom blends that give buttons depth.
App splash screens
Full-screen colour washes that scale to every phone size.
Students
Learning how angles and stop positions change a gradient.
Linear vs radial gradients
A linear-gradient blends colours along a straight line at the angle you set: 0° runs bottom to top, 90° left to right and 135° diagonally from the top-left. A radial-gradient spreads colours outward from the centre in a circle or ellipse. Colour stops are the percentage positions where each colour is pure; moving two stops close together makes a sharp edge, spreading them out makes a soft blend.
Using the CSS
Copy the code into any CSS rule, usually as background or background-image. A solid fallback colour comes first for very old browsers; every modern browser supports gradients without vendor prefixes. Gradients are drawn by the browser, so they load instantly and stay sharp on any screen — great for hero sections, buttons and cards. For text gradients add background-clip: text; color: transparent;.
Reading the angle and stop numbers
In CSS, gradient angles follow a compass rather than school maths: 0deg points up, 90deg points right and 180deg points down. So 90deg means the first colour is on the left and the last on the right. The keyword forms to right and to bottom are exact equivalents of 90° and 180°.
Corner keywords behave differently from angles, though. to bottom right adjusts the angle to the shape of the box so the middle colour runs neatly from the top-right to the bottom-left corner, while 135deg keeps the same tilt on any box. On a wide banner the two look noticeably different; if you want the diagonal to follow the corners, edit the copied angle into the keyword form.
Stop positions are percentages of the gradient line. Between two stops the browser blends evenly; before the first stop and after the last one the colour stays solid. That is why moving stop 1 from 0% to 30% creates a solid band of colour 1 across the first 30%.
Avoiding muddy middles and banding
Browsers traditionally blend gradient colours in the sRGB colour space, which takes a straight line between the two colours’ red, green and blue values. Between colours on opposite sides of the colour wheel — blue to orange, or green to pink — that straight line passes through greyish, desaturated shades. Three common fixes:
- Add a middle stop with a bright in-between hue, which is exactly what the third colour is for (Sunset goes orange → pink → violet rather than orange → violet).
- Choose neighbouring hues; the presets mostly stay within one family, such as Mint’s three greens.
- In browsers that support newer colour syntax, add an interpolation space by hand, for example
linear-gradient(in oklch 90deg, …). Keep the generated line above it as the fallback, because older browsers will ignore the whole declaration they don’t understand.
Banding — visible steps in a long, subtle gradient — appears when two very similar colours are stretched across a large screen, especially on 8-bit displays. Make the colours slightly further apart, shorten the distance, or lay a faint noise texture on top. For patterned rather than smooth backgrounds, see the CSS Pattern Generator; for blob-like multi-point colour, the Gradient Mesh Generator stacks several radial gradients.
Worked examples
Default diagonal blend
The starting settings (linear, 135°, three colours at 0%, 50% and 100%) produce:
background: #4f46e5;
background: linear-gradient(135deg, #4f46e5 0%, #db2777 50%, #f59e0b 100%);Two-colour radial
Apply the Sunset preset, switch to Radial and untick “Use 3 colours”. The second colour automatically moves to 100%, giving:
background: #f97316;
background: radial-gradient(circle, #f97316 0%, #db2777 100%);The angle slider is ignored for radial gradients.
A hard split for a two-tone banner
Set colours 1 and 2 to the same navy (#0f172a), colour 3 to amber (#f59e0b), angle 90°, and stops at 0%, 60% and 60%:
background: linear-gradient(90deg, #0f172a 0%, #0f172a 60%, #f59e0b 60%);Because two stops share 60%, the colours change with a crisp vertical edge instead of a blend.
Pro tips
- The radial option always uses a centred circle; edit
circletocircle at top leftin the copied code to move its centre. - A gradient is a background image, so it can sit on top of a photo: list it first in
background-imagewith transparent stops. - Keep text over gradients readable by testing the lightest and darkest stop with the Contrast Checker.
Glossary
- Colour stop
- A colour plus the position along the gradient where it is at full strength.
- Gradient line
- The imaginary line, set by the angle, along which a linear gradient’s colours are laid out.
- Banding
- Visible stripes in a smooth gradient caused by too few distinct colour values across a large area.
- Interpolation space
- The colour model used to calculate in-between shades, such as sRGB or OKLCH.
Frequently asked questions
Do I need -webkit- prefixes?
No, all current browsers support standard gradient syntax.
How do I make a hard colour edge?
Put two stops at the same percentage.
Can I use a gradient on text?
Yes, with background-clip: text and transparent text colour.
Why does the second stop slider stop working with two colours?
When “Use 3 colours” is off, the tool pins colour 2 to 100% so the gradient always reaches the end. Move stop 1 instead, or turn the third colour back on.
Can I make a radial gradient an ellipse?
The tool writes circle. Delete the word circle in the copied code and the browser draws an ellipse that matches the shape of the box.
Last updated 2026-11-28 · Built by Vinayak Agarwal · Part of CSS & Design (37 tools)