CSS Gradient Generator - Create Beautiful Gradients Online

Build linear, radial, and conic gradients with live preview

linear-gradient 2 stops
Gradient Type
Angle
135deg
Center Position
Start Angle
0deg
Color Stops
Quick Actions
Preset Gradients
Generated CSS
CSS with Fallback
Background Shorthand

What Is a CSS Gradient?

A CSS gradient is a smooth color transition rendered directly by the browser, without loading an image file. Gradients are declared via the background or background-image CSS property and scale perfectly at any screen resolution, including Retina and high-DPI displays.

CSS supports three gradient functions:

  • linear-gradient() -- colors flow along a straight line at a specified angle (e.g., top-to-bottom, diagonal)
  • radial-gradient() -- colors radiate outward from a center point in a circle or ellipse
  • conic-gradient() -- colors sweep around a center point, like a color wheel or pie chart

Because gradients are generated by the rendering engine, they add zero HTTP requests, have a tiny CSS footprint, and are more performant than equivalent image backgrounds.

How CSS Gradients Work

Linear Gradients

A linear gradient transitions colors along a straight line. The direction is set by an angle or keyword:

  • background: linear-gradient(180deg, #ff6b6b, #4ecdc4);
  • background: linear-gradient(to right, #667eea, #764ba2);
  • background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);

Common angles: 0deg = bottom to top, 90deg = left to right, 180deg = top to bottom, 135deg = top-left to bottom-right (diagonal).

Radial Gradients

Radial gradients radiate from a center point outward. You control the shape (circle or ellipse) and the origin position:

  • background: radial-gradient(circle at center, #00d4aa, #3b82f6);
  • background: radial-gradient(ellipse at top left, #fa709a, #fee140);

Conic Gradients

Conic gradients sweep colors around a center point. They are useful for pie charts, color wheels, and decorative patterns:

  • background: conic-gradient(from 0deg, red, yellow, green, blue, red);
  • background: conic-gradient(from 90deg at center, #667eea, #764ba2);

Color Stops Explained

Color stops define where each color appears along the gradient. Each stop is a color value followed by an optional position (a percentage or length):

  • #ff6b6b 0% -- red at the start
  • #fee140 50% -- yellow at the midpoint
  • #4ecdc4 100% -- teal at the end

If you omit positions, the browser spaces colors evenly. You can add as many stops as needed. Placing two stops at the same position creates a hard color edge instead of a smooth transition.

Practical Examples

Page hero background

linear-gradient(135deg, #667eea, #764ba2)

Sunset button

linear-gradient(90deg, #fa709a, #fee140)

Radial spotlight

radial-gradient(circle at 30% 50%, #4facfe, #00f2fe)

Three-color blend

linear-gradient(90deg, #43e97b, #38f9d7, #4facfe)

Common Mistakes

  • Using background-color instead of background. Gradients are images, not colors. Use background or background-image, not background-color.
  • Forgetting a fallback color. Always declare a solid background-color before the gradient for older browsers: background-color: #667eea; background: linear-gradient(...);
  • Too many color stops. More stops do not always mean better. Two or three well-chosen colors usually produce cleaner results than five or six.
  • Confusing angle direction. In CSS, 0deg points upward (bottom to top) and angles increase clockwise. This differs from standard math conventions where 0 degrees points right.
  • Hard lines when you want smooth transitions. If you see a visible line between colors, your color stops are too close together. Space them further apart or add an intermediate color.

CSS Gradient FAQ

What is a CSS gradient?

A CSS gradient is a smooth transition between two or more colors rendered by the browser without an image file. CSS supports three types: linear-gradient, radial-gradient, and conic-gradient. They are applied via the background or background-image property.

What is the difference between linear, radial, and conic gradients?

Linear gradients flow along a straight line at a specified angle. Radial gradients radiate outward from a center point in a circular or elliptical shape. Conic gradients sweep colors around a center point, like a color wheel or pie chart.

How do I create a gradient with multiple colors?

Add multiple color stops separated by commas: background: linear-gradient(90deg, red 0%, yellow 50%, green 100%);. You can use as many stops as you want. Control each stop's position with a percentage value.

What are color stops?

Color stops define where each color appears in the gradient. They consist of a color value and an optional position (usually a percentage from 0% to 100%). If positions are omitted, colors are distributed evenly.

How do I change the direction of a gradient?

For linear gradients, set the angle as the first argument: linear-gradient(90deg, red, blue) goes left to right. Use degree values (0deg = bottom to top, 90deg = left to right, 180deg = top to bottom) or keywords like to right or to bottom left.

Can I use gradients as text fill?

Yes. Apply the gradient to background-image, then set -webkit-background-clip: text and color: transparent. This clips the gradient to the text shape, creating gradient-colored text.

Are CSS gradients supported in all browsers?

Linear and radial gradients have near-universal support in modern browsers. Conic gradients are supported in all major browsers since 2020. For older browsers, set a solid background-color as a fallback before the gradient declaration.

Do gradients affect page performance?

CSS gradients have minimal performance impact. They are rendered by the browser's graphics engine, scale perfectly at any resolution, produce zero HTTP requests, and have a tiny CSS footprint. They are generally more performant than image backgrounds.

How do I create a hard color edge instead of a smooth transition?

Place two different color stops at the same position: linear-gradient(90deg, red 50%, blue 50%). This creates an instant switch from red to blue at the 50% mark with no blending.

Can I animate CSS gradients?

CSS gradients cannot be directly animated with transition. However, you can animate the background-position or background-size of a gradient to create movement effects. Another approach is using CSS custom properties (variables) with @property to animate individual color values.

What is the difference between background and background-image for gradients?

Both work for gradients, but background is a shorthand that resets other background properties (like background-color). Using background-image only sets the image layer, preserving any existing background-color as a fallback. For most cases, background is simpler.

How do I create a repeating gradient?

Use repeating-linear-gradient() or repeating-radial-gradient(). Define color stops with fixed units (like px) instead of percentages: repeating-linear-gradient(45deg, #667eea 0px, #667eea 10px, #764ba2 10px, #764ba2 20px) creates diagonal stripes.

Related Tools

Privacy & Limitations

  • All calculations run entirely in your browser -- nothing is sent to any server.
  • Results are computed locally and should be verified for critical applications.

Related Tools

View all tools

Gradient Generator FAQ

What is a CSS gradient?

A CSS gradient is a smooth transition between two or more colors, rendered by the browser without using an image file. CSS supports three gradient types: linear-gradient (colors flow along a straight line), radial-gradient (colors radiate outward from a center point), and conic-gradient (colors sweep around a center point like a pie chart). Gradients are set via the background or background-image CSS property.

What is the difference between linear, radial, and conic gradients?

Linear gradients transition colors along a straight line at a specified angle (e.g., top to bottom, left to right, or diagonal). Radial gradients radiate colors outward from a center point in a circular or elliptical shape. Conic gradients sweep colors around a center point, similar to how a color wheel or pie chart looks. Each type is suited for different design effects.

How do I create a CSS gradient with multiple colors?

Add multiple color stops separated by commas inside the gradient function. For example: background: linear-gradient(90deg, red 0%, yellow 50%, green 100%); -- this creates a horizontal gradient that transitions from red to yellow to green. You can use as many color stops as you need and control each stop's position with a percentage.

What are color stops in CSS gradients?

Color stops define where each color appears along the gradient. They consist of a color value and an optional position (usually a percentage from 0% to 100%). For example, 'red 0%, blue 100%' means the gradient starts red and ends blue. If you omit positions, the browser distributes colors evenly.

How do I change the direction of a CSS gradient?

For linear gradients, set the angle as the first argument: background: linear-gradient(90deg, red, blue) creates a left-to-right gradient. You can use degree values (0deg = bottom to top, 90deg = left to right, 180deg = top to bottom) or keywords like 'to right', 'to bottom left', etc.

Can I use CSS gradients as backgrounds for text?

Yes. Apply the gradient to background-image, then use background-clip: text and -webkit-background-clip: text with color: transparent. This clips the gradient to the text shape. Example: background: linear-gradient(90deg, #ff6b6b, #4ecdc4); -webkit-background-clip: text; color: transparent;

Are CSS gradients supported in all browsers?

Linear and radial gradients have near-universal support across modern browsers (Chrome, Firefox, Safari, Edge). Conic gradients are supported in all modern browsers since 2020. For older browser support, you can set a solid background-color as a fallback before the gradient declaration.

Do CSS gradients affect page performance?

CSS gradients are rendered by the browser's graphics engine and have minimal performance impact compared to loading image files. They scale perfectly at any resolution (including Retina displays), produce zero HTTP requests, and have a tiny CSS footprint. For most use cases, gradients are more performant than equivalent image backgrounds.

Request a New Tool
Improve This Tool