CSS Gradients in Practice

By the ToolPocket team · Updated 2026-12-05 · Editorial standards

A gradient is a background image generated by the browser from a short rule. It needs no image files, scales to any size and can be changed with one value.

The two common forms

A linear gradient runs along a line: linear-gradient(135deg, #ff7e5f, #feb47b). The angle is measured clockwise from the top: 0deg points up, 90deg right, 180deg down.

A radial gradient spreads from a point: radial-gradient(circle at 50% 50%, #ff7e5f, #feb47b). You can move the centre and change the shape.

Colour stops

Each colour can carry a position: linear-gradient(90deg, red 0%, blue 50%, green 100%). Without positions the browser distributes them evenly. Hard stops are made by giving two colours the same position: red 50%, blue 50%.

Multiple layers

A background can hold several gradients stacked, separated by commas, with the first painted on top. Combined with transparency this produces stripes, glows and mesh-like effects without images.

When not to use one

Gradients are cheap, but a very large blurred radial gradient over a scrolling page can cost painting time on low-end devices. For a static hero section it is fine; for a full-page animated background, test on a phone.

Keep it subtle

The most common mistake is too much contrast. Two close hues with a soft angle usually look more professional than a rainbow. If the gradient sits behind text, check the contrast ratio at both ends.

Conic gradients and hard stops

A conic gradient sweeps around a centre point rather than across the box: conic-gradient(from 0deg, red, blue, red). They are the basis of pie charts, colour wheels and many "glass" effects. Hard stops — two colours at the same position — turn any gradient into crisp stripes without a repeating background image.

Layering is the other useful trick: several gradients with transparency stacked in one background rule produce glows, grain and mesh effects that would otherwise need image files. Keep the number of layers small; each one is painted separately.

Generate the rule with the CSS gradient generator, then paste it into your stylesheet.

← All guides