CSS Gradient Generator
The CSS Gradient Generator builds linear, radial and conic gradients from 2 to 5 colours, shows a live preview, and gives you CSS ready to paste, with a solid colour fallback. It can also blend in Oklab or OKLCH for a cleaner middle, with a classic line for older browsers.
What is the CSS Gradient Generator?
The CSS Gradient Generator writes the background code for a colour gradient so you do not have to remember the syntax. Choose linear, radial or conic, set the angle or the centre, pick 2 to 5 colours and where each sits, and the preview and code update as you go. The output uses background-color as a fallback and background-image for the gradient, so it does not reset other background settings. You can repeat the pattern for stripes, reverse the colours, start from a few ready combinations, and blend in the Oklab or OKLCH colour space, which avoids the grey, muddy middle that two bright colours often get in plain sRGB. Web designers, front-end developers, students and people styling a blog or Notion-style page use it.
Who it is for: Web designers, front-end developers, students learning CSS, and bloggers or small business owners styling a header, button or banner.
How to use the CSS Gradient Generator
- Choose linear, radial or conic, and set the angle or centre.
- Choose how many colours, then pick each colour and its position.
- Optionally blend in Oklab or OKLCH, or repeat the pattern.
- Check the preview and press Copy CSS.
Why use it
- Three gradient typesLinear for straight blends, radial for glows and spotlights, conic for pie charts and colour wheels.
- Cleaner colour blendsBlend in Oklab or OKLCH to keep the middle bright, with a plain sRGB line kept first for older browsers.
- Safe CSSA solid colour fallback comes first, and background-image leaves your other background settings alone.
- Quick to try ideasPresets, a reverse button and an even-spacing button let you test a look in seconds.
At a glance
- What you put in
- Gradient type, angle or centre, shape, 2 to 5 hex colours with positions, colour space, repeat and fallback options
- What you get
- CSS: background-color fallback and background-image with linear-gradient, radial-gradient or conic-gradient (or the repeating forms), plus a live preview
- Limits
- 2 to 5 colour stops; hex colours only (#rgb, #rrggbb, with or without alpha); one gradient layer; no animation
- Privacy
- Runs in your browser. Nothing you enter is uploaded or stored.
- Price
- Free for everyone. No subscriptions, no payments, no watermark.
- Works offline
- Yes, once the page has loaded
- Last checked
- by AK Shine
Worked example
Linear, 90 degrees, 3 colours: #0ea5e9 at 0%, #22c55e at 50%, #facc15 at 100%, sRGB, fallback on
background-color: #0ea5e9; background-image: linear-gradient(90deg, #0ea5e9 0%, #22c55e 50%, #facc15 100%);
90deg runs from left to right; 180deg, the default in CSS, runs from top to bottom. Choosing 3 colours spaced them at 0, 50 and 100% automatically. With OKLCH chosen, a second background-image line with "in oklch" is added after this one.
When to use something else
- For text with a gradient fill, or for animated gradients, you need extra CSS (background-clip: text, or @property with an animation) that this tool does not write. Copy the gradient here and add those rules yourself.
- Very subtle gradients can show visible bands on some screens. If you see stripes, use colours a little further apart, or add a light noise texture image on top.
Questions people ask
How do I make a gradient background in CSS?
Set background-image to a gradient function, for example background-image: linear-gradient(90deg, #0ea5e9, #facc15). Add background-color with a solid colour before it, so something still shows if the gradient cannot be drawn.
What does the angle in linear-gradient mean?
It is the direction the colours travel. 0deg goes from bottom to top, 90deg from left to right, 180deg from top to bottom, which is the default, and 270deg from right to left. Angles go clockwise.
What is the difference between linear, radial and conic gradients?
Linear blends along a straight line. Radial spreads out from a centre point in a circle or ellipse. Conic sweeps around a centre point like the hands of a clock, which suits pie charts and colour wheels.
Why does the middle of my gradient look grey?
In the default sRGB blend, two bright opposite colours such as blue and yellow pass through a dull grey. Choose Oklab or OKLCH under Blend colours in. All current major browsers have supported this since 2024; the CSS keeps a plain line first for older ones.
How do I make hard stripes instead of a smooth blend?
Give two colours the same position, for example red 0%, red 50%, blue 50%, blue 100%, and you get a sharp line. Tick Repeat the pattern to make the stripes repeat across the element.
Can I use transparent colours?
Yes. Type an 8 digit hex code such as #0ea5e980, where the last two digits set the opacity, or #0000 for fully transparent. The colour picker itself only offers solid colours.
Is the CSS Gradient Generator free?
Yes. It is free with no subscriptions, works offline once loaded, and the code it writes is yours to use in any project without credit.