CSS Gradient Generator
Gradients turn flat blocks of colour into depth — a soft purple fade behind a hero section, a sunrise blend on a button, a dark vignette over a photo. Writing the CSS by hand means remembering the angle syntax and guessing how the colours will blend.
Pick your colours, set the angle, watch the live preview, and copy the CSS — linear or radial, two colours or three.
Preview & CSS
How It Works
A CSS gradient is a smooth blend between two or more colours. A linear gradient blends along a straight line at an angle: 0 degrees points up, 90 degrees points right, 180 degrees points down. A radial gradient blends outward from a centre point, like a spotlight. Each colour sits at a stop — a position along the blend, measured in percent — and the browser fills in every shade in between.
The CSS for a gradient is a single background value: linear-gradient(135deg, #667eea 0%, #764ba2 100%). The first colour starts at 0%, the last ends at 100%, and any middle stop sits where you put it — a middle stop at 50% splits the blend evenly. The preview box above shows exactly what the CSS produces, so what you see is what your site gets.
Worked Example
A diagonal blend from #667eea (a soft indigo) to #764ba2 (a muted purple) at 135 degrees gives background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); — the classic purple gradient used on countless landing pages. Add a middle stop of #f093fb (pink) at 50% and the CSS becomes linear-gradient(135deg, #667eea 0%, #f093fb 50%, #764ba2 100%).
How to Use This Tool
Pick your colours and angle, watch the preview update live, and copy the CSS when you are happy.
- Choose a type. Linear blends in one direction; radial blends outward from the centre.
- Pick two colours. Use the colour pickers or type hex values directly. Tick "Add a middle colour stop" for a three-colour blend.
- Set the angle. Drag the slider or click a direction preset — 135 degrees diagonal is a popular choice.
- Copy the CSS. Click Copy CSS and paste the
backgroundline into your stylesheet.
The preview updates as you change anything, so you can try colours freely until the blend looks right.
Tips and Practical Advice
- Keep gradients subtle for text backgrounds. A gentle blend keeps text readable; a loud one fights with it. If text sits on the gradient, check the contrast at both ends.
- Pick colours that are neighbours. Colours close on the wheel (blue to purple, teal to green) blend smoothly; opposites (red to green) pass through a muddy middle. A color palette generator builds a harmonious set to start from.
- Use the middle stop for sunsets. Three stops — deep blue, pink, warm orange — make a sunset blend that two colours cannot reach.
- Gradients are just CSS. The output works in every modern browser with no prefix needed, and it costs zero bytes of image downloads.
How Gradient Stops Shape the Blend
A gradient is defined by its colour stops — each stop is a colour plus a position along the blend, measured in percent. The browser fills in every shade between neighbouring stops, so the stops are the whole design: two stops make one smooth blend, three stops make two blends joined at the middle colour. Where you put the middle stop decides where the blend pivots — at 50% the two halves are equal, at 25% the first colour dominates and the second half of the blend is compressed into the remaining 75%.
Angles follow a convention that trips people up: in CSS, 0deg points up, not right. Degrees are measured clockwise from the vertical, so 90deg points right, 180deg points down and 270deg points left — the opposite of the maths convention, where 0° points right and angles run anticlockwise. The keyword directions say the same thing in words: “to bottom” is 180deg and “to bottom right” is 135deg. A diagonal of 135deg runs from the top-left corner to the bottom-right, which is why it is the most popular angle for hero sections — it follows the direction the eye naturally scans.
Two stops at the same position make a hard edge instead of a blend. linear-gradient(90deg, #3b82f6 0%, #3b82f6 50%, #f59e0b 50%, #f59e0b 100%) is blue for the left half and amber for the right half, with a sharp line down the middle — no blending at all, because there is no distance between the two 50% stops for the browser to interpolate across. The same trick makes stripes: repeat the pattern at 0%, 25%, 50%, 75% and 100% and you get four bands. This generator builds up to three stops; for a hard edge, copy the CSS it produces and edit the stop positions by hand.
A radial gradient works the same way, but the blend runs outward from a centre point instead of along a line: the first colour is at the centre and the last at the edge. This generator produces circle-shaped radial gradients, so the blend reaches the edge at the same rate in every direction. Whatever the type, a gradient is pure CSS — no image is downloaded, it scales to any screen size without losing quality, and it costs nothing in page weight. The one thing gradients cannot do smoothly is animate: browsers cannot transition between two different gradient values, so a gradient that needs to change should fade in over a solid background colour instead.
Last reviewed: 21 November 2026.
Frequently Asked Questions
What is the difference between linear and radial gradients?
A linear gradient blends colours along a straight line at an angle — top to bottom, left to right, or diagonal. A radial gradient blends outward from a centre point, like a spotlight or a glow.
What angle should I use?
135 degrees (diagonal, top-left to bottom-right) is the most popular choice for hero sections. 90 degrees runs left to right, 180 degrees runs top to bottom. Any angle from 0 to 360 works.
Can I use more than two colours?
Yes — tick 'Add a middle colour stop' for a three-colour blend, and set where the middle colour sits (50% splits the blend evenly).
Will the CSS work in all browsers?
Yes. The linear-gradient and radial-gradient syntax is supported in every modern browser with no vendor prefix needed.
How do I make a hard edge instead of a blend?
Put two stops at the same position — for example, blue at 50% and amber at 50% gives a sharp line down the middle, because there is no distance for the browser to blend across. This generator builds up to three stops, so copy its CSS and edit the stop positions by hand for hard edges or stripes.
Why does 0deg point up?
CSS measures gradient angles clockwise from the vertical, so 0deg points up, 90deg points right and 180deg points down. It is the opposite of the maths convention, where 0° points right. The keyword 'to bottom' means the same as 180deg.
Last updated: