When i add a background-image to the Body element, the background-image actually appears on the HTML container, not the Body. Same thing applies for background-color too. If i however add some background-color to the HTML container, then the background-image and color of the body don't get inherited by the HTML container.
Here's an example.
<html>
<head>
<style>
* {
margin:;
padding:;
}
body {
border:3px solid green;
height:200px;
background-image:url(https://images.immediate.co.uk/production/volatile/sites/30/2020/08/flat-white-3402c4f.jpg?quality=90&resize=500%2C454);
background-repeat:no-repeat;
background-size:100px 100px;
background-color: tan;
background-position:center bottom;
}
html {
border:2px solid red;
height:300px;
}
</style>
</head>
<body>
</body>
</html>
As you can see from this example, i have added a background-image to the body, yet the image gets attached to the HTML container instead.
But, if i now add background-color to the HTML container,
html {
border:2px solid red;
height:300px;
background-color:#f1f1f1;
}
..now you see how the background-image of the Body does doesn't get sort of taken by the HTML, but it remains inside the body.
What is happening here? Why the background-image of the body gets inherited by the html container, but if you add background-color to the html container, it doesn't?
The same thing does not happen if i add a background-image to a div inside a body. The background-image of the div doesn't get inherited by the body.
<body>
<div></div>
</body>
CSS:
div {
height:500px;
border:2px solid red;
background-image: url(https://images.immediate.co.uk/production/volatile/sites/30/2020/08/flat-white-3402c4f.jpg?quality=90&resize=500%2C454);
background-size:100px 100px;
background-repeat: no-repeat;
background-position:center bottom;
}
body {
background-color: tan;
height:600px;
border:2px solid;
}