I have the following HTML code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="1.css">
</head>
<body>
<body>
My CSS code is as follows:
body {
background-image: url(tree.png);
background-repeat: no-repeat;
background-position: center;
}
My Chrome browser now displays the following output:

Here the image tree is on top and partially outside the window.
To fix this, I change my CSS code to the following:
body {
background-image: url(tree.png);
background-repeat: no-repeat;
background-position: center;
margin-top: 600px;
}
Now my browser shows the following output:

My question is why should I add margin at the top and the default background-image will not be in the center of my browser page?
source
share