How to Create Beautiful CSS Gradients: Linear, Radial and Conic
Learn how to create CSS gradients with linear, radial and conic syntax, color stops, angles and practical tips for websites.
A gradient is a smooth blend from one color to another. Instead of a flat block of color, you get a gentle transition that adds depth, energy and polish to a design. Gradients are used for hero backgrounds, buttons, cards, images and text effects, and they are built into CSS, so you do not need an image file to use them.
This guide explains the three types of CSS gradient: linear, radial and conic. You will learn the syntax for each one, how to control direction and color stops, and how to use gradients well on real websites.
What Is a CSS Gradient?
A CSS gradient is a background created by the browser from two or more colors. You list the colors, and the browser blends them smoothly. Because the gradient is code, not an image, it loads fast, scales to any screen size, and stays sharp on every device.
Linear Gradients: Straight-Line Blends
A linear gradient blends colors along a straight line. By default, it runs from top to bottom. You can change the direction with a keyword such as to right, or with an angle in degrees.
/* Top to bottom, the default */
.hero {
background: linear-gradient(#2563eb, #16a34a);
}
/* Left to right */
.hero {
background: linear-gradient(to right, #2563eb, #8b5cf6);
}
/* Diagonal, at a 135-degree angle */
.hero {
background: linear-gradient(135deg, #ec4899, #8b5cf6, #2563eb);
}
You can also control where each color starts and ends with color stops. A color stop is a color plus a position, such as #2563eb 0% or #8b5cf6 70%. If two stops share the same position, the blend becomes a hard edge instead of a smooth transition. That technique is useful for split backgrounds and striped effects.
Radial Gradients: Circles and Ellipses
A radial gradient blends colors outward from a center point, like ripples spreading across water. It is the right choice for glows, spotlights, soft vignettes and circular highlights.
/* A soft glow in the center */
.spotlight {
background: radial-gradient(circle, #fde68a, #f59e0b);
}
/* An ellipse that starts near the top */
.card {
background: radial-gradient(ellipse at top, #dbeafe, #2563eb);
}
/* A tighter glow, with a clear center */
.badge {
background: radial-gradient(circle at 30% 30%, #ffffff, #c7d2fe);
}
The first part of the value sets the shape: circle or ellipse. The at part sets the center, such as at top or at 30% 30%. After that, you list the colors from the center outward. The first color sits in the middle, and the last color fills the edges.
Conic Gradients: Blends Around a Point
A conic gradient blends colors around a center point, like the sweep of a clock hand or the slices of a pie chart. It is the newest of the three types, and it is useful for color wheels, pie charts, loading rings and decorative patterns.
/* A simple two-color sweep */
.wheel {
background: conic-gradient(#2563eb, #ec4899);
}
/* A full color wheel */
.wheel {
background: conic-gradient(red, yellow, green, cyan, blue, magenta, red);
}
/* A pie-chart slice: one color to 25%, then another */
.chart {
background: conic-gradient(#16a34a 0% 25%, #e5e7eb 25% 100%);
}
By default, a conic gradient starts at the top and sweeps clockwise. You can change the start angle with from, for example conic-gradient(from 90deg, #2563eb, #ec4899). You can also set the center with at, in the same way as a radial gradient.
Practical Uses and Tips for Readable Text
Gradients are most useful in a few places on a website. Hero sections use a soft linear gradient to add depth behind a headline. Buttons use a short gradient to look raised and clickable. Cards use a subtle gradient to separate them from the page background. Image overlays use a dark gradient to make white text readable over a photo.
- Keep text readable. Put dark text on light gradients and white text on dark gradients. If the gradient changes a lot behind the text, add a dark overlay or a solid panel behind the words.
- Test contrast at both ends. A headline may be readable over the dark end of a gradient but unreadable over the light end. Check the whole area, not just one corner.
- Use close colors for large areas. Two colors from the same family give a smooth, calm blend. Very different colors can create a muddy middle band.
- Try a subtle gradient first. A gentle shift between two nearby shades often looks more professional than a bold rainbow. Save strong gradients for accents and calls to action.
- Match the gradient to your palette. Build gradients from colors already in your brand palette, so the page feels consistent. A ready-made set helps here: try the free color palette generator to find colors that work together.
The fastest way to experiment is with the free CSS gradient generator on Front Design Tool. Pick your colors, choose linear, radial or conic, adjust the angle and stops, and copy the CSS straight into your project. You can also browse all the free tools on Front Design Tool when you need a color picker or palette for the same design.