html - Why does -webkit-margin-collapse take the smallest value when there is an h1 inside of the body tag? -


i'm trying understand default stylesheet chrome.

if have html:

<body><h1>hello</h1></body>

by default <body> tag has margin of 8px, , <h1> tag has default -webkit-margin-before of 0.67 em, comes 21.44px. why <h1> tag appear ignore 21.44px margin? margin collapse rules should take larger of 2 margins.

thanks!

in quirks mode, margin collapsing behaves differently in variety of situations. in example, default top margin of first child of body has default margins, such p or h1, ignored. believe chrome implements behavior via -webkit-margin-collapse property (as mentioned in title); firefox instead zeroes out top margin of body > :-moz-first-node elements (see quirk.css).

you'll see expected behavior when include doctype.


Comments