CHAPTER 47
CSS Multiple Backgrounds
Learn how multiple background images and colors can be combined in a single CSS background declaration.
01. What is CSS Multiple Backgrounds?
CSS allows multiple background layers on one element.
Each background layer can have its own position and size.
Multiple backgrounds are useful for advanced visual effects.
02. Syntax
selector {
background-image:
url(image1.png),
url(image2.png);
}
03. Example
CSS / HTML Example
AIFA Coding Lab
<!DOCTYPE html>
<html>
<head>
<style>
.hero {
min-height: 300px;
padding: 40px;
color: white;
background-image:
radial-gradient(
circle at top right,
rgba(59,130,246,.5),
transparent 40%
),
linear-gradient(
135deg,
#020617,
#172554
);
}
</style>
</head>
<body>
<section class="hero">
<h1>
AIFA Coding Lab
</h1>
<p>
Multiple background layers.
</p>
</section>
</body>
</html>
04. Important Points
✓
Multiple backgrounds are separated using commas.
✓
The first background is generally the topmost layer.
✓
Background-size and background-position can be controlled separately.
✓
Gradients can also be combined with images.
05. Common Mistakes
⚠
Using incorrect layer order.
⚠
Forgetting commas between background layers.
⚠
Creating backgrounds that make text difficult to read.
06. Real World Use
Multiple backgrounds are useful for hero sections, overlays, decorative cards, landing pages and premium UI designs.
Ready to Practice? 🚀
Open the AIFA CSS Editor and practice this chapter live.
Try It Yourself →
Practice Exercise
Create a Layered Hero
Create a hero section using two background layers: a gradient and another decorative background.