</ol><h5 id=closing-elements-that-have-implied-end-tags><span class=secno>12.2.5.3 </span>Closing elements that have implied end tags</h5>
<!--CLEANUP-->
<p>When the steps below require the UA to <dfn id=generate-implied-end-tags>generate implied end
tags</dfn>, then, while the <a href=#current-node>current node</a> is a
<code><a href=#the-dd-element>dd</a></code> element, a <code><a href=#the-dt-element>dt</a></code> element, an
pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
elements</a>.</p>
<!--CLEANUP-->
<p>If a step requires the UA to generate implied end tags but lists
an element to exclude from the process, then the UA must perform the
above steps as if that element was not in the above list.</p>
<p>When the steps below require the UA to <dfn id=generate-all-implied-end-tags-thoroughly>generate all implied end tags thoroughly</dfn>,
then, while the <a href=#current-node>current node</a> is a <code><a href=#the-caption-element>caption</a></code> element, a
<code><a href=#the-colgroup-element>colgroup</a></code> element, a <code><a href=#the-dd-element>dd</a></code> element, a <code><a href=#the-dt-element>dt</a></code> element, an
<code><a href=#the-li-element>li</a></code> element, an <code><a href=#the-option-element>option</a></code> element, an <code><a href=#the-optgroup-element>optgroup</a></code> element, a
<code><a href=#the-p-element>p</a></code> element, an <code><a href=#the-rp-element>rp</a></code> element, an <code><a href=#the-rt-element>rt</a></code> element, a
<code><a href=#the-tbody-element>tbody</a></code> element, a <code><a href=#the-td-element>td</a></code> element, a <code><a href=#the-tfoot-element>tfoot</a></code> element, a
<code><a href=#the-th-element>th</a></code> element, a <code><a href=#the-thead-element>thead</a></code> element, or a <code><a href=#the-tr-element>tr</a></code> element, the UA must
pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p>
<h5 id=parsing-main-inhtml><span class=secno>12.2.5.4 </span>The rules for parsing tokens in HTML content</h5>
<p>Otherwise, run these steps:</p>
<ol><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>.</li>
<ol><li><p><a href=#generate-all-implied-end-tags-thoroughly>Generate all implied end tags thoroughly</a>.</li>
<li><p>If the <a href=#current-node>current node</a> is not a <code><a href=#the-template-element>template</a></code> element, then this is a
</ol><h5 id=closing-elements-that-have-implied-end-tags><span class=secno>12.2.5.3 </span>Closing elements that have implied end tags</h5>
<!--CLEANUP-->
<p>When the steps below require the UA to <dfn id=generate-implied-end-tags>generate implied end
tags</dfn>, then, while the <a href=#current-node>current node</a> is a
<code><a href=#the-dd-element>dd</a></code> element, a <code><a href=#the-dt-element>dt</a></code> element, an
pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
elements</a>.</p>
<!--CLEANUP-->
<p>If a step requires the UA to generate implied end tags but lists
an element to exclude from the process, then the UA must perform the
above steps as if that element was not in the above list.</p>
<p>When the steps below require the UA to <dfn id=generate-all-implied-end-tags-thoroughly>generate all implied end tags thoroughly</dfn>,
then, while the <a href=#current-node>current node</a> is a <code><a href=#the-caption-element>caption</a></code> element, a
<code><a href=#the-colgroup-element>colgroup</a></code> element, a <code><a href=#the-dd-element>dd</a></code> element, a <code><a href=#the-dt-element>dt</a></code> element, an
<code><a href=#the-li-element>li</a></code> element, an <code><a href=#the-option-element>option</a></code> element, an <code><a href=#the-optgroup-element>optgroup</a></code> element, a
<code><a href=#the-p-element>p</a></code> element, an <code><a href=#the-rp-element>rp</a></code> element, an <code><a href=#the-rt-element>rt</a></code> element, a
<code><a href=#the-tbody-element>tbody</a></code> element, a <code><a href=#the-td-element>td</a></code> element, a <code><a href=#the-tfoot-element>tfoot</a></code> element, a
<code><a href=#the-th-element>th</a></code> element, a <code><a href=#the-thead-element>thead</a></code> element, or a <code><a href=#the-tr-element>tr</a></code> element, the UA must
pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open elements</a>.</p>
<h5 id=parsing-main-inhtml><span class=secno>12.2.5.4 </span>The rules for parsing tokens in HTML content</h5>
<p>Otherwise, run these steps:</p>
<ol><li><p><a href=#generate-implied-end-tags>Generate implied end tags</a>.</li>
<ol><li><p><a href=#generate-all-implied-end-tags-thoroughly>Generate all implied end tags thoroughly</a>.</li>
<li><p>If the <a href=#current-node>current node</a> is not a <code><a href=#the-template-element>template</a></code> element, then this is a