Developer Tools

How to Create Beautiful CSS Gradients (With Code Examples)

A complete guide to CSS gradients — linear, radial, and conic. Learn gradient syntax, color stops, angles, and how to create stunning backgrounds.

Published February 20, 2026Updated March 1, 2026 7 min read
css gradients web design frontend ui design

Mentioned in this article

Free Online Tool: Try it now →

Open Tool

Introduction to CSS Gradients

CSS gradients let you create smooth transitions between two or more colors — no image files needed. They're resolution-independent, infinitely scalable, and reduce HTTP requests compared to using raster images.

CSS supports three types of gradients:

  • Linear gradients: Colors transition along a straight line.
  • Radial gradients: Colors radiate outward from a center point.
  • Conic gradients: Colors rotate around a center point (like a pie chart).

Linear Gradients — Syntax and Examples

Basic syntax:

background: linear-gradient(direction, color1, color2, ...);

Simple Top-to-Bottom Gradient

background: linear-gradient(to bottom, #667eea, #764ba2);

Diagonal Gradient with Angle

background: linear-gradient(135deg, #f093fb, #f5576c);

Multi-Color Gradient with Color Stops

background: linear-gradient(to right, #4facfe 0%, #00f2fe 100%);

Radial Gradients — Syntax and Examples

background: radial-gradient(shape size at position, color1, color2);

Simple Circular Gradient

background: radial-gradient(circle, #a18cd1, #fbc2eb);

Elliptical Gradient at Custom Position

background: radial-gradient(ellipse at top, #e0c3fc, #8ec5fc);

Conic Gradients — The Modern Gradient

background: conic-gradient(from angle at position, color1, color2);

Simple Conic Gradient (Pie Effect)

background: conic-gradient(#ff6b6b 0deg 90deg, #feca57 90deg 180deg, #48dbfb 180deg 270deg, #ff9ff3 270deg 360deg);

How to Use the CSS Gradient Generator

Rather than writing gradient code by hand, use RapidKit's CSS Gradient Generator:

  1. Choose your gradient type (linear, radial, or conic).
  2. Pick your colors using the color pickers.
  3. Add multiple color stops and position them visually.
  4. Adjust the angle or direction.
  5. Copy the generated CSS code with one click.

Gradient Best Practices

  • Use HSL colors for harmonious gradients: Rotating the hue value while keeping saturation and lightness consistent produces naturally beautiful gradients.
  • Avoid "gray dead zone": Gradients going through gray (e.g., red to blue through white) look muddy. Add an intermediate color stop to route around it.
  • Test in dark mode: Gradients that look great in light mode can look washed out in dark mode.
  • Subtle gradients ≠ simple: A 5-10% lightness difference can add depth without being obvious.

Performance Notes

CSS gradients are rendered by the GPU and are extremely performant. They are always preferred over gradient images for:

  • Backgrounds that need to scale to any size
  • Hover states and transitions
  • Animated gradients (using CSS custom properties and transitions)

Ready to Try It?

Use our free online tool — no sign-up, no download, no limits.

Open Free Tool