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.

deg

0 points up and angles turn clockwise: 90 points right, 180 down.

HEX, 3 or 6 digits

%

Leave empty to let CSS place it: the first stop at 0%, the last at 100% and the others evenly between.

%

Linear gradient

linear-gradient(135deg, #6366F1, #EC4899)

2 stops · fallback #6366F1

Sample text
  • 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%
Color stops: where each is drawn and the text contrast at that point
StopColorPosition writtenDrawn atWhite textBlack text
1#6366F1auto0%4.46:14.70:1
2#EC4899auto100%3.52:15.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?

Defaults from CSS Images Level 3 and 4 and MDN; browser support from MDN's Baseline data, checked 2026-10-20
FunctionDirection or shapeCenterSize or startWorks 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 cornersJuly 2015
radial-gradient()ellipse, or circlecenterfarthest-cornerJuly 2015
conic-gradient()Clockwise from the topcenterfrom 0degNovember 2020

How to make a CSS gradient

  1. 1
    Choose the typePick linear for a straight blend, radial for one that spreads from a center, or conic for one that sweeps around it.
  2. 2
    Set 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.
  3. 3
    Pick the stopsChoose two to four colors and, if you want, a position for each; leave positions empty to space them evenly.
  4. 4
    Check 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?
Two stops share a position, or a stop is placed before one listed earlier. CSS moves a stop like that up to the largest earlier position, so the colors meet without blending. Put the positions in ascending order, or leave them empty to space the stops evenly.
Can I use a gradient as background-color?
No. Gradients belong to CSS's image type, so linear-gradient() won't work on background-color or any other property that takes a color. Use background-image, or the background shorthand, and set a solid background-color as a fallback.
Which way does 0deg point in linear-gradient?
Up. 0deg is the same as to top, and angles turn clockwise from there: 90deg is to right, 180deg is to bottom and 270deg is to left. With no angle at all, a linear gradient runs to bottom.
Why put a solid background color before the gradient?
So there is a color if the gradient isn't drawn, such as in a browser that doesn't understand the syntax. The background shorthand resets background-image, so it goes first and background-image second; a browser that can draw the gradient paints it over the solid color.
How do I check text contrast on a gradient background?
Check the lowest point, not one stop. The text's background changes along the gradient, and the blend between two stops can be darker than both of them, so this tool samples the whole gradient and reports the lowest WCAG ratio for white and black text. WCAG AA asks for 4.5:1 for normal text.

Sources

Related tools

See all 73 free tools

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