YourFileKit
Esc
Log in
Design & CSS

How CSS Gradients Actually Work (And Why Yours Might Look Banded)

Linear vs radial gradients, what a color stop actually controls, and the real reason smooth gradients sometimes show visible stripes.

August 17, 20267 min read

Quick answer: A CSS gradient is a smooth color transition built from an explicit list of color stops, each stop a color plus a position along a path. A linear gradient's path is a straight line at a chosen angle; a radial gradient's path radiates outward from a center point; a conic gradient's path sweeps around a center point like a clock hand. Visible banding, where a gradient shows stripes instead of a smooth blend, almost always means the gradient needs more color stops, not a different gradient type.

A CSS gradient looks like a single smooth color transition, but under the hood it's built from a small number of explicit control points, and most of what makes a gradient look right or wrong comes down to how those points are placed.

What a color stop actually controls

A gradient is defined by a list of color stops, each one a color plus (optionally) a position along the gradient's path. The browser interpolates smoothly between consecutive stops. A simple two-color gradient has exactly two stops, at the start and end. Nothing stops you from adding more:

background: linear-gradient(90deg, #7c3aed 0%, #a855f7 50%, #ec4899 100%);

That third color stop in the middle isn't decorative, it's a real control point the gradient passes through at exactly the 50% mark, which is how a gradient goes from a simple two-color fade to a more deliberate multi-color transition. CSS Gradient Generator builds this visually, with a live preview and copyable CSS, which makes it much faster to see what adding, removing, or repositioning a stop actually does than reasoning about it from the syntax alone.

How the browser interpolates between two stops

Between any two adjacent color stops, the browser doesn't just average the two colors once, it calculates a continuous blend across every point along the path, moving from one color's channel values (commonly red, green, and blue, though newer syntax supports other color spaces) toward the next stop's values in proportion to how far along the path that point sits. A pixel sitting 25% of the way between a purple stop and a pink stop gets a color that's 75% purple's channel values and 25% pink's, not a simple midpoint average of just the two endpoints. This is also exactly why the choice of two colors matters: the interpolated colors in between are whatever falls on the direct path between them, which isn't always a color that looks intentional.

Linear vs. radial vs. conic: different shapes, same underlying idea

A linear gradient transitions along a straight line at a chosen angle, 90deg moves left-to-right, 180deg top-to-bottom, and so on. A radial gradient instead transitions outward from a center point in a circle or ellipse, which is why it's the natural choice for a spotlight or glow effect rather than an edge-to-edge fade. A third, less commonly used type, the conic gradient, sweeps its color stops around a center point instead, like the hands of a clock, which makes it the natural fit for a pie-chart wedge or a full color wheel, something neither linear nor radial can do cleanly. All three are built from the same core concept, an ordered list of color stops, just interpolated along a different shape of path. None is more "correct" than the others, the choice comes down to whether the effect you want reads as directional (linear), radiating from a point (radial), or rotating around one (conic).

Keyword directions versus explicit angles

linear-gradient(to right, ...) and linear-gradient(90deg, ...) produce the same result for a simple horizontal gradient, but they aren't computed the same way under the hood. A keyword direction like to bottom right is defined relative to the element's actual corners, so on a very wide or very tall element, the resulting angle bends to still hit that exact corner, it isn't a fixed 135deg. An explicit numeric angle ignores the box's shape entirely and always points the same direction. For most everyday gradients this distinction doesn't matter, it starts to matter on an element whose aspect ratio changes responsively and a diagonal gradient needs to behave consistently.

Why gradients sometimes show visible banding

This is the most common thing that makes an otherwise correct gradient look wrong: instead of a smooth blend, you see faint but visible stripes, like a topographic map instead of a photograph. This is color banding, and it's a genuine rendering limitation, not a mistake in the gradient's definition.

It happens because color is stored with limited precision (commonly 8 bits per channel, giving 256 possible values per channel). Stretched across a large, smooth area between two colors that are close in hue, there often aren't enough distinct intermediate values to represent a perfectly smooth transition, so the display falls back to visible discrete steps instead. It shows up most on large flat surfaces (a full-width hero background, say) and least on smaller or busier areas where the banding has less room to become visible.

The most reliable fix is adding one or two intermediate color stops rather than relying on the browser to interpolate smoothly across a wide gap on its own, since more explicit stops give the renderer more real control points to work from instead of stretching a long interpolation between just two. CSS Filter Generator is a related but different tool worth knowing about here: it adjusts an existing image or element (blur, brightness, contrast, saturation) rather than building a gradient from scratch, useful once you've got a background gradient in place and want to fine-tune how content sits on top of it.

A second fix worth knowing: dithering

Beyond adding stops, a subtle noise texture layered over a banded gradient (a technique called dithering) can visually break up the discrete steps without changing the underlying colors, a trick borrowed from image and video encoding where the same 8-bit precision limit exists. It's more setup than just adding a color stop, so it's typically worth reaching for only when extra stops alone don't fully resolve the banding on a particularly large, particularly smooth surface.

Picking colors that actually work together

A gradient between two colors picked at random often looks muddy in the middle, especially across a wide hue difference, since the interpolated midpoint colors are whatever falls between them on the color wheel, which isn't always a pleasant color in its own right. One practical way around this: pull colors from something that already looks good together instead of guessing. Color Palette Extractor pulls the dominant colors out of any image as hex codes, which is a fast way to get a gradient's start and end (or middle) colors from a photo, a logo, or existing design work that already has a color relationship you like, rather than starting from an arbitrary pair of hex values.

Practical takeaways

  • A color stop is a real control point, not decoration, add more of them for finer control over the transition.
  • Linear, radial, and conic are about the shape of the path, not which one is "better." Match it to whether the effect should read as directional, radiating, or rotating.
  • Visible banding means the gradient needs more stops, particularly across a wide color gap on a large surface.
  • Pull gradient colors from an existing palette rather than guessing two hex values that might not blend well together.

The short version

A CSS gradient is built from explicit color stops the browser interpolates between, and most gradient problems, whether it's a transition that looks wrong or one that visibly bands, come down to not having enough of those stops placed deliberately. Add intermediate stops for finer control and to fix banding, and choose colors that already relate to each other rather than picking two values at random. CSS Gradient Generator makes all of this visual instead of a guessing game in raw syntax.

Frequently asked

What's the difference between a linear and a radial gradient?

A linear gradient transitions along a straight line at a chosen angle, edge to edge. A radial gradient transitions outward from a center point in a circle or ellipse. Same underlying idea (color stops along a path), different shape of path.

Why does my gradient show visible stripes instead of a smooth blend?

This is color banding, and it happens most often on a large, smooth area transitioning between two colors that are close in hue, because there aren't enough distinct color values available to render a perfectly smooth step between them. Adding an intermediate color stop or two usually fixes it.

Can I use more than two colors in a gradient?

Yes, and it's normal to. A gradient can have as many color stops as you want, each with its own position along the gradient line, which is exactly how more complex, multi-color gradients are built.

What's the difference between writing a gradient angle as 'to right' versus '90deg'?

Both describe a direction, but they're defined differently. Keyword directions like 'to right' or 'to bottom left' are anchored to the box's corners and edges, so the exact angle they produce actually depends on the element's aspect ratio for a diagonal keyword. A numeric angle like 90deg is a fixed angle regardless of the box's shape. For a simple edge-to-edge gradient the difference rarely matters, for a diagonal one on a non-square element, it can.

Can a CSS gradient be animated?

Not by smoothly transitioning the gradient property itself in every browser, `background` and `background-image` aren't reliably animatable with a plain CSS transition the way `color` or `opacity` are. The common workarounds are animating a `background-position` on an oversized gradient, cross-fading two gradient layers with opacity, or using `@property` to register a custom property as an animatable angle or color, a newer approach with less universal support.

What is a conic gradient and how is it different from a radial one?

A radial gradient's color stops move outward from a center point, like ripples. A conic gradient's color stops instead sweep around a center point, like the hands of a clock, which is why it's the natural choice for a pie-chart segment or a color-wheel effect rather than a spotlight or glow.

More in Design & CSS

Design & CSS

More guides like this

Practical, tool-linked how-tos across PDF, image, finance, video, and more, no signup to read them.

Browse all articles