[html5] r8000 - / images

whatwg at whatwg.org whatwg at whatwg.org
Fri Jun 28 15:44:18 PDT 2013


Author: ianh
Date: 2013-06-28 15:44:17 -0700 (Fri, 28 Jun 2013)
New Revision: 8000

Modified:
   complete.html
   images/content-venn.svg
   index
   source
Log:
[cgiow] (1) Integrate <template> into HTML.
Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=17930
Affected topics: DOM APIs, HTML, HTML Syntax and Parsing, Rendering

Modified: complete.html
===================================================================
--- complete.html	2013-06-25 20:55:18 UTC (rev 7999)
+++ complete.html	2013-06-28 22:44:17 UTC (rev 8000)
@@ -256,7 +256,7 @@
 
   <header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
    <hgroup><h1 class=allcaps>HTML</h1>
-    <h2 class="no-num no-toc">Living Standard — Last Updated 25 June 2013</h2>
+    <h2 class="no-num no-toc">Living Standard — Last Updated 28 June 2013</h2>
    </hgroup><dl><dt><strong>Web developer edition:</strong></dt>
     <dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
     <dt>Multiple-page version:</dt>
@@ -471,7 +471,10 @@
        <li><a href=#restrictions-for-contents-of-script-elements><span class=secno>4.3.1.2 </span>Restrictions for contents of <code>script</code> elements</a></li>
        <li><a href=#inline-documentation-for-external-scripts><span class=secno>4.3.1.3 </span>Inline documentation for external scripts</a></li>
        <li><a href=#scriptTagXSLT><span class=secno>4.3.1.4 </span>Interaction of <code>script</code> elements and XSLT</a></ol></li>
-     <li><a href=#the-noscript-element><span class=secno>4.3.2 </span>The <code>noscript</code> element</a></ol></li>
+     <li><a href=#the-noscript-element><span class=secno>4.3.2 </span>The <code>noscript</code> element</a></li>
+     <li><a href=#the-template-element><span class=secno>4.3.3 </span>The <code>template</code> element</a>
+      <ol>
+       <li><a href=#template-XSLT-XPath><span class=secno>4.3.3.1 </span>Interaction of <code>template</code> elements with XSLT and XPath</a></ol></ol></li>
    <li><a href=#sections><span class=secno>4.4 </span>Sections</a>
     <ol>
      <li><a href=#the-body-element><span class=secno>4.4.1 </span>The <code>body</code> element</a></li>
@@ -1281,11 +1284,12 @@
          <li><a href=#parsing-main-intd><span class=secno>12.2.5.4.15 </span>The "in cell" insertion mode</a></li>
          <li><a href=#parsing-main-inselect><span class=secno>12.2.5.4.16 </span>The "in select" insertion mode</a></li>
          <li><a href=#parsing-main-inselectintable><span class=secno>12.2.5.4.17 </span>The "in select in table" insertion mode</a></li>
-         <li><a href=#parsing-main-afterbody><span class=secno>12.2.5.4.18 </span>The "after body" insertion mode</a></li>
-         <li><a href=#parsing-main-inframeset><span class=secno>12.2.5.4.19 </span>The "in frameset" insertion mode</a></li>
-         <li><a href=#parsing-main-afterframeset><span class=secno>12.2.5.4.20 </span>The "after frameset" insertion mode</a></li>
-         <li><a href=#the-after-after-body-insertion-mode><span class=secno>12.2.5.4.21 </span>The "after after body" insertion mode</a></li>
-         <li><a href=#the-after-after-frameset-insertion-mode><span class=secno>12.2.5.4.22 </span>The "after after frameset" insertion mode</a></ol></li>
+         <li><a href=#parsing-main-intemplate><span class=secno>12.2.5.4.18 </span>The "in template" insertion mode</a></li>
+         <li><a href=#parsing-main-afterbody><span class=secno>12.2.5.4.19 </span>The "after body" insertion mode</a></li>
+         <li><a href=#parsing-main-inframeset><span class=secno>12.2.5.4.20 </span>The "in frameset" insertion mode</a></li>
+         <li><a href=#parsing-main-afterframeset><span class=secno>12.2.5.4.21 </span>The "after frameset" insertion mode</a></li>
+         <li><a href=#the-after-after-body-insertion-mode><span class=secno>12.2.5.4.22 </span>The "after after body" insertion mode</a></li>
+         <li><a href=#the-after-after-frameset-insertion-mode><span class=secno>12.2.5.4.23 </span>The "after after frameset" insertion mode</a></ol></li>
        <li><a href=#parsing-main-inforeign><span class=secno>12.2.5.5 </span>The rules for parsing tokens in foreign content</a></ol></li>
      <li><a href=#the-end><span class=secno>12.2.6 </span>The end</a></li>
      <li><a href=#coercing-an-html-dom-into-an-infoset><span class=secno>12.2.7 </span>Coercing an HTML DOM into an infoset</a></li>
@@ -10309,8 +10313,11 @@
   <h4 id=content-models><span class=secno>3.2.5 </span><dfn>Content models</dfn></h4>
 
   <p>Each element defined in this specification has a content model: a description of the element's
-  expected contents. An <a href=#html-elements title="HTML elements">HTML element</a> must have contents that
-  match the requirements described in the element's content model.</p>
+  expected <a href=#concept-html-contents title=concept-html-contents>contents</a>. An <a href=#html-elements title="HTML elements">HTML element</a> must have contents that
+  match the requirements described in the element's content model. The <dfn id=concept-html-contents title=concept-html-contents>contents</dfn> of an element are
+  its children in the DOM, except for <code><a href=#the-template-element>template</a></code> elements, where the children are those
+  in the <a href=#template-contents>template contents</a> (a separate <code><a href=#documentfragment>DocumentFragment</a></code> assigned to the
+  element when the element is created).</p>
 
   <p>The <a href=#space-character title="space character">space characters</a> are always allowed between elements.
   User agents represent these characters between elements in the source markup as <code><a href=#text>Text</a></code>
@@ -10403,6 +10410,7 @@
    <li><code><a href=#the-noscript-element>noscript</a></code></li>
    <li><code><a href=#the-script-element>script</a></code></li>
    <li><code><a href=#the-style-element>style</a></code></li>
+   <li><code><a href=#the-template-element>template</a></code></li>
    <li><code><a href=#the-title-element>title</a></code></li>
   </ul><p>Elements from other namespaces whose semantics are primarily metadata-related (e.g. RDF) are
   also <a href=#metadata-content>metadata content</a>.</p>
@@ -10520,6 +10528,7 @@
    <li><code><a href=#the-sub-and-sup-elements>sup</a></code></li>
    <li><code><a href=#svg>svg</a></code></li>
    <li><code><a href=#the-table-element>table</a></code></li>
+   <li><code><a href=#the-template-element>template</a></code></li>
    <li><code><a href=#the-textarea-element>textarea</a></code></li>
    <li><code><a href=#the-time-element>time</a></code></li>
    <li><code><a href=#the-u-element>u</a></code></li>
@@ -10614,6 +10623,7 @@
    <li><code><a href=#the-sub-and-sup-elements>sub</a></code></li>
    <li><code><a href=#the-sub-and-sup-elements>sup</a></code></li>
    <li><code><a href=#svg>svg</a></code></li>
+   <li><code><a href=#the-template-element>template</a></code></li>
    <li><code><a href=#the-textarea-element>textarea</a></code></li>
    <li><code><a href=#the-time-element>time</a></code></li>
    <li><code><a href=#the-u-element>u</a></code></li>
@@ -10621,13 +10631,7 @@
    <li><code><a href=#the-video-element>video</a></code></li>
    <li><code><a href=#the-wbr-element>wbr</a></code></li>
    <li><a href=#text-content title="text content">Text</a></li>
-  </ul><p>As a general rule, elements whose content model allows any <a href=#phrasing-content>phrasing content</a> should
-  have either at least one descendant <code><a href=#text>Text</a></code> node that is not <a href=#inter-element-whitespace>inter-element
-  whitespace</a>, or at least one descendant element node that is <a href=#embedded-content>embedded content</a>.
-  For the purposes of this requirement, nodes that are descendants of <code><a href=#the-del-element>del</a></code> elements must
-  not be counted as contributing to the ancestors of the <code><a href=#the-del-element>del</a></code> element.</p>
-
-  <p class=note>Most elements that are categorized as phrasing content can only contain elements
+  </ul><p class=note>Most elements that are categorized as phrasing content can only contain elements
   that are themselves categorized as phrasing content, not any flow content.</p>
 
   <p><dfn id=text-content title="text content">Text</dfn>, in the context of content models, means either nothing,
@@ -10813,7 +10817,7 @@
   <h6 id=palpable-content-0><span class=secno>3.2.5.1.8 </span>Palpable content</h6>
 
   <p>As a general rule, elements whose content model allows any <a href=#flow-content>flow content</a> or
-  <a href=#phrasing-content>phrasing content</a> should have at least one child node that is <dfn id=palpable-content>palpable
+  <a href=#phrasing-content>phrasing content</a> should have at least one node in its <a href=#concept-html-contents title=concept-html-contents>contents</a> that is <dfn id=palpable-content>palpable
   content</dfn> and that does not have the <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> attribute
   specified.</p>
 
@@ -10923,7 +10927,7 @@
      without first violating the earlier requirement)
   <p>Furthermore, when a content model includes a part that is "transparent", those parts must not
   contain content that would not be conformant if all transparent elements in the tree were
-  replaced, in their parent element, by the children in the "transparent" part of their content
+  replaced, in their parent element, by the <span title="concept-html-contents">contents</span> in the "transparent" part of their content
   model, retaining order.</p>
 
   <div class="example">
@@ -11028,7 +11032,7 @@
 
   <p>Let <var title="">view</var> be a view of the DOM that replaces all <code><a href=#the-a-element>a</a></code>,
   <code><a href=#the-ins-element>ins</a></code>, <code><a href=#the-del-element>del</a></code>, and <code><a href=#the-map-element>map</a></code> elements in the document with their
-  contents. Then, in <var title="">view</var>, for each run of sibling <a href=#phrasing-content>phrasing content</a>
+  <a href=#concept-html-contents title=concept-html-contents>contents</a>. Then, in <var title="">view</var>, for each run of sibling <a href=#phrasing-content>phrasing content</a>
   nodes uninterrupted by other types of content, in an element that accepts content other than
   <a href=#phrasing-content>phrasing content</a> as well as <a href=#phrasing-content>phrasing content</a>, let <var title="">first</var> be the first node of the run, and let <var title="">last</var> be the last
   node of the run. For each such run that consists of at least one node that is neither
@@ -11142,7 +11146,7 @@
 
   <h4 id=requirements-relating-to-bidirectional-algorithm-formatting-characters><span class=secno>3.2.6 </span>Requirements relating to bidirectional-algorithm formatting characters</h4>
 
-  <p><a href=#text-content>Text content</a> in <a href=#html-elements>HTML elements</a> with child <code><a href=#text>Text</a></code> nodes, and
+  <p><a href=#text-content>Text content</a> in <a href=#html-elements>HTML elements</a> with <code><a href=#text>Text</a></code> nodes in their <a href=#concept-html-contents title=concept-html-contents>contents</a>, and
   text in attributes of <a href=#html-elements>HTML elements</a> that allow free-form text, may contain characters
   in the ranges U+202A to U+202E and U+2066 to U+2069 (the bidirectional-algorithm formatting
   characters). However, the use of these characters is restricted so that any embedding or overrides
@@ -11441,6 +11445,9 @@
     <tr><td><code><a href=#the-summary-element>summary</a></code> element
      <td><a href=#concept-role-none title=concept-role-none>No role</a>
 
+    <tr><td><code><a href=#the-template-element>template</a></code> element
+     <td><a href=#concept-role-none title=concept-role-none>No role</a>, with the <code title=attr-aria-hidden>aria-hidden</code> state set to "true"
+
     <tr><td><code><a href=#the-textarea-element>textarea</a></code> element
      <td><code title=attr-aria-role-textbox>textbox</code> role, with the <code title=attr-aria-multiline>aria-multiline</code> property set to "true", and the <code title=attr-aria-readonly>aria-readonly</code> property set to "true" if the element has a <code title=attr-textarea-readonly><a href=#attr-textarea-readonly>readonly</a></code> attribute
 
@@ -11771,7 +11778,9 @@
   output, or are rendered inline, etc).</p>
 
   <p class=note>There are also additional non-normative comments regarding the interaction of XSLT
-  and HTML <a href=#scriptTagXSLT>in the <code>script</code> element section</a>.</p>
+  and HTML <a href=#scriptTagXSLT>in the <code>script</code> element section</a>, and of
+  XSLT, XPath, and HTML <a href=#template-XSLT-XPath>in the <code>template</code> element
+  section</a>.</p>
 
   </div>
 
@@ -15436,7 +15445,186 @@
   </div>
 
 
+  <h4 id=the-template-element><span class=secno>4.3.3 </span>The <dfn><code>template</code></dfn> element</h4>
 
+  <dl class=element><dt><a href=#element-dfn-categories title=element-dfn-categories>Categories</a>:</dt>
+   <dd><a href=#metadata-content>Metadata content</a>.</dd>
+   <dd><a href=#flow-content>Flow content</a>.</dd>
+   <dd><a href=#phrasing-content>Phrasing content</a>.</dd>
+   <dt><a href=#element-dfn-contexts title=element-dfn-contexts>Contexts in which this element can be used</a>:</dt>
+   <dd>Where <a href=#metadata-content>metadata content</a> is expected.</dd>
+   <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd>
+   <dd>As a child of an <code><a href=#the-hgroup-element>hgroup</a></code> element.</dd>
+   <dd>As a child of an <code><a href=#the-ol-element>ol</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-ul-element>ul</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-dl-element>dl</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-table-element>table</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-colgroup-element>colgroup</a></code> element that doesn't have a <code title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code> attribute.</dd>
+   <dd>As a child of a <code><a href=#the-thead-element>thead</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-tbody-element>tbody</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-tfoot-element>tfoot</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-tr-element>tr</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-select-element>select</a></code> element.</dd>
+   <dd>As a child of an <code><a href=#the-optgroup-element>optgroup</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-menu-element>menu</a></code> element.</dd>
+   <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
+   <dd>Either: <a href=#metadata-content>Metadata content</a>.</dd>
+   <dd>Or: <a href=#flow-content>Flow content</a>.</dd>
+   <dd>Or: The content model of <code><a href=#the-ol-element>ol</a></code> and <code><a href=#the-ul-element>ul</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-dl-element>dl</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-figure-element>figure</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-ruby-element>ruby</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-object-element>object</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-video-element>video</a></code> and <code><a href=#the-audio-element>audio</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-table-element>table</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-colgroup-element>colgroup</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, and <code><a href=#the-tfoot-element>tfoot</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-tr-element>tr</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-fieldset-element>fieldset</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-select-element>select</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-details-element>details</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-menu-element>menu</a></code> elements whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#popup-menu-state>popup menu state</a>.</dd>
+   <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
+   <dd>Neither tag is omissible.</dd>
+   <dt><a href=#element-dfn-attributes title=element-dfn-attributes>Content attributes</a>:</dt>
+   <dd><a href=#global-attributes>Global attributes</a></dd>
+   <dt><a href=#element-dfn-dom title=element-dfn-dom>DOM interface</a>:</dt><!--TOPIC:DOM APIs-->
+   <dd>
+<pre class=idl>interface <dfn id=htmltemplateelement>HTMLTemplateElement</dfn> : <a href=#htmlelement>HTMLElement</a> {
+  readonly attribute <a href=#documentfragment>DocumentFragment</a> <a href=#dom-template-content title=dom-template-content>content</a>;
+};</pre>
+</dd>
+  </dl><!--TOPIC:HTML--><p>The <code><a href=#the-template-element>template</a></code> element is used to declare fragments of HTML that can be cloned and
+  inserted in the document by script.</p>
+
+  <p>In a rendering, the <code><a href=#the-template-element>template</a></code> element <a href=#represents>represents</a> nothing.</p>
+
+  <dl class=domintro><dt><var title="">template</var> . <code title=dom-template-content><a href=#dom-template-content>content</a></code></dt>
+
+   <dd>
+
+    <p>Returns the contents of the <code><a href=#the-template-element>template</a></code>, which are stored in a
+    <code><a href=#documentfragment>DocumentFragment</a></code> associated with a different <code><a href=#document>Document</a></code> so as to avoid
+    the <code><a href=#the-template-element>template</a></code> contents interfering with the main <code><a href=#document>Document</a></code>. (For
+    example, this avoids form controls from being submitted, scripts from executing, and so
+    forth.)</p>
+
+   </dd>
+
+  </dl><div class=impl>
+
+  <p>Each <code><a href=#the-template-element>template</a></code> element has an associated <code><a href=#documentfragment>DocumentFragment</a></code> object that
+  is its <dfn id=template-contents>template contents</dfn>. When a <code><a href=#the-template-element>template</a></code> element is created, the user
+  agent must run the following steps to establish the <a href=#template-contents>template contents</a>:</p>
+
+  <ol><li><p>Let <var title="">doc</var> be the <code><a href=#the-template-element>template</a></code> element's <code title=dom-node-ownerdocument><a href=#dom-node-ownerdocument>ownerDocument</a></code>.</li>
+
+   <li>
+
+    <p>If <var title="">doc</var> has an associated <a href=#browsing-context>browsing context</a>, run these substeps:</p>
+
+    <ol><li><p>Let <var title="">new doc</var> be a new <code><a href=#document>Document</a></code> (that does not have a
+     <a href=#browsing-context>browsing context</a>).</li>
+
+     <li><p>If <var title="">doc</var> is an <a href=#html-documents title="HTML documents">HTML document</a>, mark
+     <var title="">new doc</var> as an <a href=#html-documents title="HTML documents">HTML document</a>
+     also.</li>
+
+     <li><p>Set <var title="">doc</var> to <var title="">new doc</var>.</li>
+
+    </ol></li>
+
+   <li><p>Create a <code><a href=#documentfragment>DocumentFragment</a></code> object whose <code title=dom-node-ownerdocument><a href=#dom-node-ownerdocument>ownerDocument</a></code> is <var title="">doc</var>.</li>
+
+   <li><p>Set the <code><a href=#the-template-element>template</a></code> element's <a href=#template-contents>template contents</a> to the newly
+   created <code><a href=#documentfragment>DocumentFragment</a></code> object.</li>
+
+  </ol><p>The <dfn id=dom-template-content title=dom-template-content><code>content</code></dfn> IDL attribute must return the
+  <code><a href=#the-template-element>template</a></code> element's <a href=#template-contents>template contents</a>.</p>
+
+  <hr><p>The <a href=#concept-node-clone-ext title=concept-node-clone-ext>cloning steps</a> for a <code><a href=#the-template-element>template</a></code>
+  element <var title="">node</var> being cloned to a copy <var title="">copy</var> must run the
+  following steps:</p>
+
+  <ol><li><p>If the <var title="">clone children flag</var> is not set in the calling <a href=#concept-node-clone title=concept-node-clone>clone</a> algorithm, abort these steps.</li>
+
+   <li><p>Let <var title="">copied contents</var> be the result of <a href=#concept-node-clone title=concept-node-clone>cloning</a> all the children of <var title="">node</var>'s
+   <a href=#template-contents>template contents</a>, with <var title="">ownerDocument</var> set to <var title="">copy</var>'s <a href=#template-contents>template contents</a>'s <code title=dom-node-ownerdocument><a href=#dom-node-ownerdocument>ownerDocument</a></code>, and with the <var title="">clone children
+   flag</var> set.</li>
+
+   <li><p>Append <var title="">copied contents</var> to <var title="">copy</var>'s <a href=#template-contents>template
+   contents</a>.</li>
+
+  </ol></div>
+
+  <div class=example>
+
+   <p>In this example, a script populates a table with data from a data structure, using a
+   <code><a href=#the-template-element>template</a></code> to provide the element structure instead of manually generating the
+   structure from markup.</p>
+
+   <pre><!DOCTYPE html>
+<title>Cat data</title>
+<script>
+ // Data is hard-coded here, but could come from the server
+ var data = [
+   { name: 'Pillar', color: 'Ticked Tabby', sex: 'Female (neutered)', legs: 3 },
+   { name: 'Hedral', color: 'Tuxedo', sex: 'Male (neutered)', legs: 4 },
+ ];
+</script>
+<table>
+ <thead>
+  <tr>
+   <th>Name <th>Color <th>Sex <th>Legs
+ <tbody>
+  <template id="row">
+   <tr><td><td><td><td>
+  </template>
+</table>
+<script>
+ var template = document.querySelector('#row');
+ for (var i in data) {
+   var cat = data[i];
+   var clone = template.content.cloneNode(true);
+   var cells = clone.querySelectorAll('td');
+   cells[0].textContent = cat.name;
+   cells[1].textContent = cat.color;
+   cells[2].textContent = cat.sex;
+   cells[3].textContent = cat.legs;
+   template.parentNode.appendChild(clone);
+ }
+</script></pre>
+
+  </div>
+
+
+
+  <div class=impl>
+
+  <h5 id=template-XSLT-XPath><span class=secno>4.3.3.1 </span>Interaction of <code><a href=#the-template-element>template</a></code> elements with XSLT and XPath</h5>
+
+  <p><i>This section is non-normative.</i></p>
+
+  <p>This specification does not define how XSLT and XPath interact with the <code><a href=#the-template-element>template</a></code>
+  element. However, in the absence of another specification actually defining this, here are some
+  guidelines for implementors, which are intended to be consistent with other processing described
+  in this specification:</p>
+
+  <ul><li><p>An XSLT processor based on an XML parser that acts <a href=#xml-parser title="xml parser">as described
+   in this specification</a> needs to act as if <code><a href=#the-template-element>template</a></code> elements contain as
+   descendants their <a href=#template-contents>template contents</a> for the purposes of the transform.</li>
+
+   <li><p>An XSLT processor that outputs a DOM needs to ensure that nodes that would go into a
+   <code><a href=#the-template-element>template</a></code> element are instead placed into the element's <a href=#template-contents>template
+   contents</a>.</li>
+
+   <li><p>XPath evaluation using the XPath DOM API when applied to a <code><a href=#document>Document</a></code> parsed
+   using the <a href=#html-parser>HTML parser</a> or the <a href=#xml-parser>XML parser</a> described in this specification
+   needs to ignore <a href=#template-contents>template contents</a>.</p>
+
+  </ul></div>
+
+
   <h3 id=sections><span class=secno>4.4 </span>Sections</h3>
 
   <h4 id=the-body-element><span class=secno>4.4.1 </span>The <dfn><code>body</code></dfn> element</h4>
@@ -16215,7 +16403,7 @@
    <dt><a href=#element-dfn-contexts title=element-dfn-contexts>Contexts in which this element can be used</a>:</dt>
    <dd>Where <a href=#flow-content>flow content</a> is expected.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>One or more <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>, and <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> elements.</dd>
+   <dd>One or more <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code>, and <code><a href=#the-template-element>template</a></code> elements.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>Neither tag is omissible.</dd>
    <dt><a href=#element-dfn-attributes title=element-dfn-attributes>Content attributes</a>:</dt>
@@ -18159,7 +18347,7 @@
    <dt><a href=#element-dfn-contexts title=element-dfn-contexts>Contexts in which this element can be used</a>:</dt>
    <dd>Where <a href=#flow-content>flow content</a> is expected.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more <code><a href=#the-li-element>li</a></code> elements.</dd>
+   <dd>Zero or more <code><a href=#the-li-element>li</a></code> and <code><a href=#the-template-element>template</a></code> elements.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>Neither tag is omissible.</dd>
    <dt><a href=#element-dfn-attributes title=element-dfn-attributes>Content attributes</a>:</dt>
@@ -18323,7 +18511,7 @@
    <dt><a href=#element-dfn-contexts title=element-dfn-contexts>Contexts in which this element can be used</a>:</dt>
    <dd>Where <a href=#flow-content>flow content</a> is expected.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more <code><a href=#the-li-element>li</a></code> elements.</dd>
+   <dd>Zero or more <code><a href=#the-li-element>li</a></code> and <code><a href=#the-template-element>template</a></code> elements.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>Neither tag is omissible.</dd>
    <dt><a href=#element-dfn-attributes title=element-dfn-attributes>Content attributes</a>:</dt>
@@ -18491,9 +18679,9 @@
    <dt><a href=#element-dfn-contexts title=element-dfn-contexts>Contexts in which this element can be used</a>:</dt>
    <dd>Where <a href=#flow-content>flow content</a> is expected.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more groups each consisting of one or more
-   <code><a href=#the-dt-element>dt</a></code> elements followed by one or more <code><a href=#the-dd-element>dd</a></code>
-   elements.</dd>
+   <dd>Either: Zero or more groups each consisting of one or more <code><a href=#the-dt-element>dt</a></code> elements followed by one or more <code><a href=#the-dd-element>dd</a></code> elements.</dd>
+   <dd>Or: A <code><a href=#the-template-element>template</a></code> element.</dd>
+   <dd>Or: A <code><a href=#the-template-element>template</a></code> element or a <code><a href=#the-dt-element>dt</a></code> element, followed by zero or more <code><a href=#the-template-element>template</a></code>, <code><a href=#the-dt-element>dt</a></code>, and <code><a href=#the-dd-element>dd</a></code> elements, followed by a <code><a href=#the-template-element>template</a></code> element or a <code><a href=#the-dd-element>dd</a></code> element.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>Neither tag is omissible.</dd>
    <dt><a href=#element-dfn-attributes title=element-dfn-attributes>Content attributes</a>:</dt>
@@ -39274,7 +39462,7 @@
    <dd><a href=#flow-content>Flow content</a>.</dd>
    <dd><a href=#phrasing-content>Phrasing content</a>.</dd>
    <dt><a href=#element-dfn-contexts title=element-dfn-contexts>Contexts in which this element can be used</a>:</dt>
-   <dd>Where <a href=#phrasing-content>phrasing content</a> is expected, but only if there is a <code><a href=#the-map-element>map</a></code> element ancestor.</dd>
+   <dd>Where <a href=#phrasing-content>phrasing content</a> is expected, but only if there is a <code><a href=#the-map-element>map</a></code> element ancestor or a <code><a href=#the-template-element>template</a></code> element ancestor.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
    <dd>Empty.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
@@ -39314,7 +39502,7 @@
   map</a>, or a dead area on an image map.</p>
 
   <p>An <code><a href=#the-area-element>area</a></code> element with a parent node must have a <code><a href=#the-map-element>map</a></code> element
-  ancestor.</p>
+  ancestor or a <code><a href=#the-template-element>template</a></code> element ancestor.</p>
 
   <p>If the <code><a href=#the-area-element>area</a></code> element has an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute, then the
   <code><a href=#the-area-element>area</a></code> element represents a <a href=#hyperlink>hyperlink</a>. In
@@ -39949,7 +40137,7 @@
    <code><a href=#the-tbody-element>tbody</a></code> elements or one or more <code><a href=#the-tr-element>tr</a></code>
    elements, followed optionally by a <code><a href=#the-tfoot-element>tfoot</a></code> element (but
    there can only be one <code><a href=#the-tfoot-element>tfoot</a></code> element child in
-   total).</dd>
+   total), optionally with one or more <code><a href=#the-template-element>template</a></code> elements between any of the other elements.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>Neither tag is omissible.</dd>
    <dt><a href=#element-dfn-attributes title=element-dfn-attributes>Content attributes</a>:</dt>
@@ -40692,7 +40880,7 @@
    elements.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
    <dd>If the <code title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code> attribute is present: Empty.</dd>
-   <dd>If the <code title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code> attribute is absent: Zero or more <code><a href=#the-col-element>col</a></code> elements.</dd>
+   <dd>If the <code title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code> attribute is absent: Zero or more <code><a href=#the-col-element>col</a></code> and <code><a href=#the-template-element>template</a></code> elements.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>A <code><a href=#the-colgroup-element>colgroup</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> can be omitted if the
    first thing inside the <code><a href=#the-colgroup-element>colgroup</a></code> element is a
@@ -40790,7 +40978,7 @@
    <code><a href=#the-tr-element>tr</a></code> elements that are children of the
    <code><a href=#the-table-element>table</a></code> element.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more <code><a href=#the-tr-element>tr</a></code> elements</dd>
+   <dd>Zero or more <code><a href=#the-tr-element>tr</a></code> and <code><a href=#the-template-element>template</a></code> elements</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>A <code><a href=#the-tbody-element>tbody</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> can be omitted if the
    first thing inside the <code><a href=#the-tbody-element>tbody</a></code> element is a
@@ -40895,7 +41083,7 @@
    <code><a href=#the-thead-element>thead</a></code> elements that are children of the
    <code><a href=#the-table-element>table</a></code> element.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more <code><a href=#the-tr-element>tr</a></code> elements</dd>
+   <dd>Zero or more <code><a href=#the-tr-element>tr</a></code> and <code><a href=#the-template-element>template</a></code> elements</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>A <code><a href=#the-thead-element>thead</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end
    tag</a> can be omitted if the <code><a href=#the-thead-element>thead</a></code> element is
@@ -40974,7 +41162,7 @@
    are no other <code><a href=#the-tfoot-element>tfoot</a></code> elements that are children of the
    <code><a href=#the-table-element>table</a></code> element.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more <code><a href=#the-tr-element>tr</a></code> elements</dd>
+   <dd>Zero or more <code><a href=#the-tr-element>tr</a></code> and <code><a href=#the-template-element>template</a></code> elements</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>A <code><a href=#the-tfoot-element>tfoot</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end
    tag</a> can be omitted if the <code><a href=#the-tfoot-element>tfoot</a></code> element is
@@ -41011,7 +41199,7 @@
    elements, but only if there are no <code><a href=#the-tbody-element>tbody</a></code> elements that
    are children of the <code><a href=#the-table-element>table</a></code> element.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more <code><a href=#the-td-element>td</a></code> or <code><a href=#the-th-element>th</a></code> elements</dd>
+   <dd>Zero or more <code><a href=#the-td-element>td</a></code>, <code><a href=#the-th-element>th</a></code>, and <code><a href=#the-template-element>template</a></code> elements</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>A <code><a href=#the-tr-element>tr</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end
    tag</a> can be omitted if the <code><a href=#the-tr-element>tr</a></code> element is
@@ -50665,7 +50853,7 @@
    <dt><a href=#element-dfn-contexts title=element-dfn-contexts>Contexts in which this element can be used</a>:</dt>
    <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more <code><a href=#the-option-element>option</a></code> or <code><a href=#the-optgroup-element>optgroup</a></code> elements.</dd>
+   <dd>Zero or more <code><a href=#the-option-element>option</a></code>, <code><a href=#the-optgroup-element>optgroup</a></code>, and <code><a href=#the-template-element>template</a></code> elements.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>Neither tag is omissible.</dd>
    <dt><a href=#element-dfn-attributes title=element-dfn-attributes>Content attributes</a>:</dt>
@@ -51199,7 +51387,7 @@
    <dt><a href=#element-dfn-contexts title=element-dfn-contexts>Contexts in which this element can be used</a>:</dt>
    <dd>As a child of a <code><a href=#the-select-element>select</a></code> element.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more <code><a href=#the-option-element>option</a></code> elements.</dd>
+   <dd>Zero or more <code><a href=#the-option-element>option</a></code> and <code><a href=#the-template-element>template</a></code> elements.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>An <code><a href=#the-optgroup-element>optgroup</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> can be omitted if the
    <code><a href=#the-optgroup-element>optgroup</a></code> element <!--has an ancestor
@@ -56471,8 +56659,8 @@
    <dd>Where <a href=#flow-content>flow content</a> is expected.</dd>
    <dd>If the element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#popup-menu-state title="popup menu state">popup menu</a> state: as the child of a <code><a href=#the-menu-element>menu</a></code> element whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#popup-menu-state title="popup menu state">popup menu</a> state.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>If the element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state: either zero or more <code><a href=#the-li-element>li</a></code> elements, or <a href=#flow-content>flow content</a>.</dd>
-   <dd>If the element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#popup-menu-state title="popup menu state">popup menu</a> state: in any order, zero or more <code><a href=#the-menuitem-element>menuitem</a></code> elements, zero or more <code><a href=#the-hr-element>hr</a></code> elements, and zero or more <code><a href=#the-menu-element>menu</a></code> elements whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attributes are in the <a href=#popup-menu-state title="popup menu state">popup menu</a> state.</dd>
+   <dd>If the element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state: either zero or more <code><a href=#the-li-element>li</a></code> and <code><a href=#the-template-element>template</a></code> elements, or, <a href=#flow-content>flow content</a>.</dd>
+   <dd>If the element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#popup-menu-state title="popup menu state">popup menu</a> state: in any order, zero or more <code><a href=#the-menuitem-element>menuitem</a></code> elements, zero or more <code><a href=#the-hr-element>hr</a></code> elements, zero or more <code><a href=#the-menu-element>menu</a></code> elements whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attributes are in the <a href=#popup-menu-state title="popup menu state">popup menu</a> state, and zero or more <code><a href=#the-template-element>template</a></code> elements.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>Neither tag is omissible.</dd>
    <dt><a href=#element-dfn-attributes title=element-dfn-attributes>Content attributes</a>:</dt>
@@ -84224,12 +84412,12 @@
   start tag that is marked as self-closing, in which case they must
   not have an end tag.</p>
 
-  <p>The contents of the element must be placed between just after the
+  <p>The <a href=#concept-html-contents title=concept-html-contents>contents</a> of the element must be placed between just after the
   start tag (which <a href=#syntax-tag-omission title=syntax-tag-omission>might be implied,
   in certain cases</a>) and just before the end tag (which again,
   <a href=#syntax-tag-omission title=syntax-tag-omission>might be implied in certain
   cases</a>). The exact allowed contents of each individual element
-  depend on the content model of that element, as described earlier in
+  depend on the <a href=#content-models title="content models">content model</a> of that element, as described earlier in
   this specification. Elements must not contain content that their
   content model disallows. In addition to the restrictions placed on
   the contents by those content models, however, the five types of
@@ -84878,6 +85066,8 @@
   HYPHEN-MINUS, U+003E GREATER-THAN SIGN (<code title="">--></code>).</p>
 
 
+<!--HTMLPARSER-->
+
   <div class=impl>
 
   <h3 id=parsing><span class=secno>12.2 </span>Parsing HTML documents</h3>
@@ -86007,7 +86197,8 @@
   row">in row</a>", "<a href=#parsing-main-intd title="insertion mode: in cell">in
   cell</a>", "<a href=#parsing-main-inselect title="insertion mode: in select">in
   select</a>", "<a href=#parsing-main-inselectintable title="insertion mode: in select in table">in
