This CSS Gradient Generator lets you build simple background gradients for web pages and UI components. You can choose between a linear gradient (which blends colors along a straight line) and a radial gradient (which blends colors outward from a center point). The tool focuses on the most common use case: smooth transitions between two colors, with an adjustable angle or size.
All calculations run in your browser. After choosing a gradient type, angle or size, and start/end colors, the tool shows a live preview and provides a ready-to-copy CSS background declaration you can paste into a stylesheet or inline style attribute.
A CSS gradient is a function that tells the browser how to transition between two or more colors across space. You can think of every pixel in the element as having a position parameter that determines how much of each color is mixed in.
For a basic two-color linear gradient, the color at any point along the gradient axis can be modeled as a weighted average of the start and end colors:
Here:
C(t) is the resulting color at position t along the gradient axis.t ranges from 0 to 1, where 0 is the start of the gradient and 1 is the end.C0 is the start color in RGB space.C1 is the end color in RGB space.The browser interpolates each RGB channel independently, so red, green, and blue components each change linearly with t. A similar idea applies to radial gradients, except the parameter is distance from the center rather than distance along a straight line.
CSS provides two primary gradient functions that this tool focuses on:
linear-gradient() for gradients that flow along a straight line defined by an angle.radial-gradient() for gradients that radiate outward from a center point.A linear gradient in CSS usually looks like this:
background: linear-gradient(45deg, #ff0000, #0000ff);
Key points:
45deg or 180deg).0deg pointing up. 90deg runs left-to-right, 180deg runs top-to-bottom, and so on.A radial gradient uses a circular or elliptical shape and blends colors from the center out toward the edges:
background: radial-gradient(circle 50%, #ff0000, #0000ff);
Important aspects:
circle or ellipse defines the shape.50%) indicates how far the gradient extends relative to the element’s box.90 for left-to-right, 180 for top-to-bottom).50 or 75 are treated as relative radii, such as 50%.background line.background declaration into your stylesheet, or paste it directly into an element’s style attribute.Internally, the generator converts your inputs into one of two CSS functions:
linear-gradient(deg, , ) .radial-gradient(circle %, , ) (or a simplified variation of this form).The angle field accepts any numeric value. When converted to CSS, values greater than 360 degrees are effectively taken modulo 360, because CSS interprets them cyclically. For radial gradients, the numeric value is treated as a percentage size relative to the container, which in practice controls how tight or expansive the gradient appears.
The underlying interpolation for both types uses the linear blending idea described earlier. For a radial gradient, we conceptually replace the linear position parameter t with a normalized radius parameter r, which varies from 0 at the center to 1 at the outer edge:
Again, r runs from 0 at the center to 1 at the defined radius, and C0 / C1 are your chosen start and end colors.
After you generate a gradient, you will typically see two things:
The browser where you paste this code will calculate the same gradient at render time. The key part to look at is the background value, which may look like:
background: linear-gradient(120deg, #34d399, #1d4ed8);
or:
background: radial-gradient(circle 60%, #f97316, #9333ea);
You can freely change colors, angles, or sizes later without returning to the tool; just edit the values in your CSS. However, the generator provides an easy visual way to experiment, especially when you are trying out unfamiliar color combinations.
Suppose you want a header background that fades from bright red to deep blue diagonally. Here is one way to do it with this generator:
135 in the angle field. This creates a diagonal gradient that roughly runs from top-left toward bottom-right.#ff0000 (pure red) as the start color.#0000ff (pure blue) as the end color.The generated snippet might look like this:
background: linear-gradient(135deg, #ff0000, #0000ff);
You can then apply it to a header element as follows:
.site-header {
background: linear-gradient(135deg, #ff0000, #0000ff);
color: #ffffff;
padding: 2rem;
}
If you prefer a softer effect, you could switch the generator to a radial gradient with the same colors:
70 (interpreted as 70%).The resulting CSS could be:
background: radial-gradient(circle 70%, #ff0000, #0000ff);
This configuration concentrates your start color toward the center and lets the end color dominate near the edges, which can be useful for spotlight or vignette-style backgrounds.
| Aspect | Linear Gradient | Radial Gradient |
|---|---|---|
| Direction control | Controlled with an angle in degrees (0–360). | Controlled by center point and shape; this tool simplifies it to a circular radius percentage. |
| Visual appearance | Color transition along a straight line, often used for stripes or directional lighting. | Color transition from the center outward, good for spotlight and radial glow effects. |
| Typical use cases | Section backgrounds, buttons, navigation bars, and banners. | Highlights behind icons, avatars, callouts, or hero sections. |
| Control in this tool | Pick type Linear, set an angle (degrees), and two colors. | Pick type Radial, set a relative size (percentage), and two colors. |
| CSS function used | linear-gradient() |
radial-gradient() |
This tool is intentionally streamlined for fast experimentation. It does not aim to cover the full CSS gradient specification. When you use it, keep the following constraints and assumptions in mind:
#ff0000. While CSS gradients can include rgba() values with transparency, those are not exposed directly through this UI.linear-gradient() and radial-gradient() functions. Older vendor-prefixed forms (such as -webkit-linear-gradient) are not included.0deg points upward and increases clockwise. If you are accustomed to a different convention (for example, mathematical angles where 0 degrees points to the right), be aware of this difference.A few guidelines to get nicer results from your gradients:
The generator is best used as a quick visual lab for simple two-color gradients. You can start with the generated CSS, then expand it by hand if you need more advanced effects: additional color stops, custom positions, or alpha transparency. Because the output follows standard linear-gradient() and radial-gradient() syntax, it should integrate cleanly into modern front-end workflows, CSS frameworks, and component libraries.
As you explore gradients, combine this tool with other CSS resources—such as color palettes or box-shadow utilities—to create cohesive, layered designs without relying on heavy image assets.