<div id="title">
<h1>
Title
</h1>
</div>
I know there is some default margin along with h1 tag. When I check it out with chrome dev tools, I find that the div part is smaller than h1 part(the highlighted zone of h1 is larger than div). It seems div does not include the margin of h1, can anyone tell me why ?
From the 2.1 Spec:
"The top margin of an in-flow block element collapses with its first in-flow block-level child's top margin if the element has no top border, no top padding, and the child has no clearance."
Also:
overflow property value other than visible do not have collapsing margins, not even with in-flow block descendantsRegarding negative margin collapsing, the 2.1 Spec states:
"In the case of negative margins, the maximum of the absolute values of the negative adjoining margins is deducted from the maximum of the positive adjoining margins. If there are no positive margins, the maximum of the absolute values of the adjoining margins is deducted from zero."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With