One of the lesser known improvements in CSS3 is the ability to specify multiple backgrounds with the background. In this way the different backgrounds will be assembled in a cascade.
But first let’s check the property background.
background: [color] [image] [repeat] [attachment] [position];
In this way, putting an image in a simple way could be done as follows:
background:url(logo.png) no-repeat 50px 700px;
To put multiple backgrounds with CSS we will simply have to concatenate them with commas. Thus, if we want to have two background images we will do it in the following way:
background:url(logo.png) no-repeat 50px 700px,
url(bg.gif) repeat 0 0;
As multiple background support is not in all browsers we will have to use a little trick, and this will be to specify multiple backgrounds. One of them will be defined in the traditional way:
background:url(bg.gif) repeat 0 0;
background:url(logo.png) no-repeat 50px 700px,
url(bg.gif) repeat 0 0;
So the browser that does not support multiple backgrounds will load a single background, in the traditional way.
The browser versions from which multiple backgrounds are supported with CSS are:
- Chrome 4.0
- Safari 4.0
- Opera 10.10
- Firefox 3.6
- Internet Explorer 9
