Quick Answer
A top-to-bottom gradient from indigo to purple is background: linear-gradient(180deg, #667eea 0%, #764ba2 100%). A radial gradient uses background: radial-gradient(circle, #667eea 0%, #764ba2 100%).
Gradient Settings
Color Stops
Preview
Common Examples
| Input | Result |
|---|---|
| Linear, 180deg, #667eea 0% to #764ba2 100% | background: linear-gradient(180deg, #667eea 0%, #764ba2 100%); |
| Linear, 90deg, #f093fb 0% to #f5576c 100% | background: linear-gradient(90deg, #f093fb 0%, #f5576c 100%); |
| Radial, #667eea 0% to #764ba2 100% | background: radial-gradient(circle, #667eea 0%, #764ba2 100%); |
| Linear, 135deg, #a8edea 0% to #fed6e3 100% | background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); |
| Linear, 45deg, #ff9a9e 0% to #fecfef 100% | background: linear-gradient(45deg, #ff9a9e 0%, #fecfef 100%); |
How It Works
CSS gradients create smooth transitions between two or more colors. They are rendered by the browser as generated images and can be used anywhere a CSS url() image would work, including background, border-image, and list-style-image.
Linear Gradient
linear-gradient(angle, color-stop1, color-stop2, …)
The angle determines the direction of the gradient line:
- 0deg = bottom to top
- 90deg = left to right
- 180deg = top to bottom (default)
- 270deg = right to left
- 135deg = top-left to bottom-right (diagonal)
Each color stop specifies a color and an optional position as a percentage. The browser interpolates smoothly between stops.
Radial Gradient
radial-gradient(shape, color-stop1, color-stop2, …)
Creates a circular or elliptical gradient emanating from a center point. The circle keyword produces a circular gradient, while ellipse (the default) matches the element’s aspect ratio.
Color Stop Positions
Positions are percentages along the gradient line. Setting the first stop at 0% and the last at 100% creates a full gradient. Moving stops closer together creates a sharper transition; for example, #ff0000 45%, #0000ff 55% creates a narrow 10% transition zone between red and blue.
Worked Example
For a diagonal gradient from light teal to soft pink: type = linear, angle = 135deg, color1 = #a8edea at 0%, color2 = #fed6e3 at 100%. The CSS output is background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);. At the 135-degree angle, the gradient flows from the top-left corner to the bottom-right corner. The browser calculates the gradient line, projects each pixel onto it, and interpolates the color based on its position between 0% and 100%.
Related Calculators
Frequently Asked Questions
What is the difference between linear and radial gradients?
Can I use more than two color stops?
linear-gradient(90deg, red 0%, yellow 50%, green 100%) creates a three-color gradient. The browser interpolates smoothly between each adjacent pair of stops.
What does the angle value mean in a linear gradient?
How do I create a hard color boundary instead of a smooth transition?
linear-gradient(90deg, #ff0000 50%, #0000ff 50%) creates a sharp split between red and blue at the midpoint with no blending.
CalculateY