what is the use of css background image property
Answers
Answer:
The background-image property is used to specify the background image of an element. It can be applied to block elements and inline elements. The background-repeat property is used with background-image to specify whether and how a background image should repeat.
Answer:
CSS background-image property is used to set the background image of an element.
Explanation:
CSS background-image has the following syntax:-
.background{
background-image:url(chrysanthemum.jpg");
}
Here .background is used as a class for any element which requires a background-image. The Url that we have used is to specify the path for the image that will get displayed in the browser.
For Example:-
<!DOCTYPE html>
<html>
<head>
<title>
background-image
</title>
<style>
p{
background-image:url("chrysanthemum.jpg");
}
</style>
</head>
<body>
<p class="background"> image </p>
</body>
</html>
The output of the code:- We will see a background image of chrysanthemum in the webpage.
We can add other properties like background-repeat. This property is applicable when the user has used images that is in png format. So to make the image to be represented horizontally we have to write in this way that is:-
.background{
background-image:url("chrysanthemum.png");
background-repeat:repeat-x;
}
The output of the code:- We will see the image to get represented horizontally.
we can also use this background-image property in case of designing the webpage and more.