Color Palettes

CSS Gradient Generator

Create beautiful linear, radial, and conic gradients with our free online tool. Add unlimited color stops, customize angles, and export CSS code instantly.

Preview
Live gradient preview - click to copy CSS
CSS Code
background: linear-gradient(90deg, rgba(99, 102, 241, 1) 0%, rgba(236, 72, 153, 1) 100%);
Gradient Settings
Customize your gradient type, colors, and positions
%
Opacity100%
%
Opacity100%
Preset Gradients
Click on any preset to apply it instantly

Complete Guide to CSS Gradients

CSS gradients are one of the most powerful tools in a web designer's arsenal. They allow you to create smooth transitions between colors, adding depth, dimension, and visual interest to your designs without using images. This comprehensive guide covers everything you need to know about creating stunning gradients for your web projects.

Understanding CSS Gradients

A gradient is a gradual blending from one color to another. In CSS, gradients are treated as images, which means they can be used anywhere an image is accepted, including backgrounds, borders, and even masks. Unlike traditional images, gradients are generated by the browser mathematically, resulting in perfectly smooth transitions at any resolution without any file size overhead.

CSS supports three primary types of gradients, each serving different design purposes. Linear gradients create color transitions along a straight line and are the most commonly used type. Radial gradients emanate from a central point outward in a circular or elliptical pattern. Conic gradients rotate colors around a center point, similar to how a color wheel is organized.

Linear Gradients: The Foundation

Linear gradients are defined using the linear-gradient() function. The basic syntax requires at least two colors, with an optional direction parameter. By default, gradients flow from top to bottom, but you can specify any angle or direction using keywords like to right, to bottom left, or degree values like 45deg or 135deg.

The angle in a linear gradient determines the direction of the color flow. A value of 0degpoints upward, 90deg points to the right, 180deg points downward, and 270degpoints to the left. Understanding this relationship allows you to create precisely angled gradients that complement your design's visual flow.

Color stops define where each color appears in the gradient and can include position values as percentages or length units. For example, linear-gradient(90deg, red 0%, yellow 50%, green 100%) creates a three-color gradient with yellow positioned exactly in the middle. You can also create hard stops by placing two colors at the same position, creating sharp color transitions instead of smooth blends.

Radial Gradients: Creating Depth

Radial gradients use the radial-gradient() function and create color transitions that radiate outward from a center point. They're perfect for creating spotlight effects, buttons with depth, circular overlays, and organic-looking backgrounds. The default shape is an ellipse that fills the entire element, but you can specify a circle for perfectly round gradients.

The size and position of radial gradients can be controlled precisely. Size keywords include closest-side,closest-corner, farthest-side, and farthest-corner, each determining how far the gradient extends. Position is set using the at keyword followed by percentage or length values, such as radial-gradient(circle at 25% 25%, blue, green) for an off-center effect.

Conic Gradients: Advanced Effects

Conic gradients, created with conic-gradient(), are the newest addition to CSS gradients. Colors transition in a sweeping motion around a center point, like the hands of a clock. This makes them ideal for creating color wheels, pie charts, progress indicators, and unique visual effects that aren't possible with linear or radial gradients.

The starting angle of a conic gradient can be adjusted using the from keyword. For example,conic-gradient(from 45deg, red, yellow, green, blue, red) starts the gradient at 45 degrees and cycles through colors before returning to red for a seamless loop. The center position is controlled with the at keyword, just like radial gradients.

Creating Transparent Gradients

Transparent gradients are incredibly useful for creating fade effects, overlays, and layered designs. Instead of using named colors or hex values, use RGBA or HSLA color formats where the alpha channel controls opacity. A gradient like linear-gradient(to bottom, rgba(0,0,0,0.8), rgba(0,0,0,0))creates a classic top-to-bottom fade effect perfect for text overlays on images.

You can also combine transparent gradients with background images using CSS's multiple background feature. List the gradient first (so it appears on top), followed by your image: background: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url('image.jpg');. This technique is widely used for hero sections, cards, and anywhere you need text legibility over images.

Repeating Gradients

CSS provides repeating versions of all three gradient types: repeating-linear-gradient(),repeating-radial-gradient(), and repeating-conic-gradient(). These create patterns by repeating the gradient at specified intervals. They're excellent for creating striped backgrounds, concentric circles, and various geometric patterns without images.

To create stripes, position color stops in pairs at the same position. For example,repeating-linear-gradient(45deg, blue 0px, blue 10px, white 10px, white 20px) creates diagonal stripes. The key is understanding that the gradient repeats based on the last color stop position, so setting stops at 10px and 20px creates stripes that repeat every 20 pixels.

Performance and Best Practices

CSS gradients are highly performant because they're rendered by the browser's GPU. However, complex gradients with many color stops or very large gradient areas can occasionally cause banding—visible steps between colors instead of smooth transitions. To minimize banding, use colors that are close in hue and value, add intermediate color stops to smooth transitions, and consider using larger gradient areas when possible.

For maximum browser compatibility, always provide a solid color fallback before your gradient declaration. While all modern browsers support CSS gradients, some older mobile browsers or corporate environments may have limited support. The fallback ensures your design remains usable even if the gradient doesn't render.

Gradient Design Tips

When choosing colors for gradients, consider using analogous colors (colors next to each other on the color wheel) for smooth, harmonious transitions. Complementary colors can create vibrant, eye-catching gradients but may produce muddy middle tones—add a neutral midpoint to prevent this. For professional designs, subtle gradients using shades of the same color often work better than dramatic multi-color transitions.

The direction of your gradient should follow the natural reading flow or complement your design's visual hierarchy. Vertical gradients (top to bottom) feel stable and grounded, while diagonal gradients add energy and movement. Horizontal gradients can suggest progression or transition. Always consider how the gradient interacts with your content and whether it enhances or distracts from your message.

Using This Gradient Generator

Our gradient generator tool simplifies the process of creating CSS gradients. Start by selecting your gradient type (linear, radial, or conic), then add and adjust color stops to achieve your desired effect. Use the angle slider for linear gradients or position controls for radial and conic gradients to fine-tune the direction and center point.

The real-time preview shows exactly how your gradient will appear, and you can click it at any time to copy the CSS code to your clipboard. Use the preset gradients for quick inspiration, or click the random button to generate unexpected color combinations. When you're satisfied with your gradient, use the download button to save it as a high-resolution PNG image for use in other applications.

Frequently Asked Questions
Common questions about CSS gradients and this tool

What is a CSS gradient?

A CSS gradient is a smooth transition between two or more colors that can be applied as a background to HTML elements. CSS supports three types of gradients: linear gradients (transitions along a straight line), radial gradients (transitions radiating from a center point), and conic gradients (transitions rotating around a center point). Gradients are generated mathematically by the browser, resulting in smooth, scalable graphics without file size overhead.

How do I create a linear gradient in CSS?

To create a linear gradient in CSS, use the linear-gradient() function with the background property. The basic syntax is: background: linear-gradient(direction, color1, color2, ...);For example: background: linear-gradient(90deg, #ff0000, #0000ff);creates a horizontal gradient from red to blue. You can add multiple color stops and specify exact positions for complete control.

What is the difference between linear and radial 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 transition colors from a center point outward in a circular or elliptical pattern. Linear gradients are ideal for backgrounds, buttons, and general UI elements, while radial gradients work well for spotlight effects, circular elements, and creating depth in your designs.

Can I use multiple color stops in a gradient?

Yes, you can use unlimited color stops in CSS gradients. Each color stop defines a color and optionally its position along the gradient line. For example: linear-gradient(90deg, red 0%, yellow 25%, green 50%, blue 75%, purple 100%)creates a rainbow effect with five colors at specific positions. Our tool makes it easy to add, remove, and reposition color stops visually.

How do I make a gradient transparent?

To create transparent gradients, use RGBA or HSLA color values where the last value (alpha) controls opacity. For example: linear-gradient(90deg, rgba(255,0,0,1), rgba(255,0,0,0))creates a gradient from solid red to fully transparent red. Our tool includes opacity controls for each color stop, making it easy to create fade effects and semi-transparent overlays.

Are CSS gradients supported in all browsers?

CSS gradients are supported in all modern browsers including Chrome, Firefox, Safari, Edge, and Opera. Linear and radial gradients have had excellent support since around 2012-2013. Conic gradients have more recent support (2019+) but are now available in all major browsers. For older browsers, consider providing a solid color fallback before your gradient declaration.

What is a conic gradient?

A conic gradient creates color transitions that rotate around a center point, similar to a color wheel or pie chart. The colors transition in a circular motion rather than along a line or from a center point. Conic gradients are created using conic-gradient() and are perfect for creating color wheels, progress indicators, pie charts, and unique visual effects.

How do I create a smooth gradient without banding?

To create smooth gradients without visible color banding, use colors that are closer in hue and value, add intermediate color stops for smoother transitions, use larger gradient areas, and consider adding subtle noise via CSS filters. Using HSL colors instead of RGB can also help create more perceptually uniform transitions between colors.