title: HTML/CSS Div Extending Beyond Its Closing Tag
body: <p>On a web page I'm creating, the page is dynamically generated by a PHP-based CMS. The CMS fetches all the information for the page from a database, then echoes the correct HTML tags etc onto the page.</p>
  
  <p>The problem I have is that for some reason my browser is extending a div beyond it's closing tag. </p>
  
  <p>IE: even though I can see the tag closes, the browser doesn't appear to, so any styling applied within that <code>div</code> are being applied to the whole page.</p>
  
  <p>Below is the HTML output. (This is an extract of the page, and the header div is the one that's persisting).</p>
  
  <pre><code>&lt;div id="header"&gt;
   &lt;table&gt;
    &lt;tr&gt;
     &lt;td style="width: 10%;"&gt;
      &lt;img style="height: 120px; width: 101px;" src="img" alt="some alt"&gt;
     &lt;/td&gt;
     &lt;td&gt;
      &lt;h2&gt;Heading&lt;/h2&gt;
      &lt;h3&gt;Subhead&lt;/h3&gt;
     &lt;/td&gt;
    &lt;/tr&gt;
   &lt;table&gt;
  &lt;/div&gt;
  &lt;div id="menubar"&gt;
  </code></pre>
  
  <p>I've also included the opening of the next <code>div</code>.</p>
  
  <p>If I try and style the <code>h2</code> and <code>h3</code> inside of the <code>div</code>, all of the <code>h2</code> and <code>h3</code> tags on the page are affected. Here's my CSS:</p>
  
  <pre><code>#header h2 {
      font-size: 24pt;
      font-weight: 900;
      color: #776F65;
      letter-spacing: 0;
      line-height: 0;
  }
  
  #header h3 {
      font-weight: 900;
      color: #776F65;
      letter-spacing: 0;
      padding-left: 35px;
  }
  </code></pre>
  
  <p>And finally, here's the PHP code I use to generate the HTML output:</p>
  
  <pre><code>echo('&lt;div id="header"&gt;'); // HEADER ELEMENT BEGINS HERE
      while($row = mysql_fetch_array($getHeaderElements)) {
          echo($row['content']);
      }
  echo('&lt;/div&gt;'); // End Header Element.
  </code></pre>
  
  <p>The browser I'm using is Google Chrome.</p>
  
  <p>Does anybody know why this strange behavior is occurring?</p>
  
  <p>Regards,
  Ben.</p>