CSS Gradient Guide

Create Beautiful CSS Gradients Without Images

Learn linear, radial, conic and repeating gradients — complete syntax, practical examples, a ready-to-use gradient gallery, and best practices for modern web design. Includes a live generator and 150+ copy-paste ready examples.

🎨 4 Gradient Types ⚡ Live Generator 📋 150+ Examples

? What Is a CSS Gradient?

A CSS gradient is a CSS feature that creates a smooth transition between two or more colors — no image file required.

Gradients are commonly used in website backgrounds, navigation bars, buttons, hero sections, cards, text effects, and other design elements. CSS provides three main gradient types: linear, radial, and conic. You can also create repeating gradients and combine multiple gradients to produce more advanced background patterns.

Why it matters: gradients are rendered by the browser, so they scale perfectly on any screen, need no HTTP requests, and can be changed with a single line of code.

⚙ Try the Interactive Gradient Generator

Use the live tool below to build gradients in real time — pick colors, drag stops, switch between linear / radial / conic / repeating, stack multiple layers, and copy the generated CSS with a single click.

100%

Blend mode, size, position and repeat are set per gradient layer inside the Gradients tab.

/* CSS will appear here */

★ Benefits of Using a Gradient Generator

  • Create attractive backgrounds quickly.
  • Experiment with different color combinations.
  • Customize gradient directions and color stops.
  • Preview designs before using them on a website.
  • Copy ready-to-use CSS code.
  • Build modern interfaces without external background images.
  • Save development time when designing buttons, cards, and banners.

1 CSS Linear Gradient

A linear gradient creates a smooth transition between colors along a straight line. You can control the direction of the transition using keywords or an angle.

Syntax

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

Example 1 — Simple Linear Gradient

.gradient-box {
  background: linear-gradient(to right, red, blue);
  height: 200px;
  border-radius: 12px;
}
Red → Blue

Example 2 — Three-Color Gradient

.gradient-box {
  background: linear-gradient(
    to right,
    #ff0080,
    #7928ca,
    #00c6ff
  );
  height: 200px;
}
Pink → Purple → Cyan

Example 3 — Diagonal Gradient

.gradient-box {
  background: linear-gradient(135deg, #667eea, #764ba2);
  height: 200px;
}
135° Diagonal
Linear gradients are useful for website headers, call-to-action buttons, hero sections, and modern UI components.

2 CSS Radial Gradient

A radial gradient creates a transition between colors that spreads outward from a central point. By default it uses an elliptical shape, but you can specify a circular shape.

Syntax

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

Example 1 — Basic Radial Gradient

.gradient-box {
  background: radial-gradient(circle, yellow, red);
  height: 200px;
}
Yellow Center → Red Edge

Example 2 — Multiple Colors

.gradient-box {
  background: radial-gradient(
    circle,
    #ffffff,
    #667eea,
    #764ba2,
    #1a1a2e
  );
  height: 200px;
}
Multi-Color Glow

Example 3 — Custom Radial Position

.gradient-box {
  background: radial-gradient(
    circle at top left,
    #00c6ff,
    #0072ff,
    #001f54
  );
  height: 200px;
}
Top-Left Spotlight
Radial gradients are useful for glowing effects, decorative backgrounds, spotlight effects, and colorful website sections.

3 CSS Conic Gradient

A conic gradient creates a color transition around a central point, similar to the arrangement of colors on a color wheel.

Syntax

background: conic-gradient(color1, color2, color3);

Example 1 — Basic Conic Gradient

.gradient-box {
  background: conic-gradient(red, yellow, green, blue, red);
  height: 200px;
  border-radius: 50%;
}

Example 2 — Conic Gradient with an Angle

.gradient-box {
  background: conic-gradient(
    from 90deg,
    #ff0080,
    #7928ca,
    #00c6ff,
    #ff0080
  );
  height: 200px;
  border-radius: 50%;
}

Example 3 — Color Segments

.gradient-box {
  background: conic-gradient(
    red    0deg 90deg,
    yellow 90deg 180deg,
    blue   180deg 270deg,
    green  270deg 360deg
  );
  height: 200px;
  border-radius: 50%;
}
Conic gradients are useful for decorative circles, color wheels, pie-chart-style visuals, and creative UI designs.

4 CSS Repeating Gradients

Repeating gradients repeat a gradient pattern across an element. They can be used to create stripes, rings, and other decorative patterns.

Example 1 — Repeating Linear Gradient

.gradient-box {
  background: repeating-linear-gradient(
    45deg,
    #ff0080 0px,
    #ff0080 10px,
    #7928ca 10px,
    #7928ca 20px
  );
  height: 200px;
}
Diagonal Stripes

Example 2 — Repeating Radial Gradient

.gradient-box {
  background: repeating-radial-gradient(
    circle,
    #00c6ff 0px,
    #00c6ff 10px,
    #001f54 10px,
    #001f54 20px
  );
  height: 200px;
}
Rings

Example 3 — Repeating Conic Gradient

.gradient-box {
  background: repeating-conic-gradient(
    #667eea 0deg 15deg,
    #764ba2 15deg 30deg
  );
  height: 200px;
  border-radius: 50%;
}

5 How to Use Multiple CSS Gradients

You can combine multiple gradients in a single background declaration. Each gradient layer is separated by a comma.

Example — Multiple Gradient Background

.gradient-box {
  background:
    linear-gradient(135deg, rgba(255,0,128,.7), transparent),
    linear-gradient(45deg, #667eea, #764ba2);
  height: 250px;
  border-radius: 16px;
}
Two Layers Combined

6 Understanding Color Stops

Color stops define the colors used in a gradient and where those colors appear along the gradient line.

Example — Custom Color Stops

.gradient-box {
  background: linear-gradient(
    to right,
    red    0%,
    orange 25%,
    yellow 50%,
    green  75%,
    blue   100%
  );
  height: 200px;
}
0% → 100%

Using the same position for adjacent color stops creates a sharp color boundary instead of a smooth transition.

/* Sharp boundary at 50% */
background: linear-gradient(to right, #667eea 50%, #ff0080 50%);
Hard Edge

7 Create a Gradient Using an Online Tool

Follow these steps to create a custom gradient with the generator above.

  1. Open the CSS Gradient Generator Use the interactive tool near the top of this page.
  2. Choose your colors Select the starting and ending color, and add more colors for a multi-color gradient.
  3. Select the gradient type Pick linear, radial, conic, or repeating.
  4. Adjust the direction For linear gradients, change the angle until it looks right.
  5. Customize color stops Move the color positions to control the transition.
  6. Preview your design Check the preview and refine until it matches your requirements.
  7. Copy the CSS code Click Copy CSS and paste it into your stylesheet.
  8. Apply it to an element Use the generated background on the element you want to style.
.hero-section {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 60px 20px;
  border-radius: 16px;
}

9 CSS Gradients for Buttons

Gradient backgrounds can make buttons more visually attractive. However, ensure the text stays readable and the button has a clear interactive state.

<button class="gradient-button">Get Started</button>
.gradient-button {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  padding: 14px 28px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .2s ease;
}
.gradient-button:hover { transform: translateY(-2px); }
.gradient-button:focus-visible { outline: 3px solid #222; outline-offset: 3px; }

10 CSS Gradients for Website Backgrounds

Gradients are useful for creating visually interesting website backgrounds. You can use them on the body, hero sections, cards, and other elements.

Example — Full-Page Gradient Background

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(
    135deg,
    #0f2027,
    #203a43,
    #2c5364
  );
  color: white;
}
Dark Blue-Green Background

11 CSS Gradients for Text Effects

You can apply a gradient to text using background-clip: text and a transparent text color.

Create Beautiful Designs
<h1 class="gradient-text">Create Beautiful Designs</h1>
.gradient-text {
  background: linear-gradient(90deg, #ff0080, #7928ca, #00c6ff);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

12 Best Practices

  • Choose suitable colors: match your website's theme and purpose.
  • Maintain readability: ensure text and interactive elements stay easy to see.
  • Use gradients consistently: avoid too many unrelated gradient styles on one page.
  • Optimize performance: gradients need no downloads, but complex designs and animations can still affect rendering.
  • Test on different screens: check mobile, tablet, and desktop displays.
  • Consider accessibility: verify text contrast, provide visible focus indicators, and respect reduced-motion preferences.
  • Use responsive layouts: make sure backgrounds work with changing element sizes.
  • Test browser support: confirm the CSS features you use are supported by your target browsers.

13 Common CSS Gradient Mistakes

  • Using too many colors without a clear design purpose.
  • Choosing colors that make text difficult to read.
  • Forgetting to specify an element's height or content when testing a background.
  • Using incorrect gradient syntax.
  • Adding unnecessary gradient layers that make the design hard to maintain.
  • Using animated gradients without considering users who prefer reduced motion.
  • Assuming that a gradient automatically provides sufficient text contrast.

14 Frequently Asked Questions

What is a CSS Gradient Generator?

A CSS Gradient Generator is a tool that helps you create custom gradient backgrounds and generate the CSS code needed to use them on a website.

What are the main types of CSS gradients?

The three main types are linear gradients, radial gradients, and conic gradients. CSS also supports repeating versions of these gradient types.

How do I create a linear gradient in CSS?

Use the linear-gradient() function with a direction and two or more colors.

background: linear-gradient(to right, red, blue);
Can I use more than two colors in a CSS gradient?

Yes. You can use multiple colors and control their positions with color stops.

background: linear-gradient(90deg, red, orange, yellow, green, blue);
Are CSS gradients better than background images?

CSS gradients can be a good alternative when you need a simple color transition or pattern. Complex illustrations or photographic backgrounds may still require images.

Can CSS gradients be animated?

Yes. You can animate suitable CSS properties or use techniques involving background positioning and pseudo-elements. Always test for performance and accessibility.

Do CSS gradients work on mobile devices?

CSS gradients are supported by modern mobile browsers. Test your designs on the devices and browsers relevant to your audience.

✓ Conclusion

CSS gradients are a useful way to create modern and attractive website designs.

With linear, radial, conic, and repeating gradients, developers can build colorful backgrounds, buttons, cards, banners, and text effects using pure CSS.

A CSS Gradient Generator simplifies the process — and the one on this page lets you experiment with colors, adjust settings, preview your design, and copy the resulting code in seconds.

Experiment with different color combinations, keep accessibility in mind, and choose gradient styles that improve your website's overall user experience.