[html5] r1403 - /

whatwg at whatwg.org whatwg at whatwg.org
Sat Apr 5 04:14:54 PDT 2008


Author: ianh
Date: 2008-04-05 04:14:50 -0700 (Sat, 05 Apr 2008)
New Revision: 1403

Modified:
   index
   source
Log:
[e] (0) Move some of the tree construction state to before the tokeniser.

Modified: index
===================================================================
--- index	2008-04-05 10:50:19 UTC (rev 1402)
+++ index	2008-04-05 11:14:50 UTC (rev 1403)
@@ -1623,98 +1623,101 @@
           the encoding while parsing</a>
         </ul>
 
-       <li><a href="#tokenisation"><span class=secno>8.2.3
+       <li><a href="#parse"><span class=secno>8.2.3 </span>Parse state</a>
+        <ul class=toc>
+         <li><a href="#the-insertion"><span class=secno>8.2.3.1. </span>The
+          insertion mode</a>
+
+         <li><a href="#the-stack"><span class=secno>8.2.3.2. </span>The stack
+          of open elements</a>
+
+         <li><a href="#the-list"><span class=secno>8.2.3.3. </span>The list
+          of active formatting elements</a>
+
+         <li><a href="#the-element"><span class=secno>8.2.3.4. </span>The
+          element pointers</a>
+        </ul>
+
+       <li><a href="#tokenisation"><span class=secno>8.2.4
         </span>Tokenisation</a>
         <ul class=toc>
-         <li><a href="#tokenising"><span class=secno>8.2.3.1.
+         <li><a href="#tokenising"><span class=secno>8.2.4.1.
           </span>Tokenising entities</a>
         </ul>
 
-       <li><a href="#tree-construction"><span class=secno>8.2.4 </span>Tree
+       <li><a href="#tree-construction"><span class=secno>8.2.5 </span>Tree
         construction</a>
         <ul class=toc>
-         <li><a href="#the-stack"><span class=secno>8.2.4.1. </span>The stack
-          of open elements</a>
-
-         <li><a href="#the-list"><span class=secno>8.2.4.2. </span>The list
-          of active formatting elements</a>
-
-         <li><a href="#creating"><span class=secno>8.2.4.3. </span>Creating
+         <li><a href="#creating"><span class=secno>8.2.5.1. </span>Creating
           and inserting HTML elements</a>
 
-         <li><a href="#closing"><span class=secno>8.2.4.4. </span>Closing
+         <li><a href="#closing"><span class=secno>8.2.5.2. </span>Closing
           elements that have implied end tags</a>
 
-         <li><a href="#the-element"><span class=secno>8.2.4.5. </span>The
-          element pointers</a>
-
-         <li><a href="#resetting"><span class=secno>8.2.4.6. </span>Resetting
-          the insertion mode</a>
-
-         <li><a href="#the-initial"><span class=secno>8.2.4.7. </span>The
+         <li><a href="#the-initial"><span class=secno>8.2.5.3. </span>The
           "initial" insertion mode</a>
 
-         <li><a href="#the-before"><span class=secno>8.2.4.8. </span>The
+         <li><a href="#the-before"><span class=secno>8.2.5.4. </span>The
           "before html" insertion mode</a>
 
-         <li><a href="#the-before0"><span class=secno>8.2.4.9. </span>The
+         <li><a href="#the-before0"><span class=secno>8.2.5.5. </span>The
           "before head" insertion mode</a>
 
-         <li><a href="#parsing-main-inhead"><span class=secno>8.2.4.10.
+         <li><a href="#parsing-main-inhead"><span class=secno>8.2.5.6.
           </span>The "in head" insertion mode</a>
 
          <li><a href="#parsing-main-inheadnoscript"><span
-          class=secno>8.2.4.11. </span>The "in head noscript" insertion
+          class=secno>8.2.5.7. </span>The "in head noscript" insertion
           mode</a>
 
-         <li><a href="#the-after"><span class=secno>8.2.4.12. </span>The
+         <li><a href="#the-after"><span class=secno>8.2.5.8. </span>The
           "after head" insertion mode</a>
 
-         <li><a href="#parsing-main-inbody"><span class=secno>8.2.4.13.
+         <li><a href="#parsing-main-inbody"><span class=secno>8.2.5.9.
           </span>The "in body" insertion mode</a>
 
-         <li><a href="#parsing-main-intable"><span class=secno>8.2.4.14.
+         <li><a href="#parsing-main-intable"><span class=secno>8.2.5.10.
           </span>The "in table" insertion mode</a>
 
-         <li><a href="#parsing-main-incaption"><span class=secno>8.2.4.15.
+         <li><a href="#parsing-main-incaption"><span class=secno>8.2.5.11.
           </span>The "in caption" insertion mode</a>
 
-         <li><a href="#parsing-main-incolgroup"><span class=secno>8.2.4.16.
+         <li><a href="#parsing-main-incolgroup"><span class=secno>8.2.5.12.
           </span>The "in column group" insertion mode</a>
 
-         <li><a href="#parsing-main-intbody"><span class=secno>8.2.4.17.
+         <li><a href="#parsing-main-intbody"><span class=secno>8.2.5.13.
           </span>The "in table body" insertion mode</a>
 
-         <li><a href="#parsing-main-intr"><span class=secno>8.2.4.18.
+         <li><a href="#parsing-main-intr"><span class=secno>8.2.5.14.
           </span>The "in row" insertion mode</a>
 
-         <li><a href="#parsing-main-intd"><span class=secno>8.2.4.19.
+         <li><a href="#parsing-main-intd"><span class=secno>8.2.5.15.
           </span>The "in cell" insertion mode</a>
 
-         <li><a href="#parsing-main-inselect"><span class=secno>8.2.4.20.
+         <li><a href="#parsing-main-inselect"><span class=secno>8.2.5.16.
           </span>The "in select" insertion mode</a>
 
-         <li><a href="#parsing-main-inselect"><span class=secno>8.2.4.21.
+         <li><a href="#parsing-main-inselect"><span class=secno>8.2.5.17.
           </span>The "in select in table" insertion mode</a>
 
-         <li><a href="#parsing-main-afterbody"><span class=secno>8.2.4.22.
+         <li><a href="#parsing-main-afterbody"><span class=secno>8.2.5.18.
           </span>The "after body" insertion mode</a>
 
-         <li><a href="#parsing-main-inframeset"><span class=secno>8.2.4.23.
+         <li><a href="#parsing-main-inframeset"><span class=secno>8.2.5.19.
           </span>The "in frameset" insertion mode</a>
 
          <li><a href="#parsing-main-afterframeset"><span
-          class=secno>8.2.4.24. </span>The "after frameset" insertion
+          class=secno>8.2.5.20. </span>The "after frameset" insertion
           mode</a>
 
-         <li><a href="#the-after0"><span class=secno>8.2.4.25. </span>The
+         <li><a href="#the-after0"><span class=secno>8.2.5.21. </span>The
           "after after body" insertion mode</a>
 
-         <li><a href="#the-after1"><span class=secno>8.2.4.26. </span>The
+         <li><a href="#the-after1"><span class=secno>8.2.5.22. </span>The
           "after after frameset" insertion mode</a>
         </ul>
 
-       <li><a href="#the-end"><span class=secno>8.2.5 </span>The end</a>
+       <li><a href="#the-end"><span class=secno>8.2.6 </span>The end</a>
       </ul>
 
      <li><a href="#namespaces"><span class=secno>8.3 </span>Namespaces</a>
@@ -21762,7 +21765,7 @@
    conforming document with no <code><a href="#noscript">noscript</a></code>
    elements and no <code><a href="#script0">script</a></code> elements, and
    such that no step in the algorithm causes an <a href="#html-0">HTML
-   parser</a> to flag a <a href="#parse0">parse error</a>:
+   parser</a> to flag a <a href="#parse1">parse error</a>:
 
   <ol>
    <li>Remove every <code><a href="#script0">script</a></code> element from
@@ -28123,7 +28126,7 @@
 
   <h5 id=parsing0><span class=secno>4.6.3.2. </span>Parsing cache manifests</h5>
 
-  <p>When a user agent is to <dfn id=parse>parse a manifest</dfn>, it means
+  <p>When a user agent is to <dfn id=parse0>parse a manifest</dfn>, it means
    that the user agent must run the following steps:
 
   <ol>
@@ -28411,7 +28414,7 @@
 
     <p>If the resource is labelled with the MIME type <code
      title="">text/cache-manifest</code>, parse <var title="">manifest</var>
-     according to the <a href="#parse" title="parse a manifest">rules for
+     according to the <a href="#parse0" title="parse a manifest">rules for
      parsing manifests</a>, obtaining a list of <a href="#explicit"
      title=concept-appcache-explicit>explicit entries</a>, <a
      href="#fallback0" title=concept-appcache-fallback>fallback entries</a>
@@ -38822,7 +38825,7 @@
 
   <p>This specification defines the parsing rules for HTML documents, whether
    they are syntactically valid or not. Certain points in the parsing
-   algorithm are said to be <dfn id=parse0 title="parse error">parse
+   algorithm are said to be <dfn id=parse1 title="parse error">parse
    errors</dfn>. The error handling for parse errors is well-defined: user
    agents must either act as described below when encountering such problems,
    or must abort processing at the first error that they encounter for which
@@ -39339,7 +39342,7 @@
    use the ISO-8859-11 encoding, it must instead use the Windows-874
    encoding. In both cases, any bytes in the range 0x80 to 0x9F must, in
    addition to being interpreted as per the Windows encoding instead of as a
-   control character, be considered <a href="#parse0" title="parse
+   control character, be considered <a href="#parse1" title="parse
    error">parse errors</a>.
 
   <p class=note>The requirement to treat certain ISO-8859 encodings as
@@ -39379,7 +39382,7 @@
 
   <p>All U+0000 NULL characters in the input must be replaced by U+FFFD
    REPLACEMENT CHARACTERs. Any occurrences of such characters is a <a
-   href="#parse0">parse error</a>.
+   href="#parse1">parse error</a>.
 
   <p>Any occurrences of any characters in the ranges U+0001 to U+0008,
    <!-- space characters allowed --> U+000E to U+001F, <!-- ASCII
@@ -39392,7 +39395,7 @@
    U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE, U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE,
    U+7FFFF, U+8FFFE, U+8FFFF, U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE,
    U+BFFFF, U+CFFFE, U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE,
-   U+FFFFF, U+10FFFE, and U+10FFFF are <a href="#parse0" title="parse
+   U+FFFFF, U+10FFFE, and U+10FFFF are <a href="#parse1" title="parse
    error">parse errors</a>. (These are all control characters or permanently
    undefined Unicode characters.)
 
@@ -39468,7 +39471,449 @@
   <p class=note>While the invocation of this algorithm is not a parse error,
    it is <a href="#charset">still indicative of non-conforming content</a>.
 
-  <h4 id=tokenisation><span class=secno>8.2.3 </span><dfn
+  <h4 id=parse><span class=secno>8.2.3 </span>Parse state</h4>
+
+  <h5 id=the-insertion><span class=secno>8.2.3.1. </span>The insertion mode</h5>
+
+  <p>Initially the <span>insertion mode</span> is "<a href="#initial"
+   title="insertion mode: initial">initial</a>". It can change to "<a
+   href="#before4" title="insertion mode: before html">before html</a>", "<a
+   href="#before5" title="insertion mode: before head">before head</a>", "<a
+   href="#in-head" title="insertion mode: in head">in head</a>", "<a
+   href="#in-head0" title="insertion mode: in head noscript">in head
+   noscript</a>", "<a href="#after4" title="insertion mode: after head">after
+   head</a>", "<a href="#in-body" title="insertion mode: in body">in
+   body</a>", "<a href="#in-table" title="insertion mode: in table">in
+   table</a>", "<a href="#in-caption" title="insertion mode: in caption">in
+   caption</a>", "<a href="#in-column" title="insertion mode: in column
+   group">in column group</a>", "<a href="#in-table0" title="insertion mode:
+   in table body">in table body</a>", "<a href="#in-row" title="insertion
+   mode: in row">in row</a>", "<a href="#in-cell" title="insertion mode: in
+   cell">in cell</a>", "<a href="#in-select" title="insertion mode: in
+   select">in select</a>", "<a href="#in-select0" title="insertion mode: in
+   select in table">in select in table</a>", "<a href="#after5"
+   title="insertion mode: after body">after body</a>", "<a
+   href="#in-frameset" title="insertion mode: in frameset">in frameset</a>",
+   "<a href="#after6" title="insertion mode: after frameset">after
+   frameset</a>", "<a href="#after7" title="insertion mode: after after
+   body">after after body</a>", and "<a href="#after8" title="insertion mode:
+   after after frameset">after after frameset</a>" during the course of the
+   parsing, as described in the <a href="#tree-construction0">tree
+   construction</a> stage. The insertion mode affects how tokens are
+   processed and whether CDATA blocks are supported.
+
+  <p>Seven of these modes, namely "<a href="#in-head" title="insertion mode:
+   in head">in head</a>", "<a href="#in-body" title="insertion mode: in
+   body">in body</a>", "<a href="#in-table" title="insertion mode: in
+   table">in table</a>", "<a href="#in-table0" title="insertion mode: in
+   table body">in table body</a>", "<a href="#in-row" title="insertion mode:
+   in row">in row</a>", "<a href="#in-cell" title="insertion mode: in
+   cell">in cell</a>", and "<a href="#in-select" title="insertion mode: in
+   select">in select</a>", are special, in that the other modes defer to them
+   at various times. When the algorithm below says that the user agent is to
+   do something "<dfn id=using8>using the rules for</dfn> the <var
+   title="">m</var> insertion mode", where <var title="">m</var> is one of
+   these modes, the user agent must use the rules described under that
+   <span>insertion mode</span>'s section, but must leave the <span>insertion
+   mode</span> unchanged (unless the rules in that section themselves switch
+   the <span>insertion mode</span>).
+
+  <p>When the steps below require the UA to <dfn id=reset>reset the insertion
+   mode appropriately</dfn>, it means the UA must follow these steps:
+
+  <ol>
+   <li>Let <var title="">last</var> be false.
+
+   <li>Let <var title="">node</var> be the last node in the <a
+    href="#stack">stack of open elements</a>.
+
+   <li>If <var title="">node</var> is the first node in the stack of open
+    elements, then set <var title="">last</var> to true; if, in addition, the
+    <var title="">context</var> element of the <a href="#html-fragment0">HTML
+    fragment parsing algorithm</a> is neither a <code><a
+    href="#td">td</a></code> element nor a <code><a href="#th">th</a></code>
+    element, then set <var title="">node</var> to the <var
+    title="">context</var> element. (<a href="#fragment">fragment case</a>)
+
+   <li>If <var title="">node</var> is a <code>select</code> element, then
+    switch the <span>insertion mode</span> to "<a href="#in-select"
+    title="insertion mode: in select">in select</a>" and abort these steps.
+    (<a href="#fragment">fragment case</a>)
+
+   <li>If <var title="">node</var> is a <code><a href="#td">td</a></code> or
+    <code><a href="#th">th</a></code> element, then switch the
+    <span>insertion mode</span> to "<a href="#in-cell" title="insertion mode:
+    in cell">in cell</a>" and abort these steps.
+
+   <li>If <var title="">node</var> is a <code><a href="#tr">tr</a></code>
+    element, then switch the <span>insertion mode</span> to "<a
+    href="#in-row" title="insertion mode: in row">in row</a>" and abort these
+    steps.
+
+   <li>If <var title="">node</var> is a <code><a
+    href="#tbody">tbody</a></code>, <code><a href="#thead0">thead</a></code>,
+    or <code><a href="#tfoot0">tfoot</a></code> element, then switch the
+    <span>insertion mode</span> to "<a href="#in-table0" title="insertion
+    mode: in table body">in table body</a>" and abort these steps.
+
+   <li>If <var title="">node</var> is a <code><a
+    href="#caption0">caption</a></code> element, then switch the
+    <span>insertion mode</span> to "<a href="#in-caption" title="insertion
+    mode: in caption">in caption</a>" and abort these steps.
+
+   <li>If <var title="">node</var> is a <code><a
+    href="#colgroup">colgroup</a></code> element, then switch the
+    <span>insertion mode</span> to "<a href="#in-column" title="insertion
+    mode: in column group">in column group</a>" and abort these steps. (<a
+    href="#fragment">fragment case</a>)
+
+   <li>If <var title="">node</var> is a <code><a
+    href="#table">table</a></code> element, then switch the <span>insertion
+    mode</span> to "<a href="#in-table" title="insertion mode: in table">in
+    table</a>" and abort these steps.
+
+   <li>If <var title="">node</var> is a <code><a href="#head">head</a></code>
+    element, then switch the <span>insertion mode</span> to "<a
+    href="#in-body" title="insertion mode: in body">in body</a>" ("<a
+    href="#in-body" title="insertion mode: in body">in body</a>"! <em> not
+    "<a href="#in-head" title="insertion mode: in head">in head</a>"</em>!)
+    and abort these steps. (<a href="#fragment">fragment case</a>)</li>
+   <!-- This is only
+   here for now in case people think that the spec accidentally
+   omitted it and try to "fix" it. Note that noscript-in-head is also
+   handled this way. This is all intentional. The only thing it
+   doesn't handle is the scripting-enabled fragment parsing case for a
+   <head> element containing a <noscript> which itself contains
+   something other than a <link> or a <style> element; you'd expect
+   that to break out of the <noscript> but it doesn't. This is an edge
+   case that doesn't affect the spec, since the algorithm for fragment
+   parsing is only used for innerHTML, where we know scripting is
+   enabled. -->
+
+   <li>If <var title="">node</var> is a <code><a
+    href="#body0">body</a></code> element, then switch the <span>insertion
+    mode</span> to "<a href="#in-body" title="insertion mode: in body">in
+    body</a>" and abort these steps.
+
+   <li>If <var title="">node</var> is a <code>frameset</code> element, then
+    switch the <span>insertion mode</span> to "<a href="#in-frameset"
+    title="insertion mode: in frameset">in frameset</a>" and abort these
+    steps. (<a href="#fragment">fragment case</a>)
+
+   <li>If <var title="">node</var> is an <code><a
+    href="#html">html</a></code> element, then: if the <a
+    href="#head-element"><code title="">head</code> element pointer</a> is
+    null, switch the <span>insertion mode</span> to "<a href="#before5"
+    title="insertion mode: before head">before head</a>", otherwise, switch
+    the <span>insertion mode</span> to "<a href="#after4" title="insertion
+    mode: after head">after head</a>". In either case, abort these steps. (<a
+    href="#fragment">fragment case</a>)</li>
+   <!-- XXX
+   can the head element pointer ever be non-null when we're going
+   through these steps? -->
+
+   <li>If <var title="">last</var> is true, then switch the <span>insertion
+    mode</span> to "<a href="#in-body" title="insertion mode: in body">in
+    body</a>" and abort these steps. (<a href="#fragment">fragment case</a>)
+
+   <li>Let <var title="">node</var> now be the node before <var
+    title="">node</var> in the <a href="#stack">stack of open elements</a>.
+
+   <li>Return to step 3.
+  </ol>
+
+  <h5 id=the-stack><span class=secno>8.2.3.2. </span>The stack of open
+   elements</h5>
+
+  <p>Initially the <dfn id=stack>stack of open elements</dfn> is empty. The
+   stack grows downwards; the topmost node on the stack is the first one
+   added to the stack, and the bottommost node of the stack is the most
+   recently added node in the stack (notwithstanding when the stack is
+   manipulated in a random access fashion as part of <a
+   href="#adoptionAgency">the handling for misnested tags</a>).
+
+  <p>The "<a href="#before4" title="insertion mode: before html">before
+   html</a>" <span>insertion mode</span> creates the <code><a
+   href="#html">html</a></code> root element node, which is then added to the
+   stack.
+
+  <p>In the <a href="#fragment">fragment case</a>, the <a href="#stack">stack
+   of open elements</a> is initialised to contain an <code><a
+   href="#html">html</a></code> element that is created as part of <a
+   href="#html-fragment0" title="html fragment parsing algorithm">that
+   algorithm</a>. (The <a href="#fragment">fragment case</a> skips the "<a
+   href="#before4" title="insertion mode: before html">before html</a>"
+   <span>insertion mode</span>.)
+
+  <p>The <code><a href="#html">html</a></code> node, however it is created,
+   is the topmost node of the stack. It never gets popped off the stack.
+
+  <p>The <dfn id=current4>current node</dfn> is the bottommost node in this
+   stack.
+
+  <p>The <dfn id=current5>current table</dfn> is the last <code><a
+   href="#table">table</a></code> element in the <a href="#stack">stack of
+   open elements</a>, if there is one. If there is no <code><a
+   href="#table">table</a></code> element in the <a href="#stack">stack of
+   open elements</a> (<a href="#fragment">fragment case</a>), then the <a
+   href="#current5">current table</a> is the first element in the <a
+   href="#stack">stack of open elements</a> (the <code><a
+   href="#html">html</a></code> element).
+
+  <p>Elements in the stack fall into the following categories:
+
+  <dl>
+   <dt><dfn id=special>Special</dfn>
+
+   <dd>
+    <p>The following HTML elements have varying levels of special parsing
+     rules: <code><a href="#address">address</a></code>, <code><a
+     href="#area">area</a></code>, <code><a href="#base">base</a></code>,
+     <code>basefont</code>, <code>bgsound</code>, <code><a
+     href="#blockquote">blockquote</a></code>, <code><a
+     href="#body0">body</a></code>, <code><a href="#br">br</a></code>,
+     <code>center</code>, <code><a href="#col">col</a></code>, <code><a
+     href="#colgroup">colgroup</a></code>, <code><a href="#dd">dd</a></code>,
+     <code>dir</code>, <code><a href="#div">div</a></code>, <code><a
+     href="#dl">dl</a></code>, <code><a href="#dt">dt</a></code>, <code><a
+     href="#embed">embed</a></code>, <code>fieldset</code>,
+     <code>form</code>, <code>frame</code>, <code>frameset</code>, <code><a
+     href="#h1">h1</a></code>, <code><a href="#h2">h2</a></code>, <code><a
+     href="#h3">h3</a></code>, <code><a href="#h4">h4</a></code>, <code><a
+     href="#h5">h5</a></code>, <code><a href="#h6">h6</a></code>, <code><a
+     href="#head">head</a></code>, <code><a href="#hr">hr</a></code>,
+     <code><a href="#iframe">iframe</a></code>,
+     <code>image</code><!-- XXX ? this isn't an element that can end up
+   on the stack-->,
+     <code><a href="#img">img</a></code>, <code>input</code>,
+     <code>isindex</code>, <code><a href="#li">li</a></code>, <code><a
+     href="#link">link</a></code>, <code>listing</code>, <code><a
+     href="#menu">menu</a></code>, <code><a href="#meta0">meta</a></code>,
+     <code>noembed</code>, <code>noframes</code>, <code><a
+     href="#noscript">noscript</a></code>, <code><a href="#ol">ol</a></code>,
+     <code>optgroup</code>, <code>option</code>, <code><a
+     href="#p">p</a></code>, <code><a href="#param">param</a></code>,
+     <code>plaintext</code>, <code><a href="#pre">pre</a></code>, <code><a
+     href="#script0">script</a></code>, <code>select</code>,
+     <code>spacer</code>, <code><a href="#style">style</a></code>, <code><a
+     href="#tbody">tbody</a></code>, <code>textarea</code>, <code><a
+     href="#tfoot0">tfoot</a></code>, <code><a
+     href="#thead0">thead</a></code>, <code><a
+     href="#title1">title</a></code>, <code><a href="#tr">tr</a></code>,
+     <code><a href="#ul">ul</a></code>, and <code>wbr</code>.
+
+   <dt><dfn id=scoping>Scoping</dfn>
+
+   <dd>
+    <p>The following HTML elements introduce new <a href="#have-an"
+     title="has an element in scope">scopes</a> for various parts of the
+     parsing: <code>applet</code>, <code>button</code>, <code><a
+     href="#caption0">caption</a></code>, <code><a
+     href="#html">html</a></code>, <code>marquee</code>, <code><a
+     href="#object">object</a></code>, <code><a
+     href="#table">table</a></code>, <code><a href="#td">td</a></code> and
+     <code><a href="#th">th</a></code>.
+
+   <dt><dfn id=formatting>Formatting</dfn>
+
+   <dd>
+    <p>The following HTML elements are those that end up in the <a
+     href="#list-of4">list of active formatting elements</a>: <code><a
+     href="#a">a</a></code>, <code><a href="#b">b</a></code>,
+     <code>big</code>, <code><a href="#em">em</a></code>, <code><a
+     href="#font">font</a></code>, <code><a href="#i">i</a></code>,
+     <code>nobr</code>, <code>s</code>, <code><a
+     href="#small">small</a></code>, <code>strike</code>, <code><a
+     href="#strong">strong</a></code>, <code>tt</code>, and <code>u</code>.
+
+   <dt><dfn id=phrasing1>Phrasing</dfn>
+
+   <dd>
+    <p>All other elements found while parsing an HTML document.
+  </dl>
+
+  <p class=big-issue>Still need to add these new elements to the lists:
+   <code><a href="#event-source">event-source</a></code>, <code><a
+   href="#section">section</a></code>, <code><a href="#nav">nav</a></code>,
+   <code><a href="#article">article</a></code>, <code><a
+   href="#aside">aside</a></code>, <code><a href="#header">header</a></code>,
+   <code><a href="#footer">footer</a></code>, <code><a
+   href="#datagrid0">datagrid</a></code>, <code><a
+   href="#command0">command</a></code>
+
+  <p>The <a href="#stack">stack of open elements</a> is said to <dfn
+   id=have-an title="has an element in scope">have an element in scope</dfn>
+   or <dfn id=have-an0 title="has an element in table scope">have an element
+   in <em>table scope</em></dfn> when the following algorithm terminates in a
+   match state:
+
+  <ol>
+   <li>
+    <p>Initialise <var title="">node</var> to be the <a
+     href="#current4">current node</a> (the bottommost node of the stack).
+
+   <li>
+    <p>If <var title="">node</var> is the target node, terminate in a match
+     state.
+
+   <li>
+    <p>Otherwise, if <var title="">node</var> is a <code><a
+     href="#table">table</a></code> element, terminate in a failure state.
+
+   <li>
+    <p>Otherwise, if the algorithm is the "has an element in scope" variant
+     (rather than the "has an element in table scope" variant), and <var
+     title="">node</var> is one of the following, terminate in a failure
+     state:</p>
+
+    <ul class=brief>
+     <li><code>applet</code>
+
+     <li><code><a href="#caption0">caption</a></code>
+
+     <li><code><a href="#td">td</a></code>
+
+     <li><code><a href="#th">th</a></code>
+
+     <li><code>button</code>
+
+     <li><code>marquee</code>
+
+     <li><code><a href="#object">object</a></code>
+    </ul>
+
+   <li>
+    <p>Otherwise, if <var title="">node</var> is an <code><a
+     href="#html">html</a></code> element, terminate in a failure state.
+     (This can only happen if the <var title="">node</var> is the topmost
+     node of the <a href="#stack">stack of open elements</a>, and prevents
+     the next step from being invoked if there are no more elements in the
+     stack.)
+
+   <li>
+    <p>Otherwise, set <var title="">node</var> to the previous entry in the
+     <a href="#stack">stack of open elements</a> and return to step 2. (This
+     will never fail, since the loop will always terminate in the previous
+     step if the top of the stack is reached.)
+  </ol>
+
+  <p>Nothing happens if at any time any of the elements in the <a
+   href="#stack">stack of open elements</a> are moved to a new location in,
+   or removed from, the <code>Document</code> tree. In particular, the stack
+   is not changed in this situation. This can cause, amongst other strange
+   effects, content to be appended to nodes that are no longer in the DOM.
+
+  <p class=note>In some cases (namely, when <a href="#adoptionAgency">closing
+   misnested formatting elements</a>), the stack is manipulated in a
+   random-access fashion.
+
+  <h5 id=the-list><span class=secno>8.2.3.3. </span>The list of active
+   formatting elements</h5>
+
+  <p>Initially the <dfn id=list-of4>list of active formatting elements</dfn>
+   is empty. It is used to handle mis-nested <a href="#formatting"
+   title=formatting>formatting element tags</a>.
+
+  <p>The list contains elements in the <a href="#formatting">formatting</a>
+   category, and scope markers. The scope markers are inserted when entering
+   <code>applet</code> elements, buttons, <code><a
+   href="#object">object</a></code> elements, marquees, table cells, and
+   table captions, and are used to prevent formatting from "leaking" into
+   <code>applet</code> elements, buttons, <code><a
+   href="#object">object</a></code> elements, marquees, and tables.
+
+  <p>When the steps below require the UA to <dfn id=reconstruct>reconstruct
+   the active formatting elements</dfn>, the UA must perform the following
+   steps:
+
+  <ol>
+   <li>If there are no entries in the <a href="#list-of4">list of active
+    formatting elements</a>, then there is nothing to reconstruct; stop this
+    algorithm.
+
+   <li>If the last (most recently added) entry in the <a
+    href="#list-of4">list of active formatting elements</a> is a marker, or
+    if it is an element that is in the <a href="#stack">stack of open
+    elements</a>, then there is nothing to reconstruct; stop this algorithm.
+
+   <li>Let <var title="">entry</var> be the last (most recently added)
+    element in the <a href="#list-of4">list of active formatting
+    elements</a>.
+
+   <li>If there are no entries before <var title="">entry</var> in the <a
+    href="#list-of4">list of active formatting elements</a>, then jump to
+    step 8.
+
+   <li>Let <var title="">entry</var> be the entry one earlier than <var
+    title="">entry</var> in the <a href="#list-of4">list of active formatting
+    elements</a>.
+
+   <li>If <var title="">entry</var> is neither a marker nor an element that
+    is also in the <a href="#stack">stack of open elements</a>, go to step 4.
+
+   <li>Let <var title="">entry</var> be the element one later than <var
+    title="">entry</var> in the <a href="#list-of4">list of active formatting
+    elements</a>.
+
+   <li>Perform a shallow clone of the element <var title="">entry</var> to
+    obtain <var title="">clone</var>. <a href="#refsDOM3CORE">[DOM3CORE]</a>
+
+   <li>Append <var title="">clone</var> to the <a href="#current4">current
+    node</a> and push it onto the <a href="#stack">stack of open elements</a>
+    so that it is the new <a href="#current4">current node</a>.
+
+   <li>Replace the entry for <var title="">entry</var> in the list with an
+    entry for <var title="">clone</var>.
+
+   <li>If the entry for <var title="">clone</var> in the <a
+    href="#list-of4">list of active formatting elements</a> is not the last
+    entry in the list, return to step 7.
+  </ol>
+
+  <p>This has the effect of reopening all the formatting elements that were
+   opened in the current body, cell, or caption (whichever is youngest) that
+   haven't been explicitly closed.
+
+  <p class=note>The way this specification is written, the <a
+   href="#list-of4">list of active formatting elements</a> always consists of
+   elements in chronological order with the least recently added element
+   first and the most recently added element last (except for while steps 8
+   to 11 of the above algorithm are being executed, of course).
+
+  <p>When the steps below require the UA to <dfn id=clear0>clear the list of
+   active formatting elements up to the last marker</dfn>, the UA must
+   perform the following steps:
+
+  <ol>
+   <li>Let <var title="">entry</var> be the last (most recently added) entry
+    in the <a href="#list-of4">list of active formatting elements</a>.
+
+   <li>Remove <var title="">entry</var> from the <a href="#list-of4">list of
+    active formatting elements</a>.
+
+   <li>If <var title="">entry</var> was a marker, then stop the algorithm at
+    this point. The list has been cleared up to the last marker.
+
+   <li>Go to step 1.
+  </ol>
+
+  <h5 id=the-element><span class=secno>8.2.3.4. </span>The element pointers</h5>
+
+  <p>Initially the <dfn id=head-element><code title="">head</code> element
+   pointer</dfn> and the <dfn id=form-element><code title="">form</code>
+   element pointer</dfn> are both null.
+
+  <p>Once a <code><a href="#head">head</a></code> element has been parsed
+   (whether implicitly or explicitly) the <a href="#head-element"><code
+   title="">head</code> element pointer</a> gets set to point to this node.
+
+  <p>The <a href="#form-element"><code title="">form</code> element
+   pointer</a> points to the last <code>form</code> element that was opened
+   and whose end tag has not yet been seen. It is used to make form controls
+   associate with forms in the face of dramatically bad markup, for
+   historical reasons.
+
+  <h4 id=tokenisation><span class=secno>8.2.4 </span><dfn
    id=tokenisation0>Tokenisation</dfn></h4>
 
   <p>Implementations must act as if they used the following state machine to
