Designio

A practical guide to CSS gradients

CSS gradients let you blend colors with one line of code. They need no image files and stay sharp at any size.

Linear gradients

A linear gradient moves along a straight line. In linear-gradient(90deg, #F2C14E, #B4436C), 0deg points up and 90deg points right. You can place each color precisely with percentages.

Radial gradients

A radial gradient spreads out from a center point. It works well for soft spotlights behind a product or a heading.

Conic gradients

A conic gradient sweeps around a center, like the hands of a clock. It is handy for color wheels and simple pie charts.

Avoid gray in the middle

Blending two opposite colors can create a dull midpoint. Add a stop between them with a saturated in-between color. Modern CSS also lets you choose a different interpolation space, such as "in oklch", for smoother transitions in supporting browsers.

Make text readable

Test text against the lightest and darkest parts of the gradient. If one end fails, add a dark overlay using a second background layer, or keep the text on the darker side.

Keep reading