CSS Gradients let you blend multiple colors smoothly without using images. They are great for modern backgrounds, buttons, cards, and UI elements while keeping pages lightweight and scalable.
All gradients are usually applied with the background or background-image property and come in three main types:
✨ No images required
to right or angles like 45deg.red 10%, blue 90%).circle or ellipse and positions like at top left.from and at to control rotation and center point.Gradients are functions used as values of background / background-image. Here is the general syntax for each gradient type:
/* Basic gradient function syntax for all three types */
background: linear-gradient(direction, color-stop1, color-stop2, ...);
background: radial-gradient(shape size at position, color-stop1, color-stop2, ...);
background: conic-gradient(from angle at position, color-stop1, color-stop2, ...);
Linear gradients move along a direction, for example to right, to bottom right, or an angle like 135deg.
Radial gradients start from the center by default, but you can control shape and position, such as circle at center or ellipse at bottom left.
Conic gradients rotate around a center point. You can set the starting angle with from and center with at, like from 90deg at center.
Below are sample boxes that use linear, radial, and conic gradients as backgrounds.
to right45degcircle at centerellipse at bottom leftfrom 0degfrom 90deg at centerEach box uses a different gradient function and parameters to control direction, shape, and colors.
/* Linear gradient backgrounds */
.linear-bg {
background: linear-gradient(to right, #ff7e5f, #feb47b);
}
.linear-angle {
background: linear-gradient(135deg, #00c6ff, #0072ff);
}
/* Radial gradient backgrounds */
.radial-bg {
background: radial-gradient(circle, #43cea2, #185a9d);
}
.radial-ellipse {
background: radial-gradient(ellipse at bottom left, pink, purple);
}
/* Conic gradient backgrounds */
.conic-bg {
background: conic-gradient(from 0deg, red, yellow, green, blue, red);
}
.conic-90 {
background: conic-gradient(from 90deg at center, #ff6a00, #ee0979, #ff6a00);
}
<!-- Example gradient demo structure -->
<div class="linear-bg">Linear Gradient to right</div>
<div class="linear-angle">Linear Gradient at 135deg</div>
<div class="radial-bg">Radial Gradient circle</div>
<div class="radial-ellipse">Radial Gradient ellipse at bottom left</div>
<div class="conic-bg">Conic Gradient from 0deg</div>
<div class="conic-90">Conic Gradient from 90deg</div>
red 10% and blue 90% to avoid harsh transitions.background-blend-mode for advanced visual effects.background-color before the gradient as a graceful fallback.div with a diagonal linear gradient using to bottom right and apply it as a card background.90deg and includes five different colors for a pie-like effect.:hover and a smooth transition.rgba(255, 0, 0, 0.7)).
/* Starter styles for experimenting with gradients */
.gradient-card {
width: 260px;
padding: 20px;
border-radius: 16px;
color: #ffffff;
text-align: center;
background: linear-gradient(to bottom right, #4facfe, #00f2fe);
transition: background 0.4s ease;
}
.gradient-card:hover {
background: radial-gradient(circle at top left, #ff9a9e, #fecfef);
}