The html
height
of this element is 47px.
body {
line-height: 20px;
margin: 8px;
display: flow-root;
}
.div {
margin-top: 11px;
margin-bottom: 10px;
}
<html>
<body>
I am a body
<div class="div">
</div>
</body>
</html>
Is this because:
margin-top of body is 8px.
line-height
is 20px and there is only one line of text.
body
's block-formatting-context means div
s 11px doesn't collapse with body
's margin-bottom and so it expands body
by 11px.
body
's margin-bottom adds 8px to expand html
. This'd give a total of 47px.
Initially, I thought the margin-bottom of div
would collapse with body
's margin-bottom as I interpreted this site as saying block-formatting-context (BFC) didn't effect margin-bottom-collapsing.