The reason the first method does not work but the second one does is that the second is not shorthand for the first. As per this significantly better answer the use of the comma in the background property sets multiple backgrounds which get layered on top of each other (instead of a single background with an image over a colour).
Hence, it is recommended to use a background on body (rather than on html). If you want a background-image to stretch the whole container (i.e. body), then you could use the style:
will look for images folder in the folder from which css is loaded. So if images are in another folder or out of the CSS folder tree you should use absolute path or relative to the root path (starting with /) 3) you should use complete declaration for background-image to make it behave consistently across standards compliant browsers like:
If the background-size property is set to "100% 100%", the background image will stretch to cover the entire content area There it shows the 'img_flowers.jpg' stretching to the size of the screen or browser regardless of how you resize it.
Related to How do I give text or an image a transparent background using CSS?, but slightly different. I'd like to know if it's possible to change the alpha value of a background image, rather tha...
CSS background image to fit width, height should auto-scale in proportion Asked 13 years, 10 months ago Modified 2 years, 3 months ago Viewed 1.2m times
But in this case, since it is a background-image, that solution won't work. One solution would be to generate the image as a PNG with the required opacity in the image itself. Another solution would be to take the child div out and make it absolutely positioned.
Use background-image if you intend to have people print your page and you do not want the image to be included by default. — JayTee Use background-image if you need to improve download times, as with CSS sprites. Use background-image if you need for only a portion of the image to be visible, as with CSS sprites.