@@ -39512,7 +39957,7 @@
    flag</a> must be switched to the PCDATA state.
 
   <p>When an end tag token is emitted with attributes, that is a <a
-   href="#parse0">parse error</a>.
+   href="#parse1">parse error</a>.
 
   <p>A <dfn id=permitted>permitted slash</dfn> is a U+002F SOLIDUS character
    that is immediately followed by a U+003E GREATER-THAN SIGN, if, and only
@@ -39666,18 +40111,18 @@
 
        <dt>U+003E GREATER-THAN SIGN (>)
 
-       <dd><a href="#parse0">Parse error</a>. Emit a U+003C LESS-THAN SIGN
+       <dd><a href="#parse1">Parse error</a>. Emit a U+003C LESS-THAN SIGN
         character token and a U+003E GREATER-THAN SIGN character token.
         Switch to the <a href="#data-state">data state</a>.
 
        <dt>U+003F QUESTION MARK (?)
 
-       <dd><a href="#parse0">Parse error</a>. Switch to the <a
+       <dd><a href="#parse1">Parse error</a>. Switch to the <a
         href="#bogus">bogus comment state</a>.
 
        <dt>Anything else
 
-       <dd><a href="#parse0">Parse error</a>. Emit a U+003C LESS-THAN SIGN
+       <dd><a href="#parse1">Parse error</a>. Emit a U+003C LESS-THAN SIGN
         character token and reconsume the current input character in the <a
         href="#data-state">data state</a>.
       </dl>
@@ -39739,18 +40184,18 @@
 
      <dt>U+003E GREATER-THAN SIGN (>)
 
-     <dd><a href="#parse0">Parse error</a>. Switch to the <a
+     <dd><a href="#parse1">Parse error</a>. Switch to the <a
       href="#data-state">data state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Emit a U+003C LESS-THAN SIGN
+     <dd><a href="#parse1">Parse error</a>. Emit a U+003C LESS-THAN SIGN
       character token and a U+002F SOLIDUS character token. Reconsume the EOF
       character in the <a href="#data-state">data state</a>.
 
      <dt>Anything else
 
-     <dd><a href="#parse0">Parse error</a>. Switch to the <a
+     <dd><a href="#parse1">Parse error</a>. Switch to the <a
       href="#bogus">bogus comment state</a>.
     </dl>
 
@@ -39787,13 +40232,13 @@
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Emit the current tag token.
+     <dd><a href="#parse1">Parse error</a>. Emit the current tag token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
 
      <dt>U+002F SOLIDUS (/)
 
-     <dd><a href="#parse0">Parse error</a> unless this is a <a
+     <dd><a href="#parse1">Parse error</a> unless this is a <a
       href="#permitted">permitted slash</a>. Switch to the <a
       href="#before">before attribute name state</a>.
 
@@ -39837,7 +40282,7 @@
 
      <dt>U+002F SOLIDUS (/)
 
-     <dd><a href="#parse0">Parse error</a> unless this is a <a
+     <dd><a href="#parse1">Parse error</a> unless this is a <a
       href="#permitted">permitted slash</a>. Stay in the <a
       href="#before">before attribute name state</a>.
 
@@ -39847,12 +40292,12 @@
 
      <dt>U+003D EQUALS SIGN (=)
 
-     <dd><a href="#parse0">Parse error</a>. Treat it as per the "anything
+     <dd><a href="#parse1">Parse error</a>. Treat it as per the "anything
       else" entry below.
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Emit the current tag token.
+     <dd><a href="#parse1">Parse error</a>. Emit the current tag token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
 
@@ -39900,7 +40345,7 @@
 
      <dt>U+002F SOLIDUS (/)
 
-     <dd><a href="#parse0">Parse error</a> unless this is a <a
+     <dd><a href="#parse1">Parse error</a> unless this is a <a
       href="#permitted">permitted slash</a>. Switch to the <a
       href="#before">before attribute name state</a>.
 
@@ -39908,12 +40353,12 @@
 
      <dt>U+0027 APOSTROPHE (')
 
-     <dd><a href="#parse0">Parse error</a>. Treat it as per the "anything
+     <dd><a href="#parse1">Parse error</a>. Treat it as per the "anything
       else" entry below.
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Emit the current tag token.
+     <dd><a href="#parse1">Parse error</a>. Emit the current tag token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
 
@@ -39927,7 +40372,7 @@
      emitting the tag token, if appropriate), the complete attribute's name
      must be compared to the other attributes on the same token; if there is
      already an attribute on the token with the exact same name, then this is
-     a <a href="#parse0">parse error</a> and the new attribute must be
+     a <a href="#parse1">parse error</a> and the new attribute must be
      dropped, along with the value that gets associated with it (if any).</p>
 
    <dt><dfn id=after>After attribute name state</dfn>
@@ -39968,13 +40413,13 @@
 
      <dt>U+002F SOLIDUS (/)
 
-     <dd><a href="#parse0">Parse error</a> unless this is a <a
+     <dd><a href="#parse1">Parse error</a> unless this is a <a
       href="#permitted">permitted slash</a>. Switch to the <a
       href="#before">before attribute name state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Emit the current tag token.
+     <dd><a href="#parse1">Parse error</a>. Emit the current tag token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
 
@@ -40026,12 +40471,12 @@
 
      <dt>U+003D EQUALS SIGN (=)
 
-     <dd><a href="#parse0">Parse error</a>. Treat it as per the "anything
+     <dd><a href="#parse1">Parse error</a>. Treat it as per the "anything
       else" entry below.
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Emit the current tag token.
+     <dd><a href="#parse1">Parse error</a>. Emit the current tag token.
       Reconsume the character in the <a href="#data-state">data state</a>.
 
      <dt>Anything else
@@ -40060,7 +40505,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Emit the current tag token.
+     <dd><a href="#parse1">Parse error</a>. Emit the current tag token.
       Reconsume the character in the <a href="#data-state">data state</a>.
 
      <dt>Anything else
@@ -40089,7 +40534,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Emit the current tag token.
+     <dd><a href="#parse1">Parse error</a>. Emit the current tag token.
       Reconsume the character in the <a href="#data-state">data state</a>.
 
      <dt>Anything else
@@ -40135,12 +40580,12 @@
 
      <dt>U+003D EQUALS SIGN (=)
 
-     <dd><a href="#parse0">Parse error</a>. Treat it as per the "anything
+     <dd><a href="#parse1">Parse error</a>. Treat it as per the "anything
       else" entry below.
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Emit the current tag token.
+     <dd><a href="#parse1">Parse error</a>. Emit the current tag token.
       Reconsume the character in the <a href="#data-state">data state</a>.
 
      <dt>Anything else
@@ -40189,13 +40634,13 @@
 
      <dt>U+002F SOLIDUS (/)
 
-     <dd><a href="#parse0">Parse error</a> unless this is a <a
+     <dd><a href="#parse1">Parse error</a> unless this is a <a
       href="#permitted">permitted slash</a>. Switch to the <a
       href="#before">before attribute name state</a>.
 
      <dt>Anything else
 
-     <dd><a href="#parse0">Parse error</a>. Reconsume the character in the <a
+     <dd><a href="#parse1">Parse error</a>. Reconsume the character in the <a
       href="#before">before attribute name state</a>.
     </dl>
 
@@ -40234,7 +40679,7 @@
      word "DOCTYPE", then consume those characters and switch to the <a
      href="#doctype0">DOCTYPE state</a>.</p>
 
-    <p>Otherwise, this is a <a href="#parse0">parse error</a>. Switch to the
+    <p>Otherwise, this is a <a href="#parse1">parse error</a>. Switch to the
      <a href="#bogus">bogus comment state</a>. The next character that is
      consumed, if any, is the first character that will be in the comment.</p>
 
@@ -40250,12 +40695,12 @@
 
      <dt>U+003E GREATER-THAN SIGN (>)
 
-     <dd><a href="#parse0">Parse error</a>. Emit the comment token. Switch to
+     <dd><a href="#parse1">Parse error</a>. Emit the comment token. Switch to
       the <a href="#data-state">data state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Emit the comment token. Reconsume
+     <dd><a href="#parse1">Parse error</a>. Emit the comment token. Reconsume
       the EOF character in the <a href="#data-state">data state</a>.
 
      <dt>Anything else
@@ -40276,12 +40721,12 @@
 
      <dt>U+003E GREATER-THAN SIGN (>)
 
-     <dd><a href="#parse0">Parse error</a>. Emit the comment token. Switch to
+     <dd><a href="#parse1">Parse error</a>. Emit the comment token. Switch to
       the <a href="#data-state">data state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Emit the comment token. Reconsume
+     <dd><a href="#parse1">Parse error</a>. Emit the comment token. Reconsume
       the EOF character in the <a href="#data-state">data state</a>.
 
      <dt>Anything else
@@ -40303,7 +40748,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Emit the comment token. Reconsume
+     <dd><a href="#parse1">Parse error</a>. Emit the comment token. Reconsume
       the EOF character in the <a href="#data-state">data state</a>.</dd>
      <!-- For
      security reasons: otherwise, hostile user could put a <script> in
@@ -40329,7 +40774,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Emit the comment token. Reconsume
+     <dd><a href="#parse1">Parse error</a>. Emit the comment token. Reconsume
       the EOF character in the <a href="#data-state">data state</a>.</dd>
      <!-- For
      security reasons: otherwise, hostile user could put a <script> in
@@ -40357,13 +40802,13 @@
 
      <dt>U+002D HYPHEN-MINUS (-)
 
-     <dd><a href="#parse0">Parse error</a>. Append a U+002D HYPHEN-MINUS (-)
+     <dd><a href="#parse1">Parse error</a>. Append a U+002D HYPHEN-MINUS (-)
       character to the comment token's data. Stay in the <a
       href="#comment3">comment end state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Emit the comment token. Reconsume
+     <dd><a href="#parse1">Parse error</a>. Emit the comment token. Reconsume
       the EOF character in the <a href="#data-state">data state</a>.</dd>
      <!-- For
      security reasons: otherwise, hostile user could put a <script> in
@@ -40373,7 +40818,7 @@
 
      <dt>Anything else
 
-     <dd><a href="#parse0">Parse error</a>. Append two U+002D HYPHEN-MINUS
+     <dd><a href="#parse1">Parse error</a>. Append two U+002D HYPHEN-MINUS
       (-) characters and the input character to the comment token's data.
       Switch to the <a href="#comment">comment state</a>.
     </dl>
@@ -40399,7 +40844,7 @@
 
      <dt>Anything else
 
-     <dd><a href="#parse0">Parse error</a>. Reconsume the current character
+     <dd><a href="#parse1">Parse error</a>. Reconsume the current character
       in the <a href="#before1">before DOCTYPE name state</a>.
     </dl>
 
@@ -40424,13 +40869,13 @@
 
      <dt>U+003E GREATER-THAN SIGN (>)
 
-     <dd><a href="#parse0">Parse error</a>. Create a new DOCTYPE token. Set
+     <dd><a href="#parse1">Parse error</a>. Create a new DOCTYPE token. Set
       its <i>force-quirks flag</i> to <i>on</i>. Emit the token. Switch to
       the <a href="#data-state">data state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Create a new DOCTYPE token. Set
