Linear gradient
Colors blend along a straight line. Set any angle from 0 to 359 degrees, or click an arrow for one of the eight common directions.
.hero {
background: linear-gradient(
90deg,
#6366f1 0%,
#f59e0b 100%
);
}Make a linear, radial, or conic gradient, see it update as you go, and copy the CSS or Tailwind classes. Drag the color stops to change the blend. Everything runs in your browser.
Click the bar to add a color. Drag a handle to move it, or use the arrow keys.
Type a HEX code or pick a color.
background: linear-gradient(90deg, #6366f1 0%, #ec4899 50%, #f59e0b 100%);A CSS gradient is an image the browser draws from code by blending two or more colors. Because it counts as an image, you set it with the background or background-image property, not background-color.
There are three kinds: linear-gradient(), radial-gradient(), and conic-gradient(). Each takes a list of color stops, which are colors with a position such as #6366f1 0%. Gradients stay sharp at any size and add no image file for the page to download.
Choose Linear for a straight blend, Radial for a blend that spreads out from a point, or Conic for a blend that sweeps around a point.
Click a handle on the color bar, then pick a color or type a HEX code. Click anywhere on the bar to add another color, or start from one of the presets.
Drag the angle slider or click an arrow to change the direction. Drag the handles, or use the Position slider, to change where each color starts.
Choose CSS, Tailwind v4, or Tailwind v3 under the preview and click the copy button. Paste the CSS into your stylesheet, or the Tailwind classes into your HTML.
Colors blend along a straight line. Set any angle from 0 to 359 degrees, or click an arrow for one of the eight common directions.
.hero {
background: linear-gradient(
90deg,
#6366f1 0%,
#f59e0b 100%
);
}Colors spread out from a center point as an ellipse or a circle. Move the center to one of nine spots, such as the top left corner.
.spotlight {
background: radial-gradient(
circle at top left,
#6366f1 0%,
#f59e0b 100%
);
}Colors sweep around a center point like the hands of a clock. Good for color wheels and pie chart shapes. You can set the starting angle and the center.
.wheel {
background: conic-gradient(
from 90deg,
#6366f1 0%,
#f59e0b 100%
);
}Turn on Repeat the pattern and the colors start again after the last stop. With the last stop at 20%, the pattern repeats five times. Put two stops at the same spot for hard stripes.
.stripes {
background: repeating-linear-gradient(
45deg,
#6366f1 0%,
#6366f1 10%,
#f59e0b 10%,
#f59e0b 20%
);
}Standard blending mixes colors in sRGB, which turns gray between opposite colors like blue and yellow. OKLab and OKLCH keep the middle bright. The CSS adds an sRGB fallback line for older browsers.
.blend {
/* Fallback for older browsers */
background: linear-gradient(
90deg,
#0000ff 0%,
#ffff00 100%
);
background: linear-gradient(
90deg in oklab,
#0000ff 0%,
#ffff00 100%
);
}Lower a stop's opacity to fade into whatever is behind it, such as a photo. See-through stops are written as rgba() so the opacity is easy to read.
.photo-overlay {
background: linear-gradient(
180deg,
rgba(0, 0, 0, 0.6) 0%,
rgba(0, 0, 0, 0) 100%
);
}The angle in a linear gradient is the direction the colors travel. 0deg points up, and the angle turns clockwise from there. If you leave the angle out, the gradient runs from top to bottom. You can also write a direction as a keyword:
| Angle | Keyword | Colors run |
|---|---|---|
| 0deg | to top | Bottom to top |
| 90deg | to right | Left to right |
| 180deg | to bottom | Top to bottom (the default) |
| 270deg | to left | Right to left |
| 45deg | to top right (only on a square box) | Bottom left to top right |
Corner keywords like to top right aim at the corner of the box, so on a wide box they are not the same as45deg. Under Write the direction as, pick Degrees for a direction that stays the same on any box shape, or Keyword when the gradient should always run corner to corner.
Browsers mix gradient colors in sRGB unless you say otherwise. Halfway between blue (#0000ff) and yellow (#ffff00) that mix is #808080, a flat gray. Set Color blending to Smooth (OKLab), or add a bright color in the middle as a third stop.
A gradient on the body is sized to the page content. On a short page it ends early and repeats to fill the window. Make the page at least as tall as the window:
html {
min-height: 100%;
}Give two stops the same position. The color changes at that point with no blend. In this tool, select a stop and set its Position slider to match its neighbor.
.split {
background: linear-gradient(
90deg,
#6366f1 50%,
#f59e0b 50%
);
}Paste the gradient as the background, clip it to the text, and make the text color transparent so the gradient shows through:
h1 {
background: linear-gradient(90deg, #6366f1 0%, #f59e0b 100%);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}Browsers cannot blend from one background-image to another, so a transition between two gradients switches instantly. Make the gradient wider than the element with background-size and animate background-position instead. Or put the second gradient on a ::before layer and fade its opacity.
.button {
background: linear-gradient(90deg, #6366f1, #ec4899, #f59e0b);
background-size: 200% 100%;
transition: background-position 0.4s ease;
}
.button:hover {
background-position: 100% 0;
}Most screens show 256 levels for each of red, green, and blue. When two very similar colors are stretched across a large area, the steps between those levels can show up as bands. Use colors that are further apart, or lay a faint noise texture over the gradient.