-  select in table</a>", "<a href=#parsing-main-afterbody title="insertion mode: after
+  select in table</a>", "<a href=#parsing-main-intemplate title="insertion mode: in template">in
+  template</a>", "<a href=#parsing-main-afterbody title="insertion mode: after
   body">after body</a>", "<a href=#parsing-main-inframeset title="insertion mode: in
   frameset">in frameset</a>", "<a href=#parsing-main-afterframeset title="insertion mode: after
   frameset">after frameset</a>", "<a href=#the-after-after-body-insertion-mode title="insertion mode:
@@ -86036,7 +86227,15 @@
   is also set. This is the insertion mode to which the tree
   construction stage will return.</p>
 
-  <hr><p>When the steps below require the UA to <dfn id=reset-the-insertion-mode-appropriately>reset the insertion
+  <p>Similarly, to parse nested <code><a href=#the-template-element>template</a></code> elements, a <dfn id=stack-of-template-insertion-modes>stack of template insertion
+  modes</dfn> is used. It is initially empty. The <dfn id=current-template-insertion-mode>current template insertion mode</dfn> is the
+  insertion mode that was most recently added to the <a href=#stack-of-template-insertion-modes>stack of template insertion modes</a>.
+  The algorithms in the sections below will <i>push</i> insertion modes onto this stack, meaning
+  that the specified insertion mode is to be added to the stack, and <i>pop</i> insertion modes from
+  the stack, which means that the most recently added insertion mode must be removed from the
+  stack.</p>
+
+  <hr><!--CLEANUP--><!--<p>s--><p>When the steps below require the UA to <dfn id=reset-the-insertion-mode-appropriately>reset the insertion
   mode appropriately</dfn>, it means the UA must follow these
   steps:</p>
 