+     <dd><a href="#parse1">Parse error</a>. Create a new DOCTYPE token. Set
       its <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
       the EOF character in the <a href="#data-state">data state</a>.
 
@@ -40467,7 +40912,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
@@ -40504,7 +40949,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
@@ -40522,7 +40967,7 @@
        the word "SYSTEM", then consume those characters and switch to the <a
        href="#before3">before DOCTYPE system identifier state</a>.</p>
 
-      <p>Otherwise, this is the <a href="#parse0">parse error</a>. Set the
+      <p>Otherwise, this is the <a href="#parse1">parse error</a>. Set the
        DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to the
        <a href="#bogus0">bogus DOCTYPE state</a>.</p>
     </dl>
@@ -40561,20 +41006,20 @@
 
      <dt>U+003E GREATER-THAN SIGN (>)
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Switch
       to the <a href="#data-state">data state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
 
      <dt>Anything else
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Switch to the <a
       href="#bogus0">bogus DOCTYPE state</a>.
     </dl>
@@ -40592,13 +41037,13 @@
 
      <dt>U+003E GREATER-THAN SIGN (>)
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Switch
       to the <a href="#data-state">data state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
@@ -40623,13 +41068,13 @@
 
      <dt>U+003E GREATER-THAN SIGN (>)
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Switch
       to the <a href="#data-state">data state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
@@ -40680,14 +41125,14 @@
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
 
      <dt>Anything else
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Switch to the <a
       href="#bogus0">bogus DOCTYPE state</a>.
     </dl>
@@ -40726,20 +41171,20 @@
 
      <dt>U+003E GREATER-THAN SIGN (>)
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Switch
       to the <a href="#data-state">data state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
 
      <dt>Anything else
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Switch to the <a
       href="#bogus0">bogus DOCTYPE state</a>.
     </dl>
@@ -40757,13 +41202,13 @@
 
      <dt>U+003E GREATER-THAN SIGN (>)
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Switch
       to the <a href="#data-state">data state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
@@ -40788,13 +41233,13 @@
 
      <dt>U+003E GREATER-THAN SIGN (>)
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token. Switch
       to the <a href="#data-state">data state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
@@ -40833,14 +41278,14 @@
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse1">Parse error</a>. Set the DOCTYPE token's
       <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
 
      <dt>Anything else
 
-     <dd><a href="#parse0">Parse error</a>. Switch to the <a
+     <dd><a href="#parse1">Parse error</a>. Switch to the <a
       href="#bogus0">bogus DOCTYPE state</a>. (This does <em>not</em> set the
       DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>.)
     </dl>
@@ -40858,7 +41303,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse0">Parse error</a>. Emit the DOCTYPE token. Reconsume
+     <dd><a href="#parse1">Parse error</a>. Emit the DOCTYPE token. Reconsume
       the EOF character in the <a href="#data-state">data state</a>.
 
      <dt>Anything else
@@ -40867,7 +41312,7 @@
     </dl>
   </dl>
 
-  <h5 id=tokenising><span class=secno>8.2.3.1. </span>Tokenising entities</h5>
+  <h5 id=tokenising><span class=secno>8.2.4.1. </span>Tokenising entities</h5>
 
   <p>This section defines how to <dfn id=consume>consume an entity</dfn>.
    This definition is used when parsing entities <a href="#entity"
@@ -40941,18 +41386,18 @@
 
     <p>If no characters match the range, then don't consume any characters
      (and unconsume the U+0023 NUMBER SIGN character and, if appropriate, the
-     X character). This is a <a href="#parse0">parse error</a>; nothing is
+     X character). This is a <a href="#parse1">parse error</a>; nothing is
      returned.</p>
 
     <p>Otherwise, if the next character is a U+003B SEMICOLON, consume that
-     too. If it isn't, there is a <a href="#parse0">parse error</a>.</p>
+     too. If it isn't, there is a <a href="#parse1">parse error</a>.</p>
 
     <p>If one or more characters match the range, then take them all and
      interpret the string of characters as a number (either hexadecimal or
      decimal as appropriate).</p>
 
     <p>If that number is one of the numbers in the first column of the
-     following table, then this is a <a href="#parse0">parse error</a>. Find
+     following table, then this is a <a href="#parse1">parse error</a>. Find
      the row with that number in the first column, and return a character
      token for the Unicode character given in the second column of that row.</p>
 
@@ -41198,7 +41643,7 @@
 
     <p>Otherwise, if the number is zero, if the number is higher than
      0x10FFFF, or if it's one of the surrogate characters (characters in the
-     range 0xD800 to 0xDFFF), then this is a <a href="#parse0">parse
+     range 0xD800 to 0xDFFF), then this is a <a href="#parse1">parse
      error</a>; return a character token for the U+FFFD REPLACEMENT CHARACTER
      character instead.</p>
 
@@ -41212,11 +41657,11 @@
      characters case-sensitively matching one of the identifiers in the first
      column of the <a href="#entities0">entities</a> table.</p>
 
-    <p>If no match can be made, then this is a <a href="#parse0">parse
+    <p>If no match can be made, then this is a <a href="#parse1">parse
      error</a>. No characters are consumed, and nothing is returned.</p>
 
     <p>If the last character matched is not a U+003B SEMICOLON (<code
-     title="">;</code>), there is a <a href="#parse0">parse error</a>.</p>
+     title="">;</code>), there is a <a href="#parse1">parse error</a>.</p>
 
     <p>If the entity is being consumed <a href="#entity0" title="entity in
      attribute value state">as part of an attribute</a>, and the last
@@ -41240,7 +41685,7 @@
     </div>
   </dl>
 
-  <h4 id=tree-construction><span class=secno>8.2.4 </span><dfn
+  <h4 id=tree-construction><span class=secno>8.2.5 </span><dfn
    id=tree-construction0>Tree construction</dfn></h4>
 
   <p>The input to the tree construction stage is a sequence of tokens from
@@ -41253,6 +41698,10 @@
    render the <code>Document</code> so that it is available to the user, or
    when it has to begin accepting user input.
 
+  <p>As each token is emitted from the tokeniser, the user agent must process
+   the token according to the rules given in the section corresponding to the
+   current <span>insertion mode</span>.
+
   <p>When the steps below require the UA to <dfn id=insert>insert a
    character</dfn> into a node, if that node has a child immediately before
    where the character is to be inserted, and that child is a
@@ -41284,331 +41733,7 @@
    href="#hardwareLimitations">practical concerns</a> will likely force user
    agents to impose nesting depths.
 
-  <p>As each token is emitted from the tokeniser, the user agent must process
-   the token according to the rules given in the section corresponding to the
-   current <dfn id=insertion0>insertion mode</dfn>.
-
-  <p>Initially the <a href="#insertion0">insertion mode</a> is "<a
-   href="#initial" title="insertion mode: initial">initial</a>". It can
-   change to "<a href="#before4" title="insertion mode: before html">before
-   html</a>", "<a href="#before5" title="insertion mode: before head">before
-   head</a>", "<a href="#in-head" title="insertion mode: in head">in
-   head</a>", "<a href="#in-head0" title="insertion mode: in head
-   noscript">in head noscript</a>", "<a href="#after4" title="insertion mode:
-   after head">after head</a>", "<a href="#in-body" title="insertion mode: in
-   body">in body</a>", "<a href="#in-table" title="insertion mode: in
-   table">in table</a>", "<a href="#in-caption" title="insertion mode: in
-   caption">in caption</a>", "<a href="#in-column" title="insertion mode: in
-   column group">in column group</a>", "<a href="#in-table0" title="insertion
-   mode: in table body">in table body</a>", "<a href="#in-row"
-   title="insertion mode: in row">in row</a>", "<a href="#in-cell"
-   title="insertion mode: in cell">in cell</a>", "<a href="#in-select"
-   title="insertion mode: in select">in select</a>", "<a href="#in-select0"
-   title="insertion mode: in select in table">in select in table</a>", "<a
-   href="#after5" title="insertion mode: after body">after body</a>", "<a
-   href="#in-frameset" title="insertion mode: in frameset">in frameset</a>",
-   "<a href="#after6" title="insertion mode: after frameset">after
-   frameset</a>", "<a href="#after7" title="insertion mode: after after
-   body">after after body</a>", and "<a href="#after8" title="insertion mode:
-   after after frameset">after after frameset</a>" during the course of the
-   parsing, as described below. It affects how certain tokens are processed.
-
-  <p>Four of these modes, namely "<a href="#in-head" title="insertion mode:
-   in head">in head</a>", "<a href="#in-body" title="insertion mode: in
-   body">in body</a>", "<a href="#in-table" title="insertion mode: in
-   table">in table</a>", and "<a href="#in-select" title="insertion mode: in
-   select">in select</a>", are special, in that the other modes defer to them
-   at various times. When the algorithm below says that the user agent is to
-   do something "<dfn id=using8>using the rules for</dfn> the <var
-   title="">m</var> insertion mode", where <var title="">m</var> is one of
-   these modes, the user agent must use the rules described under that <a
-   href="#insertion0">insertion mode</a>'s section, but must leave the <a
-   href="#insertion0">insertion mode</a> unchanged (unless the rules in that
-   section themselves switch the <a href="#insertion0">insertion mode</a>).
-
-  <p>In addition to the <a href="#insertion0">insertion mode</a>, the tree
-   construction stage has several pieces of state: a <a href="#stack">stack
-   of open elements</a>, a <a href="#list-of4">list of active formatting
-   elements</a>, a <a href="#head-element"><code title="">head</code> element
-   pointer</a>, and a <a href="#form-element"><code title="">form</code>
-   element pointer</a>.
-
-  <h5 id=the-stack><span class=secno>8.2.4.1. </span>The stack of open
-   elements</h5>
-
-  <p>Initially the <dfn id=stack>stack of open elements</dfn> is empty. The
-   stack grows downwards; the topmost node on the stack is the first one
-   added to the stack, and the bottommost node of the stack is the most
-   recently added node in the stack (notwithstanding when the stack is
-   manipulated in a random access fashion as part of <a
-   href="#adoptionAgency">the handling for misnested tags</a>).
-
-  <p>The "<a href="#before4" title="insertion mode: before html">before
-   html</a>" <a href="#insertion0">insertion mode</a> creates the <code><a
-   href="#html">html</a></code> root element node, which is then added to the
-   stack.
-
-  <p>In the <a href="#fragment">fragment case</a>, the <a href="#stack">stack
-   of open elements</a> is initialised to contain an <code><a
-   href="#html">html</a></code> element that is created as part of <a
-   href="#html-fragment0" title="html fragment parsing algorithm">that
-   algorithm</a>. (The <a href="#fragment">fragment case</a> skips the "<a
-   href="#before4" title="insertion mode: before html">before html</a>" <a
-   href="#insertion0">insertion mode</a>.)
-
-  <p>The <code><a href="#html">html</a></code> node, however it is created,
-   is the topmost node of the stack. It never gets popped off the stack.
-
-  <p>The <dfn id=current4>current node</dfn> is the bottommost node in this
-   stack.
-
-  <p>The <dfn id=current5>current table</dfn> is the last <code><a
-   href="#table">table</a></code> element in the <a href="#stack">stack of
-   open elements</a>, if there is one. If there is no <code><a
-   href="#table">table</a></code> element in the <a href="#stack">stack of
-   open elements</a> (<a href="#fragment">fragment case</a>), then the <a
-   href="#current5">current table</a> is the first element in the <a
-   href="#stack">stack of open elements</a> (the <code><a
-   href="#html">html</a></code> element).
-
-  <p>Elements in the stack fall into the following categories:
-
-  <dl>
-   <dt><dfn id=special>Special</dfn>
-
-   <dd>
-    <p>The following HTML elements have varying levels of special parsing
-     rules: <code><a href="#address">address</a></code>, <code><a
-     href="#area">area</a></code>, <code><a href="#base">base</a></code>,
-     <code>basefont</code>, <code>bgsound</code>, <code><a
-     href="#blockquote">blockquote</a></code>, <code><a
-     href="#body0">body</a></code>, <code><a href="#br">br</a></code>,
-     <code>center</code>, <code><a href="#col">col</a></code>, <code><a
-     href="#colgroup">colgroup</a></code>, <code><a href="#dd">dd</a></code>,
-     <code>dir</code>, <code><a href="#div">div</a></code>, <code><a
-     href="#dl">dl</a></code>, <code><a href="#dt">dt</a></code>, <code><a
-     href="#embed">embed</a></code>, <code>fieldset</code>,
-     <code>form</code>, <code>frame</code>, <code>frameset</code>, <code><a
-     href="#h1">h1</a></code>, <code><a href="#h2">h2</a></code>, <code><a
-     href="#h3">h3</a></code>, <code><a href="#h4">h4</a></code>, <code><a
-     href="#h5">h5</a></code>, <code><a href="#h6">h6</a></code>, <code><a
-     href="#head">head</a></code>, <code><a href="#hr">hr</a></code>,
-     <code><a href="#iframe">iframe</a></code>,
-     <code>image</code><!-- XXX ? this isn't an element that can end up
-   on the stack-->,
-     <code><a href="#img">img</a></code>, <code>input</code>,
-     <code>isindex</code>, <code><a href="#li">li</a></code>, <code><a
-     href="#link">link</a></code>, <code>listing</code>, <code><a
-     href="#menu">menu</a></code>, <code><a href="#meta0">meta</a></code>,
-     <code>noembed</code>, <code>noframes</code>, <code><a
-     href="#noscript">noscript</a></code>, <code><a href="#ol">ol</a></code>,
-     <code>optgroup</code>, <code>option</code>, <code><a
-     href="#p">p</a></code>, <code><a href="#param">param</a></code>,
-     <code>plaintext</code>, <code><a href="#pre">pre</a></code>, <code><a
-     href="#script0">script</a></code>, <code>select</code>,
-     <code>spacer</code>, <code><a href="#style">style</a></code>, <code><a
-     href="#tbody">tbody</a></code>, <code>textarea</code>, <code><a
-     href="#tfoot0">tfoot</a></code>, <code><a
-     href="#thead0">thead</a></code>, <code><a
-     href="#title1">title</a></code>, <code><a href="#tr">tr</a></code>,
-     <code><a href="#ul">ul</a></code>, and <code>wbr</code>.
-
-   <dt><dfn id=scoping>Scoping</dfn>
-
-   <dd>
-    <p>The following HTML elements introduce new <a href="#have-an"
-     title="has an element in scope">scopes</a> for various parts of the
-     parsing: <code>applet</code>, <code>button</code>, <code><a
-     href="#caption0">caption</a></code>, <code><a
-     href="#html">html</a></code>, <code>marquee</code>, <code><a
-     href="#object">object</a></code>, <code><a
-     href="#table">table</a></code>, <code><a href="#td">td</a></code> and
-     <code><a href="#th">th</a></code>.
-
-   <dt><dfn id=formatting>Formatting</dfn>
-
-   <dd>
-    <p>The following HTML elements are those that end up in the <a
-     href="#list-of4">list of active formatting elements</a>: <code><a
-     href="#a">a</a></code>, <code><a href="#b">b</a></code>,
-     <code>big</code>, <code><a href="#em">em</a></code>, <code><a
-     href="#font">font</a></code>, <code><a href="#i">i</a></code>,
-     <code>nobr</code>, <code>s</code>, <code><a
-     href="#small">small</a></code>, <code>strike</code>, <code><a
-     href="#strong">strong</a></code>, <code>tt</code>, and <code>u</code>.
-
-   <dt><dfn id=phrasing1>Phrasing</dfn>
-
-   <dd>
-    <p>All other elements found while parsing an HTML document.
-  </dl>
-
-  <p class=big-issue>Still need to add these new elements to the lists:
-   <code><a href="#event-source">event-source</a></code>, <code><a
-   href="#section">section</a></code>, <code><a href="#nav">nav</a></code>,
-   <code><a href="#article">article</a></code>, <code><a
-   href="#aside">aside</a></code>, <code><a href="#header">header</a></code>,
-   <code><a href="#footer">footer</a></code>, <code><a
-   href="#datagrid0">datagrid</a></code>, <code><a
-   href="#command0">command</a></code>
-
-  <p>The <a href="#stack">stack of open elements</a> is said to <dfn
-   id=have-an title="has an element in scope">have an element in scope</dfn>
-   or <dfn id=have-an0 title="has an element in table scope">have an element
-   in <em>table scope</em></dfn> when the following algorithm terminates in a
-   match state:
-
-  <ol>
-   <li>
-    <p>Initialise <var title="">node</var> to be the <a
-     href="#current4">current node</a> (the bottommost node of the stack).
-
-   <li>
-    <p>If <var title="">node</var> is the target node, terminate in a match
-     state.
-
-   <li>
-    <p>Otherwise, if <var title="">node</var> is a <code><a
-     href="#table">table</a></code> element, terminate in a failure state.
-
-   <li>
-    <p>Otherwise, if the algorithm is the "has an element in scope" variant
-     (rather than the "has an element in table scope" variant), and <var
-     title="">node</var> is one of the following, terminate in a failure
-     state:</p>
-
-    <ul class=brief>
-     <li><code>applet</code>
-
-     <li><code><a href="#caption0">caption</a></code>
-
-     <li><code><a href="#td">td</a></code>
-
-     <li><code><a href="#th">th</a></code>
-
-     <li><code>button</code>
-
-     <li><code>marquee</code>
-
-     <li><code><a href="#object">object</a></code>
-    </ul>
-
-   <li>
-    <p>Otherwise, if <var title="">node</var> is an <code><a
-     href="#html">html</a></code> element, terminate in a failure state.
-     (This can only happen if the <var title="">node</var> is the topmost
-     node of the <a href="#stack">stack of open elements</a>, and prevents
-     the next step from being invoked if there are no more elements in the
-     stack.)
-
-   <li>
-    <p>Otherwise, set <var title="">node</var> to the previous entry in the
-     <a href="#stack">stack of open elements</a> and return to step 2. (This
-     will never fail, since the loop will always terminate in the previous
-     step if the top of the stack is reached.)
-  </ol>
-
-  <p>Nothing happens if at any time any of the elements in the <a
-   href="#stack">stack of open elements</a> are moved to a new location in,
-   or removed from, the <code>Document</code> tree. In particular, the stack
-   is not changed in this situation. This can cause, amongst other strange
-   effects, content to be appended to nodes that are no longer in the DOM.
-
-  <p class=note>In some cases (namely, when <a href="#adoptionAgency">closing
-   misnested formatting elements</a>), the stack is manipulated in a
-   random-access fashion.
-
-  <h5 id=the-list><span class=secno>8.2.4.2. </span>The list of active
-   formatting elements</h5>
-
-  <p>Initially the <dfn id=list-of4>list of active formatting elements</dfn>
-   is empty. It is used to handle mis-nested <a href="#formatting"
-   title=formatting>formatting element tags</a>.
-
-  <p>The list contains elements in the <a href="#formatting">formatting</a>
-   category, and scope markers. The scope markers are inserted when entering
-   <code>applet</code> elements, buttons, <code><a
-   href="#object">object</a></code> elements, marquees, table cells, and
-   table captions, and are used to prevent formatting from "leaking" into
-   <code>applet</code> elements, buttons, <code><a
-   href="#object">object</a></code> elements, marquees, and tables.
-
-  <p>When the steps below require the UA to <dfn id=reconstruct>reconstruct
-   the active formatting elements</dfn>, the UA must perform the following
-   steps:
-
-  <ol>
-   <li>If there are no entries in the <a href="#list-of4">list of active
-    formatting elements</a>, then there is nothing to reconstruct; stop this
-    algorithm.
-
-   <li>If the last (most recently added) entry in the <a
-    href="#list-of4">list of active formatting elements</a> is a marker, or
-    if it is an element that is in the <a href="#stack">stack of open
-    elements</a>, then there is nothing to reconstruct; stop this algorithm.
-
-   <li>Let <var title="">entry</var> be the last (most recently added)
-    element in the <a href="#list-of4">list of active formatting
-    elements</a>.
-
-   <li>If there are no entries before <var title="">entry</var> in the <a
-    href="#list-of4">list of active formatting elements</a>, then jump to
-    step 8.
-
-   <li>Let <var title="">entry</var> be the entry one earlier than <var
-    title="">entry</var> in the <a href="#list-of4">list of active formatting
-    elements</a>.
-
-   <li>If <var title="">entry</var> is neither a marker nor an element that
-    is also in the <a href="#stack">stack of open elements</a>, go to step 4.
-
-   <li>Let <var title="">entry</var> be the element one later than <var
-    title="">entry</var> in the <a href="#list-of4">list of active formatting
-    elements</a>.
-
-   <li>Perform a shallow clone of the element <var title="">entry</var> to
-    obtain <var title="">clone</var>. <a href="#refsDOM3CORE">[DOM3CORE]</a>
-
-   <li>Append <var title="">clone</var> to the <a href="#current4">current
-    node</a> and push it onto the <a href="#stack">stack of open elements</a>
-    so that it is the new <a href="#current4">current node</a>.
-
-   <li>Replace the entry for <var title="">entry</var> in the list with an
-    entry for <var title="">clone</var>.
-
-   <li>If the entry for <var title="">clone</var> in the <a
-    href="#list-of4">list of active formatting elements</a> is not the last
-    entry in the list, return to step 7.
-  </ol>
-
-  <p>This has the effect of reopening all the formatting elements that were
-   opened in the current body, cell, or caption (whichever is youngest) that
-   haven't been explicitly closed.
-
-  <p class=note>The way this specification is written, the <a
-   href="#list-of4">list of active formatting elements</a> always consists of
-   elements in chronological order with the least recently added element
-   first and the most recently added element last (except for while steps 8
-   to 11 of the above algorithm are being executed, of course).
-
-  <p>When the steps below require the UA to <dfn id=clear0>clear the list of
-   active formatting elements up to the last marker</dfn>, the UA must
-   perform the following steps:
-
-  <ol>
-   <li>Let <var title="">entry</var> be the last (most recently added) entry
-    in the <a href="#list-of4">list of active formatting elements</a>.
-
-   <li>Remove <var title="">entry</var> from the <a href="#list-of4">list of
-    active formatting elements</a>.
-
-   <li>If <var title="">entry</var> was a marker, then stop the algorithm at
-    this point. The list has been cleared up to the last marker.
-
-   <li>Go to step 1.
-  </ol>
-
-  <h5 id=creating><span class=secno>8.2.4.3. </span>Creating and inserting
+  <h5 id=creating><span class=secno>8.2.5.1. </span>Creating and inserting
    HTML elements</h5>
 
   <p>When the steps below require the UA to <dfn id=create title="create an
