Heights rendering differently in Chrome and Firefox
<p>I found if we set a block level element with <code>height:auto</code> or <code>height: 0~100%</code> without set up parent's height with explicitly value, and its block level child has bottom margin, then it will calculate height differently in Chrome, but not in Firefox. For the case which set <code>height: 1%</code>:</p>

<p><a href="http://codepen.io/anon/pen/BjgKMR" rel="noreferrer">http://codepen.io/anon/pen/BjgKMR</a></p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>html {
  background: pink;
}

body {
  background: yellow;
}

div {
  height: 1%;
}

inner {
  margin-bottom: 30px;
  margin-top: 20px;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt;
  &lt;p class="inner"&gt;block level element&lt;/p&gt;
&lt;/div&gt;</code></pre>
</div>
</div>
</p>

<p>The height of <code>div</code> block will be calculated as the <code>margin-bottom + content height of p element</code>. I am confused about <strong>why the <code>height: 1%</code> should be computed as to <code>auto</code> because the parent elements(<code>html</code> and <code>body</code> tag) not set its height explicitly, but has different height as we just directly set the height to <code>auto</code></strong>?</p>

<p>If we directly set it to <code>height: auto</code>, it will clearly just set the height as its child block-level element's height, which is not include its bottom margin.</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>html {
  background: pink;
}

body {
  background: yellow;
}

div {
  height: auto;
}

inner {
  margin-bottom: 30px;
  margin-top: 20px;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt;&lt;p class="inner"&gt;block level element&lt;/p&gt;&lt;/div&gt;</code></pre>
</div>
</div>
</p>

<p>I have read the CSS 2.1 spec and think about my question might covered with the height property and margin collapse topic, but still cannot understand why it behaves different in Chrome ver. 47.0.2526, though Firefox ver. 44.0.2 will display the height with same value.  </p>

<p>Listed references:<br>
<a href="https://www.w3.org/TR/CSS2/visudet.html#the-height-property" rel="noreferrer">https://www.w3.org/TR/CSS2/visudet.html#the-height-property</a></p>

<ul>
<li><p>10.5: percentage</p>

<blockquote>
  <p>... If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolutely positioned, the value computes to 'auto'. ...</p>
</blockquote></li>
<li><p>10.6.3: Block-level non-replaced elements in normal flow when <code>overflow</code> computes to <code>visible</code>.</p>

<blockquote>
  <p>... if 'height' is 'auto', the height depends on whether the element has any block-level children and whether it has padding or borders:</p>
  
  <p>The element's height is the distance from its top content edge to the <strong>first applicable</strong> of the following:</p>
  
  <ol>
  <li>the bottom edge of the last line box, if the box establishes a inline formatting context with one or more lines</li>
  <li>the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom margin does not collapse with the element's bottom margin</li>
  <li>the bottom border edge of the last in-flow child whose top margin doesn't collapse with the element's bottom margin</li>
  <li>zero, otherwise</li>
  </ol>
</blockquote></li>
</ul>

<p><a href="https://www.w3.org/TR/2011/REC-CSS2-20110607/box.html#collapsing-margins" rel="noreferrer">https://www.w3.org/TR/2011/REC-CSS2-20110607/box.html#collapsing-margins</a></p>

<ul>
<li><p>8.3.1 collapsing margins.</p>

<blockquote>
  <p>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.  </p>
  
  <p>The bottom margin of an in-flow block box with a 'height' of 'auto' and a 'min-height' of zero collapses with its last in-flow block-level child's bottom margin if the box has no bottom padding and no bottom border and the child's bottom margin does not collapse with a top margin that has clearance.  </p>
  
  <p>... If the top and bottom margins of a box are adjoining, then it is possible for margins to collapse through it. In this case, the position of the element depends on its relationship with the other elements whose margins are being collapsed.  </p>
  
  <ul>
  <li>If the element's margins are collapsed with its parent's top margin, the top border edge of the box is defined to be the same as the parent's.</li>
  <li>Otherwise, either the element's parent is not taking part in the margin collapsing, or only the parent's bottom margin is involved. The position of the element's top border edge is the same as it would have been if the element had a non-zero bottom border.</li>
  </ul>
</blockquote></li>
</ul>