CSS Background Image

Topic

How to set a background image in html using css?

Explanation

Property :

BackGround Image

Usage:


background-image: url('image.jpg');
background-image: none;

Definition:


Background Image can be set using the tag background-image.
It takes the image in url as said in the example.
a) Url("image directory"). We have to set the image path inside the tag url. It accepts either of the given values.
b) None, if no background image is required.

Examples


Example 1:


<div style="background-image: url('test.jpeg');"> color name <br><br><br></div>
Result:

color name


Example 2:


<font style="background-image: none; background-color: green; "> color using hex values <br><br><br><br></font>
Result:

color using hex values

Now you can see that the image test has been set as background for the div tag.
As none is set for font tag (example 2). Nothing shows up there.