@@ -41675,10 +41800,10 @@
    <li>
     <p>If the next token is an end tag token with the same tag name as the
      start tag token, ignore it. Otherwise, it's an end-of-file token, and
-     this is a <a href="#parse0">parse error</a>.
+     this is a <a href="#parse1">parse error</a>.
   </ol>
 
-  <h5 id=closing><span class=secno>8.2.4.4. </span>Closing elements that have
+  <h5 id=closing><span class=secno>8.2.5.2. </span>Closing elements that have
    implied end tags</h5>
 
   <p>When the steps below require the UA to <dfn id=generate>generate implied
@@ -41693,178 +41818,10 @@
    element to exclude from the process, then the UA must perform the above
    steps as if that element was not in the above list.
 
-  <h5 id=the-element><span class=secno>8.2.4.5. </span>The element pointers</h5>
-
-  <p>Initially the <dfn id=head-element><code title="">head</code> element
-   pointer</dfn> and the <dfn id=form-element><code title="">form</code>
-   element pointer</dfn> are both null.
-
-  <p>Once a <code><a href="#head">head</a></code> element has been parsed
-   (whether implicitly or explicitly) the <a href="#head-element"><code
-   title="">head</code> element pointer</a> gets set to point to this node.
-
-  <p>The <a href="#form-element"><code title="">form</code> element
-   pointer</a> points to the last <code>form</code> element that was opened
-   and whose end tag has not yet been seen. It is used to make form controls
-   associate with forms in the face of dramatically bad markup, for
-   historical reasons.
-
-  <h5 id=resetting><span class=secno>8.2.4.6. </span>Resetting the insertion
-   mode</h5>
-
-  <p>When the steps below require the UA to <dfn id=reset>reset the insertion
-   mode appropriately</dfn>, it means the UA must follow these steps:
-
-  <ol>
-   <li>Let <var title="">last</var> be false.
-
-   <li>Let <var title="">node</var> be the last node in the <a
-    href="#stack">stack of open elements</a>.
-
-   <li>If <var title="">node</var> is the first node in the stack of open
-    elements, then set <var title="">last</var> to true; if, in addition, the
-    <var title="">context</var> element of the <a href="#html-fragment0">HTML
-    fragment parsing algorithm</a> is neither a <code><a
-    href="#td">td</a></code> element nor a <code><a href="#th">th</a></code>
-    element, then set <var title="">node</var> to the <var
-    title="">context</var> element. (<a href="#fragment">fragment case</a>)
-
-   <li>If <var title="">node</var> is a <code>select</code> element, then
-    switch the <a href="#insertion0">insertion mode</a> to "<a
-    href="#in-select" title="insertion mode: in select">in select</a>" and
-    abort these steps. (<a href="#fragment">fragment case</a>)
-
-   <li>If <var title="">node</var> is a <code><a href="#td">td</a></code> or
-    <code><a href="#th">th</a></code> element, then switch the <a
-    href="#insertion0">insertion mode</a> to "<a href="#in-cell"
-    title="insertion mode: in cell">in cell</a>" and abort these steps.
-
-   <li>If <var title="">node</var> is a <code><a href="#tr">tr</a></code>
-    element, then switch the <a href="#insertion0">insertion mode</a> to "<a
-    href="#in-row" title="insertion mode: in row">in row</a>" and abort these
-    steps.
-
-   <li>If <var title="">node</var> is a <code><a
-    href="#tbody">tbody</a></code>, <code><a href="#thead0">thead</a></code>,
-    or <code><a href="#tfoot0">tfoot</a></code> element, then switch the <a
-    href="#insertion0">insertion mode</a> to "<a href="#in-table0"
-    title="insertion mode: in table body">in table body</a>" and abort these
-    steps.
-
-   <li>If <var title="">node</var> is a <code><a
-    href="#caption0">caption</a></code> element, then switch the <a
-    href="#insertion0">insertion mode</a> to "<a href="#in-caption"
-    title="insertion mode: in caption">in caption</a>" and abort these steps.
-
-   <li>If <var title="">node</var> is a <code><a
-    href="#colgroup">colgroup</a></code> element, then switch the <a
-    href="#insertion0">insertion mode</a> to "<a href="#in-column"
-    title="insertion mode: in column group">in column group</a>" and abort
-    these steps. (<a href="#fragment">fragment case</a>)
-
-   <li>If <var title="">node</var> is a <code><a
-    href="#table">table</a></code> element, then switch the <a
-    href="#insertion0">insertion mode</a> to "<a href="#in-table"
-    title="insertion mode: in table">in table</a>" and abort these steps.
-
-   <li>If <var title="">node</var> is a <code><a href="#head">head</a></code>
-    element, then switch the <a href="#insertion0">insertion mode</a> to "<a
-    href="#in-body" title="insertion mode: in body">in body</a>" ("<a
-    href="#in-body" title="insertion mode: in body">in body</a>"! <em> not
-    "<a href="#in-head" title="insertion mode: in head">in head</a>"</em>!)
-    and abort these steps. (<a href="#fragment">fragment case</a>)</li>
-   <!-- This is only
-   here for now in case people think that the spec accidentally
-   omitted it and try to "fix" it. Note that noscript-in-head is also
-   handled this way. This is all intentional. The only thing it
-   doesn't handle is the scripting-enabled fragment parsing case for a
-   <head> element containing a <noscript> which itself contains
-   something other than a <link> or a <style> element; you'd expect
-   that to break out of the <noscript> but it doesn't. This is an edge
-   case that doesn't affect the spec, since the algorithm for fragment
-   parsing is only used for innerHTML, where we know scripting is
-   enabled. -->
-
-   <li>If <var title="">node</var> is a <code><a
-    href="#body0">body</a></code> element, then switch the <a
-    href="#insertion0">insertion mode</a> to "<a href="#in-body"
-    title="insertion mode: in body">in body</a>" and abort these steps.
-
-   <li>If <var title="">node</var> is a <code>frameset</code> element, then
-    switch the <a href="#insertion0">insertion mode</a> to "<a
-    href="#in-frameset" title="insertion mode: in frameset">in frameset</a>"
-    and abort these steps. (<a href="#fragment">fragment case</a>)
-
-   <li>If <var title="">node</var> is an <code><a
-    href="#html">html</a></code> element, then: if the <a
-    href="#head-element"><code title="">head</code> element pointer</a> is
-    null, switch the <a href="#insertion0">insertion mode</a> to "<a
-    href="#before5" title="insertion mode: before head">before head</a>",
-    otherwise, switch the <a href="#insertion0">insertion mode</a> to "<a
-    href="#after4" title="insertion mode: after head">after head</a>". In
-    either case, abort these steps. (<a href="#fragment">fragment case</a>)</li>
-   <!-- XXX
-   can the head element pointer ever be non-null when we're going
-   through these steps? -->
-
-   <li>If <var title="">last</var> is true, then switch the <a
-    href="#insertion0">insertion mode</a> to "<a href="#in-body"
-    title="insertion mode: in body">in body</a>" and abort these steps. (<a
-    href="#fragment">fragment case</a>)
-
-   <li>Let <var title="">node</var> now be the node before <var
-    title="">node</var> in the <a href="#stack">stack of open elements</a>.
-
-   <li>Return to step 3.
-  </ol>
-  <!--When you don't have to handle the fragment case, you can use this
-simplified explanation instead:
-
-  <ol>
-
-   <li><p>If the <span>stack of open elements</span> <span title="has
-   an element in table scope">has a <code>td</code> or <code>th</code>
-   element in table scope</span>, then switch the <span>insertion
-   mode</span> to "<span title="insertion mode: in cell">in
-   cell</span>".</p></li>
-
-   <li><p>Otherwise, if the <span>stack of open elements</span> <span
-   title="has an element in table scope">has a <code>tr</code> element
-   in table scope</span>, then switch the <span>insertion mode</span>
-   to "<span title="insertion mode: in row">in row</span>".</p></li>
-
-   <li><p>Otherwise, if the <span>stack of open elements</span> <span
-   title="has an element in table scope">has a <code>tbody</code>,
-   <code>tfoot</code>, or <code>thead</code> element in table
-   scope</span>, then switch the <span>insertion mode</span> to "<span
-   title="insertion mode: in table body">in table
-   body</span>".</p></li>
-
-   <li><p>Otherwise, if the <span>stack of open elements</span> <span
-   title="has an element in table scope">has a <code>caption</code>
-   element in table scope</span>, then switch the <span>insertion
-   mode</span> to "<span title="insertion mode: in caption">in
-   caption</span>".</p></li>
-
-   ( you can't reach this point with a colgroup element on the
-   stack )
-
-   <li><p>Otherwise, if the <span>stack of open elements</span> <span
-   title="has an element in table scope">has a <code>table</code>
-   element in table scope</span>, then switch the <span>insertion
-   mode</span> to "<span title="insertion mode: in table">in
-   table</span>".</p></li>
-
-   <li><p>Otherwise, switch the <span>insertion mode</span> to "<span
-   title="insertion mode: in body">in body</span>".</p></li>
-
-  </ol>
--->
-
-  <h5 id=the-initial><span class=secno>8.2.4.7. </span>The "<dfn id=initial
+  <h5 id=the-initial><span class=secno>8.2.5.3. </span>The "<dfn id=initial
    title="insertion mode: initial">initial</dfn>" insertion mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a href="#initial"
+  <p>When the <span>insertion mode</span> is "<a href="#initial"
    title="insertion mode: initial">initial</a>", tokens must be handled as
    follows:
 
@@ -41889,7 +41846,7 @@
     <p>If the DOCTYPE token's <code title="">name</code> does not
      case-insensitively match the string "<code title="">HTML</code>", or if
      the token's public identifier is not missing, or if the token's system
-     identifier is not missing, then there is a <a href="#parse0">parse
+     identifier is not missing, then there is a <a href="#parse1">parse
      error</a>. Conformance checkers may, instead of reporting this error,
      switch to a conformance checking mode for another language (e.g. based
      on the DOCTYPE token a conformance checker could recognise that the
@@ -42168,25 +42125,25 @@
      compared to the values given in the lists above in a
      case-insensitive<!-- ASCII --> manner.</p>
 
-    <p>Then, switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#before4" title="insertion mode: before html">before html</a>".</p>
+    <p>Then, switch the <span>insertion mode</span> to "<a href="#before4"
+     title="insertion mode: before html">before html</a>".</p>
 
    <dt>Anything else
 
    <dd>
-    <p><a href="#parse0">Parse error</a>.</p>
+    <p><a href="#parse1">Parse error</a>.</p>
 
     <p>Set the document to <a href="#quirks">quirks mode</a>.</p>
 
-    <p>Switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#before4" title="insertion mode: before html">before html</a>",
-     then reprocess the current token.</p>
+    <p>Switch the <span>insertion mode</span> to "<a href="#before4"
+     title="insertion mode: before html">before html</a>", then reprocess the
+     current token.</p>
   </dl>
 
-  <h5 id=the-before><span class=secno>8.2.4.8. </span>The "<dfn id=before4
+  <h5 id=the-before><span class=secno>8.2.5.4. </span>The "<dfn id=before4
    title="insertion mode: before html">before html</dfn>" insertion mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a href="#before4"
+  <p>When the <span>insertion mode</span> is "<a href="#before4"
    title="insertion mode: before html">before html</a>", tokens must be
    handled as follows:
 
@@ -42194,7 +42151,7 @@
    <dt>A DOCTYPE token
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>A comment token
 
@@ -42225,8 +42182,8 @@
      title=concept-appcache-init-no-attribute>application cache selection
      algorithm</a> with no manifest.</p>
 
-    <p>Switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#before5" title="insertion mode: before head">before head</a>".</p>
+    <p>Switch the <span>insertion mode</span> to "<a href="#before5"
+     title="insertion mode: before head">before head</a>".</p>
 
    <dt>Anything else
 
@@ -42241,9 +42198,9 @@
      title=concept-appcache-init-no-attribute>application cache selection
      algorithm</a> with no manifest.</p>
 
-    <p>Switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#before5" title="insertion mode: before head">before head</a>",
-     then reprocess the current token.</p>
+    <p>Switch the <span>insertion mode</span> to "<a href="#before5"
+     title="insertion mode: before head">before head</a>", then reprocess the
+     current token.</p>
 
     <p class=big-issue>Should probably make end tags be ignored, so that
      "</head><!-- --><html>" puts the comment before the root node
@@ -42255,10 +42212,10 @@
    content continues being appended to the nodes as described in the next
    section.
 
-  <h5 id=the-before0><span class=secno>8.2.4.9. </span>The "<dfn id=before5
+  <h5 id=the-before0><span class=secno>8.2.5.5. </span>The "<dfn id=before5
    title="insertion mode: before head">before head</dfn>" insertion mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a href="#before5"
+  <p>When the <span>insertion mode</span> is "<a href="#before5"
    title="insertion mode: before head">before head</a>", tokens must be
    handled as follows:
 
@@ -42281,14 +42238,14 @@
    <dt>A DOCTYPE token
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>A start tag whose tag name is "html"
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-body" title="insertion mode: in body">in body</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-body" title="insertion mode: in body">in body</a>"
+     <span>insertion mode</span>.</p>
 
    <dt>A start tag whose tag name is "head"
 
@@ -42301,8 +42258,8 @@
     <p>Append the new element to the <a href="#current4">current node</a> and
      push it onto the <a href="#stack">stack of open elements</a>.</p>
 
-    <p>Switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#in-head" title="insertion mode: in head">in head</a>".</p>
+    <p>Switch the <span>insertion mode</span> to "<a href="#in-head"
+     title="insertion mode: in head">in head</a>".</p>
 
    <dt>An end tag whose tag name is one of: "head", "body", "html", "p", "br"
 
@@ -42313,7 +42270,7 @@
    <dt>Any other end tag
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
     <p class=big-issue>Do we really want to ignore end tags here?</p>
 
@@ -42326,13 +42283,13 @@
     <p class=note>This will result in an empty <code><a
      href="#head">head</a></code> element being generated, with the current
      token being reprocessed in the "<a href="#after4" title="insertion mode:
-     after head">after head</a>" <a href="#insertion0">insertion mode</a>.</p>
+     after head">after head</a>" <span>insertion mode</span>.</p>
   </dl>
 
-  <h5 id=parsing-main-inhead><span class=secno>8.2.4.10. </span>The "<dfn
+  <h5 id=parsing-main-inhead><span class=secno>8.2.5.6. </span>The "<dfn
    id=in-head title="insertion mode: in head">in head</dfn>" insertion mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a href="#in-head"
+  <p>When the <span>insertion mode</span> is "<a href="#in-head"
    title="insertion mode: in head">in head</a>", tokens must be handled as
    follows:
 
@@ -42355,14 +42312,14 @@
    <dt>A DOCTYPE token
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>A start tag whose tag name is "html"
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-body" title="insertion mode: in body">in body</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-body" title="insertion mode: in body">in body</a>"
+     <span>insertion mode</span>.</p>
 
    <dt>A start tag whose tag name is one of: "base", "link"
 
@@ -42415,9 +42372,8 @@
    <dd>
     <p><a href="#insert0">Insert an HTML element</a> for the token.</p>
 
-    <p>Switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#in-head0" title="insertion mode: in head noscript">in head
-     noscript</a>".</p>
+    <p>Switch the <span>insertion mode</span> to "<a href="#in-head0"
+     title="insertion mode: in head noscript">in head noscript</a>".</p>
 
    <dt id=scriptTag>A start tag whose tag name is "script"
 
@@ -42447,7 +42403,7 @@
      switched back to the PCDATA state.</p>
 
     <p>If the next token is not an end tag token with the tag name "script",
-     then this is a <a href="#parse0">parse error</a>; mark the <code><a
+     then this is a <a href="#parse1">parse error</a>; mark the <code><a
      href="#script0">script</a></code> element as <a href="#already">"already
      executed"</a>. Otherwise, the token is the <code><a
      href="#script0">script</a></code> element's end tag, so ignore it.</p>
@@ -42545,8 +42501,8 @@
      <code><a href="#head">head</a></code> element) off the <a
      href="#stack">stack of open elements</a>.</p>
 
-    <p>Switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#after4" title="insertion mode: after head">after head</a>".</p>
+    <p>Switch the <span>insertion mode</span> to "<a href="#after4"
+     title="insertion mode: after head">after head</a>".</p>
 
    <dt>An end tag whose tag name is one of: "body", "html", "p", "br"
 
@@ -42558,7 +42514,7 @@
    <dt>Any other end tag
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>Anything else
 
@@ -42572,26 +42528,26 @@
      get put into the head. Do we want to copy that?</p>
   </dl>
 
-  <h5 id=parsing-main-inheadnoscript><span class=secno>8.2.4.11. </span>The
+  <h5 id=parsing-main-inheadnoscript><span class=secno>8.2.5.7. </span>The
    "<dfn id=in-head0 title="insertion mode: in head noscript">in head
    noscript</dfn>" insertion mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a
-   href="#in-head0" title="insertion mode: in head noscript">in head
-   noscript</a>", tokens must be handled as follows:
+  <p>When the <span>insertion mode</span> is "<a href="#in-head0"
+   title="insertion mode: in head noscript">in head noscript</a>", tokens
+   must be handled as follows:
 
   <dl class=switch>
    <dt>A DOCTYPE token
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>A start tag whose tag name is "html"
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-body" title="insertion mode: in body">in body</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-body" title="insertion mode: in body">in body</a>"
+     <span>insertion mode</span>.</p>
 
    <dt>An end tag whose tag name is "noscript"
 
@@ -42602,8 +42558,8 @@
      href="#current4">current node</a> will be a <code><a
      href="#head">head</a></code> element.</p>
 
-    <p>Switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#in-head" title="insertion mode: in head">in head</a>".</p>
+    <p>Switch the <span>insertion mode</span> to "<a href="#in-head"
+     title="insertion mode: in head">in head</a>".</p>
 
    <dt>A character token that is one of one of U+0009 CHARACTER TABULATION,
     U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF),
@@ -42615,8 +42571,8 @@
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-head" title="insertion mode: in head">in head</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-head" title="insertion mode: in head">in head</a>"
+     <span>insertion mode</span>.</p>
 
    <dt>An end tag whose tag name is one of: "p", "br"
 
@@ -42628,19 +42584,19 @@
    <dt>Any other end tag
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>Anything else
 
    <dd> <!-- can't get here with an EOF and a fragment case -->
-    <p><a href="#parse0">Parse error</a>. Act as if an end tag with the tag
+    <p><a href="#parse1">Parse error</a>. Act as if an end tag with the tag
      name "noscript" had been seen and reprocess the current token.</p>
   </dl>
 
-  <h5 id=the-after><span class=secno>8.2.4.12. </span>The "<dfn id=after4
+  <h5 id=the-after><span class=secno>8.2.5.8. </span>The "<dfn id=after4
    title="insertion mode: after head">after head</dfn>" insertion mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a href="#after4"
+  <p>When the <span>insertion mode</span> is "<a href="#after4"
    title="insertion mode: after head">after head</a>", tokens must be handled
    as follows:
 
@@ -42663,45 +42619,44 @@
    <dt>A DOCTYPE token
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>A start tag whose tag name is "html"
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-body" title="insertion mode: in body">in body</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-body" title="insertion mode: in body">in body</a>"
+     <span>insertion mode</span>.</p>
 
    <dt>A start tag whose tag name is "body"
 
    <dd>
     <p><a href="#insert0">Insert an HTML element</a> for the token.</p>
 
-    <p>Switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#in-body" title="insertion mode: in body">in body</a>".</p>
+    <p>Switch the <span>insertion mode</span> to "<a href="#in-body"
+     title="insertion mode: in body">in body</a>".</p>
 
    <dt>A start tag whose tag name is "frameset"
 
    <dd>
     <p><a href="#insert0">Insert an HTML element</a> for the token.</p>
 
-    <p>Switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#in-frameset" title="insertion mode: in frameset">in
-     frameset</a>".</p>
+    <p>Switch the <span>insertion mode</span> to "<a href="#in-frameset"
+     title="insertion mode: in frameset">in frameset</a>".</p>
 
    <dt>A start tag token whose tag name is one of: "base", "link", "meta",
     "script", "style", "title"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>.</p>
