background image url in html code example
Example 1: how to set background image in html
<!-- Add image by a HTML element: -->
<div style="background-image: url('img.jpg');">
<!-- Add image by a <style> element: -->
<style>
div {
background-image: url('img.jpg');
}
</style>
<!-- Add to the entire body: -->
<style>
body {
background-image: url('img.jpg');
}
</style>
Example 2: html background image
<!-- Code by Scratchy -->
<!-- Twitter: @S_cratchy-->
<head>
<style>
body {
background-image: url(https://wallup.net/wp-content/uploads/2019/09/110394-cats-grey-kittens-fluffy-fat-grass-animals-cat-kitten-baby-cute-748x468.jpg)
}
</style>
<body>
You have set the background image!
</body>
Example 3: how to change background image in html
<style>
div {
background-image: url('img_girl.jpg');
}
</style>
Example 4: adding background image
body{background-image: url("paper.gif");}
Example 5: how to embed a url in html for background
div {
background-image: url("https://amymhaddad.s3.amazonaws.com/morocco-blue.png");
height: 400px;
width: 100%;
}