CSS Gradient Generator
Design a linear or radial CSS gradient with up to four colours and copy the code.
Runs in your browser — nothing is uploaded
Gradient
Colour stops (2 of 4)
- 0%
- 100%
CSS
How to use CSS Gradient Generator
- 1
Choose Linear or Radial. For linear, set the Angle with the slider or one of the preset buttons; for radial, choose Circle or Ellipse.
- 2
Pick a colour for each stop and drag its Position slider. Click Add stop for up to four colours, or × to remove one.
- 3
Watch the preview at the top, and click Reverse colours to flip the direction.
- 4
Click Copy CSS to copy the background declaration into your stylesheet.
About this tool
The tool writes standard CSS: linear-gradient() for a gradient along a straight line and radial-gradient() for one that spreads out from the centre. In a linear gradient, 0deg runs bottom to top, 90deg left to right and 180deg top to bottom. Each colour stop has a position as a percentage of the gradient line, and the browser blends smoothly between neighbouring stops.
Stops are written in position order, which is what CSS expects. Two stops at the same position make a hard line instead of a blend, a handy trick for stripes. All current browsers support these gradients without vendor prefixes.
Browsers blend gradients in sRGB, so two strongly contrasting hues, such as blue to yellow, can pass through a dull grey in the middle. Adding a third stop with a brighter in-between colour keeps the gradient lively. Gradients are drawn by the browser, so they stay sharp at any screen size and add nothing to page weight.
Questions people ask
How do I add a gradient background in CSS?
Use the background or background-image property with a gradient function, for example background: linear-gradient(135deg, #ffe45c 0%, #2f6fde 100%);.
Which direction is 0deg in a CSS linear gradient?
0deg points up, so the gradient runs from the bottom to the top. Angles increase clockwise: 90deg goes left to right.
Can I use more than four colours?
CSS allows any number of stops, but this tool keeps to four for a clean result. You can add more stops to the copied code by hand.
Do CSS gradients work in all browsers?
Yes. linear-gradient() and radial-gradient() work in every current browser without prefixes.
Related tools
- Color Palette GeneratorBuild a colour scheme from one base colour and export it as CSS variables.
- Color PickerPick a colour and copy its HEX, RGB, HSL, HSV and CMYK values, with tints and shades.
- Contrast CheckerCheck the WCAG contrast ratio between text and background colours, with AA and AAA results.
- HEX to RGB ConverterConvert a HEX colour code to RGB and HSL, or edit any value to convert the other way.