title: Should an end tag close all unclosed intervening start tags with omitted end tags?
body: <p>Am I reading the HTML 4.01 standard wrong, or is Google? In HTML 4.01, if I write:</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;body&gt;plain &lt;em&gt;+em &lt;strong&gt;+strong &lt;/em&gt;-em
  </code></pre>
  
  <p>The rendering in Google Chrome is:</p>
  
  <blockquote>
    <p>plain +<em>em</em> +<strong><em>strong</em></strong> -<strong>em</strong></p>
  </blockquote>
  
  <p>This seems to contradict the HTML 4.01 standard, which summarizes the underlying SGML rules as: “an end tag closes, back to the matching start tag, all unclosed intervening start tags with omitted end tags”.<a href="http://www.w3.org/TR/REC-html40/intro/sgmltut.html#h-3.2.1" rel="nofollow" title="HTML 4.01 Specification, section 3.2.1, Elements">¹</a></p>
  
  <p>That is, the <code>&lt;/em&gt;</code> end tag should close not only the <code>&lt;em&gt;</code> start tag but also the unclosed intervening <code>&lt;strong&gt;</code> start tag, and the rendering should be:</p>
  
  <blockquote>
    <p>plain +<em>em</em> +<strong><em>strong</em></strong> -em</p>
  </blockquote>
  
  <p>A commenter pointed out that it is bad practice to leave tags open, but this is only an academic example. An equally good example would be: <code>&lt;em&gt; +em &lt;strong&gt; +strong &lt;/em&gt; -em &lt;/strong&gt;</code>. It was my understanding from the HTML 4.01 standard that this code fragment would not work as intended because of the overlapping elements: the <code>&lt;/em&gt;</code> end tag should implicitly close the <code>&lt;strong&gt;</code>. The fact that it did work as intended was surprising, and this is what led to my question.</p>
  
  <p>And it turned out I proposed a false dichotomy in the question: neither Google nor I were reading the HTML 4.01 standard wrong. A private correspondent at <em>w3.org</em> pointed me to <em>Web SGML and HTML 4.0 Explained</em> by Martin Bryan, which explains that “[t]he parsing program will automatically close any currently open embedded element <strong>which has been declared as having omissible end-tags</strong> when it encounters an end-tag for a higher level element. (<strong>If an embedded element whose end-tag cannot be omitted is still open, however, the program will report an error in the coding</strong>.)”<a href="http://www.is-thought.co.uk/book/sgml-9.htm#Omitting" rel="nofollow">²</a> (Emphasis added.) Bryan’s summarization of the SGML standard is right, and HTML 4.01’s summarization is wrong.</p>