CSS background image is used to define the image for the background of a block.
Syntax
1 |
background-image: url(enter the image location here); |
1 2 3 4 5 6 7 8 9 10 11 |
<style> .div-bg-img{ background-image:url(../../images/nature.jpg); background-attachment:fixed; min-height:200px; color:#fff; } </style> <div class="div-bg-img"> <p>This is the HTML paragraph inside the div. The div contains some background image. This background image has fixed attachment. The background showing the nature image.</p> </div> |
Output
This is the HTML paragraph inside the div. The div contains some background image. This background image has fixed attachment. The background showing the nature image.
CSS background image values list
Sr. No. | value | Description |
---|---|---|
1 | url(image url location) | Used to make background image. The value for this is the location of the image. |
2 | none | Used to make no background image. |
3 | initial | Used to define as the property initial value. |
4 | inherit | Used to define the computed value of property on the elements parent. |
5 | unset | Used to set all the properties to their parent value if inheritable. |
Reference
The CSS background specification defines in this official webpage