+    <p><a href="#parse1">Parse error</a>.</p>
 
     <p>Push the node pointed to by the <a href="#head-element"><code
      title="">head</code> element pointer</a> onto the <a href="#stack">stack
      of open elements</a>.</p>
 
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-head" title="insertion mode: in head">in head</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-head" title="insertion mode: in head">in head</a>"
+     <span>insertion mode</span>.</p>
 
     <p>Pop the <a href="#current4">current node</a> (which will be the node
      pointed to by the <a href="#head-element"><code title="">head</code>
@@ -42715,10 +42670,10 @@
      had been seen, and then reprocess the current token.</p>
   </dl>
 
-  <h5 id=parsing-main-inbody><span class=secno>8.2.4.13. </span>The "<dfn
+  <h5 id=parsing-main-inbody><span class=secno>8.2.5.9. </span>The "<dfn
    id=in-body title="insertion mode: in body">in body</dfn>" insertion mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a href="#in-body"
+  <p>When the <span>insertion mode</span> is "<a href="#in-body"
    title="insertion mode: in body">in body</a>", tokens must be handled as
    follows:
 
@@ -42742,12 +42697,12 @@
    <dt>A DOCTYPE token
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>A start tag whose tag name is "html"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. For each attribute on the token,
+    <p><a href="#parse1">Parse error</a>. For each attribute on the token,
      check to see if the attribute is already present on the top element of
      the <a href="#stack">stack of open elements</a>. If it is not, add the
      attribute and its corresponding value to that element.</p>
@@ -42757,13 +42712,13 @@
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-head" title="insertion mode: in head">in head</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-head" title="insertion mode: in head">in head</a>"
+     <span>insertion mode</span>.</p>
 
    <dt>A start tag whose tag name is "body"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>.</p>
+    <p><a href="#parse1">Parse error</a>.</p>
 
     <p>If the second element on the <a href="#stack">stack of open
      elements</a> is not a <code><a href="#body0">body</a></code> element,
@@ -42791,7 +42746,7 @@
      href="#tr">tr</a></code> element, the <code><a
      href="#body0">body</a></code> element, or the <code><a
      href="#html">html</a></code> element, then this is a <a
-     href="#parse0">parse error</a>.</p>
+     href="#parse1">parse error</a>.</p>
     <!-- (some of those are
     fragment cases) -->
     <p><a href="#stops">Stop parsing</a>.</p>
@@ -42801,7 +42756,7 @@
    <dd>
     <p>If the <a href="#stack">stack of open elements</a> does not <a
      href="#have-an" title="has an element in scope">have a <code>body</code>
-     element in scope</a>, this is a <a href="#parse0">parse error</a>;
+     element in scope</a>, this is a <a href="#parse1">parse error</a>;
      ignore the token.</p>
 
     <p>Otherwise, if there is a node in the <a href="#stack">stack of open
@@ -42816,12 +42771,12 @@
      href="#tr">tr</a></code> element, the <code><a
      href="#body0">body</a></code> element, or the <code><a
      href="#html">html</a></code> element, then this is a <a
-     href="#parse0">parse error</a>.</p>
+     href="#parse1">parse error</a>.</p>
     <!-- (some of those are fragment cases) -->
     <!-- the insertion mode here is forcibly "in body". -->
-    <p>Switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#after5" title="insertion mode: after body">after body</a>".
-     Otherwise, ignore the token.</p>
+    <p>Switch the <span>insertion mode</span> to "<a href="#after5"
+     title="insertion mode: after body">after body</a>". Otherwise, ignore
+     the token.</p>
 
    <dt>An end tag whose tag name is "html"
 
@@ -42879,7 +42834,7 @@
 
    <dd>
     <p>If the <a href="#form-element"><code title=form>form</code> element
-     pointer</a> is not null, ignore the token with a <a href="#parse0">parse
+     pointer</a> is not null, ignore the token with a <a href="#parse1">parse
      error</a>.</p>
 
     <p>Otherwise:</p>
@@ -42913,7 +42868,7 @@
        element, then pop all the nodes from the <a href="#current4">current
        node</a> up to <var title="">node</var>, including <var
        title="">node</var>, then stop this algorithm. If more than one node
-       is popped, then this is a <a href="#parse0">parse error</a>.
+       is popped, then this is a <a href="#parse1">parse error</a>.
 
      <li>
       <p>If <var title="">node</var> is not in the <a
@@ -42959,7 +42914,7 @@
        from the <a href="#current4">current node</a> up to <var
        title="">node</var>, including <var title="">node</var>, then stop
        this algorithm. If more than one node is popped, then this is a <a
-       href="#parse0">parse error</a>.
+       href="#parse1">parse error</a>.
 
      <li>
       <p>If <var title="">node</var> is not in the <a
@@ -43010,7 +42965,7 @@
     <p>If the <a href="#stack">stack of open elements</a> does not <a
      href="#have-an" title="has an element in scope">have an element in
      scope</a> with the same tag name as that of the token, then this is a <a
-     href="#parse0">parse error</a>.</p>
+     href="#parse1">parse error</a>.</p>
 
     <p>Otherwise, run these steps:</p>
 
@@ -43021,7 +42976,7 @@
      <li>
       <p>If the <a href="#current4">current node</a> is not an element with
        the same tag name as that of the token, then this is a <a
-       href="#parse0">parse error</a>.
+       href="#parse1">parse error</a>.
 
      <li>
       <p>Pop elements from the <a href="#stack">stack of open elements</a>
@@ -43038,7 +42993,7 @@
     <p>If the <a href="#stack">stack of open elements</a> does not <a
      href="#have-an" title="has an element in scope">have an element in
      scope</a> with the same tag name as that of the token, then this is a <a
-     href="#parse0">parse error</a>.</p>
+     href="#parse1">parse error</a>.</p>
 
     <p>Otherwise, run these steps:</p>
 
@@ -43049,7 +43004,7 @@
      <li>
       <p>If the <a href="#current4">current node</a> is not an element with
        the same tag name as that of the token, then this is a <a
-       href="#parse0">parse error</a>.
+       href="#parse1">parse error</a>.
 
      <li>
       <p>Pop elements from the <a href="#stack">stack of open elements</a>
@@ -43061,7 +43016,7 @@
 
    <dd>
     <p>If the <a href="#current4">current node</a> is not a <code><a
-     href="#p">p</a></code> element, then this is a <a href="#parse0">parse
+     href="#p">p</a></code> element, then this is a <a href="#parse1">parse
      error</a>.</p>
 
     <p>If the <a href="#stack">stack of open elements</a> <a href="#have-an"
@@ -43079,7 +43034,7 @@
     <p>If the <a href="#stack">stack of open elements</a> does not <a
      href="#have-an" title="has an element in scope">have an element in
      scope</a> with the same tag name as that of the token, then this is a <a
-     href="#parse0">parse error</a>.</p>
+     href="#parse1">parse error</a>.</p>
 
     <p>Otherwise, run these steps:</p>
 
@@ -43091,7 +43046,7 @@
      <li>
       <p>If the <a href="#current4">current node</a> is not an element with
        the same tag name as that of the token, then this is a <a
-       href="#parse0">parse error</a>.
+       href="#parse1">parse error</a>.
 
      <li>
       <p>Pop elements from the <a href="#stack">stack of open elements</a>
@@ -43106,7 +43061,7 @@
     <p>If the <a href="#stack">stack of open elements</a> does not <a
      href="#have-an" title="has an element in scope">have an element in
      scope</a> whose tag name is one of "h1", "h2", "h3", "h4", "h5", or
-     "h6", then this is a <a href="#parse0">parse error</a>.
+     "h6", then this is a <a href="#parse1">parse error</a>.
      <!-- XXX quirk: Act as if
     a start tag with the tag name given in the token had been seen,
     then reprocess the current token. --></p>
@@ -43120,7 +43075,7 @@
      <li>
       <p>If the <a href="#current4">current node</a> is not an element with
        the same tag name as that of the token, then this is a <a
-       href="#parse0">parse error</a>.
+       href="#parse1">parse error</a>.
 
      <li>
       <p>Pop elements from the <a href="#stack">stack of open elements</a>
@@ -43139,7 +43094,7 @@
     <p>If the <a href="#list-of4">list of active formatting elements</a>
      contains an element whose tag name is "a" between the end of the list
      and the last marker on the list (or the start of the list if there is no
-     marker on the list), then this is a <a href="#parse0">parse error</a>;
+     marker on the list), then this is a <a href="#parse1">parse error</a>;
      act as if an end tag with the tag name "a" had been seen, then remove
      that element from the <a href="#list-of4">list of active formatting
      elements</a> and the <a href="#stack">stack of open elements</a> if the
@@ -43182,7 +43137,7 @@
 
     <p>If the <a href="#stack">stack of open elements</a> <a href="#have-an"
      title="has an element in scope">has a <code>nobr</code> element in
-     scope</a>, then this is a <a href="#parse0">parse error</a>. Act as if
+     scope</a>, then this is a <a href="#parse1">parse error</a>. Act as if
      an end tag with the tag name <code>nobr</code> had been seen, then once
      again <a href="#reconstruct">reconstruct the active formatting
      elements</a>, if any.</p>
@@ -43214,19 +43169,19 @@
       <p>If there is no such node, or, if that node is also in the <a
        href="#stack">stack of open elements</a> but the element is not <a
        href="#have-an" title="has an element in scope">in scope</a>, then
-       this is a <a href="#parse0">parse error</a>. Abort these steps. The
+       this is a <a href="#parse1">parse error</a>. Abort these steps. The
        token is ignored.</p>
 
       <p>Otherwise, if there is such a node, but that node is not in the <a
        href="#stack">stack of open elements</a>, then this is a <a
-       href="#parse0">parse error</a>; remove the element from the list, and
+       href="#parse1">parse error</a>; remove the element from the list, and
        abort these steps.</p>
 
       <p>Otherwise, there is a <var title="">formatting element</var> and
        that element is in <a href="#stack" title="stack of open elements">the
        stack</a> and is <a href="#have-an" title="has an element in scope">in
        scope</a>. If the element is not the <a href="#current4">current
-       node</a>, this is a <a href="#parse0">parse error</a>. In any case,
+       node</a>, this is a <a href="#parse1">parse error</a>. In any case,
        proceed with the algorithm as written in the following steps.</p>
 
      <li>
@@ -43370,7 +43325,7 @@
    <dd>
     <p>If the <a href="#stack">stack of open elements</a> <a href="#have-an"
      title="has an element in scope">has a <code>button</code> element in
-     scope</a>, then this is a <a href="#parse0">parse error</a>; act as if
+     scope</a>, then this is a <a href="#parse1">parse error</a>; act as if
      an end tag with the tag name "button" had been seen, then reprocess the
      token.</p>
 
@@ -43409,7 +43364,7 @@
     <p>If the <a href="#stack">stack of open elements</a> does not <a
      href="#have-an" title="has an element in scope">have an element in
      scope</a> with the same tag name as that of the token, then this is a <a
-     href="#parse0">parse error</a>.</p>
+     href="#parse1">parse error</a>.</p>
 
     <p>Otherwise, run these steps:</p>
 
@@ -43420,7 +43375,7 @@
      <li>
       <p>If the <a href="#current4">current node</a> is not an element with
        the same tag name as that of the token, then this is a <a
-       href="#parse0">parse error</a>.
+       href="#parse1">parse error</a>.
 
      <li>
       <p>Pop elements from the <a href="#stack">stack of open elements</a>
@@ -43449,8 +43404,8 @@
     <!-- XXX quirks: don't do this -->
     <p><a href="#insert0">Insert an HTML element</a> for the token.</p>
 
-    <p>Switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#in-table" title="insertion mode: in table">in table</a>".</p>
+    <p>Switch the <span>insertion mode</span> to "<a href="#in-table"
+     title="insertion mode: in table">in table</a>".</p>
 
    <dt>A start tag whose tag name is one of: "area", "basefont", "bgsound",
     "br", "embed", "img", "param", "spacer", "wbr"
@@ -43478,7 +43433,7 @@
    <dt>A start tag whose tag name is "image"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Change the token's tag name to
+    <p><a href="#parse1">Parse error</a>. Change the token's tag name to
      "img" and reprocess it. (Don't ask.)</p>
     <!-- As of
     2005-12, studies showed that around 0.2% of pages used the
@@ -43506,7 +43461,7 @@
    <dt id=isindex>A start tag whose tag name is "isindex"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>.</p>
+    <p><a href="#parse1">Parse error</a>.</p>
 
     <p>If the <a href="#form-element"><code title="">form</code> element
      pointer</a> is not null, then ignore the token.</p>
@@ -43599,7 +43554,7 @@
      switched back to the PCDATA state.</p>
 
     <p>If the next token is an end tag token with the tag name "textarea",
-     ignore it. Otherwise, this is a <a href="#parse0">parse error</a>.</p>
+     ignore it. Otherwise, this is a <a href="#parse1">parse error</a>.</p>
 
    <dt>A start tag whose tag name is one of: "iframe", "noembed", "noframes"
 
@@ -43623,23 +43578,22 @@
      pointed to by the <a href="#form-element"><code title="">form</code>
      element pointer</a>.</p>
 
-    <p>If the <a href="#insertion0">insertion mode</a> is one of <a
-     href="#in-table" title="insertion mode: in table">in table</a>", "<a
-     href="#in-caption" title="insertion mode: in caption">in caption</a>",
-     "<a href="#in-column" title="insertion mode: in column group">in column
+    <p>If the <span>insertion mode</span> is one of <a href="#in-table"
+     title="insertion mode: in table">in table</a>", "<a href="#in-caption"
+     title="insertion mode: in caption">in caption</a>", "<a
+     href="#in-column" title="insertion mode: in column group">in column
      group</a>", "<a href="#in-table0" title="insertion mode: in table
      body">in table body</a>", "<a href="#in-row" title="insertion mode: in
      row">in row</a>", or "<a href="#in-cell" title="insertion mode: in
-     cell">in cell</a>", then switch the <a href="#insertion0">insertion
-     mode</a> to "<a href="#in-select0" title="insertion mode: in select in
-     table">in select in table</a>". Otherwise, switch the <a
-     href="#insertion0">insertion mode</a> to "<a href="#in-select"
-     title="insertion mode: in select">in select</a>".</p>
+     cell">in cell</a>", then switch the <span>insertion mode</span> to "<a
+     href="#in-select0" title="insertion mode: in select in table">in select
+     in table</a>". Otherwise, switch the <span>insertion mode</span> to "<a
+     href="#in-select" title="insertion mode: in select">in select</a>".</p>
 
    <dt>An end tag whose tag name is "br"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Act as if a start tag token with
+    <p><a href="#parse1">Parse error</a>. Act as if a start tag token with
      the tag name "br" had been seen. Ignore the end tag token.</p>
 
    <dt>A start or end tag whose tag name is one of: "caption", "col",
@@ -43656,7 +43610,7 @@
     href="#scripting2">scripting is enabled</a>:
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>A start or end tag whose tag name is one of: "event-source",
     "section", "nav", "article", "aside", "header", "footer", "datagrid",
@@ -43705,7 +43659,7 @@
        <li>
         <p>If the tag name of the end tag token does not match the tag name
          of the <a href="#current4">current node</a>, this is a <a
-         href="#parse0">parse error</a>.
+         href="#parse1">parse error</a>.
 
        <li>
         <p>Pop all the nodes from the <a href="#current4">current node</a> up
@@ -43717,7 +43671,7 @@
       <p>Otherwise, if <var title="">node</var> is in neither the <a
        href="#formatting">formatting</a> category nor the <a
        href="#phrasing1">phrasing</a> category, then this is a <a
-       href="#parse0">parse error</a>. Stop this algorithm. The end tag token
+       href="#parse1">parse error</a>. Stop this algorithm. The end tag token
        is ignored.
 
      <li>
@@ -43729,13 +43683,13 @@
     </ol>
   </dl>
 
-  <h5 id=parsing-main-intable><span class=secno>8.2.4.14. </span>The "<dfn
+  <h5 id=parsing-main-intable><span class=secno>8.2.5.10. </span>The "<dfn
    id=in-table title="insertion mode: in table">in table</dfn>" insertion
    mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a
-   href="#in-table" title="insertion mode: in table">in table</a>", tokens
-   must be handled as follows:
+  <p>When the <span>insertion mode</span> is "<a href="#in-table"
+   title="insertion mode: in table">in table</a>", tokens must be handled as
+   follows:
 
   <dl class=switch>
    <dt>A character token that is one of one of U+0009 CHARACTER TABULATION,
@@ -43760,7 +43714,7 @@
    <dt>A DOCTYPE token
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>A start tag whose tag name is "caption"
 
@@ -43772,8 +43726,8 @@
      formatting elements</a>.</p>
 
     <p><a href="#insert0">Insert an HTML element</a> for the token, then
-     switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#in-caption" title="insertion mode: in caption">in caption</a>".</p>
+     switch the <span>insertion mode</span> to "<a href="#in-caption"
+     title="insertion mode: in caption">in caption</a>".</p>
 
    <dt>A start tag whose tag name is "colgroup"
 
@@ -43782,9 +43736,8 @@
      below.)</p>
 
     <p><a href="#insert0">Insert an HTML element</a> for the token, then
-     switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#in-column" title="insertion mode: in column group">in column
-     group</a>".</p>
+     switch the <span>insertion mode</span> to "<a href="#in-column"
+     title="insertion mode: in column group">in column group</a>".</p>
 
    <dt>A start tag whose tag name is "col"
 
@@ -43799,9 +43752,8 @@
      below.)</p>
 
     <p><a href="#insert0">Insert an HTML element</a> for the token, then
-     switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#in-table0" title="insertion mode: in table body">in table
-     body</a>".</p>
+     switch the <span>insertion mode</span> to "<a href="#in-table0"
+     title="insertion mode: in table body">in table body</a>".</p>
 
    <dt>A start tag whose tag name is one of: "td", "th", "tr"
 
@@ -43812,7 +43764,7 @@
    <dt>A start tag whose tag name is "table"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Act as if an end tag token with the
+    <p><a href="#parse1">Parse error</a>. Act as if an end tag token with the
      tag name "table" had been seen, then, if that token wasn't ignored,
      reprocess the current token.</p>
 
@@ -43825,7 +43777,7 @@
     <p>If the <a href="#stack">stack of open elements</a> does not <a
      href="#have-an0" title="has an element in table scope">have an element
      in table scope</a> with the same tag name as the token, this is a <a
