CHAPTER 49
CSS Gradients
Learn how linear, radial and conic gradients create smooth color transitions without image files.
01. What is CSS Gradients?
A gradient creates a smooth transition between two or more colors.
Linear gradients transition along a straight direction.
Radial gradients spread from a central point.
Conic gradients rotate around a center point.
02. Syntax
background: linear-gradient(
direction,
color1,
color2
);
03. Example
CSS / HTML Example
AIFA Coding Lab
<!DOCTYPE html>
<html>
<head>
<style>
.linear {
width: 100%;
height: 180px;
background:
linear-gradient(
135deg,
#2563eb,
#7c3aed,
#ec4899
);
}
.radial {
width: 180px;
height: 180px;
background:
radial-gradient(
circle,
#38bdf8,
#1e3a8a
);
border-radius: 50%;
}
</style>
</head>
<body>
<div class="linear"></div>
<br>
<div class="radial"></div>
</body>
</html>
04. Important Points
✓
linear-gradient creates straight color transitions.
✓
radial-gradient creates circular or elliptical transitions.
✓
conic-gradient rotates colors around a center.
✓
Gradients can be combined with backgrounds and overlays.
05. Common Mistakes
⚠
Using too many colors.
⚠
Creating gradients with poor text contrast.
⚠
Using gradients everywhere without a consistent design system.
06. Real World Use
Gradients are widely used in hero sections, buttons, cards, backgrounds, banners and modern landing pages.
Ready to Practice? 🚀
Open the AIFA CSS Editor and practice this chapter live.
Try It Yourself →
Practice Exercise
Create a Premium Gradient
Create a hero section with a three-color linear gradient and white text.