← Back to Articles
Design Guide

How to Write CSS Gradient Background Code (Linear, Radial, Conic — Copy-Paste)

Three basic gradients

  • Linear: the classic top-to-bottom gradient, most common.
  • Radial: spreads from the center, great for glows and buttons.
  • Conic: rotates color around the center, good for pie charts and iridescence.

Copy-paste code

background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);

background: radial-gradient(circle at 30% 30%, #ff5e62, #2575fc);

background: conic-gradient(from 90deg, #6a11cb, #2575fc, #ff5e62, #6a11cb);

Preview then grab colors

Tune the look in the gradient generator, copy the HEX into your CSS; for mesh try mesh, for center rotation conic, for glow radial.

💡
135deg is the safest direction for web backgrounds; try 120 or 160deg for more life.

Common pitfalls

  • Missing percent: gradient stops need percentages or colors bunch up.
  • Mobile blur: thin gradient lines look smoother on Retina; avoid 1px hard edges.
  • Low contrast: put a translucent overlay under text on gradients for readability.

Related generators

Keep reading