CSS gradient generator
A CSS gradient is an image the browser draws from color stops: linear-gradient(135deg, #6366F1, #EC4899) blends two colors along a 135-degree line. Pick the type, angle and stops, preview it, and copy the CSS.
Linear gradient
linear-gradient(135deg, #6366F1, #EC4899)
2 stops · fallback #6366F1
- Pass · Stop positions in ascending orderall automatic
- Fail · White text at least 4.5:1 everywherelowest 3.52:1 at 100%
- Pass · Black text at least 4.5:1 everywherelowest 4.63:1 at 18.8%
CSS
background: #6366F1; background-image: linear-gradient(135deg, #6366F1, #EC4899);
- Gradient value
- linear-gradient(135deg, #6366F1, #EC4899)
- Fallback color
- #6366F1
- Lowest contrast with white text
- 3.52:1 at 100%WCAG AA asks for 4.5:1 for normal text
- Lowest contrast with black text
- 4.63:1 at 18.8%
| Stop | Color | Position written | Drawn at | White text | Black text |
|---|---|---|---|---|---|
| 1 | #6366F1 | auto | 0% | 4.46:1 | 4.70:1 |
| 2 | #EC4899 | auto | 100% | 3.52:1 | 5.95:1 |
- The solid #6366F1 comes first and the gradient second, because the background shorthand resets background-image. A browser that can't draw the gradient keeps the solid color; one that can paints the gradient over it.
- Text over a gradient sits on a different color at every point, so it has to meet contrast at every point it crosses, not just at one stop. The lowest ratios above are measured along the whole gradient; to test one exact text and background pair, use our color contrast checker.
- Here the darkest point, at 18.8%, lies between #6366F1 and #EC4899 and is darker than both: CSS Color 4 has browsers blend HEX colors in gamma-encoded sRGB, and the middle of that blend can be darker than its ends. Checking only the stop colors would miss it for dark text.
How does a CSS gradient work?
A CSS gradient is an image the browser draws from a list of color stops. linear-gradient(135deg, #6366F1, #EC4899) blends indigo into pink along a line at 135 degrees. For the angle, 0deg points up and angles turn clockwise, so 90deg points right and 180deg, the default, points down.
radial-gradient() spreads the colors out from a center as an ellipse (the default) or a circle, sized by default to reach the corner of the box farthest from the center. conic-gradient() sweeps them around a center like a color wheel, starting at the top unless a from angle rotates it. Linear and radial gradients have worked across browsers since July 2015 and conic gradients since November 2020, according to MDN.
Each stop can have a position. Without one, CSS places the first stop at 0%, the last at 100% and any others evenly between their neighbors. A stop placed before an earlier one is moved up to the largest earlier position, which draws a hard edge. In a conic gradient this tool writes positions as angles, 3.6 degrees per percent.
Gradients are images, so they go in background-image (or the background shorthand), never in background-color. The output puts a solid fallback color first, then the gradient: the background shorthand resets background-image, so the order matters.
Text over a gradient has a different background at every point, so it needs enough contrast at every point. The tool samples the whole gradient, blending HEX colors in gamma-encoded sRGB as CSS Color 4 requires for them, and reports the lowest WCAG contrast ratio for white and for black text.
linear-gradient(<angle>, <color> [<position>%], …) 0deg = up, clockwise radial-gradient(<circle | ellipse> at <position>, <stops>) conic-gradient(from <angle> at <position>, <color> [<angle>], …) background: <first stop>; ← fallback background-image: <gradient>;
What are the defaults of each CSS gradient function?
| Function | Direction or shape | Center | Size or start | Works across browsers since |
|---|---|---|---|---|
| linear-gradient() | to bottom (180deg); 0deg is to top, 90deg to right, 270deg to left | — | Line sized so the first and last colors land exactly on the box's corners | July 2015 |
| radial-gradient() | ellipse, or circle | center | farthest-corner | July 2015 |
| conic-gradient() | Clockwise from the top | center | from 0deg | November 2020 |
How to make a CSS gradient
- 1Choose the typePick linear for a straight blend, radial for one that spreads from a center, or conic for one that sweeps around it.
- 2Set the directionEnter the angle for a linear gradient, the shape and center for a radial one, or the start angle and center for a conic one.
- 3Pick the stopsChoose two to four colors and, if you want, a position for each; leave positions empty to space them evenly.
- 4Check contrast and copyRead the lowest contrast for white and black text, then copy the two lines of CSS: the fallback color and the gradient.
Frequently asked questions
Why does my CSS gradient show a hard line between two colors?
Can I use a gradient as background-color?
Which way does 0deg point in linear-gradient?
Why put a solid background color before the gradient?
How do I check text contrast on a gradient background?
Sources
- CSS Images Module Level 3 (W3C Candidate Recommendation Draft): linear and radial gradients, angles, color stop fixup §3.4.3 (checked 20 Oct 2026)
- CSS Images Module Level 4 (W3C Working Draft): conic-gradient() (checked 20 Oct 2026)
- MDN: linear-gradient() (checked 20 Oct 2026)
- MDN: radial-gradient() (checked 20 Oct 2026)
- MDN: conic-gradient() (checked 20 Oct 2026)
- MDN: background shorthand (resets the properties it doesn't set) (checked 20 Oct 2026)
- MDN: CSS error handling (a declaration a browser can't parse is ignored) (checked 20 Oct 2026)
- CSS Color Module Level 4, §13.2 color space for interpolation (legacy colors in gamma-encoded sRGB) (checked 20 Oct 2026)
- Understanding WCAG 2.2 SC 1.4.3 Contrast (Minimum), incl. failure F83 for background images (checked 20 Oct 2026)
Need this, but tailored to your brand?
We design UI, UX, and interfaces that feel as good as they look.
Built by CountryDevs · No signup · No ads · We count visits, never what you enter