This one confuses me a bit. What is the default height of body element in HTML document?
I've read that the height of the body element is as height as it contents. Take a look at the following simple html document. I have no content in the body, but when I give background-color
property to the body, it seems like it take the entire viewport since I can see the color on the whole screen.
So my question is.. when there is no other HTML element in the body, what is the default height of the body?
- Is it the same height as the viewport(100vh)?
- Is it the same height as its content. If yes, the body's height should be 0px when it has no content inside it, am i right? If it is 0px in this case, why am i seeing the body's
background-color
on the whole viewport?
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: lightgray;
}
</style>
</head>
<body>
</body>
</html>