Just:
<html>
<head></head> //there is content in here
</html>
by itself shows html
has a height of 8px
(according to Chrome). Why is this?
Just:
<html>
<head></head> //there is content in here
</html>
by itself shows html
has a height of 8px
(according to Chrome). Why is this?
In most browsers including Chrome the body
element has margin:8px
by default. This is what you see.
It is only 8px and not 16px (8px top + 8px bottom added together) because of collapsing margins. There is no content so the top and bottom margins are "collapsing" together.
A body
element is added automatically even though you didn't put it in your HTML, if you inspect it in Chrome you will see it and also where the user agent stylesheet is adding the 8px:
If you inspect this snippet, the height will be 0:
body { margin:0;}
<html>
<head>
</head>
</html>
Or inspect this snippet and the height will be 20px;
body { margin: 20px 0 0 0;}
<html>
<head>
</head>
</html>
That's because the application author's stylesheet for the <body>
element comes with a margin of 8px (or similar). So the default of the <body>
element (which is a mandatory element and, thus, will automatically be added by the browser) will look like this:
<html>
<head>
<title></title>
</head>
<body style="margin: 1ex;">
</body>
</html>
PS: The default style of margin: 1ex;
may alternatively be added to the <html>
element itself. It depends on the browser manufacturer's preference.
I am not sure but I think that Chrome might just assign a default value because once I was doing something with rows where I needed to put floating-left, and I didn't so in chrome and on mozilla would look different