I read on MDN that adding overflow: hidden or float on a containing element creates a block formatting context. This should stop the margin collapsing of inner child elements. But, it doesn't seem to do that. Here's a working example:
.container {
  overflow: hidden;
  border: 1px dotted red;
}
h1, h2 {
  margin: 10px;
  border: 1px dotted blue;
}<div class="container">
  <h1>First</h1>
  <h2> Second </h2>
</div>However, adding float on individual h elements make their margin collapsing disabled. 
Why doesn't creating new Block formatting context on parent element disable margin collapsing?
