I'm new to web dev, and I'm trying to understand more about the white space on the top of the page.
Here's my code snippet:
HTML:
<div>
<p>lorem ipsum</P>
</div>
CSS:
div {
background-color: black;
}
I tried to set 0 margin to the body element but the very top of the browser will still show white space.
body {
margin: 0;
}
Then I tried to add padding to the div, and the white space will no longer be there.
div {
padding-top: 100px;
}
But is there other ways to get rid of the white space?
Also, my understanding was that the browser has default setting to set margins, why did the white space remain after I set the body element's margin to 0?