title: IE8 - Odd behavior with head margin collapse on change in CSS "display"
body: <p>I have a strange issue where my head (<code>h1</code>, <code>h2</code>, <code>h3</code>, <code>h4</code>, etc.) margins are collapsing on me, but only in IE8.  I've spent a good deal of time trying to pinpoint the issue I am having, and have narrowed it down to this example.</p>
  
  <p>I am almost completely certain that no other page objects can be removed (including the <code>DOCTYPE</code> declaration) while still representing this bug.  To make the code as compact as possible, the bug only appears after modifying the display property a couple of times, but the real page has an issue each time the display property is modified (i.e. immediately after any "nav" is followed).</p>
  
  <p>I attempted posting this as a jsFiddle, but it was not reproduceable from the result pane.  Therefore, I will post the entire, simplified test case inline, written as small/clean as possible:</p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  "http://www.w3.org/TR/html4/strict.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
     &lt;title&gt;Bug Test of IE8 Collapsing Margin problem&lt;/title&gt;
     &lt;style type="text/css"&gt;
        h2 {
           margin:                20px 0 15px -10px;
           background:            red;
        } h3 {
           margin:                10px 0 15px -10px;
           background:            green;
        } h4 {
           margin-bottom:         -15px;
           background:            blue;
        } .noShow {
           display:               none;
        }
     &lt;/style&gt;
     &lt;script type="text/javascript"&gt;
        function show(theDiv) {
           theDiv   = document.getElementById(theDiv);
           Div1     = document.getElementById('div1');
           Div2     = document.getElementById('div2');
           Div1.style.display   = 'none';
           Div2.style.display   = 'none';
           theDiv.style.display = 'block';
        }
     &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
     &lt;ul&gt;
        &lt;li&gt;&lt;a href="javascript: show('div1');"&gt;Nav1&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href="javascript: show('div2');"&gt;Nav2&lt;/a&gt;&lt;/li&gt;
     &lt;/ul&gt;
     &lt;div id="div1"&gt;
        &lt;h1&gt;Head1&lt;/h1&gt;
        &lt;h2&gt;Head2&lt;/h2&gt;
        &lt;h3&gt;Head3&lt;/h3&gt;
        &lt;h4&gt;Head4&lt;/h4&gt;
        &lt;br&gt;&lt;br&gt;
        Click on "Nav2," then "Nav1," then "Nav2" a second time to see the shift
        in header margins/padding.&lt;br&gt;
  
     &lt;/div&gt;
     &lt;div id="div2" class="noShow"&gt;
        &lt;h1&gt;Head1&lt;/h1&gt;
        &lt;h2&gt;Head2&lt;/h2&gt;
        &lt;h3&gt;Head3&lt;/h3&gt;
        &lt;h4&gt;Head4&lt;/h4&gt;
     &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I've begun reading a bit about margin collapse and how it's supposed to act this way, but if that's the case, why is IE8 the only browser I've tested with this behavior, and why is it not consistent?  I've also tried switching margin with padding to achieve a similar result without the collapsing issue, but unless I did something incorrectly, that had no effect either.</p>
  
  <p>I've tried applying <code>overflow:hidden</code> to the <code>noShow</code> declaration.  This fixes the problem, but I cannot use it in my design.  (Even when adjusting this in the example, it looks wrong and is still inconsistent in its placement.)</p>
  
  <p>Does anyone have any good suggestions on how to work around this problem?  I'd hate to have to turn off my <code>DOCTYPE</code> and force IE7 mode, as I lose other features (such as pseudo-element <code>:before</code>).</p>