I'm new to web development and I'm exploring the concept of white space at the top of a webpage.
Here is a snippet of my code:
HTML:
<div>
<p>lorem ipsum</P>
</div>
CSS:
div {
background-color: black;
}
I attempted setting the body element's margin to 0, but there was still white space at the top of the browser.
body {
margin: 0;
}
Adding padding to the div eliminated the white space.
div {
padding-top: 100px;
}
Are there alternative methods to remove the white space?
I thought that by setting the body element's margin to 0, the default browser margins should have been removed. Why did the white space persist?