How to add multiple backgrounds to an element in CSS

Overview

The background-image property can add multiple background images to an element. It allows us to append multiple image URLs with a comma (,) and stacks the images on top of each other.

Code

Explanation

HTML

  • Lines 4-5: These lines just set up the basic layout and add some text for our Html page.

  • Lines 7-10: These lines create a div (CSS element), test.

CSS

  • Lines 1-6: These lines set the layout for the test div. The styling sets the two images as the background and defines their positions.
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources