CHAPTER 03
Beginner
CSS Colors, Backgrounds, and Gradients
Updated: May 10, 2026
5 min read
# CSS Colors, Backgrounds, and Gradients
1. Introduction
Color brings the web to life! In this chapter, we will dive deep into how CSS handles colors, background images, and beautiful modern gradients to make your websites pop.2. Learning Objectives
- Master color formats: HEX, RGB, RGBA, and HSL.
- Apply background colors and background images.
- Control background repetition and positioning.
- Create linear and radial gradients.
3. Detailed Explanations
Color Formats
CSS supports several ways to define a color.-
Color Names:
red,blue,transparent
-
HEX:
#FF0000(Red)
-
RGB / RGBA:
rgba(255, 0, 0, 0.5)(Red with 50% opacity)
-
HSL:
hsl(120, 100%, 50%)(Green based on Hue, Saturation, Lightness)
css
Background Images
You can set images as backgrounds usingbackground-image.
css
Linear Gradients
Gradients smooth transition between two or more colors.
css
Radial Gradients
Radial gradients emanate from a center point outward.
css
4. Mini Project: Colorful Hero Section
html
css
> [!TIP]
> Always provide a fallback background-color in case your background-image fails to load!