background-image
Specifies a background image for an element.
Sample Code
div.test { url("img/test.jpg");}
div.test1 { url('img/test.jpg');}
div.test2 { url(img/test.jpg);}
Available Values
| Value | Description |
|---|---|
| none | No background image is applied. This is the default value. |
| Image path | Sets the specified image as the background image. |
Browser Preview
<p style="background-image: url(/dics/dictionary-css/img/sample_bg.png);">A background image is specified.</p>
Browser Compatibility
8 ○
7 ○
6 ○
2 and below ×
Android Browser
4.4+ ○
3 and below ×※ Version data is based on MDN.
Notes
Specifies a background image. Use none to remove any background image.
You can write the path in any of the following ways:
url("img/test.jpg");
url('img/test.jpg');
url(img/test.jpg);
However, if the directory or file name contains spaces, you must wrap it in " or '.
Note that on Linux and Unix systems, spaces in directory or file names are not recommended. It is safer to rename any files or directories that contain spaces.
※ background-image is also covered in detail in this tutorial article.
If you find any errors or copyright issues, please contact us.