How to build a gradient and copy the CSS
- Choose Type: Linear for a gradient that runs along a direction, Radial for one that spreads out from a point.
- Set your colours. You can paste a list such as
#2193b0, #6dd5edinto Quick colour list and press Apply colours. You can also edit each stop in the rows under the track, where every row has a colour picker, a HEX text field and a position from 0 to 100. - Drag the round handles on the track to move stops. Each Add colour stop click inserts a new stop halfway between the last two stops, up to eight in total. The × button removes a stop, but there are always at least two.
- For a linear gradient, set the angle with the slider or the number field next to it (0–360). For a radial gradient, pick Shape (Circle or Ellipse) and move the horizontal and vertical centre sliders. The preview shows the centre with a small marker.
- Press Copy CSS to put the declaration on your clipboard. Download CSS saves the same text as
gradient.css.
When you apply a pasted list, the stops are spread out evenly: two colours land at 0% and 100%, three at 0%, 50% and 100%, and four at 0%, 33%, 67% and 100%. After that you can move each one by hand.
What the generated CSS looks like
Every result is two background lines. The first is a solid fallback that uses the first stop's colour, for browsers that can't read the second line. The second is the gradient, with every stop's position written out. Colours are converted to lowercase.
The Ocean example (two colours, 135°):
background: #2193b0;
background: linear-gradient(135deg, #2193b0 0%, #6dd5ed 100%);
Four short HEX colours at 180°, which runs from top to bottom:
background: #f00;
background: linear-gradient(180deg, #f00 0%, #0f0 33%, #00f 67%, #000 100%);
An elliptical radial gradient with its centre moved to the lower left (horizontal 20%, vertical 80%):
background: #ffffff;
background: radial-gradient(ellipse at 20% 80%, #ffffff 0%, #7028e4 100%);
If you leave the centre at 50% / 50%, the output still includes at 50% 50%. That is the same as the CSS default, so you can delete it if you want shorter code.
Where these gradients are useful
- Hero sections and banners: build a two- or three-colour linear gradient and paste the declaration into the section's rule.
- Image overlays for readable text: use 8-digit HEX values with an alpha channel, for example
#000000ccat 0% and#00000000at 100% at 0deg. This gives a scrim that is dark at the bottom and fades out towards the top, which you can layer over a photo. - Spotlight or glow backgrounds: choose Radial, move the centre towards one corner and use a light colour fading into your brand colour.
- Matching a design file: type the exact HEX values and stop positions from a mockup into the stop rows instead of judging them by eye on the track.
If you only have a colour in RGB or HSL, convert it first with the Color Converter. If you have no colours chosen yet, the Color Palette Generator can suggest a harmonious set to use as stops.
Limits and edge cases
- Colours must be HEX in 3-, 6- or 8-digit form, each with a leading
#. Names likered,rgb(),hsl()and 4-digit HEX are not accepted. In the quick colour list, an invalid entry shows an error message and no CSS is generated. In a stop's HEX field, an invalid value is ignored and the previous colour comes back. - You need 2–8 stops. With fewer than two or more than eight, the quick list shows the error and doesn't change the editor.
- Stop positions are whole percentages from 0 to 100. Dragging and arrow keys snap to whole numbers. The tool doesn't produce pixel positions, hard colour bands written with two positions per stop, or colour hints between stops. Add those by hand after copying.
- Stops are re-sorted by position after every change, so dragging one past another swaps their order in the CSS.
- Only
linear-gradientandradial-gradientare generated. Repeating gradients,conic-gradient, radial size keywords such asclosest-side, and stacked multiple backgrounds are not available. - The angle must be between 0 and 360. A value outside that range removes the output until you correct it.
The full syntax, including the parts this editor doesn't write, is described in MDN's linear-gradient() reference. For a walkthrough of angles, stop placement and fallbacks, see How to Build a CSS Gradient: Angles, Stops and Fallbacks.