Guide
How CSS linear and radial gradients work
By Logappradeep · ServiceNow developer
A CSS gradient is an image that the browser generates on the fly by blending between colors. Because it is calculated rather than downloaded, it scales to any size without blurring, costs no extra HTTP request and can be changed with a single line of CSS. Gradients are used for hero backgrounds, buttons, cards, overlays that keep text readable on photos, and subtle depth effects.
Linear gradients and angles
A linear gradient blends colors along a straight line. The syntax is linear-gradient(angle, color1, color2). In CSS, the angle follows a compass rather than the math convention: 0deg points up, so the gradient runs from bottom to top, 90deg runs left to right, and 180deg (the default) runs top to bottom. This tool starts at 135deg, which flows from the top-left corner to the bottom-right. For example:
background: #3b82f6;
background: linear-gradient(135deg, #3b82f6, #9333ea);
The first line is a solid fallback for any environment that cannot render gradients; the second overrides it where gradients are supported. The copied CSS includes both lines.
Radial gradients
A radial gradient radiates outward from a center point. This generator uses radial-gradient(circle, color1, color2), which places the first color in the middle of the element and the second at the farthest corner. Radial gradients work well for spotlight effects, soft vignettes and glowing buttons. Angles do not apply to them, so the angle slider is hidden in radial mode.
Practical uses
- Full-width hero sections that look polished without a large background image.
- Gradient buttons and badges that match a brand's two main colors.
- A dark-to-transparent overlay placed over photos so white text stays legible.
Pitfalls designers and developers hit
The muddy middle. Browsers blend colors in the sRGB color space by default. Between two colors that sit far apart on the color wheel, such as blue and yellow, the midpoint passes through a dull gray. Picking colors closer in hue, or adding a third color stop by hand, avoids it. Modern browsers also accept an interpolation hint such as linear-gradient(in oklch, ...) for more vivid transitions.
Banding. Subtle gradients stretched across a large area can show visible stripes on some displays because there are not enough intermediate shades. A slightly larger color difference usually hides it.
Animation. Gradients are background-image values, not colors, so transition: background will not animate smoothly between two gradients. Animate background-position on an oversized gradient, or fade an overlay, instead.
Contrast. Text over a gradient must be readable at both ends. Check contrast against the lightest and darkest colors, not just the middle.
Your colors, angle and type are saved in local storage, and everything renders locally in the browser.