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
- How to get a clean background removal
What makes a photo easy to cut out, and how to fix the edges for product and profile images.
- How to improve image quality: what works and what does not
A realistic guide to upscaling, sharpening and color fixes for low-quality images.
- PNG, JPG, WebP or SVG: which image format should you use?
A plain comparison of the main image formats, with a quick rule for each job.