How to use the CSS Gradient Generator
- 1Choose the gradient type: linear, radial or conic.
- 2Set the angle and edit, add or remove colour stops.
- 3Try a preset for a quick start.
- 4Copy the CSS and paste it into your stylesheet.
What is a CSS gradient generator?
A CSS gradient generator builds the code for a smooth blend between colours that you can use as a background on any web page. This one creates the three CSS gradient types (linear, radial and conic), supports any number of colour stops, shows a live preview and copies ready-to-paste CSS, including a fallback colour and a Tailwind class.
Gradients replace background images in many designs. They are just text, so they add almost nothing to page weight and stay sharp on every screen.
How do CSS gradients work?
A gradient is a CSS image generated by the browser. You give it a direction or shape and a list of colour stops (MDN: Using CSS gradients).
linear-gradient(angle, stops)blends along a straight line.0deggoes upward,90degto the right,180degdownward.radial-gradient(circle, stops)blends outward from the centre in rings.conic-gradient(from angle, stops)blends around the centre like the hands of a clock. It is handy for pie charts and colour wheels.
Each colour stop is a colour plus a position from 0% to 100%. Between two stops, the browser blends the colours evenly. If two stops share the same position, you get a hard line instead of a blend, which is how stripes are made.
The generated code puts a plain background colour first and the gradient second. Very old browsers that do not understand gradients simply use the plain colour.
Worked example
You want a header that fades from deep green on the left to mint on the right.
- Choose Linear and set the angle to 90°.
- Set stop 1 to
#0f6957at 0% and stop 2 to#78d8baat 100%. - The tool outputs:
background: #0f6957;
background: linear-gradient(90deg, #0f6957 0%, #78d8ba 100%);
Move stop 2 to 60% and the mint colour is reached earlier, leaving the right 40% solid mint. Add a third stop of #ffffff at 100% and the header ends in white.
Gradient types compared
| Type | Shape | Good for | Main setting |
|---|---|---|---|
| Linear | Straight band | Headers, buttons, page backgrounds | Angle |
| Radial | Circles from the centre | Spotlights, glows, soft vignettes | Shape and centre |
| Conic | Sweep around a point | Pie charts, colour wheels, loading rings | Start angle |
Tips for good-looking gradients
- Use colours that are close on the colour wheel for smooth blends. Blending opposites like red and green passes through a muddy grey in the middle.
- Add a middle stop when a blend looks dull. A slightly brighter mid-colour keeps it vivid.
- Keep text readable. Check your text colour against the darkest and lightest parts of the gradient with the Color Palette Generator.
- Borrow colours from your brand or photos with the Color Picker from Image.
- Pair a gradient card with a soft shadow from the Box Shadow Generator.
- If your stylesheet grows large, shrink it with the Code Minifier.
Limitations
- Banding: long, subtle gradients across large screens can show visible steps because screens have limited colour levels. Adding a tiny amount of noise in a design tool, or using a shorter blend, helps.
- Radial options are simplified. This tool uses a centred circle. CSS also supports ellipses, custom sizes and off-centre positions, which you can add by hand (for example
radial-gradient(circle at 20% 30%, ...)). - Interpolation colour space: browsers blend in sRGB by default. Newer CSS lets you choose spaces like
oklchfor smoother blends, which this tool does not add. - Tailwind class uses an arbitrary value; very long gradients are easier to manage in a CSS file.
Key terms
- Colour stop: a colour at a set point along the gradient.
- Angle: the direction of a linear gradient, in degrees.
- Fallback: a simpler style used when a browser does not support the main one.
Frequently asked questions
Do CSS gradients work in all browsers?
Linear and radial gradients work in every current browser. Conic gradients are supported in all major current browsers too.
Are gradients better than images?
Usually, yes. A CSS gradient is a few bytes of text, scales to any size and needs no extra download.
What do the stop percentages mean?
Each stop says where along the gradient its colour is fully reached. 0% is the start and 100% is the end.
How do I keep text readable on a gradient?
Check the contrast of your text against both the lightest and darkest part of the gradient with the Color Palette Generator.
Last updated: . Written and tested by Abdul Moid Khan, ATechCraft. Read how we build and test tools.