@@ -86050,10 +86249,34 @@
    true and set <var title="">node</var> to the <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element.
    (<a href=#fragment-case>fragment case</a>)</li>
 
-   <li>If <var title="">node</var> is a <code><a href=#the-select-element>select</a></code> element,
-   then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inselect title="insertion mode: in select">in select</a>" and abort these
-   steps. (<a href=#fragment-case>fragment case</a>)</li>
+   <li>
 
+    <p>If <var title="">node</var> is a <code><a href=#the-select-element>select</a></code> element, run these substeps:</p>
+
+    <ol><li><p>Let <var title="">ancestor</var> be <var title="">node</var>.</li>
+
+     <li><p><i>Loop</i>: If <var title="">ancestor</var> is the first node in the <a href=#stack-of-open-elements>stack of open
+     elements</a>, jump to the step below labeled <i>done</i>.</li>
+
+     <li><p>Let <var title="">ancestor</var> be the node before <var title="">ancestor</var> in the
+     <a href=#stack-of-open-elements>stack of open elements</a>.</li>
+
+     <li><p>If <var title="">ancestor</var> is a <code><a href=#the-template-element>template</a></code> node, jump to the step below
+     labeled <i>done</i>.</li>
+
+     <li><p>If <var title="">ancestor</var> is a <code><a href=#the-table-element>table</a></code> node, switch the <a href=#insertion-mode>insertion
+     mode</a> to "<a href=#parsing-main-inselectintable title="insertion mode: in select in table">in select in table</a>" and
+     abort these steps.</li>
+      <!-- consider <table><tr><td><select><template></template><caption></table>
+           http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2374 -->
+
+     <li><p>Jump back to the step labeled <i>loop</i>.</li>
+
+     <li><p><i>Done</i>: Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inselect title="insertion mode: in
+     select">in select</a>" and abort these steps.</li>
+
+    </ol></li>
+
    <li>If <var title="">node</var> is a <code><a href=#the-td-element>td</a></code> or
    <code><a href=#the-th-element>th</a></code> element and <var title="">last</var> is false, then
    switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intd title="insertion
@@ -86074,26 +86297,36 @@
 
    <li>If <var title="">node</var> is a <code><a href=#the-colgroup-element>colgroup</a></code> element,
    then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-incolgroup title="insertion mode: in column group">in column group</a>" and
-   abort these steps. (<a href=#fragment-case>fragment case</a>)</li>
+   abort these steps.</li>
 
    <li>If <var title="">node</var> is a <code><a href=#the-table-element>table</a></code> element,
    then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>" and abort these
    steps.</li>
 
-   <li>If <var title="">node</var> is a <code><a href=#the-head-element>head</a></code> element,
-   then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" ("<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>"! <em> not "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>"</em>!) and abort
-   these steps. (<a href=#fragment-case>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-disabled 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/outerHTML/insertAdjacentHTML(),
-   where we know scripting is enabled. -->
+   <li>If <var title="">node</var> is a <code><a href=#the-template-element>template</a></code> element, then switch the
+   <a href=#insertion-mode>insertion mode</a> to the <a href=#current-template-insertion-mode>current template insertion mode</a> and abort these
+   steps.</li>
 
+<!--
+   <li>If <var title="">node</var> is a <code>head</code> element
+   and <var title="">last</var> is true,
+   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>
+--><!-- The above is only here 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-disabled 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/outerHTML/insertAdjacentHTML(), where we know scripting is enabled. -->
+
+   <li>If <var title="">node</var> is a <code><a href=#the-head-element>head</a></code> element and <var title="">last</var> is
+   false, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inhead title="insertion mode: in head">in
+   head</a>" and abort these steps.</li> <!-- for the case of <head><template></template>... -->
+
    <li>If <var title="">node</var> is a <code><a href=#the-body-element>body</a></code> element,
    then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" and abort these
    steps.</li>
@@ -86148,6 +86381,7 @@
   <p>Elements in the <a href=#stack-of-open-elements>stack of open elements</a> fall into the following categories:</p>
 
   <dl><dt><dfn id=special>Special</dfn></dt>
+<!--CLEANUP-->
    <dd><p>The following elements have varying levels of special parsing rules: HTML's
    <code><a href=#the-address-element>address</a></code>, <code><a href=#the-applet-element>applet</a></code>, <code><a href=#the-area-element>area</a></code>, <code><a href=#the-article-element>article</a></code>,
    <code><a href=#the-aside-element>aside</a></code>, <code><a href=#the-base-element>base</a></code>, <code><a href=#basefont>basefont</a></code>, <code><a href=#bgsound>bgsound</a></code>,
@@ -86167,7 +86401,7 @@
    <code><a href=#the-p-element>p</a></code>, <code><a href=#the-param-element>param</a></code>, <code><a href=#plaintext>plaintext</a></code>, <code><a href=#the-pre-element>pre</a></code>,
    <code><a href=#the-script-element>script</a></code>, <code><a href=#the-section-element>section</a></code>, <code><a href=#the-select-element>select</a></code>, <code><a href=#the-source-element>source</a></code>,
    <code><a href=#the-style-element>style</a></code>, <code><a href=#the-summary-element>summary</a></code>, <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>,
-   <code><a href=#the-td-element>td</a></code>, <code><a href=#the-textarea-element>textarea</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-th-element>th</a></code>, <code><a href=#the-thead-element>thead</a></code>,
+   <code><a href=#the-td-element>td</a></code>, <code><a href=#the-template-element>template</a></code>, <code><a href=#the-textarea-element>textarea</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-th-element>th</a></code>, <code><a href=#the-thead-element>thead</a></code>,
    <code><a href=#the-title-element>title</a></code>, <code><a href=#the-tr-element>tr</a></code>, <code><a href=#the-track-element>track</a></code>, <code><a href=#the-ul-element>ul</a></code>, <code><a href=#the-wbr-element>wbr</a></code>, and
    <code><a href=#xmp>xmp</a></code>; MathML's <code title="">mi</code>, <code title="">mo</code>, <code title="">mn</code>, <code title="">ms</code>, <code title="">mtext</code>, and <code title="">annotation-xml</code>; and SVG's <code title="">foreignObject</code>, <code title="">desc</code>, and <code title="">title</code>.</dd> <!-- we could actually put all
    non-HTML elements in this list, I think -->
@@ -86209,6 +86443,7 @@
    <li><code><a href=#the-th-element>th</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
    <li><code><a href=#the-marquee-element>marquee</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
    <li><code><a href=#the-object-element>object</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
+   <li><code><a href=#the-template-element>template</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
    <li><code title="">mi</code> in the <a href=#mathml-namespace>MathML namespace</a></li>
    <li><code title="">mo</code> in the <a href=#mathml-namespace>MathML namespace</a></li>
    <li><code title="">mn</code> in the <a href=#mathml-namespace>MathML namespace</a></li>
@@ -86239,6 +86474,7 @@
 
   <ul class=brief><li><code><a href=#the-html-element>html</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <!-- (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.) -->
    <li><code><a href=#the-table-element>table</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
+   <li><code><a href=#the-template-element>template</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
   </ul><p>The <a href=#stack-of-open-elements>stack of open elements</a> is said to <dfn id=has-an-element-in-select-scope title="has an element in select
   scope">have an element in select scope</dfn> when it <a href=#has-an-element-in-the-specific-scope>has an element in the specific
   scope</a> consisting of all element types <em>except</em> the following:</p>
@@ -88637,6 +88873,9 @@
 
   <h5 id=creating-and-inserting-nodes><span class=secno>12.2.5.1 </span>Creating and inserting nodes</h5>
 
+  <p>While the parser is processing a token, it can enable or disable <dfn id=foster-parent title="foster
+  parent">foster parenting</dfn>. This affects the following algorithm.</p>
+
   <p>The <dfn id=appropriate-place-for-inserting-a-node>appropriate place for inserting a node</dfn>, optionally using a particular
   <i>override target</i>, is the position in an element returned by running the following steps:</p>
 
@@ -88654,42 +88893,59 @@
     <p>Determine the <var title="">adjusted insertion location</var> using the first matching steps
     from the following list:</p>
 
-    <dl class=switch><dt>If <dfn id=foster-parent title="foster parent">foster parenting</dfn> is enabled and <var title="">target</var> is a <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>,
+    <dl class=switch><dt>If <a href=#foster-parent title="foster parent">foster parenting</a> is enabled and <var title="">target</var> is a <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>,
      <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-tr-element>tr</a></code> element</dt>
 
      <dd>
 
       <p class=note>Foster parenting happens when content is misnested in tables.</p>
 
-      <p>The <dfn id=foster-parent-element>foster parent element</dfn> is the parent element of the last <code><a href=#the-table-element>table</a></code>
-      element in the <a href=#stack-of-open-elements>stack of open elements</a>, if there is a <code><a href=#the-table-element>table</a></code> element and
-      it has such a parent element.</p>
+      <p>Run these substeps:</p>
 
-      <p class=note>It might have no parent or some other kind parent if a script manipulated the
-      DOM after the element was inserted by the parser.</p>
+      <ol><li><p>Let <var title="">last template</var> be the last <code><a href=#the-template-element>template</a></code> element in the
+       <a href=#stack-of-open-elements>stack of open elements</a>, if any.</p>
 
-      <p>If there is no <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>
-      (<a href=#fragment-case>fragment case</a>), then the <i><a href=#foster-parent-element>foster parent element</a></i> is the first element in the
-      <a href=#stack-of-open-elements>stack of open elements</a> (the <code><a href=#the-html-element>html</a></code> element). Otherwise, if there is a
-      <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>, but the last
-      <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a> has no parent, or its
-      parent node is not an element, then the <i><a href=#foster-parent-element>foster parent element</a></i> is the element before the
-      last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>.</p>
+       <li><p>Let <var title="">last table</var> be the last <code><a href=#the-table-element>table</a></code> element in the
+       <a href=#stack-of-open-elements>stack of open elements</a>, if any.</p>
 
-      <p>If the <i><a href=#foster-parent-element>foster parent element</a></i> is the parent element of the last <code><a href=#the-table-element>table</a></code>
-      element in the <a href=#stack-of-open-elements>stack of open elements</a>, then the <var title="">adjusted insertion
-      location</var> is inside the <i><a href=#foster-parent-element>foster parent element</a></i>, immediately <em>before</em> the
-      last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>; otherwise, the
-      <var title="">adjusted insertion location</var> is inside the <i><a href=#foster-parent-element>foster parent element</a></i>,
-      after its last child (if any).</p>
+       <li><p>If there is a <var title="">last template</var> and either there is no <var title="">last table</var>, or there is one, but <var title="">last template</var> is lower
+       (more recently added) than <var title="">last table</var> in the <a href=#stack-of-open-elements>stack of open
+       elements</a>, then: let <var title="">adjusted insertion location</var> be inside <var title="">last template</var>'s <a href=#template-contents>template contents</a>, after its last child (if any),
+       and abort these substeps.</li>
 
+       <li><p>If there is no <var title="">last table</var>, <!-- there's also implicitly no last
+       template, since we didn't hit the previous step --> then let <var title="">adjusted insertion
+       location</var> be inside the first element in the <a href=#stack-of-open-elements>stack of open elements</a> (the
+       <code><a href=#the-html-element>html</a></code> element), after its last child (if any), and abort these substeps.
+       (<a href=#fragment-case>fragment case</a>)</p>
+
+       <!-- if we get here, we know there's a last table, and if there's a last template, it's older
+       than the last table. -->
+
+       <li><p>If <var title="">last table</var> has a parent element, then let <var title="">adjusted insertion location</var> be inside <var title="">last table</var>'s parent
+       element, immediately before <var title="">last table</var>, and abort these
+       substeps.</li>
+
+       <!-- if we get here, we know there's a last table, but it has no parent, and if there's a
+       last template, it's older than the last table. -->
+
+       <li><p>Let <var title="">previous element</var> be the element immediately above <var title="">last table</var> in the <a href=#stack-of-open-elements>stack of open elements</a>.</li>
+
+       <li><p>Let <var title="">adjusted insertion location</var> be inside <var title="">previous
+       element</var>, after its last child (if any).</li>
+
+      </ol><p class=note>These steps are involved in part because it's possible for elements, the
+      <code><a href=#the-table-element>table</a></code> element in this case in particular, to have been moved by a script around
+      in the DOM, or indeed removed from the DOM entirely, after the element was inserted by the
+      parser.</p>
+
      </dd>
 
      <dt>Otherwise</dt>
 
      <dd>
 
-      <p>The <var title="">adjusted insertion location</var> is inside <var title="">target</var>,
+      <p>Let <var title="">adjusted insertion location</var> be inside <var title="">target</var>,
       after its last child (if any).</p>
 
      </dd>
@@ -88698,6 +88954,14 @@
 
    <li>
 
+    <p>If the <var title="">adjusted insertion location</var> is inside a <code><a href=#the-template-element>template</a></code>
+    element, let it instead be inside the <code><a href=#the-template-element>template</a></code> element's <a href=#template-contents>template
+    contents</a>, after its last child (if any).</p>
+
+   </li>
+
+   <li>
+
     <p>Return the <var title="">adjusted insertion location</var>.</p>
 
    </li>
@@ -88754,9 +89018,18 @@
    pointer</a>, and suppress the running of the <a href=#reset-the-form-owner>reset the form owner</a> algorithm in
    the next step.</li>
 
-   <li><p>Insert the newly created element at the <var title="">adjusted insertion
-   location</var>.</li>
+   <li>
 
+    <p>If it is possible to insert an element at the <var title="">adjusted insertion
+    location</var>, then insert the newly created element at the <var title="">adjusted insertion
+    location</var>.</p>
+
+    <p class=note>If the <var title="">adjusted insertion location</var> cannot accept more
+    elements, e.g. because it's a <code><a href=#document>Document</a></code> that already has an element child, then the
+    newly created element is dropped on the floor.</p>
+
+   </li>
+
    <li><p>Push the element onto the <a href=#stack-of-open-elements>stack of open elements</a> so that it is the new
    <a href=#current-node>current node</a>.</li>
 
@@ -88882,6 +89155,16 @@
 
    <li>
 
+    <p>If the <var title="">adjusted insertion location</var> is in a <code><a href=#document>Document</a></code> node,
+    then abort these steps.
+
+    <p class=note>The DOM will not let <code><a href=#document>Document</a></code> nodes have <code><a href=#text>Text</a></code> node
+    children, so they are dropped on the floor.</p>
+
+   </li>
+
+   <li>
+
     <p>If there is a <code><a href=#text>Text</a></code> node immediately before the <var title="">adjusted insertion
     location</var>, then append <var title="">data</var> to that <code><a href=#text>Text</a></code> node's data.</p>
 
@@ -89407,6 +89690,7 @@
 
    </dd>
 
+
    <dt id=scriptTag>A start tag whose tag name is "script"</dt>
    <dd>
 
@@ -89470,6 +89754,53 @@
     <p>Act as described in the "anything else" entry below.</p>
    </dd>
 
+   <dt>A start tag whose tag name is "template"</dt>
+   <dd>
+
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p>
+
+    <p>Insert a marker at the end of the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>.</p>
+
+    <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intemplate title="insertion mode: in template">in
+    template</a>".</p>
+
+    <p>Push "<a href=#parsing-main-intemplate title="insertion mode: in template">in template</a>" onto the <a href=#stack-of-template-insertion-modes>stack of
+    template insertion modes</a> so that it is the new <a href=#current-template-insertion-mode>current template insertion
+    mode</a>.</p>
+
+   </dd>
+
+   <dt>An end tag whose tag name is "template"</dt>
+   <dd>
+
+    <p>If there is no <code><a href=#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements>stack of open elements</a>, then
+    this is a <a href=#parse-error>parse error</a>; ignore the token.</p>
+
+    <p>Otherwise, run these steps:</p>
+
+    <ol><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>.</li>
+
+     <li><p>If the <a href=#current-node>current node</a> is not an element with
+     the same tag name as that of the token, then this is a
+     <a href=#parse-error>parse error</a>.</li>
+
+     <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a>
+     until an element with the same tag name as the token has been
+     popped from the stack.</li>
+
+     <li><a href=#clear-the-list-of-active-formatting-elements-up-to-the-last-marker>Clear the list of active formatting elements up to the
+     last marker</a>.</li>
+
+     <li><p>Pop the <a href=#current-template-insertion-mode>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes>stack of template
+     insertion modes</a>.</p>
+
+     <li><p><a href=#reset-the-insertion-mode-appropriately title="reset the insertion mode appropriately">Reset the
+     parser's insertion mode appropriately</a>.</li>
+
+    </ol></dd>
+
    <dt>A start tag whose tag name is "head"</dt>
    <dt>Any other end tag</dt>
    <dd>
@@ -89689,7 +90020,12 @@
 
    <dt>A start tag whose tag name is "html"</dt>
    <dd>
-    <p><a href=#parse-error>Parse error</a>. For each attribute on the token,
+    <p><a href=#parse-error>Parse error</a>.</p>
+
+    <p>If there is a <code><a href=#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements>stack of open elements</a>, then
+    ignore the token.</p>
+
+    <p>Otherwise, for each attribute on the token,
     check to see if the attribute is already present on the top
     element of the <a href=#stack-of-open-elements>stack of open elements</a>. If it is not,
     add the attribute and its corresponding value to that element.</p>
@@ -89708,8 +90044,9 @@
     <p><a href=#parse-error>Parse error</a>.</p>
 
     <p>If the second element on the <a href=#stack-of-open-elements>stack of open
-    elements</a> is not a <code><a href=#the-body-element>body</a></code> element, or, if the
+    elements</a> is not a <code><a href=#the-body-element>body</a></code> element, if the
     <a href=#stack-of-open-elements>stack of open elements</a> has only one node on it,
+    or if there is a <code><a href=#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements>stack of open elements</a>,
     then ignore the token. (<a href=#fragment-case>fragment case</a>)</p>
 
     <p>Otherwise, set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok";
@@ -89726,6 +90063,7 @@
 
     <p><a href=#parse-error>Parse error</a>.</p>
 
+<!--CLEANUP--><!--should switch these clauses around-->
     <p>If the second element on the <a href=#stack-of-open-elements>stack of open
     elements</a> is not a <code><a href=#the-body-element>body</a></code> element, or, if the
     <a href=#stack-of-open-elements>stack of open elements</a> has only one node on it,
@@ -89763,8 +90101,13 @@
     this is a <a href=#parse-error>parse error</a>.</p> <!-- (some of those are
     fragment cases) -->
 
-    <p><a href=#stop-parsing>Stop parsing</a>.</p>
+    <p>If the <a href=#stack-of-template-insertion-modes>stack of template insertion modes</a> is not empty, then process the token
+    <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-intemplate title="insertion mode: in template">in
+    template</a>" <a href=#insertion-mode>insertion mode</a>.</p>
+    <!-- this is needed to handle <head><template>...[EOF] - otherwise we don't construct the <body> element -->
 
+    <p>Otherwise, <a href=#stop-parsing>stop parsing</a>.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is "body"</dt>
@@ -90811,6 +91154,15 @@
 
    </dd>
 
+   <dt>A start tag whose tag name is "template"</dt>
+   <dt>An end tag whose tag name is "template"</dt>
+   <dd>
+
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
+
+   </dd>
+
    <dt>A start <!--or end--> tag whose tag name is one of: "caption",
    "col", "colgroup", "frame", "head", "tbody", "td", "tfoot", "th",
    "thead", "tr"</dt>
@@ -91107,9 +91459,6 @@
     the tag name "table" had been seen, then, if that token wasn't
     ignored, reprocess the current token.</p>
 
-    <p class=note>The fake end tag token here can only be
-    ignored in the <a href=#fragment-case>fragment case</a>.</p>
-
    </dd>
 
    <dt>An end tag whose tag name is "table"</dt>
@@ -91117,8 +91466,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope 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=#parse-error>parse error</a>. Ignore the token. (<a href=#fragment-case>fragment
-    case</a>)</p>
+    <a href=#parse-error>parse error</a>. Ignore the token.</p>
 
     <p>Otherwise:</p>
 
@@ -91187,18 +91535,21 @@
 
    <!-- "form" end tag falls through to in-body, which does the right thing -->
 
-   <dt>An end-of-file token</dt>
+   <dt>A start tag whose tag name is "template"</dt>
+   <dt>An end tag whose tag name is "template"</dt>
    <dd>
 
-    <p>If the <a href=#current-node>current node</a> is not the root
-    <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
-    error</a>.</p>
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
 
-    <p class=note>The <a href=#current-node>current node</a> can only be the root
-    <code><a href=#the-html-element>html</a></code> element in the <a href=#fragment-case>fragment case</a>.</p>
+   </dd>
 
-    <p><a href=#stop-parsing>Stop parsing</a>.</p>
+   <dt>An end-of-file token</dt>
+   <dd>
 
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
+
    </dd>
 
    <dt>Anything else</dt>
@@ -91213,8 +91564,8 @@
 
   </dl><p>When the steps above require the UA to <dfn id=clear-the-stack-back-to-a-table-context>clear the stack
   back to a table context</dfn>, it means that the UA must, while
-  the <a href=#current-node>current node</a> is not a <code><a href=#the-table-element>table</a></code>
-  element or an <code><a href=#the-html-element>html</a></code> element, pop elements from the
+  the <a href=#current-node>current node</a> is not a <code><a href=#the-table-element>table</a></code>,
+  <code><a href=#the-template-element>template</a></code>, or <code><a href=#the-html-element>html</a></code> element, pop elements from the
   <a href=#stack-of-open-elements>stack of open elements</a>.</p>
 
   <p class=note>The <a href=#current-node>current node</a> being an
@@ -91375,13 +91726,10 @@
    <dt>An end tag whose tag name is "colgroup"</dt>
    <dd>
 
-    <p>If the <a href=#current-node>current node</a> is the root
-    <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
-    error</a>; ignore the token. (<a href=#fragment-case>fragment
-    case</a>)</p>
+    <p>If the <a href=#current-node>current node</a> is not a <code><a href=#the-colgroup-element>colgroup</a></code> element, then this is a <a href=#parse-error>parse
+    error</a>; ignore the token.</p> <!-- e.g. colgroup fragment case, or <template><col></colgroup> -->
 
-    <p>Otherwise, pop the <a href=#current-node>current node</a> (which will be
-    a <code><a href=#the-colgroup-element>colgroup</a></code> element) from the <a href=#stack-of-open-elements>stack of open
+    <p>Otherwise, pop the <a href=#current-node>current node</a> from the <a href=#stack-of-open-elements>stack of open
     elements</a>. Switch the <a href=#insertion-mode>insertion mode</a> to
     "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>".</p>
 
@@ -91392,16 +91740,21 @@
     <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
    </dd>
 
+   <dt>A start tag whose tag name is "template"</dt>
+   <dt>An end tag whose tag name is "template"</dt>
+   <dd>
+
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
+
+   </dd>
+
    <dt>An end-of-file token</dt>
    <dd>
 
-    <p>If the <a href=#current-node>current node</a> is the root <code><a href=#the-html-element>html</a></code>
-    element, then <a href=#stop-parsing>stop parsing</a>. (<a href=#fragment-case>fragment
-    case</a>)</p>
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
 
-    <p>Otherwise, act as described in the "anything else" entry
-    below.</p>
-
    </dd>
 
    <dt>Anything else</dt>
@@ -91411,9 +91764,6 @@
     seen, and then, if that token wasn't ignored, reprocess the
     current token.</p>
 
-    <p class=note>The fake end tag token here can only be
-    ignored in the <a href=#fragment-case>fragment case</a>.</p>
-
    </dd>
 
   </dl><h6 id=parsing-main-intbody><span class=secno>12.2.5.4.13 </span>The "<dfn title="insertion mode: in table body">in table body</dfn>" insertion mode</h6>
@@ -91466,8 +91816,7 @@
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope 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=#parse-error>parse
-    error</a>. Ignore the token. (<a href=#fragment-case>fragment
-    case</a>)</p>
+    error</a>. Ignore the token.</p>
 
     <p>Otherwise:</p>
 
@@ -91495,7 +91844,7 @@
   </dl><p>When the steps above require the UA to <dfn id=clear-the-stack-back-to-a-table-body-context>clear the stack
   back to a table body context</dfn>, it means that the UA must,
   while the <a href=#current-node>current node</a> is not a <code><a href=#the-tbody-element>tbody</a></code>,
-  <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-html-element>html</a></code>
+  <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-template-element>template</a></code>, or <code><a href=#the-html-element>html</a></code>
   element, pop elements from the <a href=#stack-of-open-elements>stack of open
   elements</a>.</p>
 
@@ -91528,8 +91877,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope 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=#parse-error>parse error</a>. Ignore the token. (<a href=#fragment-case>fragment
-    case</a>)</p>
+    <a href=#parse-error>parse error</a>. Ignore the token.</p>
 
     <p>Otherwise:</p>
 
@@ -91553,9 +91901,6 @@
     then, if that token wasn't ignored, reprocess the current
     token.</p>
 
-    <p class=note>The fake end tag token here can only be
-    ignored in the <a href=#fragment-case>fragment case</a>.</p>
-
    </dd>
 
    <dt>An end tag whose tag name is one of: "tbody", "tfoot",
@@ -91585,8 +91930,8 @@
 
   </dl><p>When the steps above require the UA to <dfn id=clear-the-stack-back-to-a-table-row-context>clear the stack
   back to a table row context</dfn>, it means that the UA must,
-  while the <a href=#current-node>current node</a> is not a <code><a href=#the-tr-element>tr</a></code>
-  element or an <code><a href=#the-html-element>html</a></code> element, pop elements from the
+  while the <a href=#current-node>current node</a> is not a <code><a href=#the-tr-element>tr</a></code>,
+  <code><a href=#the-template-element>template</a></code>, or <code><a href=#the-html-element>html</a></code> element, pop elements from the
   <a href=#stack-of-open-elements>stack of open elements</a>.</p>
 
   <p class=note>The <a href=#current-node>current node</a> being an
@@ -91623,7 +91968,7 @@
 
     <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intr title="insertion mode: in row">in row</a>".</p> <!-- current
     node here will be a <tr> normally; but could be <html> in the
-    fragment case -->
+    fragment case, or <template> in the template case -->
 
    </dd>
 
@@ -91653,9 +91998,7 @@
    <dd>
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have an element 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-case>fragment case</a>), then this is a <a href=#parse-error>parse
+    scope</a> with the same tag name as that of the token, then this is a <a href=#parse-error>parse
     error</a> and the token must be ignored.</p>
 
     <p>Otherwise, <a href=#close-the-cell>close the cell</a> (see below) and
@@ -91816,18 +92159,21 @@
     mode</a>.</p>
    </dd>
 
-   <dt>An end-of-file token</dt>
+   <dt>A start tag whose tag name is "template"</dt>
+   <dt>An end tag whose tag name is "template"</dt>
    <dd>
 
-    <p>If the <a href=#current-node>current node</a> is not the root
-    <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
-    error</a>.</p>
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
 
-    <p class=note>The <a href=#current-node>current node</a> can only be the root
-    <code><a href=#the-html-element>html</a></code> element in the <a href=#fragment-case>fragment case</a>.</p>
+   </dd>
 
-    <p><a href=#stop-parsing>Stop parsing</a>.</p>
+   <dt>An end-of-file token</dt>
+   <dd>
 
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
+
    </dd>
 
    <dt>Anything else</dt>
@@ -91866,8 +92212,124 @@
     mode</a>.</p>
    </dd>
 
-  </dl><h6 id=parsing-main-afterbody><span class=secno>12.2.5.4.18 </span>The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h6>
+  </dl><h6 id=parsing-main-intemplate><span class=secno>12.2.5.4.18 </span>The "<dfn title="insertion mode: in template">in template</dfn>" insertion mode</h6>
 
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-intemplate title="insertion mode: in template">in template</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
+
+  <dl class=switch><!-- first, tokens we always ignore: --><!-- html: ignored in "in body" mode if there's a <template> on the stack --><!-- head: ignored in "in body" mode always --><!-- body: ignored in "in body" mode if there's a <template> on the stack --><!-- frameset: ignored in "in body" mode if frameset-ok is set to not-ok, which <template> sets it to --><!-- second, tokens that are ambiguous (allowed in multiple modes), let's just handle them in a generic way and not pick a mode: --><dt>A character token</dt>
+   <dt>A comment token</dt>
+   <dt>A DOCTYPE token</dt>
+   <dd>
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
+   </dd>
+
+   <dt>A start tag whose tag name is one of: "base", "basefont", "bgsound", "link", "meta", "noframes", "script", "style", "title"</dt>
+   <dt>A start tag whose tag name is "template"</dt>
+   <dt>An end tag whose tag name is "template"</dt>
+   <dd>
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
+   </dd>
+
+   <!-- now, tokens that imply certain modes -->
+
+   <dt>A start tag whose tag name is one of: "caption", "colgroup", "tbody", "tfoot", "thead"</dt>
+   <dd>
+
+    <p>Pop the <a href=#current-template-insertion-mode>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes>stack of template
+    insertion modes</a>.</p>
+
+    <p>Push "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>" onto the <a href=#stack-of-template-insertion-modes>stack of
+    template insertion modes</a> so that it is the new <a href=#current-template-insertion-mode>current template insertion
+    mode</a>.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intable title="insertion mode: in table">in
+    table</a>", and reprocess the token.</p>
+
+   </dd>
+
+   <dt>A start tag whose tag name is "col"</dt>
+   <dd>
+
+    <p>Pop the <a href=#current-template-insertion-mode>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes>stack of template
+    insertion modes</a>.</p>
+
+    <p>Push "<a href=#parsing-main-incolgroup title="insertion mode: in column group">in column group</a>" onto the
+    <a href=#stack-of-template-insertion-modes>stack of template insertion modes</a> so that it is the new <a href=#current-template-insertion-mode>current template
+    insertion mode</a>.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-incolgroup title="insertion mode: in column group">in
+    column group</a>", and reprocess the token.</p>
+
+   </dd>
+
+   <dt>A start tag whose tag name is "tr"</dt>
+   <dd>
+
+    <p>Pop the <a href=#current-template-insertion-mode>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes>stack of template
+    insertion modes</a>.</p>
+
+    <p>Push "<a href=#parsing-main-intbody title="insertion mode: in table body">in table body</a>" onto the <a href=#stack-of-template-insertion-modes>stack
+    of template insertion modes</a> so that it is the new <a href=#current-template-insertion-mode>current template insertion
+    mode</a>.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intbody title="insertion mode: in table body">in
+    table body</a>", and reprocess the token.</p>
+
+   </dd>
+
+   <dt>A start tag whose tag name is one of: "td", "th"</dt>
+   <dd>
+
+    <p>Pop the <a href=#current-template-insertion-mode>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes>stack of template
+    insertion modes</a>.</p>
+
+    <p>Push "<a href=#parsing-main-intr title="insertion mode: in row">in row</a>" onto the <a href=#stack-of-template-insertion-modes>stack of template
+    insertion modes</a> so that it is the new <a href=#current-template-insertion-mode>current template insertion mode</a>.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intr title="insertion mode: in row">in
+    row</a>", and reprocess the token.</p>
+
+   </dd>
+
+   <!-- default to in-body mode -->
+
+   <dt>Any other start tag</dt>
+   <dd>
+
+    <p>Pop the <a href=#current-template-insertion-mode>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes>stack of template
+    insertion modes</a>.</p>
+
+    <p>Push "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" onto the <a href=#stack-of-template-insertion-modes>stack of template
+    insertion modes</a> so that it is the new <a href=#current-template-insertion-mode>current template insertion mode</a>.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in body">in
+    body</a>", and reprocess the token.</p>
+
+   </dd>
+
+   <dt>Any other end tag</dt>
+   <dd>
+    <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
+   </dd>
+
+   <!-- EOF -->
+
+
+   <dt>An end-of-file token</dt>
+   <dd>
+
+    <p>If there is no <code><a href=#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements>stack of open elements</a>, then
+    <a href=#stop-parsing>stop parsing</a>. (<a href=#fragment-case>fragment case</a>)</p>
+
+    <p>Otherwise, this is a <a href=#parse-error>parse error</a>; act as if an end tag with the tag name
+    "template" had been seen and reprocess the current token.</p>
+
+   </dd>
+
+  </dl><h6 id=parsing-main-afterbody><span class=secno>12.2.5.4.19 </span>The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h6>
+
   <p>When the user agent is to apply the rules for the "<a href=#parsing-main-afterbody title="insertion mode: after body">after body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A character token that is one of U+0009 CHARACTER
@@ -91922,7 +92384,7 @@
 
    </dd>
 
-  </dl><h6 id=parsing-main-inframeset><span class=secno>12.2.5.4.19 </span>The "<dfn title="insertion mode: in frameset">in frameset</dfn>" insertion mode</h6>
+  </dl><h6 id=parsing-main-inframeset><span class=secno>12.2.5.4.20 </span>The "<dfn title="insertion mode: in frameset">in frameset</dfn>" insertion mode</h6>
 
   <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inframeset title="insertion mode: in frameset">in frameset</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
@@ -92011,7 +92473,7 @@
     <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
    </dd>
 
-  </dl><h6 id=parsing-main-afterframeset><span class=secno>12.2.5.4.20 </span>The "<dfn title="insertion mode: after frameset">after frameset</dfn>" insertion mode</h6>
+  </dl><h6 id=parsing-main-afterframeset><span class=secno>12.2.5.4.21 </span>The "<dfn title="insertion mode: after frameset">after frameset</dfn>" insertion mode</h6>
 
   <p>When the user agent is to apply the rules for the "<a href=#parsing-main-afterframeset title="insertion mode: after frameset">after frameset</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
@@ -92061,7 +92523,7 @@
     <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
    </dd>
 
-  </dl><h6 id=the-after-after-body-insertion-mode><span class=secno>12.2.5.4.21 </span>The "<dfn title="insertion mode: after after body">after after body</dfn>" insertion mode</h6>
+  </dl><h6 id=the-after-after-body-insertion-mode><span class=secno>12.2.5.4.22 </span>The "<dfn title="insertion mode: after after body">after after body</dfn>" insertion mode</h6>
 
   <p>When the user agent is to apply the rules for the "<a href=#the-after-after-body-insertion-mode title="insertion mode: after after body">after after body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
@@ -92092,7 +92554,7 @@
     reprocess the token.</p>
    </dd>
 
-  </dl><h6 id=the-after-after-frameset-insertion-mode><span class=secno>12.2.5.4.22 </span>The "<dfn title="insertion mode: after after frameset">after after frameset</dfn>" insertion mode</h6>
+  </dl><h6 id=the-after-after-frameset-insertion-mode><span class=secno>12.2.5.4.23 </span>The "<dfn title="insertion mode: after after frameset">after after frameset</dfn>" insertion mode</h6>
 
   <p>When the user agent is to apply the rules for the "<a href=#the-after-after-frameset-insertion-mode title="insertion mode: after after frameset">after after frameset</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
@@ -92849,6 +93311,7 @@
   been seen up to this point.</p>
 
 
+<!--/HTMLPARSER-->
 
 
   <h3 id=serializing-html-fragments><span class=secno>12.3 </span>Serializing HTML fragments</h3>
@@ -92865,6 +93328,9 @@
   <ol><li><p>Let <var title="">s</var> be a string, and initialize it to
    the empty string.</li>
 
+   <li><p>If <var title="">the node</var> is a <code><a href=#the-template-element>template</a></code> element, then let <var title="">the node</var> instead be the <code><a href=#the-template-element>template</a></code> element's <a href=#template-contents>template
+   contents</a> (a <code><a href=#documentfragment>DocumentFragment</a></code> node).</li>
+
    <li>
 
     <p>For each child node of <var title="">the node</var>, in
@@ -93233,6 +93699,15 @@
 
      <li>
 
+      <p>If the <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element is a
+      <code><a href=#the-template-element>template</a></code> element, push "<a href=#parsing-main-intemplate title="insertion mode: in template">in
+      template</a>" onto the <a href=#stack-of-template-insertion-modes>stack of template insertion modes</a> so that it is the new
+      <a href=#current-template-insertion-mode>current template insertion mode</a>.</p>
+
+     </li>
+
+     <li>
+
       <p><a href=#reset-the-insertion-mode-appropriately title="reset the insertion mode appropriately">Reset the
       parser's insertion mode appropriately</a>.</p>
 
@@ -93351,6 +93826,8 @@
   the rules given in the XML specification to map a string of bytes or characters into a
   <code><a href=#document>Document</a></code> object.</p>
 
+  <p class=note>At the time of writing, no such rules actually exist.</p>
+
   <p>An <a href=#xml-parser>XML parser</a> is either associated with a <code><a href=#document>Document</a></code> object when it is
   created, or creates one implicitly.</p>
 
@@ -93421,6 +93898,17 @@
   available for <a href=#xml-documents>XML documents</a>, much of the complexity in the <a href=#html-parser>HTML parser</a>
   is not needed in the <a href=#xml-parser>XML parser</a>.</p>
 
+  <p id=templateTagXML>When an <a href=#xml-parser>XML parser</a> would append a node to a
+  <code><a href=#the-template-element>template</a></code> element, it must instead append it to the <code><a href=#the-template-element>template</a></code> element's
+  <a href=#template-contents>template contents</a> (a <code><a href=#documentfragment>DocumentFragment</a></code> node).</p>
+
+  <p class=note>This is a <a href=#willful-violation>willful violation</a> of the XML specification; unfortunately,
+  XML is not formally extensible in the manner that is needed for <code><a href=#the-template-element>template</a></code> processing.
+  <a href=#refsXML>[XML]</a></p>
+
+  <p>When an <a href=#xml-parser>XML parser</a> creates a <code><a href=#node>Node</a></code> object, its <code title=dom-Node-ownerDocument><a href=#dom-node-ownerdocument>ownerDocument</a></code> must be set to the <code><a href=#document>Document</a></code> of
+  the node into which the newly created node is to be inserted.</p>
+
   <p>Certain algorithms in this specification <dfn id=feed-the-parser title="feed the parser">spoon-feed the
   parser</dfn> characters one string at a time. In such cases, the <a href=#xml-parser>XML parser</a> must act
   as it would have if faced with a single string consisting of the concatenation of all those
@@ -93435,7 +93923,9 @@
   syntax</a>, then it is an <a href=#xml-documents title="XML documents">XML document</a>.</p>
 
 
+<!--//HTMLPARSER-->
 
+
   <h3 id=serializing-xhtml-fragments><span class=secno>13.3 </span>Serializing XHTML fragments</h3>
 
   <p>The <dfn id=xml-fragment-serialization-algorithm>XML fragment serialization algorithm</dfn> for a
@@ -93453,14 +93943,25 @@
 
   <p>In both cases, the string returned must be XML
   namespace-well-formed and must be an isomorphic serialization of all
-  of that node's child nodes, in <a href=#tree-order>tree order</a>. User agents
+  of that node's <a href=#relevant-child-nodes>relevant child nodes</a>, in <a href=#tree-order>tree order</a>. User agents
   may adjust prefixes and namespace declarations in the serialization
   (and indeed might be forced to do so in some cases to obtain
   namespace-well-formed XML). User agents may use a combination of
   regular text and character references to represent
   <code><a href=#text>Text</a></code> nodes in the DOM.</p>
 
-  <p>For <code><a href=#element>Element</a></code>s, if any of the elements in the
+  <p>A node's <dfn id=relevant-child-nodes>relevant child nodes</dfn> are those that apply given the following rules:</p>
+
+  <dl><dt>For <code><a href=#the-template-element>template</a></code> elements</dt>
+
+   <dd>The <a href=#relevant-child-nodes>relevant child nodes</a> are the child nodes of the <code><a href=#the-template-element>template</a></code>
+   element's <a href=#template-contents>template contents</a>, if any.</dd>
+
+   <dt>For all other nodes</dt>
+
+   <dd>The <a href=#relevant-child-nodes>relevant child nodes</a> are the child nodes of node itself, if any.</dd>
+
+  </dl><p>For <code><a href=#element>Element</a></code>s, if any of the elements in the
   serialization are in no namespace, the default namespace in scope
   for those elements must be explicitly declared as the empty
   string.<!-- because otherwise round-tripping might break since it'll
@@ -93717,7 +94218,7 @@
 
 [hidden], area, base, basefont, datalist, head, input[type=hidden i],
 link, menu[type=popup i], meta, noembed, noframes, param, rp, script,
-source, style, track, title {
+source, style, template, track, title {
   display: none;
 }
 
@@ -98715,7 +99216,8 @@
     <tr><th><code><a href=#the-base-element>base</a></code></th>
      <td>Base URL and default target <a href=#browsing-context>browsing context</a> for <a href=#attr-hyperlink-target title=attr-hyperlink-target>hyperlinks</a> and <a href=#attr-fs-target title=attr-fs-target>forms</a></td>
      <td><a href=#metadata-content title="Metadata content">metadata</a></td>
-     <td><code><a href=#the-head-element>head</a></code></td>
+     <td><code><a href=#the-head-element>head</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td>empty</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-base-href><a href=#attr-base-href>href</a></code>;
@@ -98813,7 +99315,8 @@
     <tr><th><code><a href=#the-caption-element>caption</a></code></th>
      <td>Table caption</td>
      <td>none</td>
-     <td><code><a href=#the-table-element>table</a></code></td>
+     <td><code><a href=#the-table-element>table</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#flow-content title="Flow content">flow</a>*</td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmltablecaptionelement>HTMLTableCaptionElement</a></code></td>
@@ -98836,7 +99339,8 @@
     <tr><th><code><a href=#the-col-element>col</a></code></th>
      <td>Table column</td>
      <td>none</td>
-     <td><code><a href=#the-colgroup-element>colgroup</a></code></td>
+     <td><code><a href=#the-colgroup-element>colgroup</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td>empty</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-col-span><a href=#attr-col-span>span</a></code></td>
@@ -98844,28 +99348,13 @@
     <tr><th><code><a href=#the-colgroup-element>colgroup</a></code></th>
      <td>Group of columns in a table</td>
      <td>none</td>
-     <td><code><a href=#the-table-element>table</a></code></td>
-     <td><code><a href=#the-col-element>col</a></code></td>
+     <td><code><a href=#the-table-element>table</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
+     <td><code><a href=#the-col-element>col</a></code>*;
+         <code><a href=#the-template-element>template</a></code>*</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code></td>
      <td><code><a href=#htmltablecolelement>HTMLTableColElement</a></code></td>
-    <tr><th><code><a href=#the-menuitem-element>menuitem</a></code></th>
-     <td>Menu command</td>
-     <td><a href=#metadata-content title="Metadata content">metadata</a>;
-         <a href=#flow-content title="Flow content">flow</a>;
-         <a href=#phrasing-content title="Phrasing content">phrasing</a></td>
-     <td><code><a href=#the-head-element>head</a></code>;
-         <a href=#phrasing-content title="Phrasing content">phrasing</a></td>
-     <td>empty</td>
-     <td><a href=#global-attributes title="global attributes">globals</a>;
-         <code title=attr-menuitem-type><a href=#attr-menuitem-type>type</a></code>;
-         <code title=attr-menuitem-label><a href=#attr-menuitem-label>label</a></code>;
-         <code title=attr-menuitem-icon><a href=#attr-menuitem-icon>icon</a></code>;
-         <code title=attr-menuitem-disabled><a href=#attr-menuitem-disabled>disabled</a></code>;
-         <code title=attr-menuitem-checked><a href=#attr-menuitem-checked>checked</a></code>;
-         <code title=attr-menuitem-radiogroup><a href=#attr-menuitem-radiogroup>radiogroup</a></code>;
-         <code title=attr-menuitem-command><a href=#attr-menuitem-command>command</a></code></td>
-     <td><code><a href=#htmlmenuitemelement>HTMLMenuItemElement</a></code></td>
     <tr><th><code><a href=#the-data-element>data</a></code></th>
      <td>Machine-readable equivalent</td>
      <td><a href=#flow-content title="Flow content">flow</a>;
@@ -98887,7 +99376,8 @@
     <tr><th><code><a href=#the-dd-element>dd</a></code></th>
      <td>Content for corresponding <code><a href=#the-dt-element>dt</a></code> element(s)</td>
      <td>none</td>
-     <td><code><a href=#the-dl-element>dl</a></code></td>
+     <td><code><a href=#the-dl-element>dl</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmlelement>HTMLElement</a></code></td>
@@ -98924,10 +99414,8 @@
      <td>Dialog box or window</td>
      <td><a href=#flow-content title="Flow content">flow</a>;
          <a href=#sectioning-root title="Sectioning root">sectioning root</a></td>
-     <td><code><a href=#the-dt-element>dt</a></code>;
-         <code><a href=#the-th-element>th</a></code>;
-         <a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
+     <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-dialog-open><a href=#attr-dialog-open>open</a></code></td>
      <td><code><a href=#htmldialogelement>HTMLDialogElement</a></code></td>
@@ -98943,13 +99431,15 @@
      <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><code><a href=#the-dt-element>dt</a></code>*;
-         <code><a href=#the-dd-element>dd</a></code>*</td>
+         <code><a href=#the-dd-element>dd</a></code>*;
+         <code><a href=#the-template-element>template</a></code>*</td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmldlistelement>HTMLDListElement</a></code></td>
     <tr><th><code><a href=#the-dt-element>dt</a></code></th>
      <td>Legend for corresponding <code><a href=#the-dd-element>dd</a></code> element(s)</td>
      <td>none</td>
-     <td><code><a href=#the-dl-element>dl</a></code></td>
+     <td><code><a href=#the-dl-element>dl</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#flow-content title="Flow content">flow</a>*</td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmlelement>HTMLElement</a></code></td>
@@ -98993,7 +99483,8 @@
     <tr><th><code><a href=#the-figcaption-element>figcaption</a></code></th>
      <td>Caption for <code><a href=#the-figure-element>figure</a></code></td>
      <td>none</td>
-     <td><code><a href=#the-figure-element>figure</a></code></td>
+     <td><code><a href=#the-figure-element>figure</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmlelement>HTMLElement</a></code></td>
@@ -99056,7 +99547,7 @@
      <td><a href=#flow-content title="Flow content">flow</a>;
          <a href=#heading-content title="Heading content">heading</a></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
-     <td>One or more <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>, and <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code></td>
+     <td>One or more <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code>, and <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmlelement>HTMLElement</a></code></td>
     <tr><th><code><a href=#the-hr-element>hr</a></code></th>
@@ -99216,14 +99707,18 @@
     <tr><th><code><a href=#the-legend-element>legend</a></code></th>
      <td>Caption for <code><a href=#the-fieldset-element>fieldset</a></code></td>
      <td>none</td>
-     <td><code><a href=#the-fieldset-element>fieldset</a></code></td>
+     <td><code><a href=#the-fieldset-element>fieldset</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmllegendelement>HTMLLegendElement</a></code></td>
     <tr><th><code><a href=#the-li-element>li</a></code></th>
      <td>List item</td>
      <td>none</td>
-     <td><code><a href=#the-ol-element>ol</a></code>; <code><a href=#the-ul-element>ul</a></code>; <code><a href=#the-menu-element>menu</a></code>*</td>
+     <td><code><a href=#the-ol-element>ol</a></code>;
+         <code><a href=#the-ul-element>ul</a></code>;
+         <code><a href=#the-menu-element>menu</a></code>*;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-li-value><a href=#attr-li-value>value</a></code>*</td>
@@ -99234,6 +99729,7 @@
          <a href=#flow-content title="Flow content">flow</a>*;
          <a href=#phrasing-content title="Phrasing content">phrasing</a>*</td>
      <td><code><a href=#the-head-element>head</a></code>;
+         <code><a href=#the-template-element>template</a></code>;
          <code><a href=#the-noscript-element>noscript</a></code>*;
          <a href=#phrasing-content title="phrasing content">phrasing</a>*</td>
      <td>empty</td>
@@ -99280,17 +99776,34 @@
          <a href=#flow-content title="Flow content">flow</a>*;
          <code><a href=#the-menuitem-element>menuitem</a></code>*;
          <code><a href=#the-hr-element>hr</a></code>*;
-         <code><a href=#the-menu-element>menu</a></code>*</td>
+         <code><a href=#the-menu-element>menu</a></code>*;
+         <code><a href=#the-template-element>template</a></code>*</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-menu-type><a href=#attr-menu-type>type</a></code>;
          <code title=attr-menu-label><a href=#attr-menu-label>label</a></code></td>
      <td><code><a href=#htmlmenuelement>HTMLMenuElement</a></code></td>
+    <tr><th><code><a href=#the-menuitem-element>menuitem</a></code></th>
+     <td>Menu command</td>
+     <td>none</td>
+     <td><code><a href=#the-menu-element>menu</a></code>;     
+         <code><a href=#the-template-element>template</a></code></td>
+     <td>empty</td>
+     <td><a href=#global-attributes title="global attributes">globals</a>;
+         <code title=attr-menuitem-type><a href=#attr-menuitem-type>type</a></code>;
+         <code title=attr-menuitem-label><a href=#attr-menuitem-label>label</a></code>;
+         <code title=attr-menuitem-icon><a href=#attr-menuitem-icon>icon</a></code>;
+         <code title=attr-menuitem-disabled><a href=#attr-menuitem-disabled>disabled</a></code>;
+         <code title=attr-menuitem-checked><a href=#attr-menuitem-checked>checked</a></code>;
+         <code title=attr-menuitem-radiogroup><a href=#attr-menuitem-radiogroup>radiogroup</a></code>;
+         <code title=attr-menuitem-command><a href=#attr-menuitem-command>command</a></code></td>
+     <td><code><a href=#htmlmenuitemelement>HTMLMenuItemElement</a></code></td>
     <tr><th><code><a href=#the-meta-element>meta</a></code></th>
      <td>Text metadata</td>
      <td><a href=#metadata-content title="Metadata content">metadata</a>;
          <a href=#flow-content title="Flow content">flow</a>*;
          <a href=#phrasing-content title="Phrasing content">phrasing</a>*</td>
      <td><code><a href=#the-head-element>head</a></code>;
+         <code><a href=#the-template-element>template</a></code>;
          <code><a href=#the-noscript-element>noscript</a></code>*;
          <a href=#phrasing-content title="phrasing content">phrasing</a>*</td>
      <td>empty</td>
@@ -99329,6 +99842,7 @@
          <a href=#flow-content title="Flow content">flow</a>;
          <a href=#phrasing-content title="Phrasing content">phrasing</a></td>
      <td><code><a href=#the-head-element>head</a></code>*;
+         <code><a href=#the-template-element>template</a></code>*;
          <a href=#phrasing-content title="Phrasing content">phrasing</a>*</td>
      <td>varies*</td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
@@ -99359,7 +99873,8 @@
      <td>Ordered list</td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
-     <td><code><a href=#the-li-element>li</a></code></td>
+     <td><code><a href=#the-li-element>li</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-ol-reversed><a href=#attr-ol-reversed>reversed</a></code>;
          <code title=attr-ol-start><a href=#attr-ol-start>start</a></code>;
@@ -99368,8 +99883,10 @@
     <tr><th><code><a href=#the-optgroup-element>optgroup</a></code></th>
      <td>Group of options in a list box</td>
      <td>none</td>
-     <td><code><a href=#the-select-element>select</a></code></td>
-     <td><code><a href=#the-option-element>option</a></code></td>
+     <td><code><a href=#the-select-element>select</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
+     <td><code><a href=#the-option-element>option</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-optgroup-disabled><a href=#attr-optgroup-disabled>disabled</a></code>;
          <code title=attr-optgroup-label><a href=#attr-optgroup-label>label</a></code></td>
@@ -99379,7 +99896,8 @@
      <td>none</td>
      <td><code><a href=#the-select-element>select</a></code>;
          <code><a href=#the-datalist-element>datalist</a></code>;
-         <code><a href=#the-optgroup-element>optgroup</a></code></td>
+         <code><a href=#the-optgroup-element>optgroup</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#text-content title="text content">text</a>*</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-option-disabled><a href=#attr-option-disabled>disabled</a></code>;
@@ -99412,7 +99930,8 @@
     <tr><th><code><a href=#the-param-element>param</a></code></th>
      <td>Parameter for <code><a href=#the-object-element>object</a></code></td>
      <td>none</td>
-     <td><code><a href=#the-object-element>object</a></code></td>
+     <td><code><a href=#the-object-element>object</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td>empty</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-param-name><a href=#attr-param-name>name</a></code>;
@@ -99448,14 +99967,16 @@
     <tr><th><code><a href=#the-rp-element>rp</a></code></th>
      <td>Parenthesis for ruby annotation text</td>
      <td>none</td>
-     <td><code><a href=#the-ruby-element>ruby</a></code></td>
+     <td><code><a href=#the-ruby-element>ruby</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmlelement>HTMLElement</a></code></td>
     <tr><th><code><a href=#the-rt-element>rt</a></code></th>
      <td>Ruby annotation text</td>
      <td>none</td>
-     <td><code><a href=#the-ruby-element>ruby</a></code></td>
+     <td><code><a href=#the-ruby-element>ruby</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmlelement>HTMLElement</a></code></td>
@@ -99542,7 +100063,8 @@
      <td>Media source for <code><a href=#the-video-element>video</a></code> or <code><a href=#the-audio-element>audio</a></code></td>
      <td>none</td>
      <td><code><a href=#the-video-element>video</a></code>;
-         <code><a href=#the-audio-element>audio</a></code></td>
+         <code><a href=#the-audio-element>audio</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td>empty</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-source-src><a href=#attr-source-src>src</a></code>;
@@ -99610,26 +100132,38 @@
          <code><a href=#the-thead-element>thead</a></code>*;
          <code><a href=#the-tbody-element>tbody</a></code>*;
          <code><a href=#the-tfoot-element>tfoot</a></code>*;
-         <code><a href=#the-tr-element>tr</a></code>*</td>
+         <code><a href=#the-tr-element>tr</a></code>*;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmltableelement>HTMLTableElement</a></code></td>
     <tr><th><code><a href=#the-tbody-element>tbody</a></code></th>
      <td>Group of rows in a table</td>
      <td>none</td>
-     <td><code><a href=#the-table-element>table</a></code></td>
-     <td><code><a href=#the-tr-element>tr</a></code></td>
+     <td><code><a href=#the-table-element>table</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
+     <td><code><a href=#the-tr-element>tr</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code></td>
     <tr><th><code><a href=#the-td-element>td</a></code></th>
      <td>Table cell</td>
      <td><a href=#sectioning-root title="Sectioning root">sectioning root</a></td>
-     <td><code><a href=#the-tr-element>tr</a></code></td>
+     <td><code><a href=#the-tr-element>tr</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-tdth-colspan><a href=#attr-tdth-colspan>colspan</a></code>;
          <code title=attr-tdth-rowspan><a href=#attr-tdth-rowspan>rowspan</a></code>;
          <code title=attr-tdth-headers><a href=#attr-tdth-headers>headers</a></code></td>
      <td><code><a href=#htmltabledatacellelement>HTMLTableDataCellElement</a></code></td>
+    <tr><th><code><a href=#the-template-element>template</a></code></th>
+     <td>Template</td>
+     <td><a href=#metadata-content title="Metadata content">metadata</a>;
+         <a href=#flow-content title="Flow content">flow</a>;
+         <a href=#phrasing-content title="Phrasing content">phrasing</a></td>
+     <td colspan=2>it's complicated*</td>
+     <td><a href=#global-attributes title="global attributes">globals</a></td>
+     <td><code><a href=#htmltemplateelement>HTMLTemplateElement</a></code></td>
     <tr><th><code><a href=#the-textarea-element>textarea</a></code></th>
      <td>Multiline text field</td>
      <td><a href=#flow-content title="Flow content">flow</a>;
@@ -99659,14 +100193,17 @@
     <tr><th><code><a href=#the-tfoot-element>tfoot</a></code></th>
      <td>Group of footer rows in a table</td>
      <td>none</td>
-     <td><code><a href=#the-table-element>table</a></code></td>
-     <td><code><a href=#the-tr-element>tr</a></code></td>
+     <td><code><a href=#the-table-element>table</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
+     <td><code><a href=#the-tr-element>tr</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code></td>
     <tr><th><code><a href=#the-th-element>th</a></code></th>
      <td>Table header cell</td>
      <td>none</td>
-     <td><code><a href=#the-tr-element>tr</a></code></td>
+     <td><code><a href=#the-tr-element>tr</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#flow-content title="Flow content">flow</a>*</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-tdth-colspan><a href=#attr-tdth-colspan>colspan</a></code>;
@@ -99678,8 +100215,10 @@
     <tr><th><code><a href=#the-thead-element>thead</a></code></th>
      <td>Group of heading rows in a table</td>
      <td>none</td>
-     <td><code><a href=#the-table-element>table</a></code></td>
-     <td><code><a href=#the-tr-element>tr</a></code></td>
+     <td><code><a href=#the-table-element>table</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
+     <td><code><a href=#the-tr-element>tr</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code></td>
     <tr><th><code><a href=#the-time-element>time</a></code></th>
@@ -99694,7 +100233,8 @@
     <tr><th><code><a href=#the-title-element>title</a></code></th>
      <td>Document title</td>
      <td><a href=#metadata-content title="Metadata content">metadata</a></td>
-     <td><code><a href=#the-head-element>head</a></code></td>
+     <td><code><a href=#the-head-element>head</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#text-content title="text content">text</a>*</td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmltitleelement>HTMLTitleElement</a></code></td>
@@ -99704,16 +100244,19 @@
      <td><code><a href=#the-table-element>table</a></code>;
          <code><a href=#the-thead-element>thead</a></code>;
          <code><a href=#the-tbody-element>tbody</a></code>;
-         <code><a href=#the-tfoot-element>tfoot</a></code></td>
+         <code><a href=#the-tfoot-element>tfoot</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><code><a href=#the-th-element>th</a></code>*;
-         <code><a href=#the-td-element>td</a></code></td>
+         <code><a href=#the-td-element>td</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmltablerowelement>HTMLTableRowElement</a></code></td>
     <tr><th><code><a href=#the-track-element>track</a></code></th>
      <td>Timed text track</td>
      <td>none</td>
      <td><code><a href=#the-audio-element>audio</a></code>;
-         <code><a href=#the-video-element>video</a></code></td>
+         <code><a href=#the-video-element>video</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td>empty</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-track-default><a href=#attr-track-default>default</a></code>;
@@ -99734,7 +100277,8 @@
      <td>List</td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
-     <td><code><a href=#the-li-element>li</a></code></td>
+     <td><code><a href=#the-li-element>li</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmlulistelement>HTMLUListElement</a></code></td>
     <tr><th><code><a href=#the-var-element>var</a></code></th>
@@ -99805,6 +100349,7 @@
       <code><a href=#the-noscript-element>noscript</a></code>;
       <code><a href=#the-script-element>script</a></code>;
       <code><a href=#the-style-element>style</a></code>;
+      <code><a href=#the-template-element>template</a></code>;
       <code><a href=#the-title-element>title</a></code>
      <td>
       —
@@ -99885,6 +100430,7 @@
       <code><a href=#the-sub-and-sup-elements>sup</a></code>;
       <code><a href=#svg>svg</a></code>;
       <code><a href=#the-table-element>table</a></code>;
+      <code><a href=#the-template-element>template</a></code>;
       <code><a href=#the-textarea-element>textarea</a></code>;
       <code><a href=#the-time-element>time</a></code>;
       <code><a href=#the-u-element>u</a></code>;
@@ -99967,6 +100513,7 @@
       <code><a href=#the-sub-and-sup-elements>sub</a></code>;
       <code><a href=#the-sub-and-sup-elements>sup</a></code>;
       <code><a href=#svg>svg</a></code>;
+      <code><a href=#the-template-element>template</a></code>;
       <code><a href=#the-textarea-element>textarea</a></code>;
       <code><a href=#the-time-element>time</a></code>;
       <code><a href=#the-u-element>u</a></code>;
@@ -101631,6 +102178,9 @@
     <tr><td> <code><a href=#the-td-element>td</a></code>
      <td> <code><a href=#htmltabledatacellelement>HTMLTableDataCellElement</a></code> : <code><a href=#htmltablecellelement>HTMLTableCellElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
 
+    <tr><td> <code><a href=#the-template-element>template</a></code>
+     <td> <code><a href=#htmltemplateelement>HTMLTemplateElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
+
     <tr><td> <code><a href=#the-textarea-element>textarea</a></code>
      <td> <code><a href=#htmltextareaelement>HTMLTextAreaElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
 
@@ -101771,6 +102321,7 @@
    <li><code><a href=#htmltableheadercellelement>HTMLTableHeaderCellElement</a></code>
    <li><code><a href=#htmltablerowelement>HTMLTableRowElement</a></code>, <a href=#HTMLTableRowElement-partial>partial</a>
    <li><code><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code>, <a href=#HTMLTableSectionElement-partial>partial</a>
+   <li><code><a href=#htmltemplateelement>HTMLTemplateElement</a></code>
    <li><code><a href=#htmltextareaelement>HTMLTextAreaElement</a></code>
    <li><code><a href=#htmltimeelement>HTMLTimeElement</a></code>
    <li><code><a href=#htmltitleelement>HTMLTitleElement</a></code>
@@ -102302,6 +102853,7 @@
   Adam Barth,
   Adam de Boor,
   Adam Hepton,
+  Adam Klein,
   Adam Roben,
   Addison Phillips,
   Adele Peterson,
@@ -102805,6 +103357,7 @@
   Pravir Gupta,
   李普君 (Pujun Li)<!-- masa jack -->,
   Rachid Finge,
+  Rafael Weinstein,
   Rafał Miłecki,
   Raj Doshi,
   Rajas Moonka,
@@ -102916,6 +103469,7 @@
   Tom Baker,
   Tom Pike,
   Tommy Thorsen,
+  Tony Ross,
   Travis Leithead,
   Tyler Close,
   Victor Carbune,

Modified: images/content-venn.svg
===================================================================
--- images/content-venn.svg	2013-06-25 20:55:18 UTC (rev 7999)
+++ images/content-venn.svg	2013-06-28 22:44:17 UTC (rev 8000)
@@ -100,6 +100,7 @@
      <li><code>sup</code></li>
      <li><code>svg</code></li>
      <li><code>table</code></li>
+     <li><code>template</code></li>
      <li><code>textarea</code></li>
      <li><code>time</code></li>
      <li><code>u</code></li>
@@ -159,6 +160,7 @@
      <li><code>noscript</code></li>
      <li><code>script</code></li>
      <li><code>style</code></li>
+     <li><code>template</code></li>
      <li><code>title</code></li>
     </ul>
    </div>
@@ -246,6 +248,7 @@
      <li><code>sub</code></li>
      <li><code>sup</code></li>
      <li><code>svg</code></li>
+     <li><code>template</code></li>
      <li><code>textarea</code></li>
      <li><code>time</code></li>
      <li><code>u</code></li>

Modified: index
===================================================================
--- index	2013-06-25 20:55:18 UTC (rev 7999)
+++ index	2013-06-28 22:44:17 UTC (rev 8000)
@@ -256,7 +256,7 @@
 
   <header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
    <hgroup><h1 class=allcaps>HTML</h1>
-    <h2 class="no-num no-toc">Living Standard — Last Updated 25 June 2013</h2>
+    <h2 class="no-num no-toc">Living Standard — Last Updated 28 June 2013</h2>
    </hgroup><dl><dt><strong>Web developer edition:</strong></dt>
     <dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
     <dt>Multiple-page version:</dt>
@@ -471,7 +471,10 @@
        <li><a href=#restrictions-for-contents-of-script-elements><span class=secno>4.3.1.2 </span>Restrictions for contents of <code>script</code> elements</a></li>
        <li><a href=#inline-documentation-for-external-scripts><span class=secno>4.3.1.3 </span>Inline documentation for external scripts</a></li>
        <li><a href=#scriptTagXSLT><span class=secno>4.3.1.4 </span>Interaction of <code>script</code> elements and XSLT</a></ol></li>
-     <li><a href=#the-noscript-element><span class=secno>4.3.2 </span>The <code>noscript</code> element</a></ol></li>
+     <li><a href=#the-noscript-element><span class=secno>4.3.2 </span>The <code>noscript</code> element</a></li>
+     <li><a href=#the-template-element><span class=secno>4.3.3 </span>The <code>template</code> element</a>
+      <ol>
+       <li><a href=#template-XSLT-XPath><span class=secno>4.3.3.1 </span>Interaction of <code>template</code> elements with XSLT and XPath</a></ol></ol></li>
    <li><a href=#sections><span class=secno>4.4 </span>Sections</a>
     <ol>
      <li><a href=#the-body-element><span class=secno>4.4.1 </span>The <code>body</code> element</a></li>
@@ -1281,11 +1284,12 @@
          <li><a href=#parsing-main-intd><span class=secno>12.2.5.4.15 </span>The "in cell" insertion mode</a></li>
          <li><a href=#parsing-main-inselect><span class=secno>12.2.5.4.16 </span>The "in select" insertion mode</a></li>
          <li><a href=#parsing-main-inselectintable><span class=secno>12.2.5.4.17 </span>The "in select in table" insertion mode</a></li>
-         <li><a href=#parsing-main-afterbody><span class=secno>12.2.5.4.18 </span>The "after body" insertion mode</a></li>
-         <li><a href=#parsing-main-inframeset><span class=secno>12.2.5.4.19 </span>The "in frameset" insertion mode</a></li>
-         <li><a href=#parsing-main-afterframeset><span class=secno>12.2.5.4.20 </span>The "after frameset" insertion mode</a></li>
-         <li><a href=#the-after-after-body-insertion-mode><span class=secno>12.2.5.4.21 </span>The "after after body" insertion mode</a></li>
-         <li><a href=#the-after-after-frameset-insertion-mode><span class=secno>12.2.5.4.22 </span>The "after after frameset" insertion mode</a></ol></li>
+         <li><a href=#parsing-main-intemplate><span class=secno>12.2.5.4.18 </span>The "in template" insertion mode</a></li>
+         <li><a href=#parsing-main-afterbody><span class=secno>12.2.5.4.19 </span>The "after body" insertion mode</a></li>
+         <li><a href=#parsing-main-inframeset><span class=secno>12.2.5.4.20 </span>The "in frameset" insertion mode</a></li>
+         <li><a href=#parsing-main-afterframeset><span class=secno>12.2.5.4.21 </span>The "after frameset" insertion mode</a></li>
+         <li><a href=#the-after-after-body-insertion-mode><span class=secno>12.2.5.4.22 </span>The "after after body" insertion mode</a></li>
+         <li><a href=#the-after-after-frameset-insertion-mode><span class=secno>12.2.5.4.23 </span>The "after after frameset" insertion mode</a></ol></li>
        <li><a href=#parsing-main-inforeign><span class=secno>12.2.5.5 </span>The rules for parsing tokens in foreign content</a></ol></li>
      <li><a href=#the-end><span class=secno>12.2.6 </span>The end</a></li>
      <li><a href=#coercing-an-html-dom-into-an-infoset><span class=secno>12.2.7 </span>Coercing an HTML DOM into an infoset</a></li>
@@ -10309,8 +10313,11 @@
   <h4 id=content-models><span class=secno>3.2.5 </span><dfn>Content models</dfn></h4>
 
   <p>Each element defined in this specification has a content model: a description of the element's
-  expected contents. An <a href=#html-elements title="HTML elements">HTML element</a> must have contents that
-  match the requirements described in the element's content model.</p>
+  expected <a href=#concept-html-contents title=concept-html-contents>contents</a>. An <a href=#html-elements title="HTML elements">HTML element</a> must have contents that
+  match the requirements described in the element's content model. The <dfn id=concept-html-contents title=concept-html-contents>contents</dfn> of an element are
+  its children in the DOM, except for <code><a href=#the-template-element>template</a></code> elements, where the children are those
+  in the <a href=#template-contents>template contents</a> (a separate <code><a href=#documentfragment>DocumentFragment</a></code> assigned to the
+  element when the element is created).</p>
 
   <p>The <a href=#space-character title="space character">space characters</a> are always allowed between elements.
   User agents represent these characters between elements in the source markup as <code><a href=#text>Text</a></code>
@@ -10403,6 +10410,7 @@
    <li><code><a href=#the-noscript-element>noscript</a></code></li>
    <li><code><a href=#the-script-element>script</a></code></li>
    <li><code><a href=#the-style-element>style</a></code></li>
+   <li><code><a href=#the-template-element>template</a></code></li>
    <li><code><a href=#the-title-element>title</a></code></li>
   </ul><p>Elements from other namespaces whose semantics are primarily metadata-related (e.g. RDF) are
   also <a href=#metadata-content>metadata content</a>.</p>
@@ -10520,6 +10528,7 @@
    <li><code><a href=#the-sub-and-sup-elements>sup</a></code></li>
    <li><code><a href=#svg>svg</a></code></li>
    <li><code><a href=#the-table-element>table</a></code></li>
+   <li><code><a href=#the-template-element>template</a></code></li>
    <li><code><a href=#the-textarea-element>textarea</a></code></li>
    <li><code><a href=#the-time-element>time</a></code></li>
    <li><code><a href=#the-u-element>u</a></code></li>
@@ -10614,6 +10623,7 @@
    <li><code><a href=#the-sub-and-sup-elements>sub</a></code></li>
    <li><code><a href=#the-sub-and-sup-elements>sup</a></code></li>
    <li><code><a href=#svg>svg</a></code></li>
+   <li><code><a href=#the-template-element>template</a></code></li>
    <li><code><a href=#the-textarea-element>textarea</a></code></li>
    <li><code><a href=#the-time-element>time</a></code></li>
    <li><code><a href=#the-u-element>u</a></code></li>
@@ -10621,13 +10631,7 @@
    <li><code><a href=#the-video-element>video</a></code></li>
    <li><code><a href=#the-wbr-element>wbr</a></code></li>
    <li><a href=#text-content title="text content">Text</a></li>
-  </ul><p>As a general rule, elements whose content model allows any <a href=#phrasing-content>phrasing content</a> should
-  have either at least one descendant <code><a href=#text>Text</a></code> node that is not <a href=#inter-element-whitespace>inter-element
-  whitespace</a>, or at least one descendant element node that is <a href=#embedded-content>embedded content</a>.
-  For the purposes of this requirement, nodes that are descendants of <code><a href=#the-del-element>del</a></code> elements must
-  not be counted as contributing to the ancestors of the <code><a href=#the-del-element>del</a></code> element.</p>
-
-  <p class=note>Most elements that are categorized as phrasing content can only contain elements
+  </ul><p class=note>Most elements that are categorized as phrasing content can only contain elements
   that are themselves categorized as phrasing content, not any flow content.</p>
 
   <p><dfn id=text-content title="text content">Text</dfn>, in the context of content models, means either nothing,
@@ -10813,7 +10817,7 @@
   <h6 id=palpable-content-0><span class=secno>3.2.5.1.8 </span>Palpable content</h6>
 
   <p>As a general rule, elements whose content model allows any <a href=#flow-content>flow content</a> or
-  <a href=#phrasing-content>phrasing content</a> should have at least one child node that is <dfn id=palpable-content>palpable
+  <a href=#phrasing-content>phrasing content</a> should have at least one node in its <a href=#concept-html-contents title=concept-html-contents>contents</a> that is <dfn id=palpable-content>palpable
   content</dfn> and that does not have the <code title=attr-hidden><a href=#the-hidden-attribute>hidden</a></code> attribute
   specified.</p>
 
@@ -10923,7 +10927,7 @@
      without first violating the earlier requirement)
   <p>Furthermore, when a content model includes a part that is "transparent", those parts must not
   contain content that would not be conformant if all transparent elements in the tree were
-  replaced, in their parent element, by the children in the "transparent" part of their content
+  replaced, in their parent element, by the <span title="concept-html-contents">contents</span> in the "transparent" part of their content
   model, retaining order.</p>
 
   <div class="example">
@@ -11028,7 +11032,7 @@
 
   <p>Let <var title="">view</var> be a view of the DOM that replaces all <code><a href=#the-a-element>a</a></code>,
   <code><a href=#the-ins-element>ins</a></code>, <code><a href=#the-del-element>del</a></code>, and <code><a href=#the-map-element>map</a></code> elements in the document with their
-  contents. Then, in <var title="">view</var>, for each run of sibling <a href=#phrasing-content>phrasing content</a>
+  <a href=#concept-html-contents title=concept-html-contents>contents</a>. Then, in <var title="">view</var>, for each run of sibling <a href=#phrasing-content>phrasing content</a>
   nodes uninterrupted by other types of content, in an element that accepts content other than
   <a href=#phrasing-content>phrasing content</a> as well as <a href=#phrasing-content>phrasing content</a>, let <var title="">first</var> be the first node of the run, and let <var title="">last</var> be the last
   node of the run. For each such run that consists of at least one node that is neither
@@ -11142,7 +11146,7 @@
 
   <h4 id=requirements-relating-to-bidirectional-algorithm-formatting-characters><span class=secno>3.2.6 </span>Requirements relating to bidirectional-algorithm formatting characters</h4>
 
-  <p><a href=#text-content>Text content</a> in <a href=#html-elements>HTML elements</a> with child <code><a href=#text>Text</a></code> nodes, and
+  <p><a href=#text-content>Text content</a> in <a href=#html-elements>HTML elements</a> with <code><a href=#text>Text</a></code> nodes in their <a href=#concept-html-contents title=concept-html-contents>contents</a>, and
   text in attributes of <a href=#html-elements>HTML elements</a> that allow free-form text, may contain characters
   in the ranges U+202A to U+202E and U+2066 to U+2069 (the bidirectional-algorithm formatting
   characters). However, the use of these characters is restricted so that any embedding or overrides
@@ -11441,6 +11445,9 @@
     <tr><td><code><a href=#the-summary-element>summary</a></code> element
      <td><a href=#concept-role-none title=concept-role-none>No role</a>
 
+    <tr><td><code><a href=#the-template-element>template</a></code> element
+     <td><a href=#concept-role-none title=concept-role-none>No role</a>, with the <code title=attr-aria-hidden>aria-hidden</code> state set to "true"
+
     <tr><td><code><a href=#the-textarea-element>textarea</a></code> element
      <td><code title=attr-aria-role-textbox>textbox</code> role, with the <code title=attr-aria-multiline>aria-multiline</code> property set to "true", and the <code title=attr-aria-readonly>aria-readonly</code> property set to "true" if the element has a <code title=attr-textarea-readonly><a href=#attr-textarea-readonly>readonly</a></code> attribute
 
@@ -11771,7 +11778,9 @@
   output, or are rendered inline, etc).</p>
 
   <p class=note>There are also additional non-normative comments regarding the interaction of XSLT
-  and HTML <a href=#scriptTagXSLT>in the <code>script</code> element section</a>.</p>
+  and HTML <a href=#scriptTagXSLT>in the <code>script</code> element section</a>, and of
+  XSLT, XPath, and HTML <a href=#template-XSLT-XPath>in the <code>template</code> element
+  section</a>.</p>
 
   </div>
 
@@ -15436,7 +15445,186 @@
   </div>
 
 
+  <h4 id=the-template-element><span class=secno>4.3.3 </span>The <dfn><code>template</code></dfn> element</h4>
 
+  <dl class=element><dt><a href=#element-dfn-categories title=element-dfn-categories>Categories</a>:</dt>
+   <dd><a href=#metadata-content>Metadata content</a>.</dd>
+   <dd><a href=#flow-content>Flow content</a>.</dd>
+   <dd><a href=#phrasing-content>Phrasing content</a>.</dd>
+   <dt><a href=#element-dfn-contexts title=element-dfn-contexts>Contexts in which this element can be used</a>:</dt>
+   <dd>Where <a href=#metadata-content>metadata content</a> is expected.</dd>
+   <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd>
+   <dd>As a child of an <code><a href=#the-hgroup-element>hgroup</a></code> element.</dd>
+   <dd>As a child of an <code><a href=#the-ol-element>ol</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-ul-element>ul</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-dl-element>dl</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-table-element>table</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-colgroup-element>colgroup</a></code> element that doesn't have a <code title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code> attribute.</dd>
+   <dd>As a child of a <code><a href=#the-thead-element>thead</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-tbody-element>tbody</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-tfoot-element>tfoot</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-tr-element>tr</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-select-element>select</a></code> element.</dd>
+   <dd>As a child of an <code><a href=#the-optgroup-element>optgroup</a></code> element.</dd>
+   <dd>As a child of a <code><a href=#the-menu-element>menu</a></code> element.</dd>
+   <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
+   <dd>Either: <a href=#metadata-content>Metadata content</a>.</dd>
+   <dd>Or: <a href=#flow-content>Flow content</a>.</dd>
+   <dd>Or: The content model of <code><a href=#the-ol-element>ol</a></code> and <code><a href=#the-ul-element>ul</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-dl-element>dl</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-figure-element>figure</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-ruby-element>ruby</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-object-element>object</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-video-element>video</a></code> and <code><a href=#the-audio-element>audio</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-table-element>table</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-colgroup-element>colgroup</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, and <code><a href=#the-tfoot-element>tfoot</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-tr-element>tr</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-fieldset-element>fieldset</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-select-element>select</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-details-element>details</a></code> elements.</dd>
+   <dd>Or: The content model of <code><a href=#the-menu-element>menu</a></code> elements whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#popup-menu-state>popup menu state</a>.</dd>
+   <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
+   <dd>Neither tag is omissible.</dd>
+   <dt><a href=#element-dfn-attributes title=element-dfn-attributes>Content attributes</a>:</dt>
+   <dd><a href=#global-attributes>Global attributes</a></dd>
+   <dt><a href=#element-dfn-dom title=element-dfn-dom>DOM interface</a>:</dt><!--TOPIC:DOM APIs-->
+   <dd>
+<pre class=idl>interface <dfn id=htmltemplateelement>HTMLTemplateElement</dfn> : <a href=#htmlelement>HTMLElement</a> {
+  readonly attribute <a href=#documentfragment>DocumentFragment</a> <a href=#dom-template-content title=dom-template-content>content</a>;
+};</pre>
+</dd>
+  </dl><!--TOPIC:HTML--><p>The <code><a href=#the-template-element>template</a></code> element is used to declare fragments of HTML that can be cloned and
+  inserted in the document by script.</p>
+
+  <p>In a rendering, the <code><a href=#the-template-element>template</a></code> element <a href=#represents>represents</a> nothing.</p>
+
+  <dl class=domintro><dt><var title="">template</var> . <code title=dom-template-content><a href=#dom-template-content>content</a></code></dt>
+
+   <dd>
+
+    <p>Returns the contents of the <code><a href=#the-template-element>template</a></code>, which are stored in a
+    <code><a href=#documentfragment>DocumentFragment</a></code> associated with a different <code><a href=#document>Document</a></code> so as to avoid
+    the <code><a href=#the-template-element>template</a></code> contents interfering with the main <code><a href=#document>Document</a></code>. (For
+    example, this avoids form controls from being submitted, scripts from executing, and so
+    forth.)</p>
+
+   </dd>
+
+  </dl><div class=impl>
+
+  <p>Each <code><a href=#the-template-element>template</a></code> element has an associated <code><a href=#documentfragment>DocumentFragment</a></code> object that
+  is its <dfn id=template-contents>template contents</dfn>. When a <code><a href=#the-template-element>template</a></code> element is created, the user
+  agent must run the following steps to establish the <a href=#template-contents>template contents</a>:</p>
+
+  <ol><li><p>Let <var title="">doc</var> be the <code><a href=#the-template-element>template</a></code> element's <code title=dom-node-ownerdocument><a href=#dom-node-ownerdocument>ownerDocument</a></code>.</li>
+
+   <li>
+
+    <p>If <var title="">doc</var> has an associated <a href=#browsing-context>browsing context</a>, run these substeps:</p>
+
+    <ol><li><p>Let <var title="">new doc</var> be a new <code><a href=#document>Document</a></code> (that does not have a
+     <a href=#browsing-context>browsing context</a>).</li>
+
+     <li><p>If <var title="">doc</var> is an <a href=#html-documents title="HTML documents">HTML document</a>, mark
+     <var title="">new doc</var> as an <a href=#html-documents title="HTML documents">HTML document</a>
+     also.</li>
+
+     <li><p>Set <var title="">doc</var> to <var title="">new doc</var>.</li>
+
+    </ol></li>
+
+   <li><p>Create a <code><a href=#documentfragment>DocumentFragment</a></code> object whose <code title=dom-node-ownerdocument><a href=#dom-node-ownerdocument>ownerDocument</a></code> is <var title="">doc</var>.</li>
+
+   <li><p>Set the <code><a href=#the-template-element>template</a></code> element's <a href=#template-contents>template contents</a> to the newly
+   created <code><a href=#documentfragment>DocumentFragment</a></code> object.</li>
+
+  </ol><p>The <dfn id=dom-template-content title=dom-template-content><code>content</code></dfn> IDL attribute must return the
+  <code><a href=#the-template-element>template</a></code> element's <a href=#template-contents>template contents</a>.</p>
+
+  <hr><p>The <a href=#concept-node-clone-ext title=concept-node-clone-ext>cloning steps</a> for a <code><a href=#the-template-element>template</a></code>
+  element <var title="">node</var> being cloned to a copy <var title="">copy</var> must run the
+  following steps:</p>
+
+  <ol><li><p>If the <var title="">clone children flag</var> is not set in the calling <a href=#concept-node-clone title=concept-node-clone>clone</a> algorithm, abort these steps.</li>
+
+   <li><p>Let <var title="">copied contents</var> be the result of <a href=#concept-node-clone title=concept-node-clone>cloning</a> all the children of <var title="">node</var>'s
+   <a href=#template-contents>template contents</a>, with <var title="">ownerDocument</var> set to <var title="">copy</var>'s <a href=#template-contents>template contents</a>'s <code title=dom-node-ownerdocument><a href=#dom-node-ownerdocument>ownerDocument</a></code>, and with the <var title="">clone children
+   flag</var> set.</li>
+
+   <li><p>Append <var title="">copied contents</var> to <var title="">copy</var>'s <a href=#template-contents>template
+   contents</a>.</li>
+
+  </ol></div>
+
+  <div class=example>
+
+   <p>In this example, a script populates a table with data from a data structure, using a
+   <code><a href=#the-template-element>template</a></code> to provide the element structure instead of manually generating the
+   structure from markup.</p>
+
+   <pre><!DOCTYPE html>
+<title>Cat data</title>
+<script>
+ // Data is hard-coded here, but could come from the server
+ var data = [
+   { name: 'Pillar', color: 'Ticked Tabby', sex: 'Female (neutered)', legs: 3 },
+   { name: 'Hedral', color: 'Tuxedo', sex: 'Male (neutered)', legs: 4 },
+ ];
+</script>
+<table>
+ <thead>
+  <tr>
+   <th>Name <th>Color <th>Sex <th>Legs
+ <tbody>
+  <template id="row">
+   <tr><td><td><td><td>
+  </template>
+</table>
+<script>
+ var template = document.querySelector('#row');
+ for (var i in data) {
+   var cat = data[i];
+   var clone = template.content.cloneNode(true);
+   var cells = clone.querySelectorAll('td');
+   cells[0].textContent = cat.name;
+   cells[1].textContent = cat.color;
+   cells[2].textContent = cat.sex;
+   cells[3].textContent = cat.legs;
+   template.parentNode.appendChild(clone);
+ }
+</script></pre>
+
+  </div>
+
+
+
+  <div class=impl>
+
+  <h5 id=template-XSLT-XPath><span class=secno>4.3.3.1 </span>Interaction of <code><a href=#the-template-element>template</a></code> elements with XSLT and XPath</h5>
+
+  <p><i>This section is non-normative.</i></p>
+
+  <p>This specification does not define how XSLT and XPath interact with the <code><a href=#the-template-element>template</a></code>
+  element. However, in the absence of another specification actually defining this, here are some
+  guidelines for implementors, which are intended to be consistent with other processing described
+  in this specification:</p>
+
+  <ul><li><p>An XSLT processor based on an XML parser that acts <a href=#xml-parser title="xml parser">as described
+   in this specification</a> needs to act as if <code><a href=#the-template-element>template</a></code> elements contain as
+   descendants their <a href=#template-contents>template contents</a> for the purposes of the transform.</li>
+
+   <li><p>An XSLT processor that outputs a DOM needs to ensure that nodes that would go into a
+   <code><a href=#the-template-element>template</a></code> element are instead placed into the element's <a href=#template-contents>template
+   contents</a>.</li>
+
+   <li><p>XPath evaluation using the XPath DOM API when applied to a <code><a href=#document>Document</a></code> parsed
+   using the <a href=#html-parser>HTML parser</a> or the <a href=#xml-parser>XML parser</a> described in this specification
+   needs to ignore <a href=#template-contents>template contents</a>.</p>
+
+  </ul></div>
+
+
   <h3 id=sections><span class=secno>4.4 </span>Sections</h3>
 
   <h4 id=the-body-element><span class=secno>4.4.1 </span>The <dfn><code>body</code></dfn> element</h4>
