The multiple background images for an element can be put in the HTML page using CSS. Use CSS background property to add multiple background images for an element in any pattern and use other CSS property to set the height and width of the images.
The used background property are listed below:
- background-image: url(), url(), …; This property is used to set one or more background images to the element, separated by commas.
- background-position: right bottom, left top; This property is used to set the position of different images in the page. It set the initial position for each background image.
- background-repeat: no-repeat, repeat; This property is used to set the repetition of the background images. The background image can be repeated along the horizontal and vertical axis.
- background-size: cover|contain|30%|200px 100px; This property is used to set the size of the element background image.
Example 1: Use individual background property to specify the multiple background images.
<!DOCTYPE html> <html> <head> <style> body { text-align:center; } h1 { color: green; } #GFG { background-image: background-position: center, center; background-repeat: no-repeat, no-repeat; background-size: 400px 200px, 500px 400px; padding:25px; height:400px; } </style> </head> <body> <div id = "GFG"> <h1>GeeksforGeeks</h1> <h2>Set Multiple Backgrounds</h2> <p> Element contains two background images </p> </div> </body> </html> |
Output:

Example 2: Use background shorthand property to specify the multiple background images.
<!DOCTYPE html> <html> <head> <style> h1 { color: green; } body { text-align: center; } #GFG { background: center no-repeat, center no-repeat; background-size:400px 200px, 400px 400px; padding:25px; height:400px; } </style> </head> <body> <div id = "GFG"> <h1>GeeksforGeeks</h1> <h2>Set Multiple Backgrounds</h2> <p> Element contains two background images </p> </div> </body> </html> |
Output:

Recommended Posts:
- How to display multiple horizontal images in Bootstrap card ?
- How to create a drag and drop feature for reordering the images using HTML CSS and jQueryUI ?
- Difference between background and background-color
- Set the size of background image using CSS ?
- CSS | Border Images
- CSS | Styling Images
- CSS | Polaroid Images
- Set the opacity only to background color not on the text in CSS
- How to give text or an image transparent background using CSS?
- How to stretch and scale background image using CSS?
- JQuery | Setting background-image using CSS property
- How to Rotate Container Background Image using CSS ?
- How to Create Wave Background using CSS ?
- How to use text as background using CSS ?
- How to Create a Wave Image for a Background using HTML and CSS ?
- How to create Skewed Background with hover effect using HTML and CSS?
- How to Create Gradient Background Animation using HTML and CSS ?
- How to Add Image in Text Background using HTML and CSS ?
- How to create a skewed background using CSS ?
- How to create texture background using CSS ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

