<head>
<style>
body{
background-color: yellow;
}
</style>
</head>
<body>
<div style="background:red;height:100px;margin-top:0;">Why is this not starting from top?</div>
</body>
I have the code as above. As you can see there is only one div. But why doesn’t the div start form the top of the browser(Why is the yellow background seen at the upper-margin?) I know a way to fix using margin-top:-10px; but is that the best way?
<head>
<style>
body{
background-color: yellow;
}
</style>
</head>
<body>
<div style=“background:red;height:100px;top:0;”>Why is this not starting from top?</div>
</body>