-     href="#parse0">parse error</a>. Ignore the token. (<a
+     href="#parse1">parse error</a>. Ignore the token. (<a
      href="#fragment">fragment case</a>)</p>
 
     <p>Otherwise:</p>
@@ -43839,7 +43791,7 @@
     "colgroup", "html", "tbody", "td", "tfoot", "th", "thead", "tr"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>A start tag whose tag name is one of: "style", "script"
 
@@ -43849,8 +43801,8 @@
      entry below.</p>
 
     <p>Otherwise, process the token <a href="#using8">using the rules for</a>
-     the "<a href="#in-head" title="insertion mode: in head">in head</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     the "<a href="#in-head" title="insertion mode: in head">in head</a>"
+     <span>insertion mode</span>.</p>
 
    <dt>A start tag whose tag name is "input"
 
@@ -43863,7 +43815,7 @@
 
     <p>Otherwise:</p>
 
-    <p><a href="#parse0">Parse error</a>.</p>
+    <p><a href="#parse1">Parse error</a>.</p>
 
     <p><a href="#insert0">Insert an HTML element</a> for the token.</p>
 
@@ -43882,7 +43834,7 @@
    <dd>
     <p>If the <a href="#current4">current node</a> is not the root <code><a
      href="#html">html</a></code> element, then this is a <a
-     href="#parse0">parse error.</a>.</p>
+     href="#parse1">parse error.</a>.</p>
 
     <p class=note>It can only be the <a href="#current4">current node</a> in
      the <a href="#fragment">fragment case</a>.</p>
@@ -43892,10 +43844,10 @@
    <dt>Anything else
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Process the token <a
+    <p><a href="#parse1">Parse error</a>. Process the token <a
      href="#using8">using the rules for</a> the "<a href="#in-body"
-     title="insertion mode: in body">in body</a>" <a
-     href="#insertion0">insertion mode</a>, with the following exception:</p>
+     title="insertion mode: in body">in body</a>" <span>insertion
+     mode</span>, with the following exception:</p>
 
     <p>If the <a href="#current4">current node</a> is a <code><a
      href="#table">table</a></code>, <code><a href="#tbody">tbody</a></code>,
@@ -43948,13 +43900,13 @@
    href="#html">html</a></code> element after this process is a <a
    href="#fragment">fragment case</a>.
 
-  <h5 id=parsing-main-incaption><span class=secno>8.2.4.15. </span>The "<dfn
+  <h5 id=parsing-main-incaption><span class=secno>8.2.5.11. </span>The "<dfn
    id=in-caption title="insertion mode: in caption">in caption</dfn>"
    insertion mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a
-   href="#in-caption" title="insertion mode: in caption">in caption</a>",
-   tokens must be handled as follows:
+  <p>When the <span>insertion mode</span> is "<a href="#in-caption"
+   title="insertion mode: in caption">in caption</a>", tokens must be handled
+   as follows:
 
   <dl class=switch>
    <dt>An end tag whose tag name is "caption"
@@ -43963,7 +43915,7 @@
     <p>If the <a href="#stack">stack of open elements</a> does not <a
      href="#have-an0" title="has an element in table scope">have an element
      in table scope</a> with the same tag name as the token, this is a <a
-     href="#parse0">parse error</a>. Ignore the token. (<a
+     href="#parse1">parse error</a>. Ignore the token. (<a
      href="#fragment">fragment case</a>)</p>
 
     <p>Otherwise:</p>
@@ -43972,7 +43924,7 @@
 
     <p>Now, if the <a href="#current4">current node</a> is not a <code><a
      href="#caption0">caption</a></code> element, then this is a <a
-     href="#parse0">parse error</a>.</p>
+     href="#parse1">parse error</a>.</p>
 
     <p>Pop elements from this stack until a <code><a
      href="#caption0">caption</a></code> element has been popped from the
@@ -43981,8 +43933,8 @@
     <p><a href="#clear0">Clear the list of active formatting elements up to
      the last marker</a>.</p>
 
-    <p>Switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#in-table" title="insertion mode: in table">in table</a>".</p>
+    <p>Switch the <span>insertion mode</span> to "<a href="#in-table"
+     title="insertion mode: in table">in table</a>".</p>
 
    <dt>A start tag whose tag name is one of: "caption", "col", "colgroup",
     "tbody", "td", "tfoot", "th", "thead", "tr"
@@ -43990,7 +43942,7 @@
    <dt>An end tag whose tag name is "table"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Act as if an end tag with the tag
+    <p><a href="#parse1">Parse error</a>. Act as if an end tag with the tag
      name "caption" had been seen, then, if that token wasn't ignored,
      reprocess the current token.</p>
 
@@ -44001,23 +43953,23 @@
     "html", "tbody", "td", "tfoot", "th", "thead", "tr"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>Anything else
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-body" title="insertion mode: in body">in body</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-body" title="insertion mode: in body">in body</a>"
+     <span>insertion mode</span>.</p>
   </dl>
 
-  <h5 id=parsing-main-incolgroup><span class=secno>8.2.4.16. </span>The "<dfn
+  <h5 id=parsing-main-incolgroup><span class=secno>8.2.5.12. </span>The "<dfn
    id=in-column title="insertion mode: in column group">in column
    group</dfn>" insertion mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a
-   href="#in-column" title="insertion mode: in column group">in column
-   group</a>", tokens must be handled as follows:
+  <p>When the <span>insertion mode</span> is "<a href="#in-column"
+   title="insertion mode: in column group">in column group</a>", tokens must
+   be handled as follows:
 
   <dl class=switch>
    <dt>A character token that is one of one of U+0009 CHARACTER TABULATION,
@@ -44038,14 +43990,14 @@
    <dt>A DOCTYPE token
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>A start tag whose tag name is "html"
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-body" title="insertion mode: in body">in body</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-body" title="insertion mode: in body">in body</a>"
+     <span>insertion mode</span>.</p>
 
    <dt>A start tag whose tag name is "col"
 
@@ -44059,19 +44011,19 @@
    <dd>
     <p>If the <a href="#current4">current node</a> is the root <code><a
      href="#html">html</a></code> element, then this is a <a
-     href="#parse0">parse error</a>, ignore the token. (<a
+     href="#parse1">parse error</a>, ignore the token. (<a
      href="#fragment">fragment case</a>)</p>
 
     <p>Otherwise, pop the <a href="#current4">current node</a> (which will be
      a <code><a href="#colgroup">colgroup</a></code> element) from the <a
-     href="#stack">stack of open elements</a>. Switch the <a
-     href="#insertion0">insertion mode</a> to "<a href="#in-table"
-     title="insertion mode: in table">in table</a>".</p>
+     href="#stack">stack of open elements</a>. Switch the <span>insertion
+     mode</span> to "<a href="#in-table" title="insertion mode: in table">in
+     table</a>".</p>
 
    <dt>An end tag whose tag name is "col"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>An end-of-file token
 
@@ -44092,13 +44044,13 @@
      href="#fragment">fragment case</a>.</p>
   </dl>
 
-  <h5 id=parsing-main-intbody><span class=secno>8.2.4.17. </span>The "<dfn
+  <h5 id=parsing-main-intbody><span class=secno>8.2.5.13. </span>The "<dfn
    id=in-table0 title="insertion mode: in table body">in table body</dfn>"
    insertion mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a
-   href="#in-table0" title="insertion mode: in table body">in table
-   body</a>", tokens must be handled as follows:
+  <p>When the <span>insertion mode</span> is "<a href="#in-table0"
+   title="insertion mode: in table body">in table body</a>", tokens must be
+   handled as follows:
 
   <dl class=switch>
    <dt>A start tag whose tag name is "tr"
@@ -44108,13 +44060,13 @@
      (See below.)</p>
 
     <p><a href="#insert0">Insert an HTML element</a> for the token, then
-     switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#in-row" title="insertion mode: in row">in row</a>".</p>
+     switch the <span>insertion mode</span> to "<a href="#in-row"
+     title="insertion mode: in row">in row</a>".</p>
 
    <dt>A start tag whose tag name is one of: "th", "td"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Act as if a start tag with the tag
+    <p><a href="#parse1">Parse error</a>. Act as if a start tag with the tag
      name "tr" had been seen, then reprocess the current token.</p>
 
    <dt>An end tag whose tag name is one of: "tbody", "tfoot", "thead"
@@ -44123,7 +44075,7 @@
     <p>If the <a href="#stack">stack of open elements</a> does not <a
      href="#have-an0" title="has an element in table scope">have an element
      in table scope</a> with the same tag name as the token, this is a <a
-     href="#parse0">parse error</a>. Ignore the token.</p>
+     href="#parse1">parse error</a>. Ignore the token.</p>
 
     <p>Otherwise:</p>
 
@@ -44131,9 +44083,9 @@
      (See below.)</p>
 
     <p>Pop the <a href="#current4">current node</a> from the <a
-     href="#stack">stack of open elements</a>. Switch the <a
-     href="#insertion0">insertion mode</a> to "<a href="#in-table"
-     title="insertion mode: in table">in table</a>".</p>
+     href="#stack">stack of open elements</a>. Switch the <span>insertion
+     mode</span> to "<a href="#in-table" title="insertion mode: in table">in
+     table</a>".</p>
 
    <dt>A start tag whose tag name is one of: "caption", "col", "colgroup",
     "tbody", "tfoot", "thead"
@@ -44144,7 +44096,7 @@
     <p>If the <a href="#stack">stack of open elements</a> does not <a
      href="#have-an0" title="has an element in table scope">have a
      <code>tbody</code>, <code>thead</code>, or <code>tfoot</code> element in
-     table scope</a>, this is a <a href="#parse0">parse error</a>. Ignore the
+     table scope</a>, this is a <a href="#parse1">parse error</a>. Ignore the
      token. (<a href="#fragment">fragment case</a>)</p>
 
     <p>Otherwise:</p>
@@ -44160,14 +44112,14 @@
     "colgroup", "html", "td", "th", "tr"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>Anything else
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-table" title="insertion mode: in table">in table</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-table" title="insertion mode: in table">in table</a>"
+     <span>insertion mode</span>.</p>
   </dl>
 
   <p>When the steps above require the UA to <dfn id=clear2>clear the stack
@@ -44182,10 +44134,10 @@
    href="#html">html</a></code> element after this process is a <a
    href="#fragment">fragment case</a>.
 
-  <h5 id=parsing-main-intr><span class=secno>8.2.4.18. </span>The "<dfn
+  <h5 id=parsing-main-intr><span class=secno>8.2.5.14. </span>The "<dfn
    id=in-row title="insertion mode: in row">in row</dfn>" insertion mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a href="#in-row"
+  <p>When the <span>insertion mode</span> is "<a href="#in-row"
    title="insertion mode: in row">in row</a>", tokens must be handled as
    follows:
 
@@ -44197,8 +44149,8 @@
      (See below.)</p>
 
     <p><a href="#insert0">Insert an HTML element</a> for the token, then
-     switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#in-cell" title="insertion mode: in cell">in cell</a>".</p>
+     switch the <span>insertion mode</span> to "<a href="#in-cell"
+     title="insertion mode: in cell">in cell</a>".</p>
 
     <p>Insert a marker at the end of the <a href="#list-of4">list of active
      formatting elements</a>.</p>
@@ -44209,7 +44161,7 @@
     <p>If the <a href="#stack">stack of open elements</a> does not <a
      href="#have-an0" title="has an element in table scope">have an element
      in table scope</a> with the same tag name as the token, this is a <a
-     href="#parse0">parse error</a>. Ignore the token. (<a
+     href="#parse1">parse error</a>. Ignore the token. (<a
      href="#fragment">fragment case</a>)</p>
 
     <p>Otherwise:</p>
@@ -44219,8 +44171,8 @@
 
     <p>Pop the <a href="#current4">current node</a> (which will be a <code><a
      href="#tr">tr</a></code> element) from the <a href="#stack">stack of
-     open elements</a>. Switch the <a href="#insertion0">insertion mode</a>
-     to "<a href="#in-table0" title="insertion mode: in table body">in table
+     open elements</a>. Switch the <span>insertion mode</span> to "<a
+     href="#in-table0" title="insertion mode: in table body">in table
      body</a>".</p>
 
    <dt>A start tag whose tag name is one of: "caption", "col", "colgroup",
@@ -44241,7 +44193,7 @@
     <p>If the <a href="#stack">stack of open elements</a> does not <a
      href="#have-an0" title="has an element in table scope">have an element
      in table scope</a> with the same tag name as the token, this is a <a
-     href="#parse0">parse error</a>. Ignore the token.</p>
+     href="#parse1">parse error</a>. Ignore the token.</p>
 
     <p>Otherwise, act as if an end tag with the tag name "tr" had been seen,
      then reprocess the current token.</p>
@@ -44250,14 +44202,14 @@
     "colgroup", "html", "td", "th"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>Anything else
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-table" title="insertion mode: in table">in table</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-table" title="insertion mode: in table">in table</a>"
+     <span>insertion mode</span>.</p>
   </dl>
 
   <p>When the steps above require the UA to <dfn id=clear3>clear the stack
@@ -44271,10 +44223,10 @@
    href="#html">html</a></code> element after this process is a <a
    href="#fragment">fragment case</a>.
 
-  <h5 id=parsing-main-intd><span class=secno>8.2.4.19. </span>The "<dfn
+  <h5 id=parsing-main-intd><span class=secno>8.2.5.15. </span>The "<dfn
    id=in-cell title="insertion mode: in cell">in cell</dfn>" insertion mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a href="#in-cell"
+  <p>When the <span>insertion mode</span> is "<a href="#in-cell"
    title="insertion mode: in cell">in cell</a>", tokens must be handled as
    follows:
 
@@ -44285,7 +44237,7 @@
     <p>If the <a href="#stack">stack of open elements</a> does not <a
      href="#have-an0" title="has an element in table scope">have an element
      in table scope</a> with the same tag name as that of the token, then
-     this is a <a href="#parse0">parse error</a> and the token must be
+     this is a <a href="#parse1">parse error</a> and the token must be
      ignored.</p>
 
     <p>Otherwise:</p>
@@ -44294,7 +44246,7 @@
 
     <p>Now, if the <a href="#current4">current node</a> is not an element
      with the same tag name as the token, then this is a <a
-     href="#parse0">parse error</a>.</p>
+     href="#parse1">parse error</a>.</p>
 
     <p>Pop elements from this stack until an element with the same tag name
      as the token has been popped from the stack.</p>
@@ -44302,8 +44254,8 @@
     <p><a href="#clear0">Clear the list of active formatting elements up to
      the last marker</a>.</p>
 
-    <p>Switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#in-row" title="insertion mode: in row">in row</a>". (The <a
+    <p>Switch the <span>insertion mode</span> to "<a href="#in-row"
+     title="insertion mode: in row">in row</a>". (The <a
      href="#current4">current node</a> will be a <code><a
      href="#tr">tr</a></code> element at this point.)</p>
 
@@ -44314,7 +44266,7 @@
     <p>If the <a href="#stack">stack of open elements</a> does <em>not</em>
      <a href="#have-an0" title="has an element in table scope">have a
      <code>td</code> or <code>th</code> element in table scope</a>, then this
-     is a <a href="#parse0">parse error</a>; ignore the token. (<a
+     is a <a href="#parse1">parse error</a>; ignore the token. (<a
      href="#fragment">fragment case</a>)</p>
 
     <p>Otherwise, <a href="#close2">close the cell</a> (see below) and
@@ -44324,7 +44276,7 @@
     "colgroup", "html"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>An end tag whose tag name is one of: "table", "tbody", "tfoot",
     "thead", "tr"
@@ -44335,7 +44287,7 @@
      in table scope</a> with the same tag name as that of the token (which
      can only happen for "tbody", "tfoot" and "thead", or, in the <a
      href="#fragment">fragment case</a>), then this is a <a
-     href="#parse0">parse error</a> and the token must be ignored.</p>
+     href="#parse1">parse error</a> and the token must be ignored.</p>
 
     <p>Otherwise, <a href="#close2">close the cell</a> (see below) and
      reprocess the current token.</p>
@@ -44344,8 +44296,8 @@
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-body" title="insertion mode: in body">in body</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-body" title="insertion mode: in body">in body</a>"
+     <span>insertion mode</span>.</p>
   </dl>
 
   <p>Where the steps above say to <dfn id=close2>close the cell</dfn>, they
@@ -44369,16 +44321,16 @@
    both a <code><a href="#td">td</a></code> and a <code><a
    href="#th">th</a></code> element <a href="#have-an0" title="has an element
    in table scope">in table scope</a> at the same time, nor can it have
-   neither when the <a href="#insertion0">insertion mode</a> is "<a
-   href="#in-cell" title="insertion mode: in cell">in cell</a>".
+   neither when the <span>insertion mode</span> is "<a href="#in-cell"
+   title="insertion mode: in cell">in cell</a>".
 
-  <h5 id=parsing-main-inselect><span class=secno>8.2.4.20. </span>The "<dfn
+  <h5 id=parsing-main-inselect><span class=secno>8.2.5.16. </span>The "<dfn
    id=in-select title="insertion mode: in select">in select</dfn>" insertion
    mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a
-   href="#in-select" title="insertion mode: in select">in select</a>", tokens
-   must be handled as follows:
+  <p>When the <span>insertion mode</span> is "<a href="#in-select"
+   title="insertion mode: in select">in select</a>", tokens must be handled
+   as follows:
 
   <dl class=switch>
    <dt>A character token
@@ -44397,14 +44349,14 @@
    <dt>A DOCTYPE token
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>A start tag whose tag name is "html"
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-body" title="insertion mode: in body">in body</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-body" title="insertion mode: in body">in body</a>"
+     <span>insertion mode</span>.</p>
 
    <dt>A start tag whose tag name is "option"
 
@@ -44438,14 +44390,14 @@
     <p>If the <a href="#current4">current node</a> is an
      <code>optgroup</code> element, then pop that node from the <a
      href="#stack">stack of open elements</a>. Otherwise, this is a <a
-     href="#parse0">parse error</a>, ignore the token.</p>
+     href="#parse1">parse error</a>, ignore the token.</p>
 
    <dt>An end tag whose tag name is "option"
 
    <dd>
     <p>If the <a href="#current4">current node</a> is an <code>option</code>
      element, then pop that node from the <a href="#stack">stack of open
-     elements</a>. Otherwise, this is a <a href="#parse0">parse error</a>,
+     elements</a>. Otherwise, this is a <a href="#parse1">parse error</a>,
      ignore the token.</p>
 
    <dt>An end tag whose tag name is "select"
@@ -44454,7 +44406,7 @@
     <p>If the <a href="#stack">stack of open elements</a> does not <a
      href="#have-an0" title="has an element in table scope">have an element
      in table scope</a> with the same tag name as the token, this is a <a
-     href="#parse0">parse error</a>. Ignore the token. (<a
+     href="#parse1">parse error</a>. Ignore the token. (<a
      href="#fragment">fragment case</a>)</p>
 
     <p>Otherwise:</p>
@@ -44467,13 +44419,13 @@
    <dt>A start tag whose tag name is "select"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Act as if the token had been an end
+    <p><a href="#parse1">Parse error</a>. Act as if the token had been an end
      tag with the tag name "select" instead.</p>
 
    <dt>A start tag whose tag name is "input"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Act as if an end tag with the tag
+    <p><a href="#parse1">Parse error</a>. Act as if an end tag with the tag
      name "select" had been seen, and reprocess the token.</p>
 
    <dt>An end-of-file token
@@ -44481,7 +44433,7 @@
    <dd>
     <p>If the <a href="#current4">current node</a> is not the root <code><a
      href="#html">html</a></code> element, then this is a <a
-     href="#parse0">parse error.</a>.</p>
+     href="#parse1">parse error.</a>.</p>
 
     <p class=note>It can only be the <a href="#current4">current node</a> in
      the <a href="#fragment">fragment case</a>.</p>
@@ -44491,30 +44443,30 @@
    <dt>Anything else
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
   </dl>
 
-  <h5 id=parsing-main-inselect><span class=secno>8.2.4.21. </span>The "<dfn
+  <h5 id=parsing-main-inselect><span class=secno>8.2.5.17. </span>The "<dfn
    id=in-select0 title="insertion mode: in select in table">in select in
    table</dfn>" insertion mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a
-   href="#in-select0" title="insertion mode: in select in table">in select in
-   table</a>", tokens must be handled as follows:
+  <p>When the <span>insertion mode</span> is "<a href="#in-select0"
+   title="insertion mode: in select in table">in select in table</a>", tokens
+   must be handled as follows:
 
   <dl class=switch>
    <dt>A start tag whose tag name is one of: "caption", "table", "tbody",
     "tfoot", "thead", "tr", "td", "th"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Act as if an end tag with the tag
+    <p><a href="#parse1">Parse error</a>. Act as if an end tag with the tag
      name "select" had been seen, and reprocess the token.</p>
 
    <dt>An end tag whose tag name is one of: "caption", "table", "tbody",
     "tfoot", "thead", "tr", "td", "th"
 
    <dd>
-    <p><a href="#parse0">Parse error</a>.</p>
+    <p><a href="#parse1">Parse error</a>.</p>
 
     <p>If the <a href="#stack">stack of open elements</a> <a
      href="#have-an0">has an element in table scope</a> with the same tag
@@ -44526,15 +44478,15 @@
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-select" title="insertion mode: in select">in select</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-select" title="insertion mode: in select">in select</a>"
+     <span>insertion mode</span>.</p>
   </dl>
 
-  <h5 id=parsing-main-afterbody><span class=secno>8.2.4.22. </span>The "<dfn
+  <h5 id=parsing-main-afterbody><span class=secno>8.2.5.18. </span>The "<dfn
    id=after5 title="insertion mode: after body">after body</dfn>" insertion
    mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a href="#after5"
+  <p>When the <span>insertion mode</span> is "<a href="#after5"
    title="insertion mode: after body">after body</a>", tokens must be handled
    as follows:
 
@@ -44545,8 +44497,8 @@
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-body" title="insertion mode: in body">in body</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-body" title="insertion mode: in body">in body</a>"
+     <span>insertion mode</span>.</p>
 
    <dt>A comment token
 
@@ -44560,24 +44512,24 @@
    <dt>A DOCTYPE token
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>A start tag whose tag name is "html"
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-body" title="insertion mode: in body">in body</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-body" title="insertion mode: in body">in body</a>"
+     <span>insertion mode</span>.</p>
 
    <dt>An end tag whose tag name is "html"
 
    <dd>
     <p>If the parser was originally created as part of the <a
      href="#html-fragment0">HTML fragment parsing algorithm</a>, this is a <a
-     href="#parse0">parse error</a>; ignore the token. (<a
+     href="#parse1">parse error</a>; ignore the token. (<a
      href="#fragment">fragment case</a>)</p>
     <!-- can only happen for <html>'s own innerHTML -->
-    <p>Otherwise, switch the <a href="#insertion0">insertion mode</a> to "<a
+    <p>Otherwise, switch the <span>insertion mode</span> to "<a
      href="#after7" title="insertion mode: after after body">after after
      body</a>".</p>
 
@@ -44589,18 +44541,18 @@
    <dt>Anything else
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Switch the <a
-     href="#insertion0">insertion mode</a> to "<a href="#in-body"
-     title="insertion mode: in body">in body</a>" and reprocess the token.</p>
+    <p><a href="#parse1">Parse error</a>. Switch the <span>insertion
+     mode</span> to "<a href="#in-body" title="insertion mode: in body">in
+     body</a>" and reprocess the token.</p>
   </dl>
 
-  <h5 id=parsing-main-inframeset><span class=secno>8.2.4.23. </span>The "<dfn
+  <h5 id=parsing-main-inframeset><span class=secno>8.2.5.19. </span>The "<dfn
    id=in-frameset title="insertion mode: in frameset">in frameset</dfn>"
    insertion mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a
-   href="#in-frameset" title="insertion mode: in frameset">in frameset</a>",
-   tokens must be handled as follows:
+  <p>When the <span>insertion mode</span> is "<a href="#in-frameset"
+   title="insertion mode: in frameset">in frameset</a>", tokens must be
+   handled as follows:
 
   <dl class=switch>
    <dt>A character token that is one of one of U+0009 CHARACTER TABULATION,
@@ -44621,14 +44573,14 @@
    <dt>A DOCTYPE token
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>A start tag whose tag name is "html"
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-body" title="insertion mode: in body">in body</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-body" title="insertion mode: in body">in body</a>"
+     <span>insertion mode</span>.</p>
 
    <dt>A start tag whose tag name is "frameset"
 
@@ -44640,7 +44592,7 @@
    <dd>
     <p>If the <a href="#current4">current node</a> is the root <code><a
      href="#html">html</a></code> element, then this is a <a
-     href="#parse0">parse error</a>; ignore the token. (<a
+     href="#parse1">parse error</a>; ignore the token. (<a
      href="#fragment">fragment case</a>)</p>
 
     <p>Otherwise, pop the <a href="#current4">current node</a> from the <a
@@ -44650,8 +44602,8 @@
      href="#html-fragment0">HTML fragment parsing algorithm</a> (<a
      href="#fragment">fragment case</a>), and the <a href="#current4">current
      node</a> is no longer a <code>frameset</code> element, then switch the
-     <a href="#insertion0">insertion mode</a> to "<a href="#after6"
-     title="insertion mode: after frameset">after frameset</a>".</p>
+     <span>insertion mode</span> to "<a href="#after6" title="insertion mode:
+     after frameset">after frameset</a>".</p>
 
    <dt>A start tag whose tag name is "frame"
 
@@ -44664,15 +44616,15 @@
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-body" title="insertion mode: in body">in body</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-body" title="insertion mode: in body">in body</a>"
+     <span>insertion mode</span>.</p>
 
    <dt>An end-of-file token
 
    <dd>
     <p>If the <a href="#current4">current node</a> is not the root <code><a
      href="#html">html</a></code> element, then this is a <a
-     href="#parse0">parse error.</a>.</p>
+     href="#parse1">parse error.</a>.</p>
 
     <p class=note>It can only be the <a href="#current4">current node</a> in
      the <a href="#fragment">fragment case</a>.</p>
@@ -44682,14 +44634,14 @@
    <dt>Anything else
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
   </dl>
 
-  <h5 id=parsing-main-afterframeset><span class=secno>8.2.4.24. </span>The
+  <h5 id=parsing-main-afterframeset><span class=secno>8.2.5.20. </span>The
    "<dfn id=after6 title="insertion mode: after frameset">after
    frameset</dfn>" insertion mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a href="#after6"
+  <p>When the <span>insertion mode</span> is "<a href="#after6"
    title="insertion mode: after frameset">after frameset</a>", tokens must be
    handled as follows:</p>
   <!-- due to rules in the "in frameset" mode, this can't be entered in the fragment case -->
@@ -44713,7 +44665,7 @@
    <dt>A DOCTYPE token
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
 
    <dt>A start tag whose tag name is "html"
 
@@ -44721,15 +44673,14 @@
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-body" title="insertion mode: in body">in body</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-body" title="insertion mode: in body">in body</a>"
+     <span>insertion mode</span>.</p>
 
    <dt>An end tag whose tag name is "html"
 
    <dd>
-    <p>Switch the <a href="#insertion0">insertion mode</a> to "<a
-     href="#after8" title="insertion mode: after after frameset">after after
-     frameset</a>".</p>
+    <p>Switch the <span>insertion mode</span> to "<a href="#after8"
+     title="insertion mode: after after frameset">after after frameset</a>".</p>
 
    <dt>An end-of-file token
 
@@ -44739,18 +44690,18 @@
    <dt>Anything else
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse1">Parse error</a>. Ignore the token.</p>
   </dl>
 
   <p class=big-issue>This doesn't handle UAs that don't support frames, or
    that do support frames but want to show the NOFRAMES content. Supporting
    the former is easy; supporting the latter is harder.
 
-  <h5 id=the-after0><span class=secno>8.2.4.25. </span>The "<dfn id=after7
+  <h5 id=the-after0><span class=secno>8.2.5.21. </span>The "<dfn id=after7
    title="insertion mode: after after body">after after body</dfn>" insertion
    mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a href="#after7"
+  <p>When the <span>insertion mode</span> is "<a href="#after7"
    title="insertion mode: after after body">after after body</a>", tokens
    must be handled as follows:
 
@@ -44772,8 +44723,8 @@
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-body" title="insertion mode: in body">in body</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-body" title="insertion mode: in body">in body</a>"
+     <span>insertion mode</span>.</p>
 
    <dt>An end-of-file token
 
@@ -44783,16 +44734,16 @@
    <dt>Anything else
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Switch the <a
-     href="#insertion0">insertion mode</a> to "<a href="#in-body"
-     title="insertion mode: in body">in body</a>" and reprocess the token.</p>
+    <p><a href="#parse1">Parse error</a>. Switch the <span>insertion
+     mode</span> to "<a href="#in-body" title="insertion mode: in body">in
+     body</a>" and reprocess the token.</p>
   </dl>
 
-  <h5 id=the-after1><span class=secno>8.2.4.26. </span>The "<dfn id=after8
+  <h5 id=the-after1><span class=secno>8.2.5.22. </span>The "<dfn id=after8
    title="insertion mode: after after frameset">after after frameset</dfn>"
    insertion mode</h5>
 
-  <p>When the <a href="#insertion0">insertion mode</a> is "<a href="#after8"
+  <p>When the <span>insertion mode</span> is "<a href="#after8"
    title="insertion mode: after after frameset">after after frameset</a>",
    tokens must be handled as follows:
 
@@ -44814,8 +44765,8 @@
 
    <dd>
     <p>Process the token <a href="#using8">using the rules for</a> the "<a
-     href="#in-body" title="insertion mode: in body">in body</a>" <a
-     href="#insertion0">insertion mode</a>.</p>
+     href="#in-body" title="insertion mode: in body">in body</a>"
+     <span>insertion mode</span>.</p>
 
    <dt>An end-of-file token
 
@@ -44825,13 +44776,12 @@
    <dt>Anything else
 
    <dd>
-    <p><a href="#parse0">Parse error</a>. Switch the <a
-     href="#insertion0">insertion mode</a> to "<a href="#in-frameset"
-     title="insertion mode: in frameset">in frameset</a>" and reprocess the
-     token.</p>
+    <p><a href="#parse1">Parse error</a>. Switch the <span>insertion
+     mode</span> to "<a href="#in-frameset" title="insertion mode: in
+     frameset">in frameset</a>" and reprocess the token.</p>
   </dl>
 
-  <h4 id=the-end><span class=secno>8.2.5 </span>The end</h4>
+  <h4 id=the-end><span class=secno>8.2.6 </span>The end</h4>
 
   <p>Once the user agent <dfn id=stops title="stop parsing">stops
    parsing</dfn> the document, the user agent must follow the steps in this

Modified: source
===================================================================
--- source	2008-04-05 10:50:19 UTC (rev 1402)
+++ source	2008-04-05 11:14:50 UTC (rev 1403)
@@ -37015,6 +37015,421 @@
 
 
 
+  <h4>Parse state</h4>
+
+  <h5>The insertion mode</h5>
+
+  <p>Initially the <span>insertion mode</span> is "<span
+  title="insertion mode: initial">initial</span>". It can change to
+  "<span title="insertion mode: before html">before html</span>",
+  "<span title="insertion mode: before head">before head</span>",
+  "<span title="insertion mode: in head">in head</span>", "<span
+  title="insertion mode: in head noscript">in head noscript</span>",
+  "<span title="insertion mode: after head">after head</span>", "<span
+  title="insertion mode: in body">in body</span>", "<span
+  title="insertion mode: in table">in table</span>", "<span
+  title="insertion mode: in caption">in caption</span>", "<span
+  title="insertion mode: in column group">in column group</span>",
+  "<span title="insertion mode: in table body">in table body</span>",
+  "<span title="insertion mode: in row">in row</span>", "<span
+  title="insertion mode: in cell">in cell</span>", "<span
+  title="insertion mode: in select">in select</span>", "<span
+  title="insertion mode: in select in table">in select in
+  table</span>", "<span title="insertion mode: after body">after
+  body</span>", "<span title="insertion mode: in frameset">in
+  frameset</span>", "<span title="insertion mode: after
+  frameset">after frameset</span>", "<span title="insertion mode:
+  after after body">after after body</span>", and "<span
+  title="insertion mode: after after frameset">after after
+  frameset</span>" during the course of the parsing, as described in
+  the <span>tree construction</span> stage. The insertion mode affects
+  how tokens are processed and whether CDATA blocks are supported.</p>
+
+  <p>Seven of these modes, namely "<span title="insertion mode: in
+  head">in head</span>", "<span title="insertion mode: in body">in
+  body</span>", "<span title="insertion mode: in table">in
+  table</span>", "<span title="insertion mode: in table body">in table
+  body</span>", "<span title="insertion mode: in row">in row</span>",
+  "<span title="insertion mode: in cell">in cell</span>", and "<span
+  title="insertion mode: in select">in select</span>", are special, in
+  that the other modes defer to them at various times. When the
+  algorithm below says that the user agent is to do something
+  "<dfn>using the rules for</dfn> the <var title="">m</var> insertion
+  mode", where <var title="">m</var> is one of these modes, the user
+  agent must use the rules described under that <span>insertion
+  mode</span>'s section, but must leave the <span>insertion
+  mode</span> unchanged (unless the rules in that section themselves
+  switch the <span>insertion mode</span>).</p>
+
+
+  <p>When the steps below require the UA to <dfn>reset the insertion
+  mode appropriately</dfn>, it means the UA must follow these
+  steps:</p>
+
+  <ol>
+
+   <li>Let <var title="">last</var> be false.</li>
+
+   <li>Let <var title="">node</var> be the last node in the
+   <span>stack of open elements</span>.</li>
+
+   <li>If <var title="">node</var> is the first node in the stack of
+   open elements, then set <var title="">last</var> to true; if, in
+   addition, the <var title="">context</var> element of the <span>HTML
+   fragment parsing algorithm</span> is neither a <code>td</code>
+   element nor a <code>th</code> element, then set <var
+   title="">node</var> to the <var title="">context</var>
+   element. (<span>fragment case</span>)</li>
+
+   <li>If <var title="">node</var> is a <code>select</code> element,
+   then switch the <span>insertion mode</span> to "<span
+   title="insertion mode: in select">in select</span>" and abort these
+   steps. (<span>fragment case</span>)</li>
+
+   <li>If <var title="">node</var> is a <code>td</code> or
+   <code>th</code> element, then switch the <span>insertion
+   mode</span> to "<span title="insertion mode: in cell">in
+   cell</span>" and abort these steps.</li>
+
+   <li>If <var title="">node</var> is a <code>tr</code> element, then
+   switch the <span>insertion mode</span> to "<span title="insertion
+   mode: in row">in row</span>" and abort these steps.</li>
+
+   <li>If <var title="">node</var> is a <code>tbody</code>,
+   <code>thead</code>, or <code>tfoot</code> element, then switch the
+   <span>insertion mode</span> to "<span title="insertion mode: in
+   table body">in table body</span>" and abort these steps.</li>
+
+   <li>If <var title="">node</var> is a <code>caption</code> element,
+   then switch the <span>insertion mode</span> to "<span
+   title="insertion mode: in caption">in caption</span>" and abort
+   these steps.</li>
+
+   <li>If <var title="">node</var> is a <code>colgroup</code> element,
+   then switch the <span>insertion mode</span> to "<span
+   title="insertion mode: in column group">in column group</span>" and
+   abort these steps. (<span>fragment case</span>)</li>
+
+   <li>If <var title="">node</var> is a <code>table</code> element,
+   then switch the <span>insertion mode</span> to "<span
+   title="insertion mode: in table">in table</span>" and abort these
+   steps.</li>
+
+   <li>If <var title="">node</var> is a <code>head</code> element,
+   then switch the <span>insertion mode</span> to "<span
+   title="insertion mode: in body">in body</span>" ("<span
+   title="insertion mode: in body">in body</span>"! <em> not "<span
+   title="insertion mode: in head">in head</span>"</em>!) and abort
+   these steps. (<span>fragment case</span>)</li> <!-- This is only
+   here for now in case people think that the spec accidentally
+   omitted it and try to "fix" it. Note that noscript-in-head is also
+   handled this way. This is all intentional. The only thing it
+   doesn't handle is the scripting-enabled fragment parsing case for a
+   <head> element containing a <noscript> which itself contains
+   something other than a <link> or a <style> element; you'd expect
+   that to break out of the <noscript> but it doesn't. This is an edge
+   case that doesn't affect the spec, since the algorithm for fragment
+   parsing is only used for innerHTML, where we know scripting is
+   enabled. -->
+
+   <li>If <var title="">node</var> is a <code>body</code> element,
+   then switch the <span>insertion mode</span> to "<span
+   title="insertion mode: in body">in body</span>" and abort these
+   steps.</li>
+
+   <li>If <var title="">node</var> is a <code>frameset</code> element,
+   then switch the <span>insertion mode</span> to "<span
+   title="insertion mode: in frameset">in frameset</span>" and abort
+   these steps. (<span>fragment case</span>)</li>
+
+   <li>If <var title="">node</var> is an <code>html</code> element,
+   then: if the <span><code title="">head</code> element
+   pointer</span> is null, switch the <span>insertion mode</span> to
+   "<span title="insertion mode: before head">before head</span>",
+   otherwise, switch the <span>insertion mode</span> to "<span
+   title="insertion mode: after head">after head</span>". In either
+   case, abort these steps. (<span>fragment case</span>)</li> <!-- XXX
+   can the head element pointer ever be non-null when we're going
+   through these steps? -->
+
+   <li>If <var title="">last</var> is true, then switch the
+   <span>insertion mode</span> to "<span title="insertion mode: in
+   body">in body</span>" and abort these steps. (<span>fragment
+   case</span>)</li>
+
+   <li>Let <var title="">node</var> now be the node before <var
+   title="">node</var> in the <span>stack of open
+   elements</span>.</li>
+
+   <li>Return to step 3.</li>
+
+  </ol>
+
+
+  <h5>The stack of open elements</h5>
+
+  <p>Initially the <dfn>stack of open elements</dfn> is empty. The
+  stack grows downwards; the topmost node on the stack is the first
+  one added to the stack, and the bottommost node of the stack is the
+  most recently added node in the stack (notwithstanding when the
+  stack is manipulated in a random access fashion as part of <a
+  href="#adoptionAgency">the handling for misnested tags</a>).</p>
+
+  <p>The "<span title="insertion mode: before html">before
+  html</span>" <span>insertion mode</span> creates the
+  <code>html</code> root element node, which is then added to the
+  stack.</p>
+
+  <p>In the <span>fragment case</span>, the <span>stack of open
+  elements</span> is initialised to contain an <code>html</code>
+  element that is created as part of <span title="html fragment
+  parsing algorithm">that algorithm</span>. (The <span>fragment
+  case</span> skips the "<span title="insertion mode: before
+  html">before html</span>" <span>insertion mode</span>.)</p>
+
+  <p>The <code>html</code> node, however it is created, is the topmost
+  node of the stack. It never gets popped off the stack.</p>
+
+  <p>The <dfn>current node</dfn> is the bottommost node in this
+  stack.</p>
+
+  <p>The <dfn>current table</dfn> is the last <code>table</code>
+  element in the <span>stack of open elements</span>, if there is
+  one. If there is no <code>table</code> element in the <span>stack of
+  open elements</span> (<span>fragment case</span>), then the
+  <span>current table</span> is the first element in the <span>stack
+  of open elements</span> (the <code>html</code> element).</p>
+
+  <p>Elements in the stack fall into the following categories:</p>
+
+  <dl>
+
+   <dt><dfn>Special</dfn></dt>
+   <dd><p>The following HTML elements have varying levels of special
+   parsing rules: <code>address</code>, <code>area</code>,
+   <code>base</code>, <code>basefont</code>, <code>bgsound</code>,
+   <code>blockquote</code>, <code>body</code>, <code>br</code>,
+   <code>center</code>, <code>col</code>, <code>colgroup</code>,
+   <code>dd</code>, <code>dir</code>, <code>div</code>,
+   <code>dl</code>, <code>dt</code>, <code>embed</code>,
+   <code>fieldset</code>, <code>form</code>, <code>frame</code>,
+   <code>frameset</code>, <code>h1</code>, <code>h2</code>,
+   <code>h3</code>, <code>h4</code>, <code>h5</code>, <code>h6</code>,
+   <code>head</code>, <code>hr</code>, <code>iframe</code>,
+   <code>image</code><!-- XXX ? this isn't an element that can end up
+   on the stack-->, <code>img</code>, <code>input</code>,
+   <code>isindex</code>, <code>li</code>, <code>link</code>,
+   <code>listing</code>, <code>menu</code>, <code>meta</code>,
+   <code>noembed</code>, <code>noframes</code>, <code>noscript</code>,
+   <code>ol</code>, <code>optgroup</code>, <code>option</code>,
+   <code>p</code>, <code>param</code>, <code>plaintext</code>,
+   <code>pre</code>, <code>script</code>, <code>select</code>,
+   <code>spacer</code>, <code>style</code>, <code>tbody</code>,
+   <code>textarea</code>, <code>tfoot</code>, <code>thead</code>,
+   <code>title</code>, <code>tr</code>, <code>ul</code>, and
+   <code>wbr</code>.</p></dd>
+
+   <dt><dfn>Scoping</dfn></dt>
+   <dd><p>The following HTML elements introduce new <span title="has
+   an element in scope">scopes</span> for various parts of the
+   parsing: <code>applet</code>, <code>button</code>,
+   <code>caption</code>, <code>html</code>, <code>marquee</code>,
+   <code>object</code>, <code>table</code>, <code>td</code> and
+   <code>th</code>.</p></dd>
+
+   <dt><dfn>Formatting</dfn></dt>
+   <dd><p>The following HTML elements are those that end up in the
+   <span>list of active formatting elements</span>: <code>a</code>,
+   <code>b</code>, <code>big</code>, <code>em</code>,
+   <code>font</code>, <code>i</code>, <code>nobr</code>,
+   <code>s</code>, <code>small</code>, <code>strike</code>,
+   <code>strong</code>, <code>tt</code>, and <code>u</code>.</p></dd>
+
+   <dt><dfn>Phrasing</dfn></dt>
+   <dd><p>All other elements found while parsing an HTML
+   document.</p></dd>
+
+  </dl>
+
+  <p class="big-issue">Still need to add these new elements to the
+  lists: <code>event-source</code>, <code>section</code>,
+  <code>nav</code>, <code>article</code>, <code>aside</code>,
+  <code>header</code>, <code>footer</code>, <code>datagrid</code>,
+  <code>command</code></p>
+
+  <p>The <span>stack of open elements</span> is said to <dfn
+  title="has an element in scope">have an element in scope</dfn> or
+  <dfn title="has an element in table scope">have an element in
+  <em>table scope</em></dfn> when the following algorithm terminates
+  in a match state:</p>
+
+  <ol>
+
+   <li><p>Initialise <var title="">node</var> to be the <span>current
+   node</span> (the bottommost node of the stack).</p></li>
+
+   <li><p>If <var title="">node</var> is the target node, terminate in a match
+   state.</p></li>
+
+   <li><p>Otherwise, if <var title="">node</var> is a <code>table</code>
+   element, terminate in a failure state.</p></li>
+
+   <li><p>Otherwise, if the algorithm is the "has an element in scope"
+   variant (rather than the "has an element in table scope" variant),
+   and <var title="">node</var> is one of the following, terminate in a failure
+   state:</p>
+    <ul class="brief">
+     <li><code>applet</code></li>
+     <li><code>caption</code></li>
+     <li><code>td</code></li>
+     <li><code>th</code></li>
+     <li><code>button</code></li>
+     <li><code>marquee</code></li>
+     <li><code>object</code></li>
+    </ul>
+   </li>
+
+   <li><p>Otherwise, if <var title="">node</var> is an <code>html</code>
+   element, terminate in a failure state. (This can only happen if the
+   <var title="">node</var> is the topmost node of the <span>stack of open
+   elements</span>, and prevents the next step from being invoked if
+   there are no more elements in the stack.)</p></li>
+
+   <li><p>Otherwise, set <var title="">node</var> to the previous entry in the
+   <span>stack of open elements</span> and return to step 2. (This
+   will never fail, since the loop will always terminate in the
+   previous step if the top of the stack is reached.)</p></li>
+
+  </ol>
+
+  <p>Nothing happens if at any time any of the elements in the
+  <span>stack of open elements</span> are moved to a new location in,
+  or removed from, the <code>Document</code> tree. In particular, the
+  stack is not changed in this situation. This can cause, amongst
+  other strange effects, content to be appended to nodes that are no
+  longer in the DOM.</p>
+
+  <p class="note">In some cases (namely, when <a
+  href="#adoptionAgency">closing misnested formatting elements</a>),
+  the stack is manipulated in a random-access fashion.</p>
+
+
+  <h5>The list of active formatting elements</h5>
+
+  <p>Initially the <dfn>list of active formatting elements</dfn> is
+  empty. It is used to handle mis-nested <span
+  title="formatting">formatting element tags</span>.</p>
+
+  <p>The list contains elements in the <span>formatting</span>
+  category, and scope markers. The scope markers are inserted when
+  entering <code>applet</code> elements, buttons, <code>object</code>
+  elements, marquees, table cells, and table captions, and are used to
+  prevent formatting from "leaking" into <code>applet</code> elements,
+  buttons, <code>object</code> elements, marquees, and tables.</p>
+
+  <p>When the steps below require the UA to <dfn>reconstruct the
+  active formatting elements</dfn>, the UA must perform the following
+  steps:</p>
+
+  <ol>
+
+   <li>If there are no entries in the <span>list of active formatting
+   elements</span>, then there is nothing to reconstruct; stop this
+   algorithm.</li>
+
+   <li>If the last (most recently added) entry in the <span>list of
+   active formatting elements</span> is a marker, or if it is an
+   element that is in the <span>stack of open elements</span>, then
+   there is nothing to reconstruct; stop this algorithm.</li>
+
+   <li>Let <var title="">entry</var> be the last (most recently added)
+   element in the <span>list of active formatting
+   elements</span>.</li>
+
+   <li>If there are no entries before <var title="">entry</var> in the
+   <span>list of active formatting elements</span>, then jump to step
+   8.</li>
+
+   <li>Let <var title="">entry</var> be the entry one earlier than
+   <var title="">entry</var> in the <span>list of active formatting
+   elements</span>.</li>
+
+   <li>If <var title="">entry</var> is neither a marker nor an element
+   that is also in the <span>stack of open elements</span>, go to step
+   4.</li>
+
+   <li>Let <var title="">entry</var> be the element one later than
+   <var title="">entry</var> in the <span>list of active formatting
+   elements</span>.</li>
+
+   <li>Perform a shallow clone of the element <var title="">entry</var> to
+   obtain <var title="">clone</var>. <a
+   href="#refsDOM3CORE">[DOM3CORE]</a></li>
+
+   <li>Append <var title="">clone</var> to the <span>current
+   node</span> and push it onto the <span>stack of open
+   elements</span> so that it is the new <span>current
+   node</span>.</li>
+
+   <li>Replace the entry for <var title="">entry</var> in the list
+   with an entry for <var title="">clone</var>.</li>
+
+   <li>If the entry for <var title="">clone</var> in the <span>list of
+   active formatting elements</span> is not the last entry in the
+   list, return to step 7.</li>
+
+  </ol>
+
+  <p>This has the effect of reopening all the formatting elements that
+  were opened in the current body, cell, or caption (whichever is
+  youngest) that haven't been explicitly closed.</p>
+
+  <p class="note">The way this specification is written, the
+  <span>list of active formatting elements</span> always consists of
+  elements in chronological order with the least recently added
+  element first and the most recently added element last (except for
+  while steps 8 to 11 of the above algorithm are being executed, of
+  course).</p>
+
+  <p>When the steps below require the UA to <dfn>clear the list of
+  active formatting elements up to the last marker</dfn>, the UA must
+  perform the following steps:</p>
+
+  <ol>
+
+   <li>Let <var title="">entry</var> be the last (most recently added)
+   entry in the <span>list of active formatting elements</span>.</li>
+
+   <li>Remove <var title="">entry</var> from the <span>list of active
+   formatting elements</span>.</li>
+
+   <li>If <var title="">entry</var> was a marker, then stop the
+   algorithm at this point. The list has been cleared up to the last
+   marker.</li>
+
+   <li>Go to step 1.</li>
+
+  </ol>
+
+
+  <h5>The element pointers</h5>
+
+  <p>Initially the <dfn><code title="">head</code> element
+  pointer</dfn> and the <dfn><code title="">form</code> element
+  pointer</dfn> are both null.</p>
+
+  <p>Once a <code>head</code> element has been parsed (whether
+  implicitly or explicitly) the <span><code title="">head</code>
+  element pointer</span> gets set to point to this node.</p>
+
+  <p>The <span><code title="">form</code> element pointer</span>
+  points to the last <code>form</code> element that was opened and
+  whose end tag has not yet been seen. It is used to make form
+  controls associate with forms in the face of dramatically bad
+  markup, for historical reasons.</p>
+
+
+
   <h4><dfn>Tokenisation</dfn></h4>
 
   <p>Implementations must act as if they used the following state
@@ -38570,6 +38985,10 @@
   has to render the <code>Document</code> so that it is available to
   the user, or when it has to begin accepting user input.</p>
 
+  <p>As each token is emitted from the tokeniser, the user agent must
+  process the token according to the rules given in the section
+  corresponding to the current <span>insertion mode</span>.</p>
+
   <p>When the steps below require the UA to <dfn>insert a
   character</dfn> into a node, if that node has a child immediately
   before where the character is to be inserted, and that child is a
@@ -38600,302 +39019,7 @@
   concerns</a> will likely force user agents to impose nesting
   depths.</p>
 
-  <p>As each token is emitted from the tokeniser, the user agent must
-  process the token according to the rules given in the section
-  corresponding to the current <dfn>insertion mode</dfn>.</p>
 
-  <p>Initially the <span>insertion mode</span> is "<span
-  title="insertion mode: initial">initial</span>". It can change to
-  "<span title="insertion mode: before html">before html</span>",
-  "<span title="insertion mode: before head">before head</span>",
-  "<span title="insertion mode: in head">in head</span>", "<span
-  title="insertion mode: in head noscript">in head noscript</span>",
-  "<span title="insertion mode: after head">after head</span>", "<span
-  title="insertion mode: in body">in body</span>", "<span
-  title="insertion mode: in table">in table</span>", "<span
-  title="insertion mode: in caption">in caption</span>", "<span
-  title="insertion mode: in column group">in column group</span>",
-  "<span title="insertion mode: in table body">in table body</span>",
-  "<span title="insertion mode: in row">in row</span>", "<span
-  title="insertion mode: in cell">in cell</span>", "<span
-  title="insertion mode: in select">in select</span>", "<span
-  title="insertion mode: in select in table">in select in
-  table</span>", "<span title="insertion mode: after body">after
-  body</span>", "<span title="insertion mode: in frameset">in
-  frameset</span>", "<span title="insertion mode: after
-  frameset">after frameset</span>", "<span title="insertion mode:
-  after after body">after after body</span>", and "<span
-  title="insertion mode: after after frameset">after after
-  frameset</span>" during the course of the parsing, as described
-  below. It affects how certain tokens are processed.</p>
-
-  <p>Four of these modes, namely "<span title="insertion mode: in
-  head">in head</span>", "<span title="insertion mode: in body">in
-  body</span>", "<span title="insertion mode: in table">in
-  table</span>", and "<span title="insertion mode: in select">in
-  select</span>", are special, in that the other modes defer to them
-  at various times. When the algorithm below says that the user agent
-  is to do something "<dfn>using the rules for</dfn> the <var
-  title="">m</var> insertion mode", where <var title="">m</var> is one
-  of these modes, the user agent must use the rules described under
-  that <span>insertion mode</span>'s section, but must leave the
-  <span>insertion mode</span> unchanged (unless the rules in that
-  section themselves switch the <span>insertion mode</span>).</p>
-
-  <p>In addition to the <span>insertion mode</span>, the tree
-  construction stage has several pieces of state: a <span>stack of
-  open elements</span>, a <span>list of active formatting
-  elements</span>, a <span><code title="">head</code> element
-  pointer</span>, and a <span><code title="">form</code> element
-  pointer</span>.</p>
-
-
-  <h5>The stack of open elements</h5>
-
-  <p>Initially the <dfn>stack of open elements</dfn> is empty. The
-  stack grows downwards; the topmost node on the stack is the first
-  one added to the stack, and the bottommost node of the stack is the
-  most recently added node in the stack (notwithstanding when the
-  stack is manipulated in a random access fashion as part of <a
-  href="#adoptionAgency">the handling for misnested tags</a>).</p>
-
-  <p>The "<span title="insertion mode: before html">before
-  html</span>" <span>insertion mode</span> creates the
-  <code>html</code> root element node, which is then added to the
-  stack.</p>
-
-  <p>In the <span>fragment case</span>, the <span>stack of open
-  elements</span> is initialised to contain an <code>html</code>
-  element that is created as part of <span title="html fragment
-  parsing algorithm">that algorithm</span>. (The <span>fragment
-  case</span> skips the "<span title="insertion mode: before
-  html">before html</span>" <span>insertion mode</span>.)</p>
-
-  <p>The <code>html</code> node, however it is created, is the topmost
-  node of the stack. It never gets popped off the stack.</p>
-
-  <p>The <dfn>current node</dfn> is the bottommost node in this
-  stack.</p>
-
-  <p>The <dfn>current table</dfn> is the last <code>table</code>
-  element in the <span>stack of open elements</span>, if there is
-  one. If there is no <code>table</code> element in the <span>stack of
-  open elements</span> (<span>fragment case</span>), then the
-  <span>current table</span> is the first element in the <span>stack
-  of open elements</span> (the <code>html</code> element).</p>
-
-  <p>Elements in the stack fall into the following categories:</p>
-
-  <dl>
-
-   <dt><dfn>Special</dfn></dt>
-   <dd><p>The following HTML elements have varying levels of special
-   parsing rules: <code>address</code>, <code>area</code>,
-   <code>base</code>, <code>basefont</code>, <code>bgsound</code>,
-   <code>blockquote</code>, <code>body</code>, <code>br</code>,
-   <code>center</code>, <code>col</code>, <code>colgroup</code>,
-   <code>dd</code>, <code>dir</code>, <code>div</code>,
-   <code>dl</code>, <code>dt</code>, <code>embed</code>,
-   <code>fieldset</code>, <code>form</code>, <code>frame</code>,
-   <code>frameset</code>, <code>h1</code>, <code>h2</code>,
-   <code>h3</code>, <code>h4</code>, <code>h5</code>, <code>h6</code>,
-   <code>head</code>, <code>hr</code>, <code>iframe</code>,
-   <code>image</code><!-- XXX ? this isn't an element that can end up
-   on the stack-->, <code>img</code>, <code>input</code>,
-   <code>isindex</code>, <code>li</code>, <code>link</code>,
-   <code>listing</code>, <code>menu</code>, <code>meta</code>,
-   <code>noembed</code>, <code>noframes</code>, <code>noscript</code>,
-   <code>ol</code>, <code>optgroup</code>, <code>option</code>,
-   <code>p</code>, <code>param</code>, <code>plaintext</code>,
-   <code>pre</code>, <code>script</code>, <code>select</code>,
-   <code>spacer</code>, <code>style</code>, <code>tbody</code>,
-   <code>textarea</code>, <code>tfoot</code>, <code>thead</code>,
-   <code>title</code>, <code>tr</code>, <code>ul</code>, and
-   <code>wbr</code>.</p></dd>
-
-   <dt><dfn>Scoping</dfn></dt>
-   <dd><p>The following HTML elements introduce new <span title="has
-   an element in scope">scopes</span> for various parts of the
-   parsing: <code>applet</code>, <code>button</code>,
-   <code>caption</code>, <code>html</code>, <code>marquee</code>,
-   <code>object</code>, <code>table</code>, <code>td</code> and
-   <code>th</code>.</p></dd>
-
-   <dt><dfn>Formatting</dfn></dt>
-   <dd><p>The following HTML elements are those that end up in the
-   <span>list of active formatting elements</span>: <code>a</code>,
-   <code>b</code>, <code>big</code>, <code>em</code>,
-   <code>font</code>, <code>i</code>, <code>nobr</code>,
-   <code>s</code>, <code>small</code>, <code>strike</code>,
-   <code>strong</code>, <code>tt</code>, and <code>u</code>.</p></dd>
-
-   <dt><dfn>Phrasing</dfn></dt>
-   <dd><p>All other elements found while parsing an HTML
-   document.</p></dd>
-
-  </dl>
-
-  <p class="big-issue">Still need to add these new elements to the
-  lists: <code>event-source</code>, <code>section</code>,
-  <code>nav</code>, <code>article</code>, <code>aside</code>,
-  <code>header</code>, <code>footer</code>, <code>datagrid</code>,
-  <code>command</code></p>
-
-  <p>The <span>stack of open elements</span> is said to <dfn
-  title="has an element in scope">have an element in scope</dfn> or
-  <dfn title="has an element in table scope">have an element in
-  <em>table scope</em></dfn> when the following algorithm terminates
-  in a match state:</p>
-
-  <ol>
-
-   <li><p>Initialise <var title="">node</var> to be the <span>current
-   node</span> (the bottommost node of the stack).</p></li>
-
-   <li><p>If <var title="">node</var> is the target node, terminate in a match
-   state.</p></li>
-
-   <li><p>Otherwise, if <var title="">node</var> is a <code>table</code>
-   element, terminate in a failure state.</p></li>
-
-   <li><p>Otherwise, if the algorithm is the "has an element in scope"
-   variant (rather than the "has an element in table scope" variant),
-   and <var title="">node</var> is one of the following, terminate in a failure
-   state:</p>
-    <ul class="brief">
-     <li><code>applet</code></li>
-     <li><code>caption</code></li>
-     <li><code>td</code></li>
-     <li><code>th</code></li>
-     <li><code>button</code></li>
-     <li><code>marquee</code></li>
-     <li><code>object</code></li>
-    </ul>
-   </li>
-
-   <li><p>Otherwise, if <var title="">node</var> is an <code>html</code>
-   element, terminate in a failure state. (This can only happen if the
-   <var title="">node</var> is the topmost node of the <span>stack of open
-   elements</span>, and prevents the next step from being invoked if
-   there are no more elements in the stack.)</p></li>
-
-   <li><p>Otherwise, set <var title="">node</var> to the previous entry in the
-   <span>stack of open elements</span> and return to step 2. (This
-   will never fail, since the loop will always terminate in the
-   previous step if the top of the stack is reached.)</p></li>
-
-  </ol>
-
-  <p>Nothing happens if at any time any of the elements in the
-  <span>stack of open elements</span> are moved to a new location in,
-  or removed from, the <code>Document</code> tree. In particular, the
-  stack is not changed in this situation. This can cause, amongst
-  other strange effects, content to be appended to nodes that are no
-  longer in the DOM.</p>
-
-  <p class="note">In some cases (namely, when <a
-  href="#adoptionAgency">closing misnested formatting elements</a>),
-  the stack is manipulated in a random-access fashion.</p>
-
-
-  <h5>The list of active formatting elements</h5>
-
-  <p>Initially the <dfn>list of active formatting elements</dfn> is
-  empty. It is used to handle mis-nested <span
-  title="formatting">formatting element tags</span>.</p>
-
-  <p>The list contains elements in the <span>formatting</span>
-  category, and scope markers. The scope markers are inserted when
-  entering <code>applet</code> elements, buttons, <code>object</code>
-  elements, marquees, table cells, and table captions, and are used to
-  prevent formatting from "leaking" into <code>applet</code> elements,
-  buttons, <code>object</code> elements, marquees, and tables.</p>
-
-  <p>When the steps below require the UA to <dfn>reconstruct the
-  active formatting elements</dfn>, the UA must perform the following
-  steps:</p>
-
-  <ol>
-
-   <li>If there are no entries in the <span>list of active formatting
-   elements</span>, then there is nothing to reconstruct; stop this
-   algorithm.</li>
-
-   <li>If the last (most recently added) entry in the <span>list of
-   active formatting elements</span> is a marker, or if it is an
-   element that is in the <span>stack of open elements</span>, then
-   there is nothing to reconstruct; stop this algorithm.</li>
-
-   <li>Let <var title="">entry</var> be the last (most recently added)
-   element in the <span>list of active formatting
-   elements</span>.</li>
-
-   <li>If there are no entries before <var title="">entry</var> in the
-   <span>list of active formatting elements</span>, then jump to step
-   8.</li>
-
-   <li>Let <var title="">entry</var> be the entry one earlier than
-   <var title="">entry</var> in the <span>list of active formatting
-   elements</span>.</li>
-
-   <li>If <var title="">entry</var> is neither a marker nor an element
-   that is also in the <span>stack of open elements</span>, go to step
-   4.</li>
-
-   <li>Let <var title="">entry</var> be the element one later than
-   <var title="">entry</var> in the <span>list of active formatting
-   elements</span>.</li>
-
-   <li>Perform a shallow clone of the element <var title="">entry</var> to
-   obtain <var title="">clone</var>. <a
-   href="#refsDOM3CORE">[DOM3CORE]</a></li>
-
-   <li>Append <var title="">clone</var> to the <span>current
-   node</span> and push it onto the <span>stack of open
-   elements</span> so that it is the new <span>current
-   node</span>.</li>
-
-   <li>Replace the entry for <var title="">entry</var> in the list
-   with an entry for <var title="">clone</var>.</li>
-
-   <li>If the entry for <var title="">clone</var> in the <span>list of
-   active formatting elements</span> is not the last entry in the
-   list, return to step 7.</li>
-
-  </ol>
-
-  <p>This has the effect of reopening all the formatting elements that
-  were opened in the current body, cell, or caption (whichever is
-  youngest) that haven't been explicitly closed.</p>
-
-  <p class="note">The way this specification is written, the
-  <span>list of active formatting elements</span> always consists of
-  elements in chronological order with the least recently added
-  element first and the most recently added element last (except for
-  while steps 8 to 11 of the above algorithm are being executed, of
-  course).</p>
-
-  <p>When the steps below require the UA to <dfn>clear the list of
-  active formatting elements up to the last marker</dfn>, the UA must
-  perform the following steps:</p>
-
-  <ol>
-
-   <li>Let <var title="">entry</var> be the last (most recently added)
-   entry in the <span>list of active formatting elements</span>.</li>
-
-   <li>Remove <var title="">entry</var> from the <span>list of active
-   formatting elements</span>.</li>
-
-   <li>If <var title="">entry</var> was a marker, then stop the
-   algorithm at this point. The list has been cleared up to the last
-   marker.</li>
-
-   <li>Go to step 1.</li>
-
-  </ol>
-
-
   <h5>Creating and inserting HTML elements</h5>
 
   <p>When the steps below require the UA to <dfn title="create an
@@ -38977,173 +39101,6 @@
   above steps as if that element was not in the above list.</p>
 
 
-  <h5>The element pointers</h5>
-
-  <p>Initially the <dfn><code title="">head</code> element
-  pointer</dfn> and the <dfn><code title="">form</code> element
-  pointer</dfn> are both null.</p>
-
-  <p>Once a <code>head</code> element has been parsed (whether
-  implicitly or explicitly) the <span><code title="">head</code>
-  element pointer</span> gets set to point to this node.</p>
-
-  <p>The <span><code title="">form</code> element pointer</span>
-  points to the last <code>form</code> element that was opened and
-  whose end tag has not yet been seen. It is used to make form
-  controls associate with forms in the face of dramatically bad
-  markup, for historical reasons.</p>
-
-
-  <h5>Resetting the insertion mode</h5>
-
-  <p>When the steps below require the UA to <dfn>reset the insertion
-  mode appropriately</dfn>, it means the UA must follow these
-  steps:</p>
-
-  <ol>
-
-   <li>Let <var title="">last</var> be false.</li>
-
-   <li>Let <var title="">node</var> be the last node in the
-   <span>stack of open elements</span>.</li>
-
-   <li>If <var title="">node</var> is the first node in the stack of
-   open elements, then set <var title="">last</var> to true; if, in
-   addition, the <var title="">context</var> element of the <span>HTML
-   fragment parsing algorithm</span> is neither a <code>td</code>
-   element nor a <code>th</code> element, then set <var
-   title="">node</var> to the <var title="">context</var>
-   element. (<span>fragment case</span>)</li>
-
-   <li>If <var title="">node</var> is a <code>select</code> element,
-   then switch the <span>insertion mode</span> to "<span
-   title="insertion mode: in select">in select</span>" and abort these
-   steps. (<span>fragment case</span>)</li>
-
-   <li>If <var title="">node</var> is a <code>td</code> or
-   <code>th</code> element, then switch the <span>insertion
-   mode</span> to "<span title="insertion mode: in cell">in
-   cell</span>" and abort these steps.</li>
-
-   <li>If <var title="">node</var> is a <code>tr</code> element, then
-   switch the <span>insertion mode</span> to "<span title="insertion
-   mode: in row">in row</span>" and abort these steps.</li>
-
-   <li>If <var title="">node</var> is a <code>tbody</code>,
-   <code>thead</code>, or <code>tfoot</code> element, then switch the
-   <span>insertion mode</span> to "<span title="insertion mode: in
-   table body">in table body</span>" and abort these steps.</li>
-
-   <li>If <var title="">node</var> is a <code>caption</code> element,
-   then switch the <span>insertion mode</span> to "<span
-   title="insertion mode: in caption">in caption</span>" and abort
-   these steps.</li>
-
-   <li>If <var title="">node</var> is a <code>colgroup</code> element,
-   then switch the <span>insertion mode</span> to "<span
-   title="insertion mode: in column group">in column group</span>" and
-   abort these steps. (<span>fragment case</span>)</li>
-
-   <li>If <var title="">node</var> is a <code>table</code> element,
-   then switch the <span>insertion mode</span> to "<span
-   title="insertion mode: in table">in table</span>" and abort these
-   steps.</li>
-
-   <li>If <var title="">node</var> is a <code>head</code> element,
-   then switch the <span>insertion mode</span> to "<span
-   title="insertion mode: in body">in body</span>" ("<span
-   title="insertion mode: in body">in body</span>"! <em> not "<span
-   title="insertion mode: in head">in head</span>"</em>!) and abort
-   these steps. (<span>fragment case</span>)</li> <!-- This is only
-   here for now in case people think that the spec accidentally
-   omitted it and try to "fix" it. Note that noscript-in-head is also
-   handled this way. This is all intentional. The only thing it
-   doesn't handle is the scripting-enabled fragment parsing case for a
-   <head> element containing a <noscript> which itself contains
-   something other than a <link> or a <style> element; you'd expect
-   that to break out of the <noscript> but it doesn't. This is an edge
-   case that doesn't affect the spec, since the algorithm for fragment
-   parsing is only used for innerHTML, where we know scripting is
-   enabled. -->
-
-   <li>If <var title="">node</var> is a <code>body</code> element,
-   then switch the <span>insertion mode</span> to "<span
-   title="insertion mode: in body">in body</span>" and abort these
-   steps.</li>
-
-   <li>If <var title="">node</var> is a <code>frameset</code> element,
-   then switch the <span>insertion mode</span> to "<span
-   title="insertion mode: in frameset">in frameset</span>" and abort
-   these steps. (<span>fragment case</span>)</li>
-
-   <li>If <var title="">node</var> is an <code>html</code> element,
-   then: if the <span><code title="">head</code> element
-   pointer</span> is null, switch the <span>insertion mode</span> to
-   "<span title="insertion mode: before head">before head</span>",
-   otherwise, switch the <span>insertion mode</span> to "<span
-   title="insertion mode: after head">after head</span>". In either
-   case, abort these steps. (<span>fragment case</span>)</li> <!-- XXX
-   can the head element pointer ever be non-null when we're going
-   through these steps? -->
-
-   <li>If <var title="">last</var> is true, then switch the
-   <span>insertion mode</span> to "<span title="insertion mode: in
-   body">in body</span>" and abort these steps. (<span>fragment
-   case</span>)</li>
-
-   <li>Let <var title="">node</var> now be the node before <var
-   title="">node</var> in the <span>stack of open
-   elements</span>.</li>
-
-   <li>Return to step 3.</li>
-
-  </ol>
-
-<!--When you don't have to handle the fragment case, you can use this
-simplified explanation instead:
-
-  <ol>
-
-   <li><p>If the <span>stack of open elements</span> <span title="has
-   an element in table scope">has a <code>td</code> or <code>th</code>
-   element in table scope</span>, then switch the <span>insertion
-   mode</span> to "<span title="insertion mode: in cell">in
-   cell</span>".</p></li>
-
-   <li><p>Otherwise, if the <span>stack of open elements</span> <span
-   title="has an element in table scope">has a <code>tr</code> element
-   in table scope</span>, then switch the <span>insertion mode</span>
-   to "<span title="insertion mode: in row">in row</span>".</p></li>
-
-   <li><p>Otherwise, if the <span>stack of open elements</span> <span
-   title="has an element in table scope">has a <code>tbody</code>,
-   <code>tfoot</code>, or <code>thead</code> element in table
-   scope</span>, then switch the <span>insertion mode</span> to "<span
-   title="insertion mode: in table body">in table
-   body</span>".</p></li>
-
-   <li><p>Otherwise, if the <span>stack of open elements</span> <span
-   title="has an element in table scope">has a <code>caption</code>
-   element in table scope</span>, then switch the <span>insertion
-   mode</span> to "<span title="insertion mode: in caption">in
-   caption</span>".</p></li>
-
-   ( you can't reach this point with a colgroup element on the
-   stack )
-
-   <li><p>Otherwise, if the <span>stack of open elements</span> <span
-   title="has an element in table scope">has a <code>table</code>
-   element in table scope</span>, then switch the <span>insertion
-   mode</span> to "<span title="insertion mode: in table">in
-   table</span>".</p></li>
-
-   <li><p>Otherwise, switch the <span>insertion mode</span> to "<span
-   title="insertion mode: in body">in body</span>".</p></li>
-
-  </ol>
--->
-
-
   <h5>The "<dfn title="insertion mode: initial">initial</dfn>" insertion mode</h5>
 
   <p>When the <span>insertion mode</span> is "<span title="insertion




More information about the Commit-Watchers mailing list