@@ -16215,7 +16403,7 @@
    <dt><a href=#element-dfn-contexts title=element-dfn-contexts>Contexts in which this element can be used</a>:</dt>
    <dd>Where <a href=#flow-content>flow content</a> is expected.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>One or more <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>, and <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> elements.</dd>
+   <dd>One or more <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code>, and <code><a href=#the-template-element>template</a></code> elements.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>Neither tag is omissible.</dd>
    <dt><a href=#element-dfn-attributes title=element-dfn-attributes>Content attributes</a>:</dt>
@@ -18159,7 +18347,7 @@
    <dt><a href=#element-dfn-contexts title=element-dfn-contexts>Contexts in which this element can be used</a>:</dt>
    <dd>Where <a href=#flow-content>flow content</a> is expected.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more <code><a href=#the-li-element>li</a></code> elements.</dd>
+   <dd>Zero or more <code><a href=#the-li-element>li</a></code> and <code><a href=#the-template-element>template</a></code> elements.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>Neither tag is omissible.</dd>
    <dt><a href=#element-dfn-attributes title=element-dfn-attributes>Content attributes</a>:</dt>
@@ -18323,7 +18511,7 @@
    <dt><a href=#element-dfn-contexts title=element-dfn-contexts>Contexts in which this element can be used</a>:</dt>
    <dd>Where <a href=#flow-content>flow content</a> is expected.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more <code><a href=#the-li-element>li</a></code> elements.</dd>
+   <dd>Zero or more <code><a href=#the-li-element>li</a></code> and <code><a href=#the-template-element>template</a></code> elements.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>Neither tag is omissible.</dd>
    <dt><a href=#element-dfn-attributes title=element-dfn-attributes>Content attributes</a>:</dt>
@@ -18491,9 +18679,9 @@
    <dt><a href=#element-dfn-contexts title=element-dfn-contexts>Contexts in which this element can be used</a>:</dt>
    <dd>Where <a href=#flow-content>flow content</a> is expected.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more groups each consisting of one or more
-   <code><a href=#the-dt-element>dt</a></code> elements followed by one or more <code><a href=#the-dd-element>dd</a></code>
-   elements.</dd>
+   <dd>Either: Zero or more groups each consisting of one or more <code><a href=#the-dt-element>dt</a></code> elements followed by one or more <code><a href=#the-dd-element>dd</a></code> elements.</dd>
+   <dd>Or: A <code><a href=#the-template-element>template</a></code> element.</dd>
+   <dd>Or: A <code><a href=#the-template-element>template</a></code> element or a <code><a href=#the-dt-element>dt</a></code> element, followed by zero or more <code><a href=#the-template-element>template</a></code>, <code><a href=#the-dt-element>dt</a></code>, and <code><a href=#the-dd-element>dd</a></code> elements, followed by a <code><a href=#the-template-element>template</a></code> element or a <code><a href=#the-dd-element>dd</a></code> element.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>Neither tag is omissible.</dd>
    <dt><a href=#element-dfn-attributes title=element-dfn-attributes>Content attributes</a>:</dt>
@@ -39274,7 +39462,7 @@
    <dd><a href=#flow-content>Flow content</a>.</dd>
    <dd><a href=#phrasing-content>Phrasing content</a>.</dd>
    <dt><a href=#element-dfn-contexts title=element-dfn-contexts>Contexts in which this element can be used</a>:</dt>
-   <dd>Where <a href=#phrasing-content>phrasing content</a> is expected, but only if there is a <code><a href=#the-map-element>map</a></code> element ancestor.</dd>
+   <dd>Where <a href=#phrasing-content>phrasing content</a> is expected, but only if there is a <code><a href=#the-map-element>map</a></code> element ancestor or a <code><a href=#the-template-element>template</a></code> element ancestor.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
    <dd>Empty.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
@@ -39314,7 +39502,7 @@
   map</a>, or a dead area on an image map.</p>
 
   <p>An <code><a href=#the-area-element>area</a></code> element with a parent node must have a <code><a href=#the-map-element>map</a></code> element
-  ancestor.</p>
+  ancestor or a <code><a href=#the-template-element>template</a></code> element ancestor.</p>
 
   <p>If the <code><a href=#the-area-element>area</a></code> element has an <code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute, then the
   <code><a href=#the-area-element>area</a></code> element represents a <a href=#hyperlink>hyperlink</a>. In
@@ -39949,7 +40137,7 @@
    <code><a href=#the-tbody-element>tbody</a></code> elements or one or more <code><a href=#the-tr-element>tr</a></code>
    elements, followed optionally by a <code><a href=#the-tfoot-element>tfoot</a></code> element (but
    there can only be one <code><a href=#the-tfoot-element>tfoot</a></code> element child in
-   total).</dd>
+   total), optionally with one or more <code><a href=#the-template-element>template</a></code> elements between any of the other elements.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>Neither tag is omissible.</dd>
    <dt><a href=#element-dfn-attributes title=element-dfn-attributes>Content attributes</a>:</dt>
@@ -40692,7 +40880,7 @@
    elements.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
    <dd>If the <code title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code> attribute is present: Empty.</dd>
-   <dd>If the <code title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code> attribute is absent: Zero or more <code><a href=#the-col-element>col</a></code> elements.</dd>
+   <dd>If the <code title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code> attribute is absent: Zero or more <code><a href=#the-col-element>col</a></code> and <code><a href=#the-template-element>template</a></code> elements.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>A <code><a href=#the-colgroup-element>colgroup</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> can be omitted if the
    first thing inside the <code><a href=#the-colgroup-element>colgroup</a></code> element is a
@@ -40790,7 +40978,7 @@
    <code><a href=#the-tr-element>tr</a></code> elements that are children of the
    <code><a href=#the-table-element>table</a></code> element.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more <code><a href=#the-tr-element>tr</a></code> elements</dd>
+   <dd>Zero or more <code><a href=#the-tr-element>tr</a></code> and <code><a href=#the-template-element>template</a></code> elements</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>A <code><a href=#the-tbody-element>tbody</a></code> element's <a href=#syntax-start-tag title=syntax-start-tag>start tag</a> can be omitted if the
    first thing inside the <code><a href=#the-tbody-element>tbody</a></code> element is a
@@ -40895,7 +41083,7 @@
    <code><a href=#the-thead-element>thead</a></code> elements that are children of the
    <code><a href=#the-table-element>table</a></code> element.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more <code><a href=#the-tr-element>tr</a></code> elements</dd>
+   <dd>Zero or more <code><a href=#the-tr-element>tr</a></code> and <code><a href=#the-template-element>template</a></code> elements</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>A <code><a href=#the-thead-element>thead</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end
    tag</a> can be omitted if the <code><a href=#the-thead-element>thead</a></code> element is
@@ -40974,7 +41162,7 @@
    are no other <code><a href=#the-tfoot-element>tfoot</a></code> elements that are children of the
    <code><a href=#the-table-element>table</a></code> element.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more <code><a href=#the-tr-element>tr</a></code> elements</dd>
+   <dd>Zero or more <code><a href=#the-tr-element>tr</a></code> and <code><a href=#the-template-element>template</a></code> elements</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>A <code><a href=#the-tfoot-element>tfoot</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end
    tag</a> can be omitted if the <code><a href=#the-tfoot-element>tfoot</a></code> element is
@@ -41011,7 +41199,7 @@
    elements, but only if there are no <code><a href=#the-tbody-element>tbody</a></code> elements that
    are children of the <code><a href=#the-table-element>table</a></code> element.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more <code><a href=#the-td-element>td</a></code> or <code><a href=#the-th-element>th</a></code> elements</dd>
+   <dd>Zero or more <code><a href=#the-td-element>td</a></code>, <code><a href=#the-th-element>th</a></code>, and <code><a href=#the-template-element>template</a></code> elements</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>A <code><a href=#the-tr-element>tr</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end
    tag</a> can be omitted if the <code><a href=#the-tr-element>tr</a></code> element is
@@ -50665,7 +50853,7 @@
    <dt><a href=#element-dfn-contexts title=element-dfn-contexts>Contexts in which this element can be used</a>:</dt>
    <dd>Where <a href=#phrasing-content>phrasing content</a> is expected.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more <code><a href=#the-option-element>option</a></code> or <code><a href=#the-optgroup-element>optgroup</a></code> elements.</dd>
+   <dd>Zero or more <code><a href=#the-option-element>option</a></code>, <code><a href=#the-optgroup-element>optgroup</a></code>, and <code><a href=#the-template-element>template</a></code> elements.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>Neither tag is omissible.</dd>
    <dt><a href=#element-dfn-attributes title=element-dfn-attributes>Content attributes</a>:</dt>
@@ -51199,7 +51387,7 @@
    <dt><a href=#element-dfn-contexts title=element-dfn-contexts>Contexts in which this element can be used</a>:</dt>
    <dd>As a child of a <code><a href=#the-select-element>select</a></code> element.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>Zero or more <code><a href=#the-option-element>option</a></code> elements.</dd>
+   <dd>Zero or more <code><a href=#the-option-element>option</a></code> and <code><a href=#the-template-element>template</a></code> elements.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>An <code><a href=#the-optgroup-element>optgroup</a></code> element's <a href=#syntax-end-tag title=syntax-end-tag>end tag</a> can be omitted if the
    <code><a href=#the-optgroup-element>optgroup</a></code> element <!--has an ancestor
@@ -56471,8 +56659,8 @@
    <dd>Where <a href=#flow-content>flow content</a> is expected.</dd>
    <dd>If the element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#popup-menu-state title="popup menu state">popup menu</a> state: as the child of a <code><a href=#the-menu-element>menu</a></code> element whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#popup-menu-state title="popup menu state">popup menu</a> state.</dd>
    <dt><a href=#element-dfn-content-model title=element-dfn-content-model>Content model</a>:</dt>
-   <dd>If the element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state: either zero or more <code><a href=#the-li-element>li</a></code> elements, or <a href=#flow-content>flow content</a>.</dd>
-   <dd>If the element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#popup-menu-state title="popup menu state">popup menu</a> state: in any order, zero or more <code><a href=#the-menuitem-element>menuitem</a></code> elements, zero or more <code><a href=#the-hr-element>hr</a></code> elements, and zero or more <code><a href=#the-menu-element>menu</a></code> elements whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attributes are in the <a href=#popup-menu-state title="popup menu state">popup menu</a> state.</dd>
+   <dd>If the element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state: either zero or more <code><a href=#the-li-element>li</a></code> and <code><a href=#the-template-element>template</a></code> elements, or, <a href=#flow-content>flow content</a>.</dd>
+   <dd>If the element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#popup-menu-state title="popup menu state">popup menu</a> state: in any order, zero or more <code><a href=#the-menuitem-element>menuitem</a></code> elements, zero or more <code><a href=#the-hr-element>hr</a></code> elements, zero or more <code><a href=#the-menu-element>menu</a></code> elements whose <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attributes are in the <a href=#popup-menu-state title="popup menu state">popup menu</a> state, and zero or more <code><a href=#the-template-element>template</a></code> elements.</dd>
    <dt><a href=#element-dfn-tag-omission title=element-dfn-tag-omission>Tag omission in text/html</a>:</dt>
    <dd>Neither tag is omissible.</dd>
    <dt><a href=#element-dfn-attributes title=element-dfn-attributes>Content attributes</a>:</dt>
@@ -84224,12 +84412,12 @@
   start tag that is marked as self-closing, in which case they must
   not have an end tag.</p>
 
-  <p>The contents of the element must be placed between just after the
+  <p>The <a href=#concept-html-contents title=concept-html-contents>contents</a> of the element must be placed between just after the
   start tag (which <a href=#syntax-tag-omission title=syntax-tag-omission>might be implied,
   in certain cases</a>) and just before the end tag (which again,
   <a href=#syntax-tag-omission title=syntax-tag-omission>might be implied in certain
   cases</a>). The exact allowed contents of each individual element
-  depend on the content model of that element, as described earlier in
+  depend on the <a href=#content-models title="content models">content model</a> of that element, as described earlier in
   this specification. Elements must not contain content that their
   content model disallows. In addition to the restrictions placed on
   the contents by those content models, however, the five types of
@@ -84878,6 +85066,8 @@
   HYPHEN-MINUS, U+003E GREATER-THAN SIGN (<code title="">--></code>).</p>
 
 
+<!--HTMLPARSER-->
+
   <div class=impl>
 
   <h3 id=parsing><span class=secno>12.2 </span>Parsing HTML documents</h3>
@@ -86007,7 +86197,8 @@
   row">in row</a>", "<a href=#parsing-main-intd title="insertion mode: in cell">in
   cell</a>", "<a href=#parsing-main-inselect title="insertion mode: in select">in
   select</a>", "<a href=#parsing-main-inselectintable title="insertion mode: in select in table">in
-  select in table</a>", "<a href=#parsing-main-afterbody title="insertion mode: after
+  select in table</a>", "<a href=#parsing-main-intemplate title="insertion mode: in template">in
+  template</a>", "<a href=#parsing-main-afterbody title="insertion mode: after
   body">after body</a>", "<a href=#parsing-main-inframeset title="insertion mode: in
   frameset">in frameset</a>", "<a href=#parsing-main-afterframeset title="insertion mode: after
   frameset">after frameset</a>", "<a href=#the-after-after-body-insertion-mode title="insertion mode:
@@ -86036,7 +86227,15 @@
   is also set. This is the insertion mode to which the tree
   construction stage will return.</p>
 
-  <hr><p>When the steps below require the UA to <dfn id=reset-the-insertion-mode-appropriately>reset the insertion
+  <p>Similarly, to parse nested <code><a href=#the-template-element>template</a></code> elements, a <dfn id=stack-of-template-insertion-modes>stack of template insertion
+  modes</dfn> is used. It is initially empty. The <dfn id=current-template-insertion-mode>current template insertion mode</dfn> is the
+  insertion mode that was most recently added to the <a href=#stack-of-template-insertion-modes>stack of template insertion modes</a>.
+  The algorithms in the sections below will <i>push</i> insertion modes onto this stack, meaning
+  that the specified insertion mode is to be added to the stack, and <i>pop</i> insertion modes from
+  the stack, which means that the most recently added insertion mode must be removed from the
+  stack.</p>
+
+  <hr><!--CLEANUP--><!--<p>s--><p>When the steps below require the UA to <dfn id=reset-the-insertion-mode-appropriately>reset the insertion
   mode appropriately</dfn>, it means the UA must follow these
   steps:</p>
 
@@ -86050,10 +86249,34 @@
    true and set <var title="">node</var> to the <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element.
    (<a href=#fragment-case>fragment case</a>)</li>
 
-   <li>If <var title="">node</var> is a <code><a href=#the-select-element>select</a></code> element,
-   then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inselect title="insertion mode: in select">in select</a>" and abort these
-   steps. (<a href=#fragment-case>fragment case</a>)</li>
+   <li>
 
+    <p>If <var title="">node</var> is a <code><a href=#the-select-element>select</a></code> element, run these substeps:</p>
+
+    <ol><li><p>Let <var title="">ancestor</var> be <var title="">node</var>.</li>
+
+     <li><p><i>Loop</i>: If <var title="">ancestor</var> is the first node in the <a href=#stack-of-open-elements>stack of open
+     elements</a>, jump to the step below labeled <i>done</i>.</li>
+
+     <li><p>Let <var title="">ancestor</var> be the node before <var title="">ancestor</var> in the
+     <a href=#stack-of-open-elements>stack of open elements</a>.</li>
+
+     <li><p>If <var title="">ancestor</var> is a <code><a href=#the-template-element>template</a></code> node, jump to the step below
+     labeled <i>done</i>.</li>
+
+     <li><p>If <var title="">ancestor</var> is a <code><a href=#the-table-element>table</a></code> node, switch the <a href=#insertion-mode>insertion
+     mode</a> to "<a href=#parsing-main-inselectintable title="insertion mode: in select in table">in select in table</a>" and
+     abort these steps.</li>
+      <!-- consider <table><tr><td><select><template></template><caption></table>
+           http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2374 -->
+
+     <li><p>Jump back to the step labeled <i>loop</i>.</li>
+
+     <li><p><i>Done</i>: Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inselect title="insertion mode: in
+     select">in select</a>" and abort these steps.</li>
+
+    </ol></li>
+
    <li>If <var title="">node</var> is a <code><a href=#the-td-element>td</a></code> or
    <code><a href=#the-th-element>th</a></code> element and <var title="">last</var> is false, then
    switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intd title="insertion
@@ -86074,26 +86297,36 @@
 
    <li>If <var title="">node</var> is a <code><a href=#the-colgroup-element>colgroup</a></code> element,
    then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-incolgroup title="insertion mode: in column group">in column group</a>" and
-   abort these steps. (<a href=#fragment-case>fragment case</a>)</li>
+   abort these steps.</li>
 
    <li>If <var title="">node</var> is a <code><a href=#the-table-element>table</a></code> element,
    then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>" and abort these
    steps.</li>
 
-   <li>If <var title="">node</var> is a <code><a href=#the-head-element>head</a></code> element,
-   then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" ("<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>"! <em> not "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>"</em>!) and abort
-   these steps. (<a href=#fragment-case>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-disabled 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/outerHTML/insertAdjacentHTML(),
-   where we know scripting is enabled. -->
+   <li>If <var title="">node</var> is a <code><a href=#the-template-element>template</a></code> element, then switch the
+   <a href=#insertion-mode>insertion mode</a> to the <a href=#current-template-insertion-mode>current template insertion mode</a> and abort these
+   steps.</li>
 
+<!--
+   <li>If <var title="">node</var> is a <code>head</code> element
+   and <var title="">last</var> is true,
+   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>
+--><!-- The above is only here 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-disabled 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/outerHTML/insertAdjacentHTML(), where we know scripting is enabled. -->
+
+   <li>If <var title="">node</var> is a <code><a href=#the-head-element>head</a></code> element and <var title="">last</var> is
+   false, then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inhead title="insertion mode: in head">in
+   head</a>" and abort these steps.</li> <!-- for the case of <head><template></template>... -->
+
    <li>If <var title="">node</var> is a <code><a href=#the-body-element>body</a></code> element,
    then switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" and abort these
    steps.</li>
@@ -86148,6 +86381,7 @@
   <p>Elements in the <a href=#stack-of-open-elements>stack of open elements</a> fall into the following categories:</p>
 
   <dl><dt><dfn id=special>Special</dfn></dt>
+<!--CLEANUP-->
    <dd><p>The following elements have varying levels of special parsing rules: HTML's
    <code><a href=#the-address-element>address</a></code>, <code><a href=#the-applet-element>applet</a></code>, <code><a href=#the-area-element>area</a></code>, <code><a href=#the-article-element>article</a></code>,
    <code><a href=#the-aside-element>aside</a></code>, <code><a href=#the-base-element>base</a></code>, <code><a href=#basefont>basefont</a></code>, <code><a href=#bgsound>bgsound</a></code>,
@@ -86167,7 +86401,7 @@
    <code><a href=#the-p-element>p</a></code>, <code><a href=#the-param-element>param</a></code>, <code><a href=#plaintext>plaintext</a></code>, <code><a href=#the-pre-element>pre</a></code>,
    <code><a href=#the-script-element>script</a></code>, <code><a href=#the-section-element>section</a></code>, <code><a href=#the-select-element>select</a></code>, <code><a href=#the-source-element>source</a></code>,
    <code><a href=#the-style-element>style</a></code>, <code><a href=#the-summary-element>summary</a></code>, <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>,
-   <code><a href=#the-td-element>td</a></code>, <code><a href=#the-textarea-element>textarea</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-th-element>th</a></code>, <code><a href=#the-thead-element>thead</a></code>,
+   <code><a href=#the-td-element>td</a></code>, <code><a href=#the-template-element>template</a></code>, <code><a href=#the-textarea-element>textarea</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-th-element>th</a></code>, <code><a href=#the-thead-element>thead</a></code>,
    <code><a href=#the-title-element>title</a></code>, <code><a href=#the-tr-element>tr</a></code>, <code><a href=#the-track-element>track</a></code>, <code><a href=#the-ul-element>ul</a></code>, <code><a href=#the-wbr-element>wbr</a></code>, and
    <code><a href=#xmp>xmp</a></code>; MathML's <code title="">mi</code>, <code title="">mo</code>, <code title="">mn</code>, <code title="">ms</code>, <code title="">mtext</code>, and <code title="">annotation-xml</code>; and SVG's <code title="">foreignObject</code>, <code title="">desc</code>, and <code title="">title</code>.</dd> <!-- we could actually put all
    non-HTML elements in this list, I think -->
@@ -86209,6 +86443,7 @@
    <li><code><a href=#the-th-element>th</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
    <li><code><a href=#the-marquee-element>marquee</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
    <li><code><a href=#the-object-element>object</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
+   <li><code><a href=#the-template-element>template</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
    <li><code title="">mi</code> in the <a href=#mathml-namespace>MathML namespace</a></li>
    <li><code title="">mo</code> in the <a href=#mathml-namespace>MathML namespace</a></li>
    <li><code title="">mn</code> in the <a href=#mathml-namespace>MathML namespace</a></li>
@@ -86239,6 +86474,7 @@
 
   <ul class=brief><li><code><a href=#the-html-element>html</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li> <!-- (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.) -->
    <li><code><a href=#the-table-element>table</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
+   <li><code><a href=#the-template-element>template</a></code> in the <a href=#html-namespace-0>HTML namespace</a></li>
   </ul><p>The <a href=#stack-of-open-elements>stack of open elements</a> is said to <dfn id=has-an-element-in-select-scope title="has an element in select
   scope">have an element in select scope</dfn> when it <a href=#has-an-element-in-the-specific-scope>has an element in the specific
   scope</a> consisting of all element types <em>except</em> the following:</p>
@@ -88637,6 +88873,9 @@
 
   <h5 id=creating-and-inserting-nodes><span class=secno>12.2.5.1 </span>Creating and inserting nodes</h5>
 
+  <p>While the parser is processing a token, it can enable or disable <dfn id=foster-parent title="foster
+  parent">foster parenting</dfn>. This affects the following algorithm.</p>
+
   <p>The <dfn id=appropriate-place-for-inserting-a-node>appropriate place for inserting a node</dfn>, optionally using a particular
   <i>override target</i>, is the position in an element returned by running the following steps:</p>
 
@@ -88654,42 +88893,59 @@
     <p>Determine the <var title="">adjusted insertion location</var> using the first matching steps
     from the following list:</p>
 
-    <dl class=switch><dt>If <dfn id=foster-parent title="foster parent">foster parenting</dfn> is enabled and <var title="">target</var> is a <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>,
+    <dl class=switch><dt>If <a href=#foster-parent title="foster parent">foster parenting</a> is enabled and <var title="">target</var> is a <code><a href=#the-table-element>table</a></code>, <code><a href=#the-tbody-element>tbody</a></code>, <code><a href=#the-tfoot-element>tfoot</a></code>,
      <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-tr-element>tr</a></code> element</dt>
 
      <dd>
 
       <p class=note>Foster parenting happens when content is misnested in tables.</p>
 
-      <p>The <dfn id=foster-parent-element>foster parent element</dfn> is the parent element of the last <code><a href=#the-table-element>table</a></code>
-      element in the <a href=#stack-of-open-elements>stack of open elements</a>, if there is a <code><a href=#the-table-element>table</a></code> element and
-      it has such a parent element.</p>
+      <p>Run these substeps:</p>
 
-      <p class=note>It might have no parent or some other kind parent if a script manipulated the
-      DOM after the element was inserted by the parser.</p>
+      <ol><li><p>Let <var title="">last template</var> be the last <code><a href=#the-template-element>template</a></code> element in the
+       <a href=#stack-of-open-elements>stack of open elements</a>, if any.</p>
 
-      <p>If there is no <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>
-      (<a href=#fragment-case>fragment case</a>), then the <i><a href=#foster-parent-element>foster parent element</a></i> is the first element in the
-      <a href=#stack-of-open-elements>stack of open elements</a> (the <code><a href=#the-html-element>html</a></code> element). Otherwise, if there is a
-      <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>, but the last
-      <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a> has no parent, or its
-      parent node is not an element, then the <i><a href=#foster-parent-element>foster parent element</a></i> is the element before the
-      last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>.</p>
+       <li><p>Let <var title="">last table</var> be the last <code><a href=#the-table-element>table</a></code> element in the
+       <a href=#stack-of-open-elements>stack of open elements</a>, if any.</p>
 
-      <p>If the <i><a href=#foster-parent-element>foster parent element</a></i> is the parent element of the last <code><a href=#the-table-element>table</a></code>
-      element in the <a href=#stack-of-open-elements>stack of open elements</a>, then the <var title="">adjusted insertion
-      location</var> is inside the <i><a href=#foster-parent-element>foster parent element</a></i>, immediately <em>before</em> the
-      last <code><a href=#the-table-element>table</a></code> element in the <a href=#stack-of-open-elements>stack of open elements</a>; otherwise, the
-      <var title="">adjusted insertion location</var> is inside the <i><a href=#foster-parent-element>foster parent element</a></i>,
-      after its last child (if any).</p>
+       <li><p>If there is a <var title="">last template</var> and either there is no <var title="">last table</var>, or there is one, but <var title="">last template</var> is lower
+       (more recently added) than <var title="">last table</var> in the <a href=#stack-of-open-elements>stack of open
+       elements</a>, then: let <var title="">adjusted insertion location</var> be inside <var title="">last template</var>'s <a href=#template-contents>template contents</a>, after its last child (if any),
+       and abort these substeps.</li>
 
+       <li><p>If there is no <var title="">last table</var>, <!-- there's also implicitly no last
+       template, since we didn't hit the previous step --> then let <var title="">adjusted insertion
+       location</var> be inside the first element in the <a href=#stack-of-open-elements>stack of open elements</a> (the
+       <code><a href=#the-html-element>html</a></code> element), after its last child (if any), and abort these substeps.
+       (<a href=#fragment-case>fragment case</a>)</p>
+
+       <!-- if we get here, we know there's a last table, and if there's a last template, it's older
+       than the last table. -->
+
+       <li><p>If <var title="">last table</var> has a parent element, then let <var title="">adjusted insertion location</var> be inside <var title="">last table</var>'s parent
+       element, immediately before <var title="">last table</var>, and abort these
+       substeps.</li>
+
+       <!-- if we get here, we know there's a last table, but it has no parent, and if there's a
+       last template, it's older than the last table. -->
+
+       <li><p>Let <var title="">previous element</var> be the element immediately above <var title="">last table</var> in the <a href=#stack-of-open-elements>stack of open elements</a>.</li>
+
+       <li><p>Let <var title="">adjusted insertion location</var> be inside <var title="">previous
+       element</var>, after its last child (if any).</li>
+
+      </ol><p class=note>These steps are involved in part because it's possible for elements, the
+      <code><a href=#the-table-element>table</a></code> element in this case in particular, to have been moved by a script around
+      in the DOM, or indeed removed from the DOM entirely, after the element was inserted by the
+      parser.</p>
+
      </dd>
 
      <dt>Otherwise</dt>
 
      <dd>
 
-      <p>The <var title="">adjusted insertion location</var> is inside <var title="">target</var>,
+      <p>Let <var title="">adjusted insertion location</var> be inside <var title="">target</var>,
       after its last child (if any).</p>
 
      </dd>
@@ -88698,6 +88954,14 @@
 
    <li>
 
+    <p>If the <var title="">adjusted insertion location</var> is inside a <code><a href=#the-template-element>template</a></code>
+    element, let it instead be inside the <code><a href=#the-template-element>template</a></code> element's <a href=#template-contents>template
+    contents</a>, after its last child (if any).</p>
+
+   </li>
+
+   <li>
+
     <p>Return the <var title="">adjusted insertion location</var>.</p>
 
    </li>
@@ -88754,9 +89018,18 @@
    pointer</a>, and suppress the running of the <a href=#reset-the-form-owner>reset the form owner</a> algorithm in
    the next step.</li>
 
-   <li><p>Insert the newly created element at the <var title="">adjusted insertion
-   location</var>.</li>
+   <li>
 
+    <p>If it is possible to insert an element at the <var title="">adjusted insertion
+    location</var>, then insert the newly created element at the <var title="">adjusted insertion
+    location</var>.</p>
+
+    <p class=note>If the <var title="">adjusted insertion location</var> cannot accept more
+    elements, e.g. because it's a <code><a href=#document>Document</a></code> that already has an element child, then the
+    newly created element is dropped on the floor.</p>
+
+   </li>
+
    <li><p>Push the element onto the <a href=#stack-of-open-elements>stack of open elements</a> so that it is the new
    <a href=#current-node>current node</a>.</li>
 
@@ -88882,6 +89155,16 @@
 
    <li>
 
+    <p>If the <var title="">adjusted insertion location</var> is in a <code><a href=#document>Document</a></code> node,
+    then abort these steps.
+
+    <p class=note>The DOM will not let <code><a href=#document>Document</a></code> nodes have <code><a href=#text>Text</a></code> node
+    children, so they are dropped on the floor.</p>
+
+   </li>
+
+   <li>
+
     <p>If there is a <code><a href=#text>Text</a></code> node immediately before the <var title="">adjusted insertion
     location</var>, then append <var title="">data</var> to that <code><a href=#text>Text</a></code> node's data.</p>
 
@@ -89407,6 +89690,7 @@
 
    </dd>
 
+
    <dt id=scriptTag>A start tag whose tag name is "script"</dt>
    <dd>
 
@@ -89470,6 +89754,53 @@
     <p>Act as described in the "anything else" entry below.</p>
    </dd>
 
+   <dt>A start tag whose tag name is "template"</dt>
+   <dd>
+
+    <p><a href=#insert-an-html-element>Insert an HTML element</a> for the token.</p>
+
+    <p>Insert a marker at the end of the <a href=#list-of-active-formatting-elements>list of active formatting elements</a>.</p>
+
+    <p>Set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intemplate title="insertion mode: in template">in
+    template</a>".</p>
+
+    <p>Push "<a href=#parsing-main-intemplate title="insertion mode: in template">in template</a>" onto the <a href=#stack-of-template-insertion-modes>stack of
+    template insertion modes</a> so that it is the new <a href=#current-template-insertion-mode>current template insertion
+    mode</a>.</p>
+
+   </dd>
+
+   <dt>An end tag whose tag name is "template"</dt>
+   <dd>
+
+    <p>If there is no <code><a href=#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements>stack of open elements</a>, then
+    this is a <a href=#parse-error>parse error</a>; ignore the token.</p>
+
+    <p>Otherwise, run these steps:</p>
+
+    <ol><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>.</li>
+
+     <li><p>If the <a href=#current-node>current node</a> is not an element with
+     the same tag name as that of the token, then this is a
+     <a href=#parse-error>parse error</a>.</li>
+
+     <li><p>Pop elements from the <a href=#stack-of-open-elements>stack of open elements</a>
+     until an element with the same tag name as the token has been
+     popped from the stack.</li>
+
+     <li><a href=#clear-the-list-of-active-formatting-elements-up-to-the-last-marker>Clear the list of active formatting elements up to the
+     last marker</a>.</li>
+
+     <li><p>Pop the <a href=#current-template-insertion-mode>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes>stack of template
+     insertion modes</a>.</p>
+
+     <li><p><a href=#reset-the-insertion-mode-appropriately title="reset the insertion mode appropriately">Reset the
+     parser's insertion mode appropriately</a>.</li>
+
+    </ol></dd>
+
    <dt>A start tag whose tag name is "head"</dt>
    <dt>Any other end tag</dt>
    <dd>
@@ -89689,7 +90020,12 @@
 
    <dt>A start tag whose tag name is "html"</dt>
    <dd>
-    <p><a href=#parse-error>Parse error</a>. For each attribute on the token,
+    <p><a href=#parse-error>Parse error</a>.</p>
+
+    <p>If there is a <code><a href=#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements>stack of open elements</a>, then
+    ignore the token.</p>
+
+    <p>Otherwise, for each attribute on the token,
     check to see if the attribute is already present on the top
     element of the <a href=#stack-of-open-elements>stack of open elements</a>. If it is not,
     add the attribute and its corresponding value to that element.</p>
@@ -89708,8 +90044,9 @@
     <p><a href=#parse-error>Parse error</a>.</p>
 
     <p>If the second element on the <a href=#stack-of-open-elements>stack of open
-    elements</a> is not a <code><a href=#the-body-element>body</a></code> element, or, if the
+    elements</a> is not a <code><a href=#the-body-element>body</a></code> element, if the
     <a href=#stack-of-open-elements>stack of open elements</a> has only one node on it,
+    or if there is a <code><a href=#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements>stack of open elements</a>,
     then ignore the token. (<a href=#fragment-case>fragment case</a>)</p>
 
     <p>Otherwise, set the <a href=#frameset-ok-flag>frameset-ok flag</a> to "not ok";
@@ -89726,6 +90063,7 @@
 
     <p><a href=#parse-error>Parse error</a>.</p>
 
+<!--CLEANUP--><!--should switch these clauses around-->
     <p>If the second element on the <a href=#stack-of-open-elements>stack of open
     elements</a> is not a <code><a href=#the-body-element>body</a></code> element, or, if the
     <a href=#stack-of-open-elements>stack of open elements</a> has only one node on it,
@@ -89763,8 +90101,13 @@
     this is a <a href=#parse-error>parse error</a>.</p> <!-- (some of those are
     fragment cases) -->
 
-    <p><a href=#stop-parsing>Stop parsing</a>.</p>
+    <p>If the <a href=#stack-of-template-insertion-modes>stack of template insertion modes</a> is not empty, then process the token
+    <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-intemplate title="insertion mode: in template">in
+    template</a>" <a href=#insertion-mode>insertion mode</a>.</p>
+    <!-- this is needed to handle <head><template>...[EOF] - otherwise we don't construct the <body> element -->
 
+    <p>Otherwise, <a href=#stop-parsing>stop parsing</a>.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is "body"</dt>
@@ -90811,6 +91154,15 @@
 
    </dd>
 
+   <dt>A start tag whose tag name is "template"</dt>
+   <dt>An end tag whose tag name is "template"</dt>
+   <dd>
+
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
+
+   </dd>
+
    <dt>A start <!--or end--> tag whose tag name is one of: "caption",
    "col", "colgroup", "frame", "head", "tbody", "td", "tfoot", "th",
    "thead", "tr"</dt>
@@ -91107,9 +91459,6 @@
     the tag name "table" had been seen, then, if that token wasn't
     ignored, reprocess the current token.</p>
 
-    <p class=note>The fake end tag token here can only be
-    ignored in the <a href=#fragment-case>fragment case</a>.</p>
-
    </dd>
 
    <dt>An end tag whose tag name is "table"</dt>
@@ -91117,8 +91466,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope 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=#parse-error>parse error</a>. Ignore the token. (<a href=#fragment-case>fragment
-    case</a>)</p>
+    <a href=#parse-error>parse error</a>. Ignore the token.</p>
 
     <p>Otherwise:</p>
 
@@ -91187,18 +91535,21 @@
 
    <!-- "form" end tag falls through to in-body, which does the right thing -->
 
-   <dt>An end-of-file token</dt>
+   <dt>A start tag whose tag name is "template"</dt>
+   <dt>An end tag whose tag name is "template"</dt>
    <dd>
 
-    <p>If the <a href=#current-node>current node</a> is not the root
-    <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
-    error</a>.</p>
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
 
-    <p class=note>The <a href=#current-node>current node</a> can only be the root
-    <code><a href=#the-html-element>html</a></code> element in the <a href=#fragment-case>fragment case</a>.</p>
+   </dd>
 
-    <p><a href=#stop-parsing>Stop parsing</a>.</p>
+   <dt>An end-of-file token</dt>
+   <dd>
 
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
+
    </dd>
 
    <dt>Anything else</dt>
@@ -91213,8 +91564,8 @@
 
   </dl><p>When the steps above require the UA to <dfn id=clear-the-stack-back-to-a-table-context>clear the stack
   back to a table context</dfn>, it means that the UA must, while
-  the <a href=#current-node>current node</a> is not a <code><a href=#the-table-element>table</a></code>
-  element or an <code><a href=#the-html-element>html</a></code> element, pop elements from the
+  the <a href=#current-node>current node</a> is not a <code><a href=#the-table-element>table</a></code>,
+  <code><a href=#the-template-element>template</a></code>, or <code><a href=#the-html-element>html</a></code> element, pop elements from the
   <a href=#stack-of-open-elements>stack of open elements</a>.</p>
 
   <p class=note>The <a href=#current-node>current node</a> being an
@@ -91375,13 +91726,10 @@
    <dt>An end tag whose tag name is "colgroup"</dt>
    <dd>
 
-    <p>If the <a href=#current-node>current node</a> is the root
-    <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
-    error</a>; ignore the token. (<a href=#fragment-case>fragment
-    case</a>)</p>
+    <p>If the <a href=#current-node>current node</a> is not a <code><a href=#the-colgroup-element>colgroup</a></code> element, then this is a <a href=#parse-error>parse
+    error</a>; ignore the token.</p> <!-- e.g. colgroup fragment case, or <template><col></colgroup> -->
 
-    <p>Otherwise, pop the <a href=#current-node>current node</a> (which will be
-    a <code><a href=#the-colgroup-element>colgroup</a></code> element) from the <a href=#stack-of-open-elements>stack of open
+    <p>Otherwise, pop the <a href=#current-node>current node</a> from the <a href=#stack-of-open-elements>stack of open
     elements</a>. Switch the <a href=#insertion-mode>insertion mode</a> to
     "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>".</p>
 
@@ -91392,16 +91740,21 @@
     <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
    </dd>
 
+   <dt>A start tag whose tag name is "template"</dt>
+   <dt>An end tag whose tag name is "template"</dt>
+   <dd>
+
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
+
+   </dd>
+
    <dt>An end-of-file token</dt>
    <dd>
 
-    <p>If the <a href=#current-node>current node</a> is the root <code><a href=#the-html-element>html</a></code>
-    element, then <a href=#stop-parsing>stop parsing</a>. (<a href=#fragment-case>fragment
-    case</a>)</p>
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
 
-    <p>Otherwise, act as described in the "anything else" entry
-    below.</p>
-
    </dd>
 
    <dt>Anything else</dt>
@@ -91411,9 +91764,6 @@
     seen, and then, if that token wasn't ignored, reprocess the
     current token.</p>
 
-    <p class=note>The fake end tag token here can only be
-    ignored in the <a href=#fragment-case>fragment case</a>.</p>
-
    </dd>
 
   </dl><h6 id=parsing-main-intbody><span class=secno>12.2.5.4.13 </span>The "<dfn title="insertion mode: in table body">in table body</dfn>" insertion mode</h6>
@@ -91466,8 +91816,7 @@
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope 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=#parse-error>parse
-    error</a>. Ignore the token. (<a href=#fragment-case>fragment
-    case</a>)</p>
+    error</a>. Ignore the token.</p>
 
     <p>Otherwise:</p>
 
@@ -91495,7 +91844,7 @@
   </dl><p>When the steps above require the UA to <dfn id=clear-the-stack-back-to-a-table-body-context>clear the stack
   back to a table body context</dfn>, it means that the UA must,
   while the <a href=#current-node>current node</a> is not a <code><a href=#the-tbody-element>tbody</a></code>,
-  <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-thead-element>thead</a></code>, or <code><a href=#the-html-element>html</a></code>
+  <code><a href=#the-tfoot-element>tfoot</a></code>, <code><a href=#the-thead-element>thead</a></code>, <code><a href=#the-template-element>template</a></code>, or <code><a href=#the-html-element>html</a></code>
   element, pop elements from the <a href=#stack-of-open-elements>stack of open
   elements</a>.</p>
 
@@ -91528,8 +91877,7 @@
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope 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=#parse-error>parse error</a>. Ignore the token. (<a href=#fragment-case>fragment
-    case</a>)</p>
+    <a href=#parse-error>parse error</a>. Ignore the token.</p>
 
     <p>Otherwise:</p>
 
@@ -91553,9 +91901,6 @@
     then, if that token wasn't ignored, reprocess the current
     token.</p>
 
-    <p class=note>The fake end tag token here can only be
-    ignored in the <a href=#fragment-case>fragment case</a>.</p>
-
    </dd>
 
    <dt>An end tag whose tag name is one of: "tbody", "tfoot",
@@ -91585,8 +91930,8 @@
 
   </dl><p>When the steps above require the UA to <dfn id=clear-the-stack-back-to-a-table-row-context>clear the stack
   back to a table row context</dfn>, it means that the UA must,
-  while the <a href=#current-node>current node</a> is not a <code><a href=#the-tr-element>tr</a></code>
-  element or an <code><a href=#the-html-element>html</a></code> element, pop elements from the
+  while the <a href=#current-node>current node</a> is not a <code><a href=#the-tr-element>tr</a></code>,
+  <code><a href=#the-template-element>template</a></code>, or <code><a href=#the-html-element>html</a></code> element, pop elements from the
   <a href=#stack-of-open-elements>stack of open elements</a>.</p>
 
   <p class=note>The <a href=#current-node>current node</a> being an
@@ -91623,7 +91968,7 @@
 
     <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intr title="insertion mode: in row">in row</a>".</p> <!-- current
     node here will be a <tr> normally; but could be <html> in the
-    fragment case -->
+    fragment case, or <template> in the template case -->
 
    </dd>
 
@@ -91653,9 +91998,7 @@
    <dd>
 
     <p>If the <a href=#stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope title="has an element in table scope">have an element 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-case>fragment case</a>), then this is a <a href=#parse-error>parse
+    scope</a> with the same tag name as that of the token, then this is a <a href=#parse-error>parse
     error</a> and the token must be ignored.</p>
 
     <p>Otherwise, <a href=#close-the-cell>close the cell</a> (see below) and
@@ -91816,18 +92159,21 @@
     mode</a>.</p>
    </dd>
 
-   <dt>An end-of-file token</dt>
+   <dt>A start tag whose tag name is "template"</dt>
+   <dt>An end tag whose tag name is "template"</dt>
    <dd>
 
-    <p>If the <a href=#current-node>current node</a> is not the root
-    <code><a href=#the-html-element>html</a></code> element, then this is a <a href=#parse-error>parse
-    error</a>.</p>
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
 
-    <p class=note>The <a href=#current-node>current node</a> can only be the root
-    <code><a href=#the-html-element>html</a></code> element in the <a href=#fragment-case>fragment case</a>.</p>
+   </dd>
 
-    <p><a href=#stop-parsing>Stop parsing</a>.</p>
+   <dt>An end-of-file token</dt>
+   <dd>
 
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
+
    </dd>
 
    <dt>Anything else</dt>
@@ -91866,8 +92212,124 @@
     mode</a>.</p>
    </dd>
 
-  </dl><h6 id=parsing-main-afterbody><span class=secno>12.2.5.4.18 </span>The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h6>
+  </dl><h6 id=parsing-main-intemplate><span class=secno>12.2.5.4.18 </span>The "<dfn title="insertion mode: in template">in template</dfn>" insertion mode</h6>
 
+  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-intemplate title="insertion mode: in template">in template</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
+
+  <dl class=switch><!-- first, tokens we always ignore: --><!-- html: ignored in "in body" mode if there's a <template> on the stack --><!-- head: ignored in "in body" mode always --><!-- body: ignored in "in body" mode if there's a <template> on the stack --><!-- frameset: ignored in "in body" mode if frameset-ok is set to not-ok, which <template> sets it to --><!-- second, tokens that are ambiguous (allowed in multiple modes), let's just handle them in a generic way and not pick a mode: --><dt>A character token</dt>
+   <dt>A comment token</dt>
+   <dt>A DOCTYPE token</dt>
+   <dd>
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
+   </dd>
+
+   <dt>A start tag whose tag name is one of: "base", "basefont", "bgsound", "link", "meta", "noframes", "script", "style", "title"</dt>
+   <dt>A start tag whose tag name is "template"</dt>
+   <dt>An end tag whose tag name is "template"</dt>
+   <dd>
+    <p>Process the token <a href=#using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion
+    mode</a>.</p>
+   </dd>
+
+   <!-- now, tokens that imply certain modes -->
+
+   <dt>A start tag whose tag name is one of: "caption", "colgroup", "tbody", "tfoot", "thead"</dt>
+   <dd>
+
+    <p>Pop the <a href=#current-template-insertion-mode>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes>stack of template
+    insertion modes</a>.</p>
+
+    <p>Push "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>" onto the <a href=#stack-of-template-insertion-modes>stack of
+    template insertion modes</a> so that it is the new <a href=#current-template-insertion-mode>current template insertion
+    mode</a>.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intable title="insertion mode: in table">in
+    table</a>", and reprocess the token.</p>
+
+   </dd>
+
+   <dt>A start tag whose tag name is "col"</dt>
+   <dd>
+
+    <p>Pop the <a href=#current-template-insertion-mode>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes>stack of template
+    insertion modes</a>.</p>
+
+    <p>Push "<a href=#parsing-main-incolgroup title="insertion mode: in column group">in column group</a>" onto the
+    <a href=#stack-of-template-insertion-modes>stack of template insertion modes</a> so that it is the new <a href=#current-template-insertion-mode>current template
+    insertion mode</a>.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-incolgroup title="insertion mode: in column group">in
+    column group</a>", and reprocess the token.</p>
+
+   </dd>
+
+   <dt>A start tag whose tag name is "tr"</dt>
+   <dd>
+
+    <p>Pop the <a href=#current-template-insertion-mode>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes>stack of template
+    insertion modes</a>.</p>
+
+    <p>Push "<a href=#parsing-main-intbody title="insertion mode: in table body">in table body</a>" onto the <a href=#stack-of-template-insertion-modes>stack
+    of template insertion modes</a> so that it is the new <a href=#current-template-insertion-mode>current template insertion
+    mode</a>.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intbody title="insertion mode: in table body">in
+    table body</a>", and reprocess the token.</p>
+
+   </dd>
+
+   <dt>A start tag whose tag name is one of: "td", "th"</dt>
+   <dd>
+
+    <p>Pop the <a href=#current-template-insertion-mode>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes>stack of template
+    insertion modes</a>.</p>
+
+    <p>Push "<a href=#parsing-main-intr title="insertion mode: in row">in row</a>" onto the <a href=#stack-of-template-insertion-modes>stack of template
+    insertion modes</a> so that it is the new <a href=#current-template-insertion-mode>current template insertion mode</a>.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-intr title="insertion mode: in row">in
+    row</a>", and reprocess the token.</p>
+
+   </dd>
+
+   <!-- default to in-body mode -->
+
+   <dt>Any other start tag</dt>
+   <dd>
+
+    <p>Pop the <a href=#current-template-insertion-mode>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes>stack of template
+    insertion modes</a>.</p>
+
+    <p>Push "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" onto the <a href=#stack-of-template-insertion-modes>stack of template
+    insertion modes</a> so that it is the new <a href=#current-template-insertion-mode>current template insertion mode</a>.</p>
+
+    <p>Switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-inbody title="insertion mode: in body">in
+    body</a>", and reprocess the token.</p>
+
+   </dd>
+
+   <dt>Any other end tag</dt>
+   <dd>
+    <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
+   </dd>
+
+   <!-- EOF -->
+
+
+   <dt>An end-of-file token</dt>
+   <dd>
+
+    <p>If there is no <code><a href=#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements>stack of open elements</a>, then
+    <a href=#stop-parsing>stop parsing</a>. (<a href=#fragment-case>fragment case</a>)</p>
+
+    <p>Otherwise, this is a <a href=#parse-error>parse error</a>; act as if an end tag with the tag name
+    "template" had been seen and reprocess the current token.</p>
+
+   </dd>
+
+  </dl><h6 id=parsing-main-afterbody><span class=secno>12.2.5.4.19 </span>The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h6>
+
   <p>When the user agent is to apply the rules for the "<a href=#parsing-main-afterbody title="insertion mode: after body">after body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
   <dl class=switch><dt>A character token that is one of U+0009 CHARACTER
@@ -91922,7 +92384,7 @@
 
    </dd>
 
-  </dl><h6 id=parsing-main-inframeset><span class=secno>12.2.5.4.19 </span>The "<dfn title="insertion mode: in frameset">in frameset</dfn>" insertion mode</h6>
+  </dl><h6 id=parsing-main-inframeset><span class=secno>12.2.5.4.20 </span>The "<dfn title="insertion mode: in frameset">in frameset</dfn>" insertion mode</h6>
 
   <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inframeset title="insertion mode: in frameset">in frameset</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
@@ -92011,7 +92473,7 @@
     <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
    </dd>
 
-  </dl><h6 id=parsing-main-afterframeset><span class=secno>12.2.5.4.20 </span>The "<dfn title="insertion mode: after frameset">after frameset</dfn>" insertion mode</h6>
+  </dl><h6 id=parsing-main-afterframeset><span class=secno>12.2.5.4.21 </span>The "<dfn title="insertion mode: after frameset">after frameset</dfn>" insertion mode</h6>
 
   <p>When the user agent is to apply the rules for the "<a href=#parsing-main-afterframeset title="insertion mode: after frameset">after frameset</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
@@ -92061,7 +92523,7 @@
     <p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
    </dd>
 
-  </dl><h6 id=the-after-after-body-insertion-mode><span class=secno>12.2.5.4.21 </span>The "<dfn title="insertion mode: after after body">after after body</dfn>" insertion mode</h6>
+  </dl><h6 id=the-after-after-body-insertion-mode><span class=secno>12.2.5.4.22 </span>The "<dfn title="insertion mode: after after body">after after body</dfn>" insertion mode</h6>
 
   <p>When the user agent is to apply the rules for the "<a href=#the-after-after-body-insertion-mode title="insertion mode: after after body">after after body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
@@ -92092,7 +92554,7 @@
     reprocess the token.</p>
    </dd>
 
-  </dl><h6 id=the-after-after-frameset-insertion-mode><span class=secno>12.2.5.4.22 </span>The "<dfn title="insertion mode: after after frameset">after after frameset</dfn>" insertion mode</h6>
+  </dl><h6 id=the-after-after-frameset-insertion-mode><span class=secno>12.2.5.4.23 </span>The "<dfn title="insertion mode: after after frameset">after after frameset</dfn>" insertion mode</h6>
 
   <p>When the user agent is to apply the rules for the "<a href=#the-after-after-frameset-insertion-mode title="insertion mode: after after frameset">after after frameset</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
 
@@ -92849,6 +93311,7 @@
   been seen up to this point.</p>
 
 
+<!--/HTMLPARSER-->
 
 
   <h3 id=serializing-html-fragments><span class=secno>12.3 </span>Serializing HTML fragments</h3>
@@ -92865,6 +93328,9 @@
   <ol><li><p>Let <var title="">s</var> be a string, and initialize it to
    the empty string.</li>
 
+   <li><p>If <var title="">the node</var> is a <code><a href=#the-template-element>template</a></code> element, then let <var title="">the node</var> instead be the <code><a href=#the-template-element>template</a></code> element's <a href=#template-contents>template
+   contents</a> (a <code><a href=#documentfragment>DocumentFragment</a></code> node).</li>
+
    <li>
 
     <p>For each child node of <var title="">the node</var>, in
@@ -93233,6 +93699,15 @@
 
      <li>
 
+      <p>If the <var title=concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element is a
+      <code><a href=#the-template-element>template</a></code> element, push "<a href=#parsing-main-intemplate title="insertion mode: in template">in
+      template</a>" onto the <a href=#stack-of-template-insertion-modes>stack of template insertion modes</a> so that it is the new
+      <a href=#current-template-insertion-mode>current template insertion mode</a>.</p>
+
+     </li>
+
+     <li>
+
       <p><a href=#reset-the-insertion-mode-appropriately title="reset the insertion mode appropriately">Reset the
       parser's insertion mode appropriately</a>.</p>
 
@@ -93351,6 +93826,8 @@
   the rules given in the XML specification to map a string of bytes or characters into a
   <code><a href=#document>Document</a></code> object.</p>
 
+  <p class=note>At the time of writing, no such rules actually exist.</p>
+
   <p>An <a href=#xml-parser>XML parser</a> is either associated with a <code><a href=#document>Document</a></code> object when it is
   created, or creates one implicitly.</p>
 
@@ -93421,6 +93898,17 @@
   available for <a href=#xml-documents>XML documents</a>, much of the complexity in the <a href=#html-parser>HTML parser</a>
   is not needed in the <a href=#xml-parser>XML parser</a>.</p>
 
+  <p id=templateTagXML>When an <a href=#xml-parser>XML parser</a> would append a node to a
+  <code><a href=#the-template-element>template</a></code> element, it must instead append it to the <code><a href=#the-template-element>template</a></code> element's
+  <a href=#template-contents>template contents</a> (a <code><a href=#documentfragment>DocumentFragment</a></code> node).</p>
+
+  <p class=note>This is a <a href=#willful-violation>willful violation</a> of the XML specification; unfortunately,
+  XML is not formally extensible in the manner that is needed for <code><a href=#the-template-element>template</a></code> processing.
+  <a href=#refsXML>[XML]</a></p>
+
+  <p>When an <a href=#xml-parser>XML parser</a> creates a <code><a href=#node>Node</a></code> object, its <code title=dom-Node-ownerDocument><a href=#dom-node-ownerdocument>ownerDocument</a></code> must be set to the <code><a href=#document>Document</a></code> of
+  the node into which the newly created node is to be inserted.</p>
+
   <p>Certain algorithms in this specification <dfn id=feed-the-parser title="feed the parser">spoon-feed the
   parser</dfn> characters one string at a time. In such cases, the <a href=#xml-parser>XML parser</a> must act
   as it would have if faced with a single string consisting of the concatenation of all those
@@ -93435,7 +93923,9 @@
   syntax</a>, then it is an <a href=#xml-documents title="XML documents">XML document</a>.</p>
 
 
+<!--//HTMLPARSER-->
 
+
   <h3 id=serializing-xhtml-fragments><span class=secno>13.3 </span>Serializing XHTML fragments</h3>
 
   <p>The <dfn id=xml-fragment-serialization-algorithm>XML fragment serialization algorithm</dfn> for a
@@ -93453,14 +93943,25 @@
 
   <p>In both cases, the string returned must be XML
   namespace-well-formed and must be an isomorphic serialization of all
-  of that node's child nodes, in <a href=#tree-order>tree order</a>. User agents
+  of that node's <a href=#relevant-child-nodes>relevant child nodes</a>, in <a href=#tree-order>tree order</a>. User agents
   may adjust prefixes and namespace declarations in the serialization
   (and indeed might be forced to do so in some cases to obtain
   namespace-well-formed XML). User agents may use a combination of
   regular text and character references to represent
   <code><a href=#text>Text</a></code> nodes in the DOM.</p>
 
-  <p>For <code><a href=#element>Element</a></code>s, if any of the elements in the
+  <p>A node's <dfn id=relevant-child-nodes>relevant child nodes</dfn> are those that apply given the following rules:</p>
+
+  <dl><dt>For <code><a href=#the-template-element>template</a></code> elements</dt>
+
+   <dd>The <a href=#relevant-child-nodes>relevant child nodes</a> are the child nodes of the <code><a href=#the-template-element>template</a></code>
+   element's <a href=#template-contents>template contents</a>, if any.</dd>
+
+   <dt>For all other nodes</dt>
+
+   <dd>The <a href=#relevant-child-nodes>relevant child nodes</a> are the child nodes of node itself, if any.</dd>
+
+  </dl><p>For <code><a href=#element>Element</a></code>s, if any of the elements in the
   serialization are in no namespace, the default namespace in scope
   for those elements must be explicitly declared as the empty
   string.<!-- because otherwise round-tripping might break since it'll
@@ -93717,7 +94218,7 @@
 
 [hidden], area, base, basefont, datalist, head, input[type=hidden i],
 link, menu[type=popup i], meta, noembed, noframes, param, rp, script,
-source, style, track, title {
+source, style, template, track, title {
   display: none;
 }
 
@@ -98715,7 +99216,8 @@
     <tr><th><code><a href=#the-base-element>base</a></code></th>
      <td>Base URL and default target <a href=#browsing-context>browsing context</a> for <a href=#attr-hyperlink-target title=attr-hyperlink-target>hyperlinks</a> and <a href=#attr-fs-target title=attr-fs-target>forms</a></td>
      <td><a href=#metadata-content title="Metadata content">metadata</a></td>
-     <td><code><a href=#the-head-element>head</a></code></td>
+     <td><code><a href=#the-head-element>head</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td>empty</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-base-href><a href=#attr-base-href>href</a></code>;
@@ -98813,7 +99315,8 @@
     <tr><th><code><a href=#the-caption-element>caption</a></code></th>
      <td>Table caption</td>
      <td>none</td>
-     <td><code><a href=#the-table-element>table</a></code></td>
+     <td><code><a href=#the-table-element>table</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#flow-content title="Flow content">flow</a>*</td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmltablecaptionelement>HTMLTableCaptionElement</a></code></td>
@@ -98836,7 +99339,8 @@
     <tr><th><code><a href=#the-col-element>col</a></code></th>
      <td>Table column</td>
      <td>none</td>
-     <td><code><a href=#the-colgroup-element>colgroup</a></code></td>
+     <td><code><a href=#the-colgroup-element>colgroup</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td>empty</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-col-span><a href=#attr-col-span>span</a></code></td>
@@ -98844,28 +99348,13 @@
     <tr><th><code><a href=#the-colgroup-element>colgroup</a></code></th>
      <td>Group of columns in a table</td>
      <td>none</td>
-     <td><code><a href=#the-table-element>table</a></code></td>
-     <td><code><a href=#the-col-element>col</a></code></td>
+     <td><code><a href=#the-table-element>table</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
+     <td><code><a href=#the-col-element>col</a></code>*;
+         <code><a href=#the-template-element>template</a></code>*</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-colgroup-span><a href=#attr-colgroup-span>span</a></code></td>
      <td><code><a href=#htmltablecolelement>HTMLTableColElement</a></code></td>
-    <tr><th><code><a href=#the-menuitem-element>menuitem</a></code></th>
-     <td>Menu command</td>
-     <td><a href=#metadata-content title="Metadata content">metadata</a>;
-         <a href=#flow-content title="Flow content">flow</a>;
-         <a href=#phrasing-content title="Phrasing content">phrasing</a></td>
-     <td><code><a href=#the-head-element>head</a></code>;
-         <a href=#phrasing-content title="Phrasing content">phrasing</a></td>
-     <td>empty</td>
-     <td><a href=#global-attributes title="global attributes">globals</a>;
-         <code title=attr-menuitem-type><a href=#attr-menuitem-type>type</a></code>;
-         <code title=attr-menuitem-label><a href=#attr-menuitem-label>label</a></code>;
-         <code title=attr-menuitem-icon><a href=#attr-menuitem-icon>icon</a></code>;
-         <code title=attr-menuitem-disabled><a href=#attr-menuitem-disabled>disabled</a></code>;
-         <code title=attr-menuitem-checked><a href=#attr-menuitem-checked>checked</a></code>;
-         <code title=attr-menuitem-radiogroup><a href=#attr-menuitem-radiogroup>radiogroup</a></code>;
-         <code title=attr-menuitem-command><a href=#attr-menuitem-command>command</a></code></td>
-     <td><code><a href=#htmlmenuitemelement>HTMLMenuItemElement</a></code></td>
     <tr><th><code><a href=#the-data-element>data</a></code></th>
      <td>Machine-readable equivalent</td>
      <td><a href=#flow-content title="Flow content">flow</a>;
@@ -98887,7 +99376,8 @@
     <tr><th><code><a href=#the-dd-element>dd</a></code></th>
      <td>Content for corresponding <code><a href=#the-dt-element>dt</a></code> element(s)</td>
      <td>none</td>
-     <td><code><a href=#the-dl-element>dl</a></code></td>
+     <td><code><a href=#the-dl-element>dl</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmlelement>HTMLElement</a></code></td>
@@ -98924,10 +99414,8 @@
      <td>Dialog box or window</td>
      <td><a href=#flow-content title="Flow content">flow</a>;
          <a href=#sectioning-root title="Sectioning root">sectioning root</a></td>
-     <td><code><a href=#the-dt-element>dt</a></code>;
-         <code><a href=#the-th-element>th</a></code>;
-         <a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
+     <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-dialog-open><a href=#attr-dialog-open>open</a></code></td>
      <td><code><a href=#htmldialogelement>HTMLDialogElement</a></code></td>
@@ -98943,13 +99431,15 @@
      <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><code><a href=#the-dt-element>dt</a></code>*;
-         <code><a href=#the-dd-element>dd</a></code>*</td>
+         <code><a href=#the-dd-element>dd</a></code>*;
+         <code><a href=#the-template-element>template</a></code>*</td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmldlistelement>HTMLDListElement</a></code></td>
     <tr><th><code><a href=#the-dt-element>dt</a></code></th>
      <td>Legend for corresponding <code><a href=#the-dd-element>dd</a></code> element(s)</td>
      <td>none</td>
-     <td><code><a href=#the-dl-element>dl</a></code></td>
+     <td><code><a href=#the-dl-element>dl</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#flow-content title="Flow content">flow</a>*</td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmlelement>HTMLElement</a></code></td>
@@ -98993,7 +99483,8 @@
     <tr><th><code><a href=#the-figcaption-element>figcaption</a></code></th>
      <td>Caption for <code><a href=#the-figure-element>figure</a></code></td>
      <td>none</td>
-     <td><code><a href=#the-figure-element>figure</a></code></td>
+     <td><code><a href=#the-figure-element>figure</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmlelement>HTMLElement</a></code></td>
@@ -99056,7 +99547,7 @@
      <td><a href=#flow-content title="Flow content">flow</a>;
          <a href=#heading-content title="Heading content">heading</a></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
-     <td>One or more <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>, and <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code></td>
+     <td>One or more <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>, <code><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code>, and <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmlelement>HTMLElement</a></code></td>
     <tr><th><code><a href=#the-hr-element>hr</a></code></th>
@@ -99216,14 +99707,18 @@
     <tr><th><code><a href=#the-legend-element>legend</a></code></th>
      <td>Caption for <code><a href=#the-fieldset-element>fieldset</a></code></td>
      <td>none</td>
-     <td><code><a href=#the-fieldset-element>fieldset</a></code></td>
+     <td><code><a href=#the-fieldset-element>fieldset</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmllegendelement>HTMLLegendElement</a></code></td>
     <tr><th><code><a href=#the-li-element>li</a></code></th>
      <td>List item</td>
      <td>none</td>
-     <td><code><a href=#the-ol-element>ol</a></code>; <code><a href=#the-ul-element>ul</a></code>; <code><a href=#the-menu-element>menu</a></code>*</td>
+     <td><code><a href=#the-ol-element>ol</a></code>;
+         <code><a href=#the-ul-element>ul</a></code>;
+         <code><a href=#the-menu-element>menu</a></code>*;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-li-value><a href=#attr-li-value>value</a></code>*</td>
@@ -99234,6 +99729,7 @@
          <a href=#flow-content title="Flow content">flow</a>*;
          <a href=#phrasing-content title="Phrasing content">phrasing</a>*</td>
      <td><code><a href=#the-head-element>head</a></code>;
+         <code><a href=#the-template-element>template</a></code>;
          <code><a href=#the-noscript-element>noscript</a></code>*;
          <a href=#phrasing-content title="phrasing content">phrasing</a>*</td>
      <td>empty</td>
@@ -99280,17 +99776,34 @@
          <a href=#flow-content title="Flow content">flow</a>*;
          <code><a href=#the-menuitem-element>menuitem</a></code>*;
          <code><a href=#the-hr-element>hr</a></code>*;
-         <code><a href=#the-menu-element>menu</a></code>*</td>
+         <code><a href=#the-menu-element>menu</a></code>*;
+         <code><a href=#the-template-element>template</a></code>*</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-menu-type><a href=#attr-menu-type>type</a></code>;
          <code title=attr-menu-label><a href=#attr-menu-label>label</a></code></td>
      <td><code><a href=#htmlmenuelement>HTMLMenuElement</a></code></td>
+    <tr><th><code><a href=#the-menuitem-element>menuitem</a></code></th>
+     <td>Menu command</td>
+     <td>none</td>
+     <td><code><a href=#the-menu-element>menu</a></code>;     
+         <code><a href=#the-template-element>template</a></code></td>
+     <td>empty</td>
+     <td><a href=#global-attributes title="global attributes">globals</a>;
+         <code title=attr-menuitem-type><a href=#attr-menuitem-type>type</a></code>;
+         <code title=attr-menuitem-label><a href=#attr-menuitem-label>label</a></code>;
+         <code title=attr-menuitem-icon><a href=#attr-menuitem-icon>icon</a></code>;
+         <code title=attr-menuitem-disabled><a href=#attr-menuitem-disabled>disabled</a></code>;
+         <code title=attr-menuitem-checked><a href=#attr-menuitem-checked>checked</a></code>;
+         <code title=attr-menuitem-radiogroup><a href=#attr-menuitem-radiogroup>radiogroup</a></code>;
+         <code title=attr-menuitem-command><a href=#attr-menuitem-command>command</a></code></td>
+     <td><code><a href=#htmlmenuitemelement>HTMLMenuItemElement</a></code></td>
     <tr><th><code><a href=#the-meta-element>meta</a></code></th>
      <td>Text metadata</td>
      <td><a href=#metadata-content title="Metadata content">metadata</a>;
          <a href=#flow-content title="Flow content">flow</a>*;
          <a href=#phrasing-content title="Phrasing content">phrasing</a>*</td>
      <td><code><a href=#the-head-element>head</a></code>;
+         <code><a href=#the-template-element>template</a></code>;
          <code><a href=#the-noscript-element>noscript</a></code>*;
          <a href=#phrasing-content title="phrasing content">phrasing</a>*</td>
      <td>empty</td>
@@ -99329,6 +99842,7 @@
          <a href=#flow-content title="Flow content">flow</a>;
          <a href=#phrasing-content title="Phrasing content">phrasing</a></td>
      <td><code><a href=#the-head-element>head</a></code>*;
+         <code><a href=#the-template-element>template</a></code>*;
          <a href=#phrasing-content title="Phrasing content">phrasing</a>*</td>
      <td>varies*</td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
@@ -99359,7 +99873,8 @@
      <td>Ordered list</td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
-     <td><code><a href=#the-li-element>li</a></code></td>
+     <td><code><a href=#the-li-element>li</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-ol-reversed><a href=#attr-ol-reversed>reversed</a></code>;
          <code title=attr-ol-start><a href=#attr-ol-start>start</a></code>;
@@ -99368,8 +99883,10 @@
     <tr><th><code><a href=#the-optgroup-element>optgroup</a></code></th>
      <td>Group of options in a list box</td>
      <td>none</td>
-     <td><code><a href=#the-select-element>select</a></code></td>
-     <td><code><a href=#the-option-element>option</a></code></td>
+     <td><code><a href=#the-select-element>select</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
+     <td><code><a href=#the-option-element>option</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-optgroup-disabled><a href=#attr-optgroup-disabled>disabled</a></code>;
          <code title=attr-optgroup-label><a href=#attr-optgroup-label>label</a></code></td>
@@ -99379,7 +99896,8 @@
      <td>none</td>
      <td><code><a href=#the-select-element>select</a></code>;
          <code><a href=#the-datalist-element>datalist</a></code>;
-         <code><a href=#the-optgroup-element>optgroup</a></code></td>
+         <code><a href=#the-optgroup-element>optgroup</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#text-content title="text content">text</a>*</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-option-disabled><a href=#attr-option-disabled>disabled</a></code>;
@@ -99412,7 +99930,8 @@
     <tr><th><code><a href=#the-param-element>param</a></code></th>
      <td>Parameter for <code><a href=#the-object-element>object</a></code></td>
      <td>none</td>
-     <td><code><a href=#the-object-element>object</a></code></td>
+     <td><code><a href=#the-object-element>object</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td>empty</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-param-name><a href=#attr-param-name>name</a></code>;
@@ -99448,14 +99967,16 @@
     <tr><th><code><a href=#the-rp-element>rp</a></code></th>
      <td>Parenthesis for ruby annotation text</td>
      <td>none</td>
-     <td><code><a href=#the-ruby-element>ruby</a></code></td>
+     <td><code><a href=#the-ruby-element>ruby</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmlelement>HTMLElement</a></code></td>
     <tr><th><code><a href=#the-rt-element>rt</a></code></th>
      <td>Ruby annotation text</td>
      <td>none</td>
-     <td><code><a href=#the-ruby-element>ruby</a></code></td>
+     <td><code><a href=#the-ruby-element>ruby</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmlelement>HTMLElement</a></code></td>
@@ -99542,7 +100063,8 @@
      <td>Media source for <code><a href=#the-video-element>video</a></code> or <code><a href=#the-audio-element>audio</a></code></td>
      <td>none</td>
      <td><code><a href=#the-video-element>video</a></code>;
-         <code><a href=#the-audio-element>audio</a></code></td>
+         <code><a href=#the-audio-element>audio</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td>empty</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-source-src><a href=#attr-source-src>src</a></code>;
@@ -99610,26 +100132,38 @@
          <code><a href=#the-thead-element>thead</a></code>*;
          <code><a href=#the-tbody-element>tbody</a></code>*;
          <code><a href=#the-tfoot-element>tfoot</a></code>*;
-         <code><a href=#the-tr-element>tr</a></code>*</td>
+         <code><a href=#the-tr-element>tr</a></code>*;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmltableelement>HTMLTableElement</a></code></td>
     <tr><th><code><a href=#the-tbody-element>tbody</a></code></th>
      <td>Group of rows in a table</td>
      <td>none</td>
-     <td><code><a href=#the-table-element>table</a></code></td>
-     <td><code><a href=#the-tr-element>tr</a></code></td>
+     <td><code><a href=#the-table-element>table</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
+     <td><code><a href=#the-tr-element>tr</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code></td>
     <tr><th><code><a href=#the-td-element>td</a></code></th>
      <td>Table cell</td>
      <td><a href=#sectioning-root title="Sectioning root">sectioning root</a></td>
-     <td><code><a href=#the-tr-element>tr</a></code></td>
+     <td><code><a href=#the-tr-element>tr</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-tdth-colspan><a href=#attr-tdth-colspan>colspan</a></code>;
          <code title=attr-tdth-rowspan><a href=#attr-tdth-rowspan>rowspan</a></code>;
          <code title=attr-tdth-headers><a href=#attr-tdth-headers>headers</a></code></td>
      <td><code><a href=#htmltabledatacellelement>HTMLTableDataCellElement</a></code></td>
+    <tr><th><code><a href=#the-template-element>template</a></code></th>
+     <td>Template</td>
+     <td><a href=#metadata-content title="Metadata content">metadata</a>;
+         <a href=#flow-content title="Flow content">flow</a>;
+         <a href=#phrasing-content title="Phrasing content">phrasing</a></td>
+     <td colspan=2>it's complicated*</td>
+     <td><a href=#global-attributes title="global attributes">globals</a></td>
+     <td><code><a href=#htmltemplateelement>HTMLTemplateElement</a></code></td>
     <tr><th><code><a href=#the-textarea-element>textarea</a></code></th>
      <td>Multiline text field</td>
      <td><a href=#flow-content title="Flow content">flow</a>;
@@ -99659,14 +100193,17 @@
     <tr><th><code><a href=#the-tfoot-element>tfoot</a></code></th>
      <td>Group of footer rows in a table</td>
      <td>none</td>
-     <td><code><a href=#the-table-element>table</a></code></td>
-     <td><code><a href=#the-tr-element>tr</a></code></td>
+     <td><code><a href=#the-table-element>table</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
+     <td><code><a href=#the-tr-element>tr</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code></td>
     <tr><th><code><a href=#the-th-element>th</a></code></th>
      <td>Table header cell</td>
      <td>none</td>
-     <td><code><a href=#the-tr-element>tr</a></code></td>
+     <td><code><a href=#the-tr-element>tr</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#flow-content title="Flow content">flow</a>*</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-tdth-colspan><a href=#attr-tdth-colspan>colspan</a></code>;
@@ -99678,8 +100215,10 @@
     <tr><th><code><a href=#the-thead-element>thead</a></code></th>
      <td>Group of heading rows in a table</td>
      <td>none</td>
-     <td><code><a href=#the-table-element>table</a></code></td>
-     <td><code><a href=#the-tr-element>tr</a></code></td>
+     <td><code><a href=#the-table-element>table</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
+     <td><code><a href=#the-tr-element>tr</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code></td>
     <tr><th><code><a href=#the-time-element>time</a></code></th>
@@ -99694,7 +100233,8 @@
     <tr><th><code><a href=#the-title-element>title</a></code></th>
      <td>Document title</td>
      <td><a href=#metadata-content title="Metadata content">metadata</a></td>
-     <td><code><a href=#the-head-element>head</a></code></td>
+     <td><code><a href=#the-head-element>head</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#text-content title="text content">text</a>*</td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmltitleelement>HTMLTitleElement</a></code></td>
@@ -99704,16 +100244,19 @@
      <td><code><a href=#the-table-element>table</a></code>;
          <code><a href=#the-thead-element>thead</a></code>;
          <code><a href=#the-tbody-element>tbody</a></code>;
-         <code><a href=#the-tfoot-element>tfoot</a></code></td>
+         <code><a href=#the-tfoot-element>tfoot</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><code><a href=#the-th-element>th</a></code>*;
-         <code><a href=#the-td-element>td</a></code></td>
+         <code><a href=#the-td-element>td</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmltablerowelement>HTMLTableRowElement</a></code></td>
     <tr><th><code><a href=#the-track-element>track</a></code></th>
      <td>Timed text track</td>
      <td>none</td>
      <td><code><a href=#the-audio-element>audio</a></code>;
-         <code><a href=#the-video-element>video</a></code></td>
+         <code><a href=#the-video-element>video</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td>empty</td>
      <td><a href=#global-attributes title="global attributes">globals</a>;
          <code title=attr-track-default><a href=#attr-track-default>default</a></code>;
@@ -99734,7 +100277,8 @@
      <td>List</td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
      <td><a href=#flow-content title="Flow content">flow</a></td>
-     <td><code><a href=#the-li-element>li</a></code></td>
+     <td><code><a href=#the-li-element>li</a></code>;
+         <code><a href=#the-template-element>template</a></code></td>
      <td><a href=#global-attributes title="global attributes">globals</a></td>
      <td><code><a href=#htmlulistelement>HTMLUListElement</a></code></td>
     <tr><th><code><a href=#the-var-element>var</a></code></th>
@@ -99805,6 +100349,7 @@
       <code><a href=#the-noscript-element>noscript</a></code>;
       <code><a href=#the-script-element>script</a></code>;
       <code><a href=#the-style-element>style</a></code>;
+      <code><a href=#the-template-element>template</a></code>;
       <code><a href=#the-title-element>title</a></code>
      <td>
       —
@@ -99885,6 +100430,7 @@
       <code><a href=#the-sub-and-sup-elements>sup</a></code>;
       <code><a href=#svg>svg</a></code>;
       <code><a href=#the-table-element>table</a></code>;
+      <code><a href=#the-template-element>template</a></code>;
       <code><a href=#the-textarea-element>textarea</a></code>;
       <code><a href=#the-time-element>time</a></code>;
       <code><a href=#the-u-element>u</a></code>;
@@ -99967,6 +100513,7 @@
       <code><a href=#the-sub-and-sup-elements>sub</a></code>;
       <code><a href=#the-sub-and-sup-elements>sup</a></code>;
       <code><a href=#svg>svg</a></code>;
+      <code><a href=#the-template-element>template</a></code>;
       <code><a href=#the-textarea-element>textarea</a></code>;
       <code><a href=#the-time-element>time</a></code>;
       <code><a href=#the-u-element>u</a></code>;
@@ -101631,6 +102178,9 @@
     <tr><td> <code><a href=#the-td-element>td</a></code>
      <td> <code><a href=#htmltabledatacellelement>HTMLTableDataCellElement</a></code> : <code><a href=#htmltablecellelement>HTMLTableCellElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
 
+    <tr><td> <code><a href=#the-template-element>template</a></code>
+     <td> <code><a href=#htmltemplateelement>HTMLTemplateElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
+
     <tr><td> <code><a href=#the-textarea-element>textarea</a></code>
      <td> <code><a href=#htmltextareaelement>HTMLTextAreaElement</a></code> : <code><a href=#htmlelement>HTMLElement</a></code>
 
@@ -101771,6 +102321,7 @@
    <li><code><a href=#htmltableheadercellelement>HTMLTableHeaderCellElement</a></code>
    <li><code><a href=#htmltablerowelement>HTMLTableRowElement</a></code>, <a href=#HTMLTableRowElement-partial>partial</a>
    <li><code><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code>, <a href=#HTMLTableSectionElement-partial>partial</a>
+   <li><code><a href=#htmltemplateelement>HTMLTemplateElement</a></code>
    <li><code><a href=#htmltextareaelement>HTMLTextAreaElement</a></code>
    <li><code><a href=#htmltimeelement>HTMLTimeElement</a></code>
    <li><code><a href=#htmltitleelement>HTMLTitleElement</a></code>
@@ -102302,6 +102853,7 @@
   Adam Barth,
   Adam de Boor,
   Adam Hepton,
+  Adam Klein,
   Adam Roben,
   Addison Phillips,
   Adele Peterson,
@@ -102805,6 +103357,7 @@
   Pravir Gupta,
   李普君 (Pujun Li)<!-- masa jack -->,
   Rachid Finge,
+  Rafael Weinstein,
   Rafał Miłecki,
   Raj Doshi,
   Rajas Moonka,
@@ -102916,6 +103469,7 @@
   Tom Baker,
   Tom Pike,
   Tommy Thorsen,
+  Tony Ross,
   Travis Leithead,
   Tyler Close,
   Victor Carbune,

Modified: source
===================================================================
--- source	2013-06-25 20:55:18 UTC (rev 7999)
+++ source	2013-06-28 22:44:17 UTC (rev 8000)
@@ -10314,8 +10314,11 @@
   <h4><dfn>Content models</dfn></h4>
 
   <p>Each element defined in this specification has a content model: a description of the element's
-  expected contents. An <span title="HTML elements">HTML element</span> must have contents that
-  match the requirements described in the element's content model.</p>
+  expected <span title="concept-html-contents">contents</span>. An <span title="HTML elements">HTML element</span> must have contents that
+  match the requirements described in the element's content model. The <dfn title="concept-html-contents">contents</dfn> of an element are
+  its children in the DOM, except for <code>template</code> elements, where the children are those
+  in the <span>template contents</span> (a separate <code>DocumentFragment</code> assigned to the
+  element when the element is created).</p>
 
   <p>The <span title="space character">space characters</span> are always allowed between elements.
   User agents represent these characters between elements in the source markup as <code>Text</code>
@@ -10412,6 +10415,7 @@
    <li><code>noscript</code></li>
    <li><code>script</code></li>
    <li><code>style</code></li>
+   <li><code>template</code></li>
    <li><code>title</code></li>
   </ul>
 
@@ -10532,6 +10536,7 @@
    <li><code>sup</code></li>
    <li><code>svg</code></li>
    <li><code>table</code></li>
+   <li><code>template</code></li>
    <li><code>textarea</code></li>
    <li><code>time</code></li>
    <li><code>u</code></li>
@@ -10638,6 +10643,7 @@
    <li><code>sub</code></li>
    <li><code>sup</code></li>
    <li><code>svg</code></li>
+   <li><code>template</code></li>
    <li><code>textarea</code></li>
    <li><code>time</code></li>
    <li><code>u</code></li>
@@ -10647,12 +10653,6 @@
    <li><span title="text content">Text</span></li>
   </ul>
 
-  <p>As a general rule, elements whose content model allows any <span>phrasing content</span> should
-  have either at least one descendant <code>Text</code> node that is not <span>inter-element
-  whitespace</span>, or at least one descendant element node that is <span>embedded content</span>.
-  For the purposes of this requirement, nodes that are descendants of <code>del</code> elements must
-  not be counted as contributing to the ancestors of the <code>del</code> element.</p>
-
   <p class="note">Most elements that are categorized as phrasing content can only contain elements
   that are themselves categorized as phrasing content, not any flow content.</p>
 
@@ -10861,7 +10861,7 @@
   <h6>Palpable content</h6>
 
   <p>As a general rule, elements whose content model allows any <span>flow content</span> or
-  <span>phrasing content</span> should have at least one child node that is <dfn>palpable
+  <span>phrasing content</span> should have at least one node in its <span title="concept-html-contents">contents</span> that is <dfn>palpable
   content</dfn> and that does not have the <code title="attr-hidden">hidden</code> attribute
   specified.</p>
 
@@ -10975,7 +10975,7 @@
      without first violating the earlier requirement)
   <p>Furthermore, when a content model includes a part that is "transparent", those parts must not
   contain content that would not be conformant if all transparent elements in the tree were
-  replaced, in their parent element, by the children in the "transparent" part of their content
+  replaced, in their parent element, by the <span title="concept-html-contents">contents</span> in the "transparent" part of their content
   model, retaining order.</p>
 
   <div class="example">
@@ -11080,7 +11080,7 @@
 
   <p>Let <var title="">view</var> be a view of the DOM that replaces all <code>a</code>,
   <code>ins</code>, <code>del</code>, and <code>map</code> elements in the document with their
-  contents. Then, in <var title="">view</var>, for each run of sibling <span>phrasing content</span>
+  <span title="concept-html-contents">contents</span>. Then, in <var title="">view</var>, for each run of sibling <span>phrasing content</span>
   nodes uninterrupted by other types of content, in an element that accepts content other than
   <span>phrasing content</span> as well as <span>phrasing content</span>, let <var
   title="">first</var> be the first node of the run, and let <var title="">last</var> be the last
@@ -11200,7 +11200,7 @@
 
   <h4>Requirements relating to bidirectional-algorithm formatting characters</h4>
 
-  <p><span>Text content</span> in <span>HTML elements</span> with child <code>Text</code> nodes, and
+  <p><span>Text content</span> in <span>HTML elements</span> with <code>Text</code> nodes in their <span title="concept-html-contents">contents</span>, and
   text in attributes of <span>HTML elements</span> that allow free-form text, may contain characters
   in the ranges U+202A to U+202E and U+2066 to U+2069 (the bidirectional-algorithm formatting
   characters). However, the use of these characters is restricted so that any embedding or overrides
@@ -11571,6 +11571,10 @@
      <td><span title="concept-role-none">No role</span>
 
     <tr>
+     <td><code>template</code> element
+     <td><span title="concept-role-none">No role</span>, with the <code title="attr-aria-hidden">aria-hidden</code> state set to "true"
+
+    <tr>
      <td><code>textarea</code> element
      <td><code title="attr-aria-role-textbox">textbox</code> role, with the <code title="attr-aria-multiline">aria-multiline</code> property set to "true", and the <code title="attr-aria-readonly">aria-readonly</code> property set to "true" if the element has a <code title="attr-textarea-readonly">readonly</code> attribute
 
@@ -11966,7 +11970,9 @@
   output, or are rendered inline, etc).</p>
 
   <p class="note">There are also additional non-normative comments regarding the interaction of XSLT
-  and HTML <a href="#scriptTagXSLT">in the <code>script</code> element section</a>.</p>
+  and HTML <a href="#scriptTagXSLT">in the <code>script</code> element section</a>, and of
+  XSLT, XPath, and HTML <a href="#template-XSLT-XPath">in the <code>template</code> element
+  section</a>.</p>
 
   </div>
 
@@ -16045,7 +16051,215 @@
   </div>
 
 
+  <h4 id="the-template-element">The <dfn><code>template</code></dfn> element</h4>
 
+  <dl class="element">
+   <dt><span title="element-dfn-categories">Categories</span>:</dt>
+   <dd><span>Metadata content</span>.</dd>
+   <dd><span>Flow content</span>.</dd>
+   <dd><span>Phrasing content</span>.</dd>
+   <dt><span title="element-dfn-contexts">Contexts in which this element can be used</span>:</dt>
+   <dd>Where <span>metadata content</span> is expected.</dd>
+   <dd>Where <span>phrasing content</span> is expected.</dd>
+   <dd>As a child of an <code>hgroup</code> element.</dd>
+   <dd>As a child of an <code>ol</code> element.</dd>
+   <dd>As a child of a <code>ul</code> element.</dd>
+   <dd>As a child of a <code>dl</code> element.</dd>
+   <dd>As a child of a <code>table</code> element.</dd>
+   <dd>As a child of a <code>colgroup</code> element that doesn't have a <code title="attr-colgroup-span">span</code> attribute.</dd>
+   <dd>As a child of a <code>thead</code> element.</dd>
+   <dd>As a child of a <code>tbody</code> element.</dd>
+   <dd>As a child of a <code>tfoot</code> element.</dd>
+   <dd>As a child of a <code>tr</code> element.</dd>
+   <dd>As a child of a <code>select</code> element.</dd>
+   <dd>As a child of an <code>optgroup</code> element.</dd>
+   <dd>As a child of a <code>menu</code> element.</dd>
+   <dt><span title="element-dfn-content-model">Content model</span>:</dt>
+   <dd>Either: <span>Metadata content</span>.</dd>
+   <dd>Or: <span>Flow content</span>.</dd>
+   <dd>Or: The content model of <code>ol</code> and <code>ul</code> elements.</dd>
+   <dd>Or: The content model of <code>dl</code> elements.</dd>
+   <dd>Or: The content model of <code>figure</code> elements.</dd>
+   <dd>Or: The content model of <code>ruby</code> elements.</dd>
+   <dd>Or: The content model of <code>object</code> elements.</dd>
+   <dd>Or: The content model of <code>video</code> and <code>audio</code> elements.</dd>
+   <dd>Or: The content model of <code>table</code> elements.</dd>
+   <dd>Or: The content model of <code>colgroup</code> elements.</dd>
+   <dd>Or: The content model of <code>thead</code>, <code>tbody</code>, and <code>tfoot</code> elements.</dd>
+   <dd>Or: The content model of <code>tr</code> elements.</dd>
+   <dd>Or: The content model of <code>fieldset</code> elements.</dd>
+   <dd>Or: The content model of <code>select</code> elements.</dd>
+   <dd>Or: The content model of <code>details</code> elements.</dd>
+   <dd>Or: The content model of <code>menu</code> elements whose <code title="attr-menu-type">type</code> attribute is in the <span>popup menu state</span>.</dd>
+   <dt><span title="element-dfn-attributes">Content attributes</span>:</dt>
+   <dd><span>Global attributes</span></dd>
+   <dt><span title="element-dfn-dom">DOM interface</span>:</dt><!--TOPIC:DOM APIs-->
+   <dd>
+<pre class="idl">interface <dfn>HTMLTemplateElement</dfn> : <span>HTMLElement</span> {
+  readonly attribute <span>DocumentFragment</span> <span title="dom-template-content">content</span>;
+};</pre>
+</dd>
+  </dl><!--TOPIC:HTML-->
+
+  <p>The <code>template</code> element is used to declare fragments of HTML that can be cloned and
+  inserted in the document by script.</p>
+
+  <p>In a rendering, the <code>template</code> element <span>represents</span> nothing.</p>
+
+  <dl class="domintro">
+
+   <dt><var title="">template</var> . <code title="dom-template-content">content</code></dt>
+
+   <dd>
+
+    <p>Returns the contents of the <code>template</code>, which are stored in a
+    <code>DocumentFragment</code> associated with a different <code>Document</code> so as to avoid
+    the <code>template</code> contents interfering with the main <code>Document</code>. (For
+    example, this avoids form controls from being submitted, scripts from executing, and so
+    forth.)</p>
+
+   </dd>
+
+  </dl>
+
+  <div class="impl">
+
+  <p>Each <code>template</code> element has an associated <code>DocumentFragment</code> object that
+  is its <dfn>template contents</dfn>. When a <code>template</code> element is created, the user
+  agent must run the following steps to establish the <span>template contents</span>:</p>
+
+  <ol>
+
+   <li><p>Let <var title="">doc</var> be the <code>template</code> element's <code
+   title="dom-node-ownerdocument">ownerDocument</code>.</p></li>
+
+   <li>
+
+    <p>If <var title="">doc</var> has an associated <span>browsing context</span>, run these substeps:</p>
+
+    <ol>
+
+     <li><p>Let <var title="">new doc</var> be a new <code>Document</code> (that does not have a
+     <span>browsing context</span>).</p></li>
+
+     <li><p>If <var title="">doc</var> is an <span title="HTML documents">HTML document</span>, mark
+     <var title="">new doc</var> as an <span title="HTML documents">HTML document</span>
+     also.</p></li>
+
+     <li><p>Set <var title="">doc</var> to <var title="">new doc</var>.</p></li>
+
+    </ol>
+
+   </li>
+
+   <li><p>Create a <code>DocumentFragment</code> object whose <code
+   title="dom-node-ownerdocument">ownerDocument</code> is <var title="">doc</var>.</p></li>
+
+   <li><p>Set the <code>template</code> element's <span>template contents</span> to the newly
+   created <code>DocumentFragment</code> object.</p></li>
+
+  </ol>
+
+  <p>The <dfn title="dom-template-content"><code>content</code></dfn> IDL attribute must return the
+  <code>template</code> element's <span>template contents</span>.</p>
+
+  <hr>
+
+  <p>The <span title="concept-node-clone-ext">cloning steps</span> for a <code>template</code>
+  element <var title="">node</var> being cloned to a copy <var title="">copy</var> must run the
+  following steps:</p>
+
+  <ol>
+
+   <li><p>If the <var title="">clone children flag</var> is not set in the calling <span
+   title="concept-node-clone">clone</span> algorithm, abort these steps.</p></li>
+
+   <li><p>Let <var title="">copied contents</var> be the result of <span
+   title="concept-node-clone">cloning</span> all the children of <var title="">node</var>'s
+   <span>template contents</span>, with <var title="">ownerDocument</var> set to <var
+   title="">copy</var>'s <span>template contents</span>'s <code
+   title="dom-node-ownerdocument">ownerDocument</code>, and with the <var title="">clone children
+   flag</var> set.</p></li>
+
+   <li><p>Append <var title="">copied contents</var> to <var title="">copy</var>'s <span>template
+   contents</span>.</p></li>
+
+  </ol>
+
+  </div>
+
+  <div class="example">
+
+   <p>In this example, a script populates a table with data from a data structure, using a
+   <code>template</code> to provide the element structure instead of manually generating the
+   structure from markup.</p>
+
+   <pre><!DOCTYPE html>
+<title>Cat data</title>
+<script>
+ // Data is hard-coded here, but could come from the server
+ var data = [
+   { name: 'Pillar', color: 'Ticked Tabby', sex: 'Female (neutered)', legs: 3 },
+   { name: 'Hedral', color: 'Tuxedo', sex: 'Male (neutered)', legs: 4 },
+ ];
+</script>
+<table>
+ <thead>
+  <tr>
+   <th>Name <th>Color <th>Sex <th>Legs
+ <tbody>
+  <template id="row">
+   <tr><td><td><td><td>
+  </template>
+</table>
+<script>
+ var template = document.querySelector('#row');
+ for (var i in data) {
+   var cat = data[i];
+   var clone = template.content.cloneNode(true);
+   var cells = clone.querySelectorAll('td');
+   cells[0].textContent = cat.name;
+   cells[1].textContent = cat.color;
+   cells[2].textContent = cat.sex;
+   cells[3].textContent = cat.legs;
+   template.parentNode.appendChild(clone);
+ }
+</script></pre>
+
+  </div>
+
+
+
+  <div class="impl">
+
+  <h5 id="template-XSLT-XPath">Interaction of <code>template</code> elements with XSLT and XPath</h5>
+
+  <!--END dev-html--><p><i>This section is non-normative.</i></p><!--START dev-html-->
+
+  <p>This specification does not define how XSLT and XPath interact with the <code>template</code>
+  element. However, in the absence of another specification actually defining this, here are some
+  guidelines for implementors, which are intended to be consistent with other processing described
+  in this specification:</p>
+
+  <ul>
+
+   <li><p>An XSLT processor based on an XML parser that acts <span title="xml parser">as described
+   in this specification</span> needs to act as if <code>template</code> elements contain as
+   descendants their <span>template contents</span> for the purposes of the transform.</p></li>
+
+   <li><p>An XSLT processor that outputs a DOM needs to ensure that nodes that would go into a
+   <code>template</code> element are instead placed into the element's <span>template
+   contents</span>.</p></li>
+
+   <li><p>XPath evaluation using the XPath DOM API when applied to a <code>Document</code> parsed
+   using the <span>HTML parser</span> or the <span>XML parser</span> described in this specification
+   needs to ignore <span>template contents</span>.</p>
+
+  </ul>
+
+  </div>
+
+
   <h3>Sections</h3>
 
   <h4 id="the-body-element">The <dfn><code>body</code></dfn> element</h4>
@@ -16826,7 +17040,7 @@
    <dt><span title="element-dfn-contexts">Contexts in which this element can be used</span>:</dt>
    <dd>Where <span>flow content</span> is expected.</dd>
    <dt><span title="element-dfn-content-model">Content model</span>:</dt>
-   <dd>One or more <code>h1</code>, <code>h2</code>, <code>h3</code>, <code>h4</code>, <code>h5</code>, and <code>h6</code> elements.</dd>
+   <dd>One or more <code>h1</code>, <code>h2</code>, <code>h3</code>, <code>h4</code>, <code>h5</code>, <code>h6</code>, and <code>template</code> elements.</dd>
    <dt><span title="element-dfn-attributes">Content attributes</span>:</dt>
    <dd><span>Global attributes</span></dd>
    <dt><span title="element-dfn-dom">DOM interface</span>:</dt><!--TOPIC:DOM APIs-->
@@ -18927,7 +19141,7 @@
    <dt><span title="element-dfn-contexts">Contexts in which this element can be used</span>:</dt>
    <dd>Where <span>flow content</span> is expected.</dd>
    <dt><span title="element-dfn-content-model">Content model</span>:</dt>
-   <dd>Zero or more <code>li</code> elements.</dd>
+   <dd>Zero or more <code>li</code> and <code>template</code> elements.</dd>
    <dt><span title="element-dfn-attributes">Content attributes</span>:</dt>
    <dd><span>Global attributes</span></dd>
    <dd><code title="attr-ol-reversed">reversed</code></dd>
@@ -19110,7 +19324,7 @@
    <dt><span title="element-dfn-contexts">Contexts in which this element can be used</span>:</dt>
    <dd>Where <span>flow content</span> is expected.</dd>
    <dt><span title="element-dfn-content-model">Content model</span>:</dt>
-   <dd>Zero or more <code>li</code> elements.</dd>
+   <dd>Zero or more <code>li</code> and <code>template</code> elements.</dd>
    <dt><span title="element-dfn-attributes">Content attributes</span>:</dt>
    <dd><span>Global attributes</span></dd>
    <dt><span title="element-dfn-dom">DOM interface</span>:</dt><!--TOPIC:DOM APIs-->
@@ -19275,9 +19489,9 @@
    <dt><span title="element-dfn-contexts">Contexts in which this element can be used</span>:</dt>
    <dd>Where <span>flow content</span> is expected.</dd>
    <dt><span title="element-dfn-content-model">Content model</span>:</dt>
-   <dd>Zero or more groups each consisting of one or more
-   <code>dt</code> elements followed by one or more <code>dd</code>
-   elements.</dd>
+   <dd>Either: Zero or more groups each consisting of one or more <code>dt</code> elements followed by one or more <code>dd</code> elements.</dd>
+   <dd>Or: A <code>template</code> element.</dd>
+   <dd>Or: A <code>template</code> element or a <code>dt</code> element, followed by zero or more <code>template</code>, <code>dt</code>, and <code>dd</code> elements, followed by a <code>template</code> element or a <code>dd</code> element.</dd>
    <dt><span title="element-dfn-attributes">Content attributes</span>:</dt>
    <dd><span>Global attributes</span></dd>
    <dt><span title="element-dfn-dom">DOM interface</span>:</dt><!--TOPIC:DOM APIs-->
@@ -42828,7 +43042,7 @@
    <dd><span>Flow content</span>.</dd>
    <dd><span>Phrasing content</span>.</dd>
    <dt><span title="element-dfn-contexts">Contexts in which this element can be used</span>:</dt>
-   <dd>Where <span>phrasing content</span> is expected, but only if there is a <code>map</code> element ancestor.</dd>
+   <dd>Where <span>phrasing content</span> is expected, but only if there is a <code>map</code> element ancestor or a <code>template</code> element ancestor.</dd>
    <dt><span title="element-dfn-content-model">Content model</span>:</dt>
    <dd>Empty.</dd>
    <dt><span title="element-dfn-attributes">Content attributes</span>:</dt>
@@ -42867,7 +43081,7 @@
   map</span>, or a dead area on an image map.</p>
 
   <p>An <code>area</code> element with a parent node must have a <code>map</code> element
-  ancestor.</p>
+  ancestor or a <code>template</code> element ancestor.</p>
 
   <p>If the <code>area</code> element has an <code
   title="attr-hyperlink-href">href</code> attribute, then the
@@ -43626,7 +43840,7 @@
    <code>tbody</code> elements or one or more <code>tr</code>
    elements, followed optionally by a <code>tfoot</code> element (but
    there can only be one <code>tfoot</code> element child in
-   total).</dd>
+   total), optionally with one or more <code>template</code> elements between any of the other elements.</dd>
    <dt><span title="element-dfn-attributes">Content attributes</span>:</dt>
    <dd><span>Global attributes</span></dd>
    <dd><code title="attr-table-sortable">sortable</code></dd>
@@ -44440,7 +44654,7 @@
    elements.</dd>
    <dt><span title="element-dfn-content-model">Content model</span>:</dt>
    <dd>If the <code title="attr-colgroup-span">span</code> attribute is present: Empty.</dd>
-   <dd>If the <code title="attr-colgroup-span">span</code> attribute is absent: Zero or more <code>col</code> elements.</dd>
+   <dd>If the <code title="attr-colgroup-span">span</code> attribute is absent: Zero or more <code>col</code> and <code>template</code> elements.</dd>
    <dt><span title="element-dfn-attributes">Content attributes</span>:</dt>
    <dd><span>Global attributes</span></dd>
    <dd><code title="attr-colgroup-span">span</code></dd>
@@ -44539,7 +44753,7 @@
    <code>tr</code> elements that are children of the
    <code>table</code> element.</dd>
    <dt><span title="element-dfn-content-model">Content model</span>:</dt>
-   <dd>Zero or more <code>tr</code> elements</dd>
+   <dd>Zero or more <code>tr</code> and <code>template</code> elements</dd>
    <dt><span title="element-dfn-attributes">Content attributes</span>:</dt>
    <dd><span>Global attributes</span></dd>
    <dt><span title="element-dfn-dom">DOM interface</span>:</dt><!--TOPIC:DOM APIs-->
@@ -44647,7 +44861,7 @@
    <code>thead</code> elements that are children of the
    <code>table</code> element.</dd>
    <dt><span title="element-dfn-content-model">Content model</span>:</dt>
-   <dd>Zero or more <code>tr</code> elements</dd>
+   <dd>Zero or more <code>tr</code> and <code>template</code> elements</dd>
    <dt><span title="element-dfn-attributes">Content attributes</span>:</dt>
    <dd><span>Global attributes</span></dd>
    <dt><span title="element-dfn-dom">DOM interface</span>:</dt><!--TOPIC:DOM APIs-->
@@ -44726,7 +44940,7 @@
    are no other <code>tfoot</code> elements that are children of the
    <code>table</code> element.</dd>
    <dt><span title="element-dfn-content-model">Content model</span>:</dt>
-   <dd>Zero or more <code>tr</code> elements</dd>
+   <dd>Zero or more <code>tr</code> and <code>template</code> elements</dd>
    <dt><span title="element-dfn-attributes">Content attributes</span>:</dt>
    <dd><span>Global attributes</span></dd>
    <dt><span title="element-dfn-dom">DOM interface</span>:</dt><!--TOPIC:DOM APIs-->
@@ -44763,7 +44977,7 @@
    elements, but only if there are no <code>tbody</code> elements that
    are children of the <code>table</code> element.</dd>
    <dt><span title="element-dfn-content-model">Content model</span>:</dt>
-   <dd>Zero or more <code>td</code> or <code>th</code> elements</dd>
+   <dd>Zero or more <code>td</code>, <code>th</code>, and <code>template</code> elements</dd>
    <dt><span title="element-dfn-attributes">Content attributes</span>:</dt>
    <dd><span>Global attributes</span></dd>
    <dt><span title="element-dfn-dom">DOM interface</span>:</dt><!--TOPIC:DOM APIs-->
@@ -55616,7 +55830,7 @@
    <dt><span title="element-dfn-contexts">Contexts in which this element can be used</span>:</dt>
    <dd>Where <span>phrasing content</span> is expected.</dd>
    <dt><span title="element-dfn-content-model">Content model</span>:</dt>
-   <dd>Zero or more <code>option</code> or <code>optgroup</code> elements.</dd>
+   <dd>Zero or more <code>option</code>, <code>optgroup</code>, and <code>template</code> elements.</dd>
    <dt><span title="element-dfn-attributes">Content attributes</span>:</dt>
    <dd><span>Global attributes</span></dd>
    <dd><code title="attr-fe-autofocus">autofocus</code></dd>
@@ -56227,7 +56441,7 @@
    <dt><span title="element-dfn-contexts">Contexts in which this element can be used</span>:</dt>
    <dd>As a child of a <code>select</code> element.</dd>
    <dt><span title="element-dfn-content-model">Content model</span>:</dt>
-   <dd>Zero or more <code>option</code> elements.</dd>
+   <dd>Zero or more <code>option</code> and <code>template</code> elements.</dd>
    <dt><span title="element-dfn-attributes">Content attributes</span>:</dt>
    <dd><span>Global attributes</span></dd>
    <dd><code title="attr-optgroup-disabled">disabled</code></dd>
@@ -62424,8 +62638,8 @@
    <dd>Where <span>flow content</span> is expected.</dd>
    <dd>If the element's <code title="attr-menu-type">type</code> attribute is in the <span title="popup menu state">popup menu</span> state: as the child of a <code>menu</code> element whose <code title="attr-menu-type">type</code> attribute is in the <span title="popup menu state">popup menu</span> state.</dd>
    <dt><span title="element-dfn-content-model">Content model</span>:</dt>
-   <dd>If the element's <code title="attr-menu-type">type</code> attribute is in the <span title="toolbar state">toolbar</span> state: either zero or more <code>li</code> elements, or <span>flow content</span>.</dd>
-   <dd>If the element's <code title="attr-menu-type">type</code> attribute is in the <span title="popup menu state">popup menu</span> state: in any order, zero or more <code>menuitem</code> elements, zero or more <code>hr</code> elements, and zero or more <code>menu</code> elements whose <code title="attr-menu-type">type</code> attributes are in the <span title="popup menu state">popup menu</span> state.</dd>
+   <dd>If the element's <code title="attr-menu-type">type</code> attribute is in the <span title="toolbar state">toolbar</span> state: either zero or more <code>li</code> and <code>template</code> elements, or, <span>flow content</span>.</dd>
+   <dd>If the element's <code title="attr-menu-type">type</code> attribute is in the <span title="popup menu state">popup menu</span> state: in any order, zero or more <code>menuitem</code> elements, zero or more <code>hr</code> elements, zero or more <code>menu</code> elements whose <code title="attr-menu-type">type</code> attributes are in the <span title="popup menu state">popup menu</span> state, and zero or more <code>template</code> elements.</dd>
    <dt><span title="element-dfn-attributes">Content attributes</span>:</dt>
    <dd><span>Global attributes</span></dd>
    <dd><code title="attr-menu-type">type</code></dd>
@@ -93968,12 +94182,12 @@
   start tag that is marked as self-closing, in which case they must
   not have an end tag.</p>
 
-  <p>The contents of the element must be placed between just after the
+  <p>The <span title="concept-html-contents">contents</span> of the element must be placed between just after the
   start tag (which <span title="syntax-tag-omission">might be implied,
   in certain cases</span>) and just before the end tag (which again,
   <span title="syntax-tag-omission">might be implied in certain
   cases</span>). The exact allowed contents of each individual element
-  depend on the content model of that element, as described earlier in
+  depend on the <span title="content models">content model</span> of that element, as described earlier in
   this specification. Elements must not contain content that their
   content model disallows. In addition to the restrictions placed on
   the contents by those content models, however, the five types of
@@ -94704,6 +94918,8 @@
   title="">--></code>).</p>
 
 
+<!--HTMLPARSER-->
+
   <div class="impl">
 
   <h3 id="parsing">Parsing HTML documents</h3>
@@ -95984,7 +96200,8 @@
   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
+  select in table</span>", "<span title="insertion mode: in template">in
+  template</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:
@@ -96015,8 +96232,17 @@
   is also set. This is the insertion mode to which the tree
   construction stage will return.</p>
 
+  <p>Similarly, to parse nested <code>template</code> elements, a <dfn>stack of template insertion
+  modes</dfn> is used. It is initially empty. The <dfn>current template insertion mode</dfn> is the
+  insertion mode that was most recently added to the <span>stack of template insertion modes</span>.
+  The algorithms in the sections below will <i>push</i> insertion modes onto this stack, meaning
+  that the specified insertion mode is to be added to the stack, and <i>pop</i> insertion modes from
+  the stack, which means that the most recently added insertion mode must be removed from the
+  stack.</p>
+
   <hr>
 
+<!--CLEANUP--><!--<p>s-->
   <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>
@@ -96034,11 +96260,38 @@
    title="concept-frag-parse-context">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>
 
+    <p>If <var title="">node</var> is a <code>select</code> element, run these substeps:</p>
+
+    <ol>
+
+     <li><p>Let <var title="">ancestor</var> be <var title="">node</var>.</p></li>
+
+     <li><p><i>Loop</i>: If <var title="">ancestor</var> is the first node in the <span>stack of open
+     elements</span>, jump to the step below labeled <i>done</i>.</p></li>
+
+     <li><p>Let <var title="">ancestor</var> be the node before <var title="">ancestor</var> in the
+     <span>stack of open elements</span>.</p></li>
+
+     <li><p>If <var title="">ancestor</var> is a <code>template</code> node, jump to the step below
+     labeled <i>done</i>.</p></li>
+
+     <li><p>If <var title="">ancestor</var> is a <code>table</code> node, switch the <span>insertion
+     mode</span> to "<span title="insertion mode: in select in table">in select in table</span>" and
+     abort these steps.</p></li>
+      <!-- consider <table><tr><td><select><template></template><caption></table>
+           http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2374 -->
+
+     <li><p>Jump back to the step labeled <i>loop</i>.</p></li>
+
+     <li><p><i>Done</i>: Switch the <span>insertion mode</span> to "<span title="insertion mode: in
+     select">in select</span>" and abort these steps.</p></li>
+
+    </ol>
+
+   </li>
+
    <li>If <var title="">node</var> is a <code>td</code> or
    <code>th</code> element and <var title="">last</var> is false, then
    switch the <span>insertion mode</span> to "<span title="insertion
@@ -96061,30 +96314,37 @@
    <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>
+   abort these steps.</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,
+   <li>If <var title="">node</var> is a <code>template</code> element, then switch the
+   <span>insertion mode</span> to the <span>current template insertion mode</span> and abort these
+   steps.</li>
+
+<!--
+   <li>If <var title="">node</var> is a <code>head</code> element
+   and <var title="">last</var> is true,
    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-disabled 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/outerHTML/insertAdjacentHTML(),
-   where we know scripting is enabled. -->
+   these steps. (<span>fragment case</span>)</li>
+--><!-- The above is only here 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-disabled 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/outerHTML/insertAdjacentHTML(), where we know scripting is enabled. -->
 
+   <li>If <var title="">node</var> is a <code>head</code> element and <var title="">last</var> is
+   false, then switch the <span>insertion mode</span> to "<span title="insertion mode: in head">in
+   head</span>" and abort these steps.</li> <!-- for the case of <head><template></template>... -->
+
    <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
@@ -96147,6 +96407,7 @@
   <dl>
 
    <dt><dfn>Special</dfn></dt>
+<!--CLEANUP-->
    <dd><p>The following elements have varying levels of special parsing rules: HTML's
    <code>address</code>, <code>applet</code>, <code>area</code>, <code>article</code>,
    <code>aside</code>, <code>base</code>, <code>basefont</code>, <code>bgsound</code>,
@@ -96166,7 +96427,7 @@
    <code>p</code>, <code>param</code>, <code>plaintext</code>, <code>pre</code>,
    <code>script</code>, <code>section</code>, <code>select</code>, <code>source</code>,
    <code>style</code>, <code>summary</code>, <code>table</code>, <code>tbody</code>,
-   <code>td</code>, <code>textarea</code>, <code>tfoot</code>, <code>th</code>, <code>thead</code>,
+   <code>td</code>, <code>template</code>, <code>textarea</code>, <code>tfoot</code>, <code>th</code>, <code>thead</code>,
    <code>title</code>, <code>tr</code>, <code>track</code>, <code>ul</code>, <code>wbr</code>, and
    <code>xmp</code>; MathML's <code title="">mi</code>, <code title="">mo</code>, <code
    title="">mn</code>, <code title="">ms</code>, <code title="">mtext</code>, and <code
@@ -96220,6 +96481,7 @@
    <li><code>th</code> in the <span>HTML namespace</span></li>
    <li><code>marquee</code> in the <span>HTML namespace</span></li>
    <li><code>object</code> in the <span>HTML namespace</span></li>
+   <li><code>template</code> in the <span>HTML namespace</span></li>
    <li><code title="">mi</code> in the <span>MathML namespace</span></li>
    <li><code title="">mo</code> in the <span>MathML namespace</span></li>
    <li><code title="">mn</code> in the <span>MathML namespace</span></li>
@@ -96259,6 +96521,7 @@
   <ul class="brief">
    <li><code>html</code> in the <span>HTML namespace</span></li> <!-- (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.) -->
    <li><code>table</code> in the <span>HTML namespace</span></li>
+   <li><code>template</code> in the <span>HTML namespace</span></li>
   </ul>
 
   <p>The <span>stack of open elements</span> is said to <dfn title="has an element in select
@@ -99020,6 +99283,9 @@
 
   <h5>Creating and inserting nodes</h5>
 
+  <p>While the parser is processing a token, it can enable or disable <dfn title="foster
+  parent">foster parenting</dfn>. This affects the following algorithm.</p>
+
   <p>The <dfn>appropriate place for inserting a node</dfn>, optionally using a particular
   <i>override target</i>, is the position in an element returned by running the following steps:</p>
 
@@ -99041,7 +99307,7 @@
 
     <dl class="switch">
 
-     <dt>If <dfn title="foster parent">foster parenting</dfn> is enabled and <var
+     <dt>If <span title="foster parent">foster parenting</span> is enabled and <var
      title="">target</var> is a <code>table</code>, <code>tbody</code>, <code>tfoot</code>,
      <code>thead</code>, or <code>tr</code> element</dt>
 
@@ -99049,35 +99315,60 @@
 
       <p class="note">Foster parenting happens when content is misnested in tables.</p>
 
-      <p>The <dfn>foster parent element</dfn> is the parent element of the last <code>table</code>
-      element in the <span>stack of open elements</span>, if there is a <code>table</code> element and
-      it has such a parent element.</p>
+      <p>Run these substeps:</p>
 
-      <p class="note">It might have no parent or some other kind parent if a script manipulated the
-      DOM after the element was inserted by the parser.</p>
+      <ol>
 
-      <p>If there is no <code>table</code> element in the <span>stack of open elements</span>
-      (<span>fragment case</span>), then the <i>foster parent element</i> is the first element in the
-      <span>stack of open elements</span> (the <code>html</code> element). Otherwise, if there is a
-      <code>table</code> element in the <span>stack of open elements</span>, but the last
-      <code>table</code> element in the <span>stack of open elements</span> has no parent, or its
-      parent node is not an element, then the <i>foster parent element</i> is the element before the
-      last <code>table</code> element in the <span>stack of open elements</span>.</p>
+       <li><p>Let <var title="">last template</var> be the last <code>template</code> element in the
+       <span>stack of open elements</span>, if any.</p>
 
-      <p>If the <i>foster parent element</i> is the parent element of the last <code>table</code>
-      element in the <span>stack of open elements</span>, then the <var title="">adjusted insertion
-      location</var> is inside the <i>foster parent element</i>, immediately <em>before</em> the
-      last <code>table</code> element in the <span>stack of open elements</span>; otherwise, the
-      <var title="">adjusted insertion location</var> is inside the <i>foster parent element</i>,
-      after its last child (if any).</p>
+       <li><p>Let <var title="">last table</var> be the last <code>table</code> element in the
+       <span>stack of open elements</span>, if any.</p>
 
+       <li><p>If there is a <var title="">last template</var> and either there is no <var
+       title="">last table</var>, or there is one, but <var title="">last template</var> is lower
+       (more recently added) than <var title="">last table</var> in the <span>stack of open
+       elements</span>, then: let <var title="">adjusted insertion location</var> be inside <var
+       title="">last template</var>'s <span>template contents</span>, after its last child (if any),
+       and abort these substeps.</p></li>
+
+       <li><p>If there is no <var title="">last table</var>, <!-- there's also implicitly no last
+       template, since we didn't hit the previous step --> then let <var title="">adjusted insertion
+       location</var> be inside the first element in the <span>stack of open elements</span> (the
+       <code>html</code> element), after its last child (if any), and abort these substeps.
+       (<span>fragment case</span>)</p>
+
+       <!-- if we get here, we know there's a last table, and if there's a last template, it's older
+       than the last table. -->
+
+       <li><p>If <var title="">last table</var> has a parent element, then let <var
+       title="">adjusted insertion location</var> be inside <var title="">last table</var>'s parent
+       element, immediately before <var title="">last table</var>, and abort these
+       substeps.</p></li>
+
+       <!-- if we get here, we know there's a last table, but it has no parent, and if there's a
+       last template, it's older than the last table. -->
+
+       <li><p>Let <var title="">previous element</var> be the element immediately above <var
+       title="">last table</var> in the <span>stack of open elements</span>.</p></li>
+
+       <li><p>Let <var title="">adjusted insertion location</var> be inside <var title="">previous
+       element</var>, after its last child (if any).</p></li>
+
+      </ol>
+
+      <p class="note">These steps are involved in part because it's possible for elements, the
+      <code>table</code> element in this case in particular, to have been moved by a script around
+      in the DOM, or indeed removed from the DOM entirely, after the element was inserted by the
+      parser.</p>
+
      </dd>
 
      <dt>Otherwise</dt>
 
      <dd>
 
-      <p>The <var title="">adjusted insertion location</var> is inside <var title="">target</var>,
+      <p>Let <var title="">adjusted insertion location</var> be inside <var title="">target</var>,
       after its last child (if any).</p>
 
      </dd>
@@ -99088,6 +99379,14 @@
 
    <li>
 
+    <p>If the <var title="">adjusted insertion location</var> is inside a <code>template</code>
+    element, let it instead be inside the <code>template</code> element's <span>template
+    contents</span>, after its last child (if any).</p>
+
+   </li>
+
+   <li>
+
     <p>Return the <var title="">adjusted insertion location</var>.</p>
 
    </li>
@@ -99161,9 +99460,18 @@
    pointer</span>, and suppress the running of the <span>reset the form owner</span> algorithm in
    the next step.</p></li>
 
-   <li><p>Insert the newly created element at the <var title="">adjusted insertion
-   location</var>.</p></li>
+   <li>
 
+    <p>If it is possible to insert an element at the <var title="">adjusted insertion
+    location</var>, then insert the newly created element at the <var title="">adjusted insertion
+    location</var>.</p>
+
+    <p class="note">If the <var title="">adjusted insertion location</var> cannot accept more
+    elements, e.g. because it's a <code>Document</code> that already has an element child, then the
+    newly created element is dropped on the floor.</p>
+
+   </li>
+
    <li><p>Push the element onto the <span>stack of open elements</span> so that it is the new
    <span>current node</span>.</p></li>
 
@@ -99308,6 +99616,16 @@
 
    <li>
 
+    <p>If the <var title="">adjusted insertion location</var> is in a <code>Document</code> node,
+    then abort these steps.
+
+    <p class="note">The DOM will not let <code>Document</code> nodes have <code>Text</code> node
+    children, so they are dropped on the floor.</p>
+
+   </li>
+
+   <li>
+
     <p>If there is a <code>Text</code> node immediately before the <var title="">adjusted insertion
     location</var>, then append <var title="">data</var> to that <code>Text</code> node's data.</p>
 
@@ -99913,6 +100231,7 @@
 
    </dd>
 
+
    <dt id="scriptTag">A start tag whose tag name is "script"</dt>
    <dd>
 
@@ -99982,6 +100301,57 @@
     <p>Act as described in the "anything else" entry below.</p>
    </dd>
 
+   <dt>A start tag whose tag name is "template"</dt>
+   <dd>
+
+    <p><span>Insert an HTML element</span> for the token.</p>
+
+    <p>Insert a marker at the end of the <span>list of active formatting elements</span>.</p>
+
+    <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
+
+    <p>Switch the <span>insertion mode</span> to "<span title="insertion mode: in template">in
+    template</span>".</p>
+
+    <p>Push "<span title="insertion mode: in template">in template</span>" onto the <span>stack of
+    template insertion modes</span> so that it is the new <span>current template insertion
+    mode</span>.</p>
+
+   </dd>
+
+   <dt>An end tag whose tag name is "template"</dt>
+   <dd>
+
+    <p>If there is no <code>template</code> element on the <span>stack of open elements</span>, then
+    this is a <span>parse error</span>; ignore the token.</p>
+
+    <p>Otherwise, run these steps:</p>
+
+    <ol>
+
+     <li><p><span>Generate implied end tags</span>.</p></li>
+
+     <li><p>If the <span>current node</span> is not an element with
+     the same tag name as that of the token, then this is a
+     <span>parse error</span>.</p></li>
+
+     <li><p>Pop elements from the <span>stack of open elements</span>
+     until an element with the same tag name as the token has been
+     popped from the stack.</p></li>
+
+     <li><span>Clear the list of active formatting elements up to the
+     last marker</span>.</li>
+
+     <li><p>Pop the <span>current template insertion mode</span> off the <span>stack of template
+     insertion modes</span>.</p>
+
+     <li><p><span title="reset the insertion mode appropriately">Reset the
+     parser's insertion mode appropriately</span>.</p></li>
+
+    </ol>
+
+   </dd>
+
    <dt>A start tag whose tag name is "head"</dt>
    <dt>Any other end tag</dt>
    <dd>
@@ -100225,7 +100595,12 @@
 
    <dt>A start tag whose tag name is "html"</dt>
    <dd>
-    <p><span>Parse error</span>. For each attribute on the token,
+    <p><span>Parse error</span>.</p>
+
+    <p>If there is a <code>template</code> element on the <span>stack of open elements</span>, then
+    ignore the token.</p>
+
+    <p>Otherwise, for each attribute on the token,
     check to see if the attribute is already present on the top
     element of the <span>stack of open elements</span>. If it is not,
     add the attribute and its corresponding value to that element.</p>
@@ -100245,8 +100620,9 @@
     <p><span>Parse error</span>.</p>
 
     <p>If the second element on the <span>stack of open
-    elements</span> is not a <code>body</code> element, or, if the
+    elements</span> is not a <code>body</code> element, if the
     <span>stack of open elements</span> has only one node on it,
+    or if there is a <code>template</code> element on the <span>stack of open elements</span>,
     then ignore the token. (<span>fragment case</span>)</p>
 
     <p>Otherwise, set the <span>frameset-ok flag</span> to "not ok";
@@ -100263,6 +100639,7 @@
 
     <p><span>Parse error</span>.</p>
 
+<!--CLEANUP--><!--should switch these clauses around-->
     <p>If the second element on the <span>stack of open
     elements</span> is not a <code>body</code> element, or, if the
     <span>stack of open elements</span> has only one node on it,
@@ -100305,8 +100682,13 @@
     this is a <span>parse error</span>.</p> <!-- (some of those are
     fragment cases) -->
 
-    <p><span>Stop parsing</span>.</p>
+    <p>If the <span>stack of template insertion modes</span> is not empty, then process the token
+    <span>using the rules for</span> the "<span title="insertion mode: in template">in
+    template</span>" <span>insertion mode</span>.</p>
+    <!-- this is needed to handle <head><template>...[EOF] - otherwise we don't construct the <body> element -->
 
+    <p>Otherwise, <span>stop parsing</span>.</p>
+
    </dd>
 
    <dt>An end tag whose tag name is "body"</dt>
@@ -101431,6 +101813,16 @@
 
    </dd>
 
+   <dt>A start tag whose tag name is "template"</dt>
+   <dt>An end tag whose tag name is "template"</dt>
+   <dd>
+
+    <p>Process the token <span>using the rules for</span> the "<span
+    title="insertion mode: in head">in head</span>" <span>insertion
+    mode</span>.</p>
+
+   </dd>
+
    <dt>A start <!--or end--> tag whose tag name is one of: "caption",
    "col", "colgroup", "frame", "head", "tbody", "td", "tfoot", "th",
    "thead", "tr"</dt>
@@ -101765,9 +102157,6 @@
     the tag name "table" had been seen, then, if that token wasn't
     ignored, reprocess the current token.</p>
 
-    <p class="note">The fake end tag token here can only be
-    ignored in the <span>fragment case</span>.</p>
-
    </dd>
 
    <dt>An end tag whose tag name is "table"</dt>
@@ -101776,8 +102165,7 @@
     <p>If the <span>stack of open elements</span> does not <span
     title="has an element in table scope">have an element in table
     scope</span> with the same tag name as the token, this is a
-    <span>parse error</span>. Ignore the token. (<span>fragment
-    case</span>)</p>
+    <span>parse error</span>. Ignore the token.</p>
 
     <p>Otherwise:</p>
 
@@ -101848,18 +102236,23 @@
 
    <!-- "form" end tag falls through to in-body, which does the right thing -->
 
-   <dt>An end-of-file token</dt>
+   <dt>A start tag whose tag name is "template"</dt>
+   <dt>An end tag whose tag name is "template"</dt>
    <dd>
 
-    <p>If the <span>current node</span> is not the root
-    <code>html</code> element, then this is a <span>parse
-    error</span>.</p>
+    <p>Process the token <span>using the rules for</span> the "<span
+    title="insertion mode: in head">in head</span>" <span>insertion
+    mode</span>.</p>
 
-    <p class="note">The <span>current node</span> can only be the root
-    <code>html</code> element in the <span>fragment case</span>.</p>
+   </dd>
 
-    <p><span>Stop parsing</span>.</p>
+   <dt>An end-of-file token</dt>
+   <dd>
 
+    <p>Process the token <span>using the rules for</span> the "<span
+    title="insertion mode: in body">in body</span>" <span>insertion
+    mode</span>.</p>
+
    </dd>
 
    <dt>Anything else</dt>
@@ -101876,8 +102269,8 @@
 
   <p>When the steps above require the UA to <dfn>clear the stack
   back to a table context</dfn>, it means that the UA must, while
-  the <span>current node</span> is not a <code>table</code>
-  element or an <code>html</code> element, pop elements from the
+  the <span>current node</span> is not a <code>table</code>,
+  <code>template</code>, or <code>html</code> element, pop elements from the
   <span>stack of open elements</span>.</p>
 
   <p class="note">The <span>current node</span> being an
@@ -102055,13 +102448,10 @@
    <dt>An end tag whose tag name is "colgroup"</dt>
    <dd>
 
-    <p>If the <span>current node</span> is the root
-    <code>html</code> element, then this is a <span>parse
-    error</span>; ignore the token. (<span>fragment
-    case</span>)</p>
+    <p>If the <span>current node</span> is not a <code>colgroup</code> element, then this is a <span>parse
+    error</span>; ignore the token.</p> <!-- e.g. colgroup fragment case, or <template><col></colgroup> -->
 
-    <p>Otherwise, pop the <span>current node</span> (which will be
-    a <code>colgroup</code> element) from the <span>stack of open
+    <p>Otherwise, pop the <span>current node</span> from the <span>stack of open
     elements</span>. Switch the <span>insertion mode</span> to
     "<span title="insertion mode: in table">in table</span>".</p>
 
@@ -102072,16 +102462,23 @@
     <p><span>Parse error</span>. Ignore the token.</p>
    </dd>
 
+   <dt>A start tag whose tag name is "template"</dt>
+   <dt>An end tag whose tag name is "template"</dt>
+   <dd>
+
+    <p>Process the token <span>using the rules for</span> the "<span
+    title="insertion mode: in head">in head</span>" <span>insertion
+    mode</span>.</p>
+
+   </dd>
+
    <dt>An end-of-file token</dt>
    <dd>
 
-    <p>If the <span>current node</span> is the root <code>html</code>
-    element, then <span>stop parsing</span>. (<span>fragment
-    case</span>)</p>
+    <p>Process the token <span>using the rules for</span> the "<span
+    title="insertion mode: in body">in body</span>" <span>insertion
+    mode</span>.</p>
 
-    <p>Otherwise, act as described in the "anything else" entry
-    below.</p>
-
    </dd>
 
    <dt>Anything else</dt>
@@ -102091,9 +102488,6 @@
     seen, and then, if that token wasn't ignored, reprocess the
     current token.</p>
 
-    <p class="note">The fake end tag token here can only be
-    ignored in the <span>fragment case</span>.</p>
-
    </dd>
 
   </dl>
@@ -102153,8 +102547,7 @@
     title="has an element in table scope">have a
     <code>tbody</code>, <code>thead</code>, or <code>tfoot</code>
     element in table scope</span>, this is a <span>parse
-    error</span>. Ignore the token. (<span>fragment
-    case</span>)</p>
+    error</span>. Ignore the token.</p>
 
     <p>Otherwise:</p>
 
@@ -102185,7 +102578,7 @@
   <p>When the steps above require the UA to <dfn>clear the stack
   back to a table body context</dfn>, it means that the UA must,
   while the <span>current node</span> is not a <code>tbody</code>,
-  <code>tfoot</code>, <code>thead</code>, or <code>html</code>
+  <code>tfoot</code>, <code>thead</code>, <code>template</code>, or <code>html</code>
   element, pop elements from the <span>stack of open
   elements</span>.</p>
 
@@ -102221,8 +102614,7 @@
     <p>If the <span>stack of open elements</span> does not <span
     title="has an element in table scope">have an element in table
     scope</span> with the same tag name as the token, this is a
-    <span>parse error</span>. Ignore the token. (<span>fragment
-    case</span>)</p>
+    <span>parse error</span>. Ignore the token.</p>
 
     <p>Otherwise:</p>
 
@@ -102246,9 +102638,6 @@
     then, if that token wasn't ignored, reprocess the current
     token.</p>
 
-    <p class="note">The fake end tag token here can only be
-    ignored in the <span>fragment case</span>.</p>
-
    </dd>
 
    <dt>An end tag whose tag name is one of: "tbody", "tfoot",
@@ -102282,8 +102671,8 @@
 
   <p>When the steps above require the UA to <dfn>clear the stack
   back to a table row context</dfn>, it means that the UA must,
-  while the <span>current node</span> is not a <code>tr</code>
-  element or an <code>html</code> element, pop elements from the
+  while the <span>current node</span> is not a <code>tr</code>,
+  <code>template</code>, or <code>html</code> element, pop elements from the
   <span>stack of open elements</span>.</p>
 
   <p class="note">The <span>current node</span> being an
@@ -102324,7 +102713,7 @@
     <p>Switch the <span>insertion mode</span> to "<span
     title="insertion mode: in row">in row</span>".</p> <!-- current
     node here will be a <tr> normally; but could be <html> in the
-    fragment case -->
+    fragment case, or <template> in the template case -->
 
    </dd>
 
@@ -102355,9 +102744,7 @@
 
     <p>If the <span>stack of open elements</span> does not <span
     title="has an element in table scope">have an element in table
-    scope</span> with the same tag name as that of the token (which
-    can only happen for "tbody", "tfoot" and "thead", or in the
-    <span>fragment case</span>), then this is a <span>parse
+    scope</span> with the same tag name as that of the token, then this is a <span>parse
     error</span> and the token must be ignored.</p>
 
     <p>Otherwise, <span>close the cell</span> (see below) and
@@ -102533,18 +102920,23 @@
     mode</span>.</p>
    </dd>
 
-   <dt>An end-of-file token</dt>
+   <dt>A start tag whose tag name is "template"</dt>
+   <dt>An end tag whose tag name is "template"</dt>
    <dd>
 
-    <p>If the <span>current node</span> is not the root
-    <code>html</code> element, then this is a <span>parse
-    error</span>.</p>
+    <p>Process the token <span>using the rules for</span> the "<span
+    title="insertion mode: in head">in head</span>" <span>insertion
+    mode</span>.</p>
 
-    <p class="note">The <span>current node</span> can only be the root
-    <code>html</code> element in the <span>fragment case</span>.</p>
+   </dd>
 
-    <p><span>Stop parsing</span>.</p>
+   <dt>An end-of-file token</dt>
+   <dd>
 
+    <p>Process the token <span>using the rules for</span> the "<span
+    title="insertion mode: in body">in body</span>" <span>insertion
+    mode</span>.</p>
+
    </dd>
 
    <dt>Anything else</dt>
@@ -102593,6 +102985,139 @@
 
 
 
+  <h6 id="parsing-main-intemplate">The "<dfn title="insertion mode: in template">in template</dfn>" insertion mode</h6>
+
+  <p>When the user agent is to apply the rules for the "<span title="insertion mode: in template">in template</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
+
+  <dl class="switch">
+
+   <!-- first, tokens we always ignore: -->
+
+   <!-- html: ignored in "in body" mode if there's a <template> on the stack -->
+   <!-- head: ignored in "in body" mode always -->
+   <!-- body: ignored in "in body" mode if there's a <template> on the stack -->
+   <!-- frameset: ignored in "in body" mode if frameset-ok is set to not-ok, which <template> sets it to -->
+
+
+   <!-- second, tokens that are ambiguous (allowed in multiple modes), let's just handle them in a generic way and not pick a mode: -->
+
+   <dt>A character token</dt>
+   <dt>A comment token</dt>
+   <dt>A DOCTYPE token</dt>
+   <dd>
+    <p>Process the token <span>using the rules for</span> the "<span
+    title="insertion mode: in body">in body</span>" <span>insertion
+    mode</span>.</p>
+   </dd>
+
+   <dt>A start tag whose tag name is one of: "base", "basefont", "bgsound", "link", "meta", "noframes", "script", "style", "title"</dt>
+   <dt>A start tag whose tag name is "template"</dt>
+   <dt>An end tag whose tag name is "template"</dt>
+   <dd>
+    <p>Process the token <span>using the rules for</span> the "<span
+    title="insertion mode: in head">in head</span>" <span>insertion
+    mode</span>.</p>
+   </dd>
+
+   <!-- now, tokens that imply certain modes -->
+
+   <dt>A start tag whose tag name is one of: "caption", "colgroup", "tbody", "tfoot", "thead"</dt>
+   <dd>
+
+    <p>Pop the <span>current template insertion mode</span> off the <span>stack of template
+    insertion modes</span>.</p>
+
+    <p>Push "<span title="insertion mode: in table">in table</span>" onto the <span>stack of
+    template insertion modes</span> so that it is the new <span>current template insertion
+    mode</span>.</p>
+
+    <p>Switch the <span>insertion mode</span> to "<span title="insertion mode: in table">in
+    table</span>", and reprocess the token.</p>
+
+   </dd>
+
+   <dt>A start tag whose tag name is "col"</dt>
+   <dd>
+
+    <p>Pop the <span>current template insertion mode</span> off the <span>stack of template
+    insertion modes</span>.</p>
+
+    <p>Push "<span title="insertion mode: in column group">in column group</span>" onto the
+    <span>stack of template insertion modes</span> so that it is the new <span>current template
+    insertion mode</span>.</p>
+
+    <p>Switch the <span>insertion mode</span> to "<span title="insertion mode: in column group">in
+    column group</span>", and reprocess the token.</p>
+
+   </dd>
+
+   <dt>A start tag whose tag name is "tr"</dt>
+   <dd>
+
+    <p>Pop the <span>current template insertion mode</span> off the <span>stack of template
+    insertion modes</span>.</p>
+
+    <p>Push "<span title="insertion mode: in table body">in table body</span>" onto the <span>stack
+    of template insertion modes</span> so that it is the new <span>current template insertion
+    mode</span>.</p>
+
+    <p>Switch the <span>insertion mode</span> to "<span title="insertion mode: in table body">in
+    table body</span>", and reprocess the token.</p>
+
+   </dd>
+
+   <dt>A start tag whose tag name is one of: "td", "th"</dt>
+   <dd>
+
+    <p>Pop the <span>current template insertion mode</span> off the <span>stack of template
+    insertion modes</span>.</p>
+
+    <p>Push "<span title="insertion mode: in row">in row</span>" onto the <span>stack of template
+    insertion modes</span> so that it is the new <span>current template insertion mode</span>.</p>
+
+    <p>Switch the <span>insertion mode</span> to "<span title="insertion mode: in row">in
+    row</span>", and reprocess the token.</p>
+
+   </dd>
+
+   <!-- default to in-body mode -->
+
+   <dt>Any other start tag</dt>
+   <dd>
+
+    <p>Pop the <span>current template insertion mode</span> off the <span>stack of template
+    insertion modes</span>.</p>
+
+    <p>Push "<span title="insertion mode: in body">in body</span>" onto the <span>stack of template
+    insertion modes</span> so that it is the new <span>current template insertion mode</span>.</p>
+
+    <p>Switch the <span>insertion mode</span> to "<span title="insertion mode: in body">in
+    body</span>", and reprocess the token.</p>
+
+   </dd>
+
+   <dt>Any other end tag</dt>
+   <dd>
+    <p><span>Parse error</span>. Ignore the token.</p>
+   </dd>
+
+   <!-- EOF -->
+
+
+   <dt>An end-of-file token</dt>
+   <dd>
+
+    <p>If there is no <code>template</code> element on the <span>stack of open elements</span>, then
+    <span>stop parsing</span>. (<span>fragment case</span>)</p>
+
+    <p>Otherwise, this is a <span>parse error</span>; act as if an end tag with the tag name
+    "template" had been seen and reprocess the current token.</p>
+
+   </dd>
+
+  </dl>
+
+
   <h6 id="parsing-main-afterbody">The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h6>
 
   <p>When the user agent is to apply the rules for the "<span title="insertion mode: after body">after body</span>" <span>insertion mode</span>, the user agent must handle the token as follows:</p>
@@ -103721,6 +104246,7 @@
   been seen up to this point.</p>
 
 
+<!--/HTMLPARSER-->
 
 
   <h3>Serializing HTML fragments</h3>
@@ -103739,6 +104265,10 @@
    <li><p>Let <var title="">s</var> be a string, and initialize it to
    the empty string.</p></li>
 
+   <li><p>If <var title="">the node</var> is a <code>template</code> element, then let <var
+   title="">the node</var> instead be the <code>template</code> element's <span>template
+   contents</span> (a <code>DocumentFragment</code> node).</p></li>
+
    <li>
 
     <p>For each child node of <var title="">the node</var>, in
@@ -104171,6 +104701,15 @@
 
      <li>
 
+      <p>If the <var title="concept-frag-parse-context">context</var> element is a
+      <code>template</code> element, push "<span title="insertion mode: in template">in
+      template</span>" onto the <span>stack of template insertion modes</span> so that it is the new
+      <span>current template insertion mode</span>.</p>
+
+     </li>
+
+     <li>
+
       <p><span title="reset the insertion mode appropriately">Reset the
       parser's insertion mode appropriately</span>.</p>
 
@@ -104308,6 +104847,8 @@
   the rules given in the XML specification to map a string of bytes or characters into a
   <code>Document</code> object.</p>
 
+  <p class="note">At the time of writing, no such rules actually exist.</p>
+
   <p>An <span>XML parser</span> is either associated with a <code>Document</code> object when it is
   created, or creates one implicitly.</p>
 
@@ -104388,6 +104929,18 @@
   available for <span>XML documents</span>, much of the complexity in the <span>HTML parser</span>
   is not needed in the <span>XML parser</span>.</p>
 
+  <p id="templateTagXML">When an <span>XML parser</span> would append a node to a
+  <code>template</code> element, it must instead append it to the <code>template</code> element's
+  <span>template contents</span> (a <code>DocumentFragment</code> node).</p>
+
+  <p class="note">This is a <span>willful violation</span> of the XML specification; unfortunately,
+  XML is not formally extensible in the manner that is needed for <code>template</code> processing.
+  <a href="#refsXML">[XML]</a></p>
+
+  <p>When an <span>XML parser</span> creates a <code>Node</code> object, its <code
+  title="dom-Node-ownerDocument">ownerDocument</code> must be set to the <code>Document</code> of
+  the node into which the newly created node is to be inserted.</p>
+
   <p>Certain algorithms in this specification <dfn title="feed the parser">spoon-feed the
   parser</dfn> characters one string at a time. In such cases, the <span>XML parser</span> must act
   as it would have if faced with a single string consisting of the concatenation of all those
@@ -104402,7 +104955,9 @@
   syntax</span>, then it is an <span title="XML documents">XML document</span>.</p>
 
 
+<!--//HTMLPARSER-->
 
+
   <h3>Serializing XHTML fragments</h3>
 
   <p>The <dfn>XML fragment serialization algorithm</dfn> for a
@@ -104422,13 +104977,28 @@
 
   <p>In both cases, the string returned must be XML
   namespace-well-formed and must be an isomorphic serialization of all
-  of that node's child nodes, in <span>tree order</span>. User agents
+  of that node's <span>relevant child nodes</span>, in <span>tree order</span>. User agents
   may adjust prefixes and namespace declarations in the serialization
   (and indeed might be forced to do so in some cases to obtain
   namespace-well-formed XML). User agents may use a combination of
   regular text and character references to represent
   <code>Text</code> nodes in the DOM.</p>
 
+  <p>A node's <dfn>relevant child nodes</dfn> are those that apply given the following rules:</p>
+
+  <dl>
+
+   <dt>For <code>template</code> elements</dt>
+
+   <dd>The <span>relevant child nodes</span> are the child nodes of the <code>template</code>
+   element's <span>template contents</span>, if any.</dd>
+
+   <dt>For all other nodes</dt>
+
+   <dd>The <span>relevant child nodes</span> are the child nodes of node itself, if any.</dd>
+
+  </dl>
+
   <p>For <code>Element</code>s, if any of the elements in the
   serialization are in no namespace, the default namespace in scope
   for those elements must be explicitly declared as the empty
@@ -104724,7 +105294,7 @@
 
 [hidden], area, base, basefont, datalist, head, input[type=hidden i],
 link, menu[type=popup i], meta, noembed, noframes, param, rp, script,
-source, style, track, title {
+source, style, template, track, title {
   display: none;
 }
 
@@ -110313,7 +110883,8 @@
      <th><code>base</code></th>
      <td>Base URL and default target <span>browsing context</span> for <span title="attr-hyperlink-target">hyperlinks</span> and <span title="attr-fs-target">forms</span></td>
      <td><span title="Metadata content">metadata</span></td>
-     <td><code>head</code></td>
+     <td><code>head</code>;
+         <code>template</code></td>
      <td>empty</td>
      <td><span title="global attributes">globals</span>;
          <code title="attr-base-href">href</code>;
@@ -110435,7 +111006,8 @@
      <th><code>caption</code></th>
      <td>Table caption</td>
      <td>none</td>
-     <td><code>table</code></td>
+     <td><code>table</code>;
+         <code>template</code></td>
      <td><span title="Flow content">flow</span>*</td>
      <td><span title="global attributes">globals</span></td>
      <td><code>HTMLTableCaptionElement</code></td>
@@ -110467,7 +111039,8 @@
      <th><code>col</code></th>
      <td>Table column</td>
      <td>none</td>
-     <td><code>colgroup</code></td>
+     <td><code>colgroup</code>;
+         <code>template</code></td>
      <td>empty</td>
      <td><span title="global attributes">globals</span>;
          <code title="attr-col-span">span</code></td>
@@ -110478,34 +111051,16 @@
      <th><code>colgroup</code></th>
      <td>Group of columns in a table</td>
      <td>none</td>
-     <td><code>table</code></td>
-     <td><code>col</code></td>
+     <td><code>table</code>;
+         <code>template</code></td>
+     <td><code>col</code>*;
+         <code>template</code>*</td>
      <td><span title="global attributes">globals</span>;
          <code title="attr-colgroup-span">span</code></td>
      <td><code>HTMLTableColElement</code></td>
     </tr>
 
     <tr>
-     <th><code>menuitem</code></th>
-     <td>Menu command</td>
-     <td><span title="Metadata content">metadata</span>;
-         <span title="Flow content">flow</span>;
-         <span title="Phrasing content">phrasing</span></td>
-     <td><code>head</code>;
-         <span title="Phrasing content">phrasing</span></td>
-     <td>empty</td>
-     <td><span title="global attributes">globals</span>;
-         <code title="attr-menuitem-type">type</code>;
-         <code title="attr-menuitem-label">label</code>;
-         <code title="attr-menuitem-icon">icon</code>;
-         <code title="attr-menuitem-disabled">disabled</code>;
-         <code title="attr-menuitem-checked">checked</code>;
-         <code title="attr-menuitem-radiogroup">radiogroup</code>;
-         <code title="attr-menuitem-command">command</code></td>
-     <td><code>HTMLMenuItemElement</code></td>
-    </tr>
-
-    <tr>
      <th><code>data</code></th>
      <td>Machine-readable equivalent</td>
      <td><span title="Flow content">flow</span>;
@@ -110533,7 +111088,8 @@
      <th><code>dd</code></th>
      <td>Content for corresponding <code>dt</code> element(s)</td>
      <td>none</td>
-     <td><code>dl</code></td>
+     <td><code>dl</code>;
+         <code>template</code></td>
      <td><span title="Flow content">flow</span></td>
      <td><span title="global attributes">globals</span></td>
      <td><code>HTMLElement</code></td>
@@ -110582,10 +111138,8 @@
      <td>Dialog box or window</td>
      <td><span title="Flow content">flow</span>;
          <span title="Sectioning root">sectioning root</span></td>
-     <td><code>dt</code>;
-         <code>th</code>;
-         <span title="Flow content">flow</span></td>
      <td><span title="Flow content">flow</span></td>
+     <td><span title="Flow content">flow</span></td>
      <td><span title="global attributes">globals</span>;
          <code title="attr-dialog-open">open</code></td>
      <td><code>HTMLDialogElement</code></td>
@@ -110607,7 +111161,8 @@
      <td><span title="Flow content">flow</span></td>
      <td><span title="Flow content">flow</span></td>
      <td><code>dt</code>*;
-         <code>dd</code>*</td>
+         <code>dd</code>*;
+         <code>template</code>*</td>
      <td><span title="global attributes">globals</span></td>
      <td><code>HTMLDListElement</code></td>
     </tr>
@@ -110616,7 +111171,8 @@
      <th><code>dt</code></th>
      <td>Legend for corresponding <code>dd</code> element(s)</td>
      <td>none</td>
-     <td><code>dl</code></td>
+     <td><code>dl</code>;
+         <code>template</code></td>
      <td><span title="Flow content">flow</span>*</td>
      <td><span title="global attributes">globals</span></td>
      <td><code>HTMLElement</code></td>
@@ -110672,7 +111228,8 @@
      <th><code>figcaption</code></th>
      <td>Caption for <code>figure</code></td>
      <td>none</td>
-     <td><code>figure</code></td>
+     <td><code>figure</code>;
+         <code>template</code></td>
      <td><span title="Flow content">flow</span></td>
      <td><span title="global attributes">globals</span></td>
      <td><code>HTMLElement</code></td>
@@ -110756,7 +111313,7 @@
      <td><span title="Flow content">flow</span>;
          <span title="Heading content">heading</span></td>
      <td><span title="Flow content">flow</span></td>
-     <td>One or more <code>h1</code>, <code>h2</code>, <code>h3</code>, <code>h4</code>, <code>h5</code>, and <code>h6</code></td>
+     <td>One or more <code>h1</code>, <code>h2</code>, <code>h3</code>, <code>h4</code>, <code>h5</code>, <code>h6</code>, and <code>template</code></td>
      <td><span title="global attributes">globals</span></td>
      <td><code>HTMLElement</code></td>
     </tr>
@@ -110949,7 +111506,8 @@
      <th><code>legend</code></th>
      <td>Caption for <code>fieldset</code></td>
      <td>none</td>
-     <td><code>fieldset</code></td>
+     <td><code>fieldset</code>;
+         <code>template</code></td>
      <td><span title="Phrasing content">phrasing</span></td>
      <td><span title="global attributes">globals</span></td>
      <td><code>HTMLLegendElement</code></td>
@@ -110959,7 +111517,10 @@
      <th><code>li</code></th>
      <td>List item</td>
      <td>none</td>
-     <td><code>ol</code>; <code>ul</code>; <code>menu</code>*</td>
+     <td><code>ol</code>;
+         <code>ul</code>;
+         <code>menu</code>*;
+         <code>template</code></td>
      <td><span title="Flow content">flow</span></td>
      <td><span title="global attributes">globals</span>;
          <code title="attr-li-value">value</code>*</td>
@@ -110973,6 +111534,7 @@
          <span title="Flow content">flow</span>*;
          <span title="Phrasing content">phrasing</span>*</td>
      <td><code>head</code>;
+         <code>template</code>;
          <code>noscript</code>*;
          <span title="phrasing content">phrasing</span>*</td>
      <td>empty</td>
@@ -111031,7 +111593,8 @@
          <span title="Flow content">flow</span>*;
          <code>menuitem</code>*;
          <code>hr</code>*;
-         <code>menu</code>*</td>
+         <code>menu</code>*;
+         <code>template</code>*</td>
      <td><span title="global attributes">globals</span>;
          <code title="attr-menu-type">type</code>;
          <code title="attr-menu-label">label</code></td>
@@ -111039,12 +111602,31 @@
     </tr>
 
     <tr>
+     <th><code>menuitem</code></th>
+     <td>Menu command</td>
+     <td>none</td>
+     <td><code>menu</code>;     
+         <code>template</code></td>
+     <td>empty</td>
+     <td><span title="global attributes">globals</span>;
+         <code title="attr-menuitem-type">type</code>;
+         <code title="attr-menuitem-label">label</code>;
+         <code title="attr-menuitem-icon">icon</code>;
+         <code title="attr-menuitem-disabled">disabled</code>;
+         <code title="attr-menuitem-checked">checked</code>;
+         <code title="attr-menuitem-radiogroup">radiogroup</code>;
+         <code title="attr-menuitem-command">command</code></td>
+     <td><code>HTMLMenuItemElement</code></td>
+    </tr>
+
+    <tr>
      <th><code>meta</code></th>
      <td>Text metadata</td>
      <td><span title="Metadata content">metadata</span>;
          <span title="Flow content">flow</span>*;
          <span title="Phrasing content">phrasing</span>*</td>
      <td><code>head</code>;
+         <code>template</code>;
          <code>noscript</code>*;
          <span title="phrasing content">phrasing</span>*</td>
      <td>empty</td>
@@ -111092,6 +111674,7 @@
          <span title="Flow content">flow</span>;
          <span title="Phrasing content">phrasing</span></td>
      <td><code>head</code>*;
+         <code>template</code>*;
          <span title="Phrasing content">phrasing</span>*</td>
      <td>varies*</td>
      <td><span title="global attributes">globals</span></td>
@@ -111128,7 +111711,8 @@
      <td>Ordered list</td>
      <td><span title="Flow content">flow</span></td>
      <td><span title="Flow content">flow</span></td>
-     <td><code>li</code></td>
+     <td><code>li</code>;
+         <code>template</code></td>
      <td><span title="global attributes">globals</span>;
          <code title="attr-ol-reversed">reversed</code>;
          <code title="attr-ol-start">start</code>;
@@ -111140,8 +111724,10 @@
      <th><code>optgroup</code></th>
      <td>Group of options in a list box</td>
      <td>none</td>
-     <td><code>select</code></td>
-     <td><code>option</code></td>
+     <td><code>select</code>;
+         <code>template</code></td>
+     <td><code>option</code>;
+         <code>template</code></td>
      <td><span title="global attributes">globals</span>;
          <code title="attr-optgroup-disabled">disabled</code>;
          <code title="attr-optgroup-label">label</code></td>
@@ -111154,7 +111740,8 @@
      <td>none</td>
      <td><code>select</code>;
          <code>datalist</code>;
-         <code>optgroup</code></td>
+         <code>optgroup</code>;
+         <code>template</code></td>
      <td><span title="text content">text</span>*</td>
      <td><span title="global attributes">globals</span>;
          <code title="attr-option-disabled">disabled</code>;
@@ -111196,7 +111783,8 @@
      <th><code>param</code></th>
      <td>Parameter for <code>object</code></td>
      <td>none</td>
-     <td><code>object</code></td>
+     <td><code>object</code>;
+         <code>template</code></td>
      <td>empty</td>
      <td><span title="global attributes">globals</span>;
          <code title="attr-param-name">name</code>;
@@ -111244,7 +111832,8 @@
      <th><code>rp</code></th>
      <td>Parenthesis for ruby annotation text</td>
      <td>none</td>
-     <td><code>ruby</code></td>
+     <td><code>ruby</code>;
+         <code>template</code></td>
      <td><span title="Phrasing content">phrasing</span></td>
      <td><span title="global attributes">globals</span></td>
      <td><code>HTMLElement</code></td>
@@ -111254,7 +111843,8 @@
      <th><code>rt</code></th>
      <td>Ruby annotation text</td>
      <td>none</td>
-     <td><code>ruby</code></td>
+     <td><code>ruby</code>;
+         <code>template</code></td>
      <td><span title="Phrasing content">phrasing</span></td>
      <td><span title="global attributes">globals</span></td>
      <td><code>HTMLElement</code></td>
@@ -111365,7 +111955,8 @@
      <td>Media source for <code>video</code> or <code>audio</code></td>
      <td>none</td>
      <td><code>video</code>;
-         <code>audio</code></td>
+         <code>audio</code>;
+         <code>template</code></td>
      <td>empty</td>
      <td><span title="global attributes">globals</span>;
          <code title="attr-source-src">src</code>;
@@ -111454,7 +112045,8 @@
          <code>thead</code>*;
          <code>tbody</code>*;
          <code>tfoot</code>*;
-         <code>tr</code>*</td>
+         <code>tr</code>*;
+         <code>template</code></td>
      <td><span title="global attributes">globals</span></td>
      <td><code>HTMLTableElement</code></td>
     </tr>
@@ -111463,8 +112055,10 @@
      <th><code>tbody</code></th>
      <td>Group of rows in a table</td>
      <td>none</td>
-     <td><code>table</code></td>
-     <td><code>tr</code></td>
+     <td><code>table</code>;
+         <code>template</code></td>
+     <td><code>tr</code>;
+         <code>template</code></td>
      <td><span title="global attributes">globals</span></td>
      <td><code>HTMLTableSectionElement</code></td>
     </tr>
@@ -111473,7 +112067,8 @@
      <th><code>td</code></th>
      <td>Table cell</td>
      <td><span title="Sectioning root">sectioning root</span></td>
-     <td><code>tr</code></td>
+     <td><code>tr</code>;
+         <code>template</code></td>
      <td><span title="Flow content">flow</span></td>
      <td><span title="global attributes">globals</span>;
          <code title="attr-tdth-colspan">colspan</code>;
@@ -111483,6 +112078,17 @@
     </tr>
 
     <tr>
+     <th><code>template</code></th>
+     <td>Template</td>
+     <td><span title="Metadata content">metadata</span>;
+         <span title="Flow content">flow</span>;
+         <span title="Phrasing content">phrasing</span></td>
+     <td colspan=2>it's complicated*</td>
+     <td><span title="global attributes">globals</span></td>
+     <td><code>HTMLTemplateElement</code></td>
+    </tr>
+
+    <tr>
      <th><code>textarea</code></th>
      <td>Multiline text field</td>
      <td><span title="Flow content">flow</span>;
@@ -111515,8 +112121,10 @@
      <th><code>tfoot</code></th>
      <td>Group of footer rows in a table</td>
      <td>none</td>
-     <td><code>table</code></td>
-     <td><code>tr</code></td>
+     <td><code>table</code>;
+         <code>template</code></td>
+     <td><code>tr</code>;
+         <code>template</code></td>
      <td><span title="global attributes">globals</span></td>
      <td><code>HTMLTableSectionElement</code></td>
     </tr>
@@ -111525,7 +112133,8 @@
      <th><code>th</code></th>
      <td>Table header cell</td>
      <td>none</td>
-     <td><code>tr</code></td>
+     <td><code>tr</code>;
+         <code>template</code></td>
      <td><span title="Flow content">flow</span>*</td>
      <td><span title="global attributes">globals</span>;
          <code title="attr-tdth-colspan">colspan</code>;
@@ -111540,8 +112149,10 @@
      <th><code>thead</code></th>
      <td>Group of heading rows in a table</td>
      <td>none</td>
-     <td><code>table</code></td>
-     <td><code>tr</code></td>
+     <td><code>table</code>;
+         <code>template</code></td>
+     <td><code>tr</code>;
+         <code>template</code></td>
      <td><span title="global attributes">globals</span></td>
      <td><code>HTMLTableSectionElement</code></td>
     </tr>
@@ -111562,7 +112173,8 @@
      <th><code>title</code></th>
      <td>Document title</td>
      <td><span title="Metadata content">metadata</span></td>
-     <td><code>head</code></td>
+     <td><code>head</code>;
+         <code>template</code></td>
      <td><span title="text content">text</span>*</td>
      <td><span title="global attributes">globals</span></td>
      <td><code>HTMLTitleElement</code></td>
@@ -111575,9 +112187,11 @@
      <td><code>table</code>;
          <code>thead</code>;
          <code>tbody</code>;
-         <code>tfoot</code></td>
+         <code>tfoot</code>;
+         <code>template</code></td>
      <td><code>th</code>*;
-         <code>td</code></td>
+         <code>td</code>;
+         <code>template</code></td>
      <td><span title="global attributes">globals</span></td>
      <td><code>HTMLTableRowElement</code></td>
     </tr>
@@ -111587,7 +112201,8 @@
      <td>Timed text track</td>
      <td>none</td>
      <td><code>audio</code>;
-         <code>video</code></td>
+         <code>video</code>;
+         <code>template</code></td>
      <td>empty</td>
      <td><span title="global attributes">globals</span>;
          <code title="attr-track-default">default</code>;
@@ -111614,7 +112229,8 @@
      <td>List</td>
      <td><span title="Flow content">flow</span></td>
      <td><span title="Flow content">flow</span></td>
-     <td><code>li</code></td>
+     <td><code>li</code>;
+         <code>template</code></td>
      <td><span title="global attributes">globals</span></td>
      <td><code>HTMLUListElement</code></td>
     </tr>
@@ -111703,6 +112319,7 @@
       <code>noscript</code>;
       <code>script</code>;
       <code>style</code>;
+      <code>template</code>;
       <code>title</code>
      <td>
       —
@@ -111784,6 +112401,7 @@
       <code>sup</code>;
       <code>svg</code>;
       <code>table</code>;
+      <code>template</code>;
       <code>textarea</code>;
       <code>time</code>;
       <code>u</code>;
@@ -111869,6 +112487,7 @@
       <code>sub</code>;
       <code>sup</code>;
       <code>svg</code>;
+      <code>template</code>;
       <code>textarea</code>;
       <code>time</code>;
       <code>u</code>;
@@ -113891,6 +114510,10 @@
      <td> <code>HTMLTableDataCellElement</code> : <code>HTMLTableCellElement</code> : <code>HTMLElement</code>
 
     <tr>
+     <td> <code>template</code>
+     <td> <code>HTMLTemplateElement</code> : <code>HTMLElement</code>
+
+    <tr>
      <td> <code>textarea</code>
      <td> <code>HTMLTextAreaElement</code> : <code>HTMLElement</code>
 
@@ -114714,6 +115337,7 @@
   Adam Barth,
   Adam de Boor,
   Adam Hepton,
+  Adam Klein,
   Adam Roben,
   Addison Phillips,
   Adele Peterson,
@@ -115217,6 +115841,7 @@
   Pravir Gupta,
   &#x674e;&#x666e;&#x541b; (Pujun Li)<!-- masa jack -->,
   Rachid Finge,
+  Rafael Weinstein,
   Rafa&#x0142; Mi&#x0142;ecki,
   Raj Doshi,
   Rajas Moonka,
@@ -115328,6 +115953,7 @@
   Tom Baker,
   Tom Pike,
   Tommy Thorsen,
+  Tony Ross,
   Travis Leithead,
   Tyler Close,
   Victor Carbune,




More information about the Commit-Watchers mailing list