CSS Gradient Generator: Create Gradients for Your Website
Create CSS gradients with a generator: understand linear and radial gradients, color stops, and generate ready-to-use CSS code instantly.
Color Tools · UtilityHub Blog
Why gradients make websites look professional
A flat background works, but a well-crafted gradient adds depth, dimension, and visual interest to any webpage. From hero sections to card backgrounds, CSS gradients are the fastest way to elevate a design — and you do not need to be a designer to create them.
A gradient generator takes the guesswork out of the process. Pick two or more colors, choose a direction, and get copy-paste CSS code ready to use.
What is a CSS gradient?
A CSS gradient is a background image created entirely with code. Unlike a PNG or JPG gradient image, CSS gradients:
- Scale to any resolution without pixelation
- Load instantly with zero HTTP requests
- Can be animated with transitions
- Work with
background-colorfallbacks for older browsers
CSS gradients are defined using the linear-gradient() or radial-gradient() functions inside the background or background-image property.
Linear gradients: the most common type
A linear gradient transitions colors along a straight line. You define a direction and one or more color stops.
Basic syntax
.element {
background: linear-gradient(direction, color1, color2);
}
Directional examples
/* Top to bottom (default) */
background: linear-gradient(to bottom, #667eea, #764ba2);
/* Left to right */
background: linear-gradient(to right, #f093fb, #f5576c);
/* Diagonal: top-left to bottom-right */
background: linear-gradient(135deg, #4facfe, #00f2fe);
/* Custom angle */
background: linear-gradient(45deg, #fa709a, #fee140);
Direction keywords
| Keyword | Angle | Effect |
|---|---|---|
to top | 0deg | Colors flow upward |
to right | 90deg | Colors flow rightward |
to bottom | 180deg | Colors flow downward (default) |
to left | 270deg | Colors flow leftward |
135deg | 135deg | Diagonal from top-left |
45deg | 45deg | Diagonal from bottom-left |
Radial gradients: circles and ellipses
A radial gradient radiates outward from a central point. It is ideal for spotlight effects, glowing buttons, and centered backgrounds.
Basic syntax
.element {
background: radial-gradient(circle, color1, color2);
}
Examples
/* Circle from center */
background: radial-gradient(circle, #a18cd1, #fbc2eb);
/* Ellipse (default shape) */
background: radial-gradient(ellipse, #ffecd2, #fcb69f);
/* Off-center circle */
background: radial-gradient(circle at 30% 20%, #667eea, #764ba2);
Color stops: controlling the transition
Color stops define where each color begins and ends along the gradient line. By default, colors are evenly distributed. You can place them at specific positions to create hard edges, smooth blends, or custom transitions.
Even distribution
background: linear-gradient(to right, red, blue);
/* Red at 0%, blue at 100%, smooth blend in between */
Custom stops
background: linear-gradient(to right, red 0%, red 30%, blue 30%, blue 100%);
/* Hard split: red for the first 30%, blue for the rest */
Midpoint control
background: linear-gradient(to right, #667eea, #764ba2 60%);
/* The blend point shifts — more blue-purple area */
Popular gradient combinations
Here are 10 trending gradient pairs used in modern web design:
| Name | Colors | CSS Code |
|---|---|---|
| Royal Purple | Purple to dark blue | linear-gradient(135deg, #667eea, #764ba2) |
| Sunset Glow | Pink to orange | linear-gradient(135deg, #f093fb, #f5576c) |
| Ocean Breeze | Blue to cyan | linear-gradient(135deg, #4facfe, #00f2fe) |
| Peach Fuzz | Coral to peach | linear-gradient(135deg, #fa709a, #fee140) |
| Mint Fresh | Green to teal | linear-gradient(135deg, #a8edea, #fed6e3) |
| Warm Flame | Orange to pink | linear-gradient(135deg, #ff9a9e, #fecfef) |
| Cool Blues | Teal to blue | linear-gradient(135deg, #89f7fe, #66a6ff) |
| Deep Space | Dark purple to black | linear-gradient(135deg, #0c0c1d, #434371) |
| Northern Lights | Green to blue to purple | linear-gradient(135deg, #43e97b, #38f9d7, #667eea) |
| Golden Hour | Yellow to orange | linear-gradient(135deg, #f6d365, #fda085) |
Multi-stop gradients for complex effects
You are not limited to two colors. Add as many stops as needed for rich, layered effects.
Rainbow gradient
background: linear-gradient(to right,
red, orange, yellow, green, blue, indigo, violet
);
Neomorphic glow
background: linear-gradient(145deg,
#e0e5ec 0%,
#f0f4f8 30%,
#d5dbe3 70%,
#c8ced6 100%
);
Metallic sheen
background: linear-gradient(90deg,
#2c3e50 0%,
#4ca1af 25%,
#2c3e50 50%,
#4ca1af 75%,
#2c3e50 100%
);
Gradient overlays for images
Gradients over images create depth and improve text readability. This technique is used on hero sections, card thumbnails, and video thumbnails.
Dark overlay for readable text
.hero {
background:
linear-gradient(to bottom, transparent 40%, rgba(0,0,0,0.8)),
url('/hero-image.jpg') center/cover;
}
Color tint overlay
.card-image {
background:
linear-gradient(135deg, rgba(102,126,234,0.4), rgba(118,75,162,0.4)),
url('/photo.jpg') center/cover;
}
Animated CSS gradients
Gradients can be animated using background-size and @keyframes to create shifting color effects.
Animated gradient background
.animated-bg {
background: linear-gradient(270deg, #667eea, #764ba2, #f093fb, #f5576c);
background-size: 400% 400%;
animation: gradientShift 8s ease infinite;
}
@keyframes gradientShift {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
Gradient border animation
.gradient-border {
border: 3px solid transparent;
background-image: linear-gradient(#fff, #fff), linear-gradient(90deg, #667eea, #764ba2);
background-origin: border-box;
background-clip: padding-box, border-box;
}
Gradient text effect
Apply a gradient directly to text using background-clip. This creates eye-catching headings without images.
.gradient-text {
background: linear-gradient(135deg, #667eea, #764ba2);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
font-size: 3rem;
font-weight: 800;
}
Fallback colors for older browsers
Always provide a solid background-color before the gradient. If a browser does not support gradients, users still see a usable background.
.element {
background-color: #667eea; /* Fallback */
background: linear-gradient(135deg, #667eea, #764ba2);
}
Performance tips for CSS gradients
- Keep gradients simple — complex multi-stop gradients on large elements can cause paint performance issues on low-end devices
- Avoid animating huge gradients — use
will-change: background-positionfor smoother animations - Use
background-sizecarefully — oversized backgrounds waste GPU memory - Test on mobile — some older Android devices struggle with animated gradients
- Prefer CSS gradients over image downloads — a gradient CSS rule is typically under 100 bytes, while a gradient PNG is 5-50KB
How to use the gradient generator tool
- Open the gradient generator
- Select your first and second colors using the color picker
- The tool generates the CSS code in real time
- Copy the gradient CSS and paste it into your stylesheet
No design skills required. The tool handles the syntax so you can focus on choosing colors that look great together.
Choosing colors that work well together
A gradient is only as good as the color combination. Here are strategies that always work:
- Analogous colors (colors next to each other on the color wheel) create smooth, harmonious transitions — blue to teal, red to orange
- Complementary colors (opposite on the wheel) create high-contrast, bold gradients — purple to yellow, blue to orange
- Monochromatic (same hue, different lightness) creates elegant, subtle depth — dark blue to light blue
- Triadic (three equally spaced colors) creates vibrant, energetic gradients — red, yellow, blue
Use a color palette generator to find the exact shades that work for your project.
Common gradient mistakes to avoid
- Too many colors — more than 3-4 stops can look muddy. Keep it clean
- Low contrast with text — always check that text over a gradient is readable
- No fallback color — always include a solid
background-color - Random directions — choose a direction that guides the eye toward your call-to-action
- Ignoring the content underneath — a gradient background should enhance, not compete with, the content on top
Final thoughts
CSS gradients give you professional-quality backgrounds, overlays, and effects with zero image files and minimal code. Use a gradient generator to speed up the process, experiment with color combinations, and get production-ready CSS code in seconds.