6459 lines
696 KiB
HTML
6459 lines
696 KiB
HTML
<!DOCTYPE html><html class=split lang=en-US-x-hixie><script src=/link-fixup.js defer=""></script><meta charset=utf-8><meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name=viewport><title>HTML Standard</title><meta content=#3c790a name=theme-color><link rel=stylesheet href=https://resources.whatwg.org/standard.css><link rel=icon href=https://resources.whatwg.org/logo.svg><script>
|
||
function toggleStatus(div) {
|
||
div.parentNode.classList.toggle('wrapped');
|
||
}
|
||
</script><style>
|
||
.status { min-height: 0.6em; font: 1em sans-serif; width: 9em; padding: 0.3em; position: absolute; z-index: 8; right: 0.3em; background: #EEE; color: black; box-shadow: 0 0 3px #999; overflow: hidden; margin: -2em 0 0 0; border-collapse: initial; border-spacing: initial; }
|
||
.status:hover { z-index: 9; }
|
||
.status:focus-within { z-index: 9; }
|
||
.status.wrapped > :not(input) { display: none; }
|
||
.status > input { position: absolute; left: 0; top: 0; width: 1em; height: 1em; border: none; background: transparent; padding: 0; margin: 0; }
|
||
.status > p { font-size: 0.6em; margin: 0; padding: 0; }
|
||
.status > p + p { padding-top: 0.5em; }
|
||
.status > p > strong { margin-left: 1.5em; }
|
||
.status > .support { display: block; }
|
||
.status > .support > span { padding: 0.2em 0; display: block; display: table; }
|
||
.status > .support > span.partial { color: #666666; filter: grayscale(50%); }
|
||
.status > .support > span.no { color: #CCCCCC; filter: grayscale(100%); }
|
||
.status > .support > span.no::before { opacity: 0.5; }
|
||
.status > .support > span:first-of-type { padding-top: 0.5em; }
|
||
.status > .support > span > span { padding: 0 0.5em; display: table-cell; vertical-align: top; }
|
||
.status > .support > span > span:first-child { width: 100%; }
|
||
.status > .support > span > span:last-child { width: 100%; white-space: pre; padding: 0; }
|
||
.status > .support > span::before { content: ' '; display: table-cell; min-width: 1.5em; height: 1.5em; background: no-repeat center center; background-size: contain; text-align: right; font-size: 0.75em; font-weight: bold; }
|
||
.status > .support > .and_chr::before { background-image: url(https://resources.whatwg.org/browser-logos/chrome.svg); }
|
||
.status > .support > .and_ff::before { background-image: url(https://resources.whatwg.org/browser-logos/firefox.png); }
|
||
.status > .support > .and_uc::before { background-image: url(https://resources.whatwg.org/browser-logos/uc.png); } /* UC Browser for Android */
|
||
.status > .support > .android::before { background-image: url(https://resources.whatwg.org/browser-logos/android.svg); }
|
||
.status > .support > .bb::before { background-image: url(https://resources.whatwg.org/browser-logos/bb.jpg); } /* Blackberry Browser */
|
||
.status > .support > .chrome::before { background-image: url(https://resources.whatwg.org/browser-logos/chrome.svg); }
|
||
.status > .support > .edge::before { background-image: url(https://resources.whatwg.org/browser-logos/edge.svg); }
|
||
.status > .support > .firefox::before { background-image: url(https://resources.whatwg.org/browser-logos/firefox.png); }
|
||
.status > .support > .ie::before { background-image: url(https://resources.whatwg.org/browser-logos/ie.png); }
|
||
.status > .support > .ie_mob::before { background-image: url(https://resources.whatwg.org/browser-logos/ie-mobile.svg); }
|
||
.status > .support > .ios_saf::before { background-image: url(https://resources.whatwg.org/browser-logos/safari-ios.svg); }
|
||
.status > .support > .op_mini::before { background-image: url(https://resources.whatwg.org/browser-logos/opera-mini.png); }
|
||
.status > .support > .op_mob::before { background-image: url(https://resources.whatwg.org/browser-logos/opera.png); }
|
||
.status > .support > .opera::before { background-image: url(https://resources.whatwg.org/browser-logos/opera.png); }
|
||
.status > .support > .safari::before { background-image: url(https://resources.whatwg.org/browser-logos/safari.png); }
|
||
.status > .support > .samsung::before { background-image: url(https://resources.whatwg.org/browser-logos/samsung.png); }
|
||
.status > .caniuse { text-align: right; font-style: italic; width: 100%; }
|
||
.status > .caniuse + p { margin-top: 0.5em; border-top: 1px solid silver; }
|
||
|
||
@media (max-width: 767px) {
|
||
.status { right: -9em; }
|
||
}
|
||
</style><style>
|
||
[hidden] { display: none; }
|
||
|
||
.bad, .bad *:not(.X\58X) { color: gray; border-color: gray; background: transparent; }
|
||
|
||
.fingerprint { position: absolute; right: 0; z-index: 5; }
|
||
@media (max-width: 767px) {
|
||
.fingerprint { max-width: 35px; }
|
||
}
|
||
|
||
.applies .yes, .yesno .yes { background: yellow; }
|
||
.yesno .yes, .yesno .no { text-align: center; }
|
||
|
||
.applies thead th > * { display: block; }
|
||
.applies thead code { display: block; }
|
||
.applies td { text-align: center; }
|
||
|
||
.matrix, .matrix td { border: hidden; text-align: right; }
|
||
.matrix { margin-left: 2em; }
|
||
|
||
.vertical-summary-table tr > th[rowspan="2"]:first-child + th,
|
||
.vertical-summary-table tr > td[rowspan="2"]:first-child + td { border-bottom: hidden; }
|
||
|
||
.dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
|
||
.dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
|
||
.dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
|
||
|
||
td.eg { border-width: thin; text-align: center; }
|
||
|
||
#table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
|
||
#table-example-1 caption { padding-bottom: 0.5em; }
|
||
#table-example-1 thead, #table-example-1 tbody { border: none; }
|
||
#table-example-1 th, #table-example-1 td { border: solid thin; }
|
||
#table-example-1 th { font-weight: normal; }
|
||
#table-example-1 td { border-style: none solid; vertical-align: top; }
|
||
#table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
|
||
#table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
|
||
#table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
|
||
#table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
|
||
#table-example-1 tbody td:first-child::after { content: leader(". "); }
|
||
#table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
|
||
#table-example-1 tbody td:first-child + td { width: 10em; }
|
||
#table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
|
||
#table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
|
||
|
||
.apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
|
||
.apple-table-examples * { font-family: "Times", serif; }
|
||
.apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
|
||
.apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
|
||
.apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
|
||
.apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
|
||
.apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
|
||
.apple-table-examples td { text-align: right; vertical-align: top; }
|
||
.apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
|
||
.apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
|
||
.apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
|
||
.apple-table-examples sup { line-height: 0; }
|
||
|
||
.three-column-nowrap tr > td:first-child,
|
||
.three-column-nowrap tr > td:first-child + td,
|
||
.three-column-nowrap tr > td:first-child + td + td { white-space: nowrap; }
|
||
|
||
.details-example img { vertical-align: top; }
|
||
|
||
.parse-error-table td > p:first-child { margin-top: 0; }
|
||
|
||
#named-character-references-table {
|
||
white-space: nowrap;
|
||
font-size: 0.6em;
|
||
column-width: 30em;
|
||
column-gap: 1em;
|
||
-moz-column-width: 30em;
|
||
-moz-column-gap: 1em;
|
||
-webkit-column-width: 30em;
|
||
-webkit-column-gap: 1em;
|
||
}
|
||
#named-character-references-table > table > tbody > tr > td:first-child + td,
|
||
#named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
|
||
#named-character-references-table > table > tbody > tr > td:last-child:hover > span { position: absolute; top: auto; left: auto; margin-left: 0.5em; line-height: 1.2; font-size: 5em; border: outset; padding: 0.25em 0.5em; background: white; width: 1.25em; height: auto; text-align: center; }
|
||
#named-character-references-table > table > tbody > tr#entity-CounterClockwiseContourIntegral > td:first-child { font-size: 0.5em; }
|
||
|
||
.glyph.control { color: red; }
|
||
|
||
#table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
|
||
@font-face {
|
||
font-family: 'Essays1743';
|
||
src: url('/fonts/Essays1743.ttf');
|
||
}
|
||
@font-face {
|
||
font-family: 'Essays1743';
|
||
font-weight: bold;
|
||
src: url('/fonts/Essays1743-Bold.ttf');
|
||
}
|
||
@font-face {
|
||
font-family: 'Essays1743';
|
||
font-style: italic;
|
||
src: url('/fonts/Essays1743-Italic.ttf');
|
||
}
|
||
@font-face {
|
||
font-family: 'Essays1743';
|
||
font-style: italic;
|
||
font-weight: bold;
|
||
src: url('/fonts/Essays1743-BoldItalic.ttf');
|
||
}
|
||
|
||
@media (max-width: 767px) {
|
||
#abstractimg { width: 100%; }
|
||
}
|
||
#abstractimg, #abstractimg text { font: inherit; }
|
||
#abstractimg rect { fill: #424242; }
|
||
#abstractimg text { fill: #ffffff; font-size: 18px }
|
||
#abstractimg .top { word-spacing: 50px; text-anchor: middle; }
|
||
#abstractimg .left, #abstractimg .bottom { word-spacing: 12px; }
|
||
#abstractimg .right { font-size: 25px; }
|
||
</style><body>
|
||
|
||
<script async="" src=/html-dfn.js></script>
|
||
<script data-file-issue-url=https://github.com/whatwg/html/issues/new src=https://resources.whatwg.org/file-issue.js async=""></script>
|
||
<header id=head class="head with-buttons">
|
||
<a href=https://whatwg.org/ class=logo><img alt=WHATWG src=https://resources.whatwg.org/logo.svg width=100 height=100></a>
|
||
<hgroup><h1 class=allcaps>HTML</h1><h2 id=living-standard class="no-num no-toc">Living Standard — Last Updated <span class=pubdate>9 September 2017</span></h2></hgroup>
|
||
|
||
|
||
|
||
|
||
</header>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<nav><a href=syntax.html>← 12 The HTML syntax</a> — <a href=./>Table of Contents</a> — <a href=named-characters.html>12.5 Named character references →</a></nav><ol class=toc><li id=toc-syntax><ol><li><a href=parsing.html#parsing><span class=secno>12.2</span> Parsing HTML documents</a><ol><li><a href=parsing.html#overview-of-the-parsing-model><span class=secno>12.2.1</span> Overview of the parsing model</a><li><a href=parsing.html#parse-errors><span class=secno>12.2.2</span> Parse errors</a><li><a href=parsing.html#the-input-byte-stream><span class=secno>12.2.3</span> The input byte stream</a><ol><li><a href=parsing.html#parsing-with-a-known-character-encoding><span class=secno>12.2.3.1</span> Parsing with a known character encoding</a><li><a href=parsing.html#determining-the-character-encoding><span class=secno>12.2.3.2</span> Determining the character encoding</a><li><a href=parsing.html#character-encodings><span class=secno>12.2.3.3</span> Character encodings</a><li><a href=parsing.html#changing-the-encoding-while-parsing><span class=secno>12.2.3.4</span> Changing the encoding while parsing</a><li><a href=parsing.html#preprocessing-the-input-stream><span class=secno>12.2.3.5</span> Preprocessing the input stream</a></ol><li><a href=parsing.html#parse-state><span class=secno>12.2.4</span> Parse state</a><ol><li><a href=parsing.html#the-insertion-mode><span class=secno>12.2.4.1</span> The insertion mode</a><li><a href=parsing.html#the-stack-of-open-elements><span class=secno>12.2.4.2</span> The stack of open elements</a><li><a href=parsing.html#the-list-of-active-formatting-elements><span class=secno>12.2.4.3</span> The list of active formatting elements</a><li><a href=parsing.html#the-element-pointers><span class=secno>12.2.4.4</span> The element pointers</a><li><a href=parsing.html#other-parsing-state-flags><span class=secno>12.2.4.5</span> Other parsing state flags</a></ol><li><a href=parsing.html#tokenization><span class=secno>12.2.5</span> Tokenization</a><ol><li><a href=parsing.html#data-state><span class=secno>12.2.5.1</span> Data state</a><li><a href=parsing.html#rcdata-state><span class=secno>12.2.5.2</span> RCDATA state</a><li><a href=parsing.html#rawtext-state><span class=secno>12.2.5.3</span> RAWTEXT state</a><li><a href=parsing.html#script-data-state><span class=secno>12.2.5.4</span> Script data state</a><li><a href=parsing.html#plaintext-state><span class=secno>12.2.5.5</span> PLAINTEXT state</a><li><a href=parsing.html#tag-open-state><span class=secno>12.2.5.6</span> Tag open state</a><li><a href=parsing.html#end-tag-open-state><span class=secno>12.2.5.7</span> End tag open state</a><li><a href=parsing.html#tag-name-state><span class=secno>12.2.5.8</span> Tag name state</a><li><a href=parsing.html#rcdata-less-than-sign-state><span class=secno>12.2.5.9</span> RCDATA less-than sign state</a><li><a href=parsing.html#rcdata-end-tag-open-state><span class=secno>12.2.5.10</span> RCDATA end tag open state</a><li><a href=parsing.html#rcdata-end-tag-name-state><span class=secno>12.2.5.11</span> RCDATA end tag name state</a><li><a href=parsing.html#rawtext-less-than-sign-state><span class=secno>12.2.5.12</span> RAWTEXT less-than sign state</a><li><a href=parsing.html#rawtext-end-tag-open-state><span class=secno>12.2.5.13</span> RAWTEXT end tag open state</a><li><a href=parsing.html#rawtext-end-tag-name-state><span class=secno>12.2.5.14</span> RAWTEXT end tag name state</a><li><a href=parsing.html#script-data-less-than-sign-state><span class=secno>12.2.5.15</span> Script data less-than sign state</a><li><a href=parsing.html#script-data-end-tag-open-state><span class=secno>12.2.5.16</span> Script data end tag open state</a><li><a href=parsing.html#script-data-end-tag-name-state><span class=secno>12.2.5.17</span> Script data end tag name state</a><li><a href=parsing.html#script-data-escape-start-state><span class=secno>12.2.5.18</span> Script data escape start state</a><li><a href=parsing.html#script-data-escape-start-dash-state><span class=secno>12.2.5.19</span> Script data escape start dash state</a><li><a href=parsing.html#script-data-escaped-state><span class=secno>12.2.5.20</span> Script data escaped state</a><li><a href=parsing.html#script-data-escaped-dash-state><span class=secno>12.2.5.21</span> Script data escaped dash state</a><li><a href=parsing.html#script-data-escaped-dash-dash-state><span class=secno>12.2.5.22</span> Script data escaped dash dash state</a><li><a href=parsing.html#script-data-escaped-less-than-sign-state><span class=secno>12.2.5.23</span> Script data escaped less-than sign state</a><li><a href=parsing.html#script-data-escaped-end-tag-open-state><span class=secno>12.2.5.24</span> Script data escaped end tag open state</a><li><a href=parsing.html#script-data-escaped-end-tag-name-state><span class=secno>12.2.5.25</span> Script data escaped end tag name state</a><li><a href=parsing.html#script-data-double-escape-start-state><span class=secno>12.2.5.26</span> Script data double escape start state</a><li><a href=parsing.html#script-data-double-escaped-state><span class=secno>12.2.5.27</span> Script data double escaped state</a><li><a href=parsing.html#script-data-double-escaped-dash-state><span class=secno>12.2.5.28</span> Script data double escaped dash state</a><li><a href=parsing.html#script-data-double-escaped-dash-dash-state><span class=secno>12.2.5.29</span> Script data double escaped dash dash state</a><li><a href=parsing.html#script-data-double-escaped-less-than-sign-state><span class=secno>12.2.5.30</span> Script data double escaped less-than sign state</a><li><a href=parsing.html#script-data-double-escape-end-state><span class=secno>12.2.5.31</span> Script data double escape end state</a><li><a href=parsing.html#before-attribute-name-state><span class=secno>12.2.5.32</span> Before attribute name state</a><li><a href=parsing.html#attribute-name-state><span class=secno>12.2.5.33</span> Attribute name state</a><li><a href=parsing.html#after-attribute-name-state><span class=secno>12.2.5.34</span> After attribute name state</a><li><a href=parsing.html#before-attribute-value-state><span class=secno>12.2.5.35</span> Before attribute value state</a><li><a href=parsing.html#attribute-value-(double-quoted)-state><span class=secno>12.2.5.36</span> Attribute value (double-quoted) state</a><li><a href=parsing.html#attribute-value-(single-quoted)-state><span class=secno>12.2.5.37</span> Attribute value (single-quoted) state</a><li><a href=parsing.html#attribute-value-(unquoted)-state><span class=secno>12.2.5.38</span> Attribute value (unquoted) state</a><li><a href=parsing.html#after-attribute-value-(quoted)-state><span class=secno>12.2.5.39</span> After attribute value (quoted) state</a><li><a href=parsing.html#self-closing-start-tag-state><span class=secno>12.2.5.40</span> Self-closing start tag state</a><li><a href=parsing.html#bogus-comment-state><span class=secno>12.2.5.41</span> Bogus comment state</a><li><a href=parsing.html#markup-declaration-open-state><span class=secno>12.2.5.42</span> Markup declaration open state</a><li><a href=parsing.html#comment-start-state><span class=secno>12.2.5.43</span> Comment start state</a><li><a href=parsing.html#comment-start-dash-state><span class=secno>12.2.5.44</span> Comment start dash state</a><li><a href=parsing.html#comment-state><span class=secno>12.2.5.45</span> Comment state</a><li><a href=parsing.html#comment-less-than-sign-state><span class=secno>12.2.5.46</span> Comment less-than sign state</a><li><a href=parsing.html#comment-less-than-sign-bang-state><span class=secno>12.2.5.47</span> Comment less-than sign bang state</a><li><a href=parsing.html#comment-less-than-sign-bang-dash-state><span class=secno>12.2.5.48</span> Comment less-than sign bang dash state</a><li><a href=parsing.html#comment-less-than-sign-bang-dash-dash-state><span class=secno>12.2.5.49</span> Comment less-than sign bang dash dash state</a><li><a href=parsing.html#comment-end-dash-state><span class=secno>12.2.5.50</span> Comment end dash state</a><li><a href=parsing.html#comment-end-state><span class=secno>12.2.5.51</span> Comment end state</a><li><a href=parsing.html#comment-end-bang-state><span class=secno>12.2.5.52</span> Comment end bang state</a><li><a href=parsing.html#doctype-state><span class=secno>12.2.5.53</span> DOCTYPE state</a><li><a href=parsing.html#before-doctype-name-state><span class=secno>12.2.5.54</span> Before DOCTYPE name state</a><li><a href=parsing.html#doctype-name-state><span class=secno>12.2.5.55</span> DOCTYPE name state</a><li><a href=parsing.html#after-doctype-name-state><span class=secno>12.2.5.56</span> After DOCTYPE name state</a><li><a href=parsing.html#after-doctype-public-keyword-state><span class=secno>12.2.5.57</span> After DOCTYPE public keyword state</a><li><a href=parsing.html#before-doctype-public-identifier-state><span class=secno>12.2.5.58</span> Before DOCTYPE public identifier state</a><li><a href=parsing.html#doctype-public-identifier-(double-quoted)-state><span class=secno>12.2.5.59</span> DOCTYPE public identifier (double-quoted) state</a><li><a href=parsing.html#doctype-public-identifier-(single-quoted)-state><span class=secno>12.2.5.60</span> DOCTYPE public identifier (single-quoted) state</a><li><a href=parsing.html#after-doctype-public-identifier-state><span class=secno>12.2.5.61</span> After DOCTYPE public identifier state</a><li><a href=parsing.html#between-doctype-public-and-system-identifiers-state><span class=secno>12.2.5.62</span> Between DOCTYPE public and system identifiers state</a><li><a href=parsing.html#after-doctype-system-keyword-state><span class=secno>12.2.5.63</span> After DOCTYPE system keyword state</a><li><a href=parsing.html#before-doctype-system-identifier-state><span class=secno>12.2.5.64</span> Before DOCTYPE system identifier state</a><li><a href=parsing.html#doctype-system-identifier-(double-quoted)-state><span class=secno>12.2.5.65</span> DOCTYPE system identifier (double-quoted) state</a><li><a href=parsing.html#doctype-system-identifier-(single-quoted)-state><span class=secno>12.2.5.66</span> DOCTYPE system identifier (single-quoted) state</a><li><a href=parsing.html#after-doctype-system-identifier-state><span class=secno>12.2.5.67</span> After DOCTYPE system identifier state</a><li><a href=parsing.html#bogus-doctype-state><span class=secno>12.2.5.68</span> Bogus DOCTYPE state</a><li><a href=parsing.html#cdata-section-state><span class=secno>12.2.5.69</span> CDATA section state</a><li><a href=parsing.html#cdata-section-bracket-state><span class=secno>12.2.5.70</span> CDATA section bracket state</a><li><a href=parsing.html#cdata-section-end-state><span class=secno>12.2.5.71</span> CDATA section end state</a><li><a href=parsing.html#character-reference-state><span class=secno>12.2.5.72</span> Character reference state</a><li><a href=parsing.html#named-character-reference-state><span class=secno>12.2.5.73</span> Named character reference state</a><li><a href=parsing.html#ambiguous-ampersand-state><span class=secno>12.2.5.74</span> Ambiguous ampersand state</a><li><a href=parsing.html#numeric-character-reference-state><span class=secno>12.2.5.75</span> Numeric character reference state</a><li><a href=parsing.html#hexademical-character-reference-start-state><span class=secno>12.2.5.76</span> Hexademical character reference start state</a><li><a href=parsing.html#decimal-character-reference-start-state><span class=secno>12.2.5.77</span> Decimal character reference start state</a><li><a href=parsing.html#hexademical-character-reference-state><span class=secno>12.2.5.78</span> Hexademical character reference state</a><li><a href=parsing.html#decimal-character-reference-state><span class=secno>12.2.5.79</span> Decimal character reference state</a><li><a href=parsing.html#numeric-character-reference-end-state><span class=secno>12.2.5.80</span> Numeric character reference end state</a></ol><li><a href=parsing.html#tree-construction><span class=secno>12.2.6</span> Tree construction</a><ol><li><a href=parsing.html#creating-and-inserting-nodes><span class=secno>12.2.6.1</span> Creating and inserting nodes</a><li><a href=parsing.html#parsing-elements-that-contain-only-text><span class=secno>12.2.6.2</span> Parsing elements that contain only text</a><li><a href=parsing.html#closing-elements-that-have-implied-end-tags><span class=secno>12.2.6.3</span> Closing elements that have implied end tags</a><li><a href=parsing.html#parsing-main-inhtml><span class=secno>12.2.6.4</span> The rules for parsing tokens in HTML content</a><ol><li><a href=parsing.html#the-initial-insertion-mode><span class=secno>12.2.6.4.1</span> The "initial" insertion mode</a><li><a href=parsing.html#the-before-html-insertion-mode><span class=secno>12.2.6.4.2</span> The "before html" insertion mode</a><li><a href=parsing.html#the-before-head-insertion-mode><span class=secno>12.2.6.4.3</span> The "before head" insertion mode</a><li><a href=parsing.html#parsing-main-inhead><span class=secno>12.2.6.4.4</span> The "in head" insertion mode</a><li><a href=parsing.html#parsing-main-inheadnoscript><span class=secno>12.2.6.4.5</span> The "in head noscript" insertion mode</a><li><a href=parsing.html#the-after-head-insertion-mode><span class=secno>12.2.6.4.6</span> The "after head" insertion mode</a><li><a href=parsing.html#parsing-main-inbody><span class=secno>12.2.6.4.7</span> The "in body" insertion mode</a><li><a href=parsing.html#parsing-main-incdata><span class=secno>12.2.6.4.8</span> The "text" insertion mode</a><li><a href=parsing.html#parsing-main-intable><span class=secno>12.2.6.4.9</span> The "in table" insertion mode</a><li><a href=parsing.html#parsing-main-intabletext><span class=secno>12.2.6.4.10</span> The "in table text" insertion mode</a><li><a href=parsing.html#parsing-main-incaption><span class=secno>12.2.6.4.11</span> The "in caption" insertion mode</a><li><a href=parsing.html#parsing-main-incolgroup><span class=secno>12.2.6.4.12</span> The "in column group" insertion mode</a><li><a href=parsing.html#parsing-main-intbody><span class=secno>12.2.6.4.13</span> The "in table body" insertion mode</a><li><a href=parsing.html#parsing-main-intr><span class=secno>12.2.6.4.14</span> The "in row" insertion mode</a><li><a href=parsing.html#parsing-main-intd><span class=secno>12.2.6.4.15</span> The "in cell" insertion mode</a><li><a href=parsing.html#parsing-main-inselect><span class=secno>12.2.6.4.16</span> The "in select" insertion mode</a><li><a href=parsing.html#parsing-main-inselectintable><span class=secno>12.2.6.4.17</span> The "in select in table" insertion mode</a><li><a href=parsing.html#parsing-main-intemplate><span class=secno>12.2.6.4.18</span> The "in template" insertion mode</a><li><a href=parsing.html#parsing-main-afterbody><span class=secno>12.2.6.4.19</span> The "after body" insertion mode</a><li><a href=parsing.html#parsing-main-inframeset><span class=secno>12.2.6.4.20</span> The "in frameset" insertion mode</a><li><a href=parsing.html#parsing-main-afterframeset><span class=secno>12.2.6.4.21</span> The "after frameset" insertion mode</a><li><a href=parsing.html#the-after-after-body-insertion-mode><span class=secno>12.2.6.4.22</span> The "after after body" insertion mode</a><li><a href=parsing.html#the-after-after-frameset-insertion-mode><span class=secno>12.2.6.4.23</span> The "after after frameset" insertion mode</a></ol><li><a href=parsing.html#parsing-main-inforeign><span class=secno>12.2.6.5</span> The rules for parsing tokens in foreign content</a></ol><li><a href=parsing.html#the-end><span class=secno>12.2.7</span> The end</a><li><a href=parsing.html#coercing-an-html-dom-into-an-infoset><span class=secno>12.2.8</span> Coercing an HTML DOM into an infoset</a><li><a href=parsing.html#an-introduction-to-error-handling-and-strange-cases-in-the-parser><span class=secno>12.2.9</span> An introduction to error handling and strange cases in the parser</a><ol><li><a href=parsing.html#misnested-tags:-b-i-/b-/i><span class=secno>12.2.9.1</span> Misnested tags: <b><i></b></i></a><li><a href=parsing.html#misnested-tags:-b-p-/b-/p><span class=secno>12.2.9.2</span> Misnested tags: <b><p></b></p></a><li><a href=parsing.html#unexpected-markup-in-tables><span class=secno>12.2.9.3</span> Unexpected markup in tables</a><li><a href=parsing.html#scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>12.2.9.4</span> Scripts that modify the page as it is being parsed</a><li><a href=parsing.html#the-execution-of-scripts-that-are-moving-across-multiple-documents><span class=secno>12.2.9.5</span> The execution of scripts that are moving across multiple documents</a><li><a href=parsing.html#unclosed-formatting-elements><span class=secno>12.2.9.6</span> Unclosed formatting elements</a></ol></ol><li><a href=parsing.html#serialising-html-fragments><span class=secno>12.3</span> Serializing HTML fragments</a><li><a href=parsing.html#parsing-html-fragments><span class=secno>12.4</span> Parsing HTML fragments</a></ol></ol><h3 id=parsing><span class=secno>12.2</span> Parsing HTML documents<a href=#parsing class=self-link></a></h3>
|
||
|
||
<p><i>This section only applies to user agents, data mining tools, and conformance
|
||
checkers.</i></p>
|
||
|
||
<p class=note>The rules for parsing XML documents into DOM trees are covered by the next
|
||
section, entitled "<a id=parsing:the-xhtml-syntax href=xhtml.html#the-xhtml-syntax>The XML syntax</a>".</p>
|
||
|
||
<p>User agents must use the parsing rules described in this section to generate the DOM trees from
|
||
<code id=parsing:text/html><a href=iana.html#text/html>text/html</a></code> resources. Together, these rules define what is referred to as the
|
||
<dfn id=html-parser data-export="">HTML parser</dfn>.</p>
|
||
|
||
<div class=note>
|
||
|
||
<p>While the HTML syntax described in this specification bears a close resemblance to SGML and
|
||
XML, it is a separate language with its own parsing rules.</p>
|
||
|
||
<p>Some earlier versions of HTML (in particular from HTML2 to HTML4) were based on SGML and used
|
||
SGML parsing rules. However, few (if any) web browsers ever implemented true SGML parsing for
|
||
HTML documents; the only user agents to strictly handle HTML as an SGML application have
|
||
historically been validators. The resulting confusion — with validators claiming documents
|
||
to have one representation while widely deployed Web browsers interoperably implemented a
|
||
different representation — has wasted decades of productivity. This version of HTML thus
|
||
returns to a non-SGML basis.</p>
|
||
|
||
<p>Authors interested in using SGML tools in their authoring pipeline are encouraged to use XML
|
||
tools and the XML serialization of HTML.</p>
|
||
|
||
</div>
|
||
|
||
<p>For the purposes of conformance checkers, if a resource is determined to be in <a id=parsing:syntax href=syntax.html#syntax>the HTML
|
||
syntax</a>, then it is an <a href=https://dom.spec.whatwg.org/#html-document id=parsing:html-documents data-x-internal=html-documents>HTML document</a>.</p>
|
||
|
||
<p class=note>As stated <a href=infrastructure.html#html-elements id=parsing:html-elements class=no-backref>in the terminology
|
||
section</a>, references to <a href=infrastructure.html#element-type id=parsing:element-type>element types</a> that do not
|
||
explicitly specify a namespace always refer to elements in the <a id=parsing:html-namespace-2 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a>. For
|
||
example, if the spec talks about "a <code id=parsing:the-menu-element><a href=grouping-content.html#the-menu-element>menu</a></code> element", then that is an element with the
|
||
local name "<code>menu</code>", the namespace "<code>http://www.w3.org/1999/xhtml</code>", and the interface <code id=parsing:htmlmenuelement><a href=grouping-content.html#htmlmenuelement>HTMLMenuElement</a></code>.
|
||
Where possible, references to such elements are hyperlinked to their definition.</p>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h4 id=overview-of-the-parsing-model><span class=secno>12.2.1</span> Overview of the parsing model<a href=#overview-of-the-parsing-model class=self-link></a></h4>
|
||
|
||
<p class=overview><img src=/images/parsing-model-overview.svg width=345 alt="" height=535></p>
|
||
|
||
<p>The input to the HTML parsing process consists of a stream of <a href=https://infra.spec.whatwg.org/#code-point id=overview-of-the-parsing-model:code-point data-x-internal=code-point>code
|
||
points</a>, which is passed through a <a href=#tokenization id=overview-of-the-parsing-model:tokenization>tokenization</a> stage followed by a <a href=#tree-construction id=overview-of-the-parsing-model:tree-construction>tree
|
||
construction</a> stage. The output is a <code id=overview-of-the-parsing-model:document><a href=dom.html#document>Document</a></code> object.</p>
|
||
|
||
<p class=note>Implementations that <a href=infrastructure.html#non-scripted>do not support scripting</a> do not
|
||
have to actually create a DOM <code id=overview-of-the-parsing-model:document-2><a href=dom.html#document>Document</a></code> object, but the DOM tree in such cases is
|
||
still used as the model for the rest of the specification.</p>
|
||
|
||
<p>In the common case, the data handled by the tokenization stage comes from the network, but
|
||
<a href=dynamic-markup-insertion.html#dynamic-markup-insertion id=overview-of-the-parsing-model:dynamic-markup-insertion>it can also come from script</a> running in the user
|
||
agent, e.g. using the <code id=overview-of-the-parsing-model:dom-document-write-2><a href=dynamic-markup-insertion.html#dom-document-write-2>document.write()</a></code> API.</p>
|
||
|
||
<p id=nestedParsing>There is only one set of states for the tokenizer stage and the tree
|
||
construction stage, but the tree construction stage is reentrant, meaning that while the tree
|
||
construction stage is handling one token, the tokenizer might be resumed, causing further tokens
|
||
to be emitted and processed before the first token's processing is complete.</p>
|
||
|
||
<div class=example>
|
||
|
||
<p>In the following example, the tree construction stage will be called upon to handle a "p"
|
||
start tag token while handling the "script" end tag token:</p>
|
||
|
||
<pre>...
|
||
<script>
|
||
document.write('<p>');
|
||
</script>
|
||
...</pre>
|
||
|
||
</div>
|
||
|
||
<p>To handle these cases, parsers have a <dfn id=script-nesting-level>script nesting level</dfn>, which must be initially
|
||
set to zero, and a <dfn id=parser-pause-flag>parser pause flag</dfn>, which must be initially set to false.</p>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h4 id=parse-errors><span class=secno>12.2.2</span> <dfn>Parse errors</dfn><a href=#parse-errors class=self-link></a></h4>
|
||
|
||
<p>This specification defines the parsing rules for HTML documents, whether they are syntactically
|
||
correct or not. Certain points in the parsing algorithm are said to be <a href=#parse-errors id=parse-errors:parse-errors>parse errors</a>. The error handling for parse errors is well-defined (that's the
|
||
processing rules described throughout this specification), but user agents, while parsing an HTML
|
||
document, may <a href=#abort-a-parser id=parse-errors:abort-a-parser>abort the parser</a> at the first <a href=#parse-errors id=parse-errors:parse-errors-2>parse
|
||
error</a> that they encounter for which they do not wish to apply the rules described in this
|
||
specification.</p>
|
||
|
||
<p>Conformance checkers must report at least one parse error condition to the user if one or more
|
||
parse error conditions exist in the document and must not report parse error conditions if none
|
||
exist in the document. Conformance checkers may report more than one parse error condition if more
|
||
than one parse error condition exists in the document.</p>
|
||
|
||
<p class=note>Parse errors are only errors with the <em>syntax</em> of HTML. In addition to
|
||
checking for parse errors, conformance checkers will also verify that the document obeys all the
|
||
other conformance requirements described in this specification.</p>
|
||
|
||
<p>Some parse errors have dedicated codes outlined in the table below that should be used by
|
||
conformance checkers in reports.</p>
|
||
|
||
<p><i>Error descriptions in the table below are non-normative.</i></p>
|
||
|
||
<table class=parse-error-table><thead><tr><th>Code
|
||
<th>Description
|
||
<tbody><tr><td><dfn id=parse-error-abrupt-closing-of-empty-comment>abrupt-closing-of-empty-comment</dfn>
|
||
<td><p>This error occurs if the parser encounters an empty <a href=syntax.html#syntax-comments id=parse-errors:syntax-comments>comment</a> that is abruptly closed by a U+003E (>) <a id=parse-errors:code-point href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code
|
||
point</a> (i.e., <code><!--></code> or <code><!---></code>). The
|
||
parser behaves as if the comment is closed correctly.</p>
|
||
|
||
<tr><td><dfn id=parse-error-abrupt-doctype-public-identifier>abrupt-doctype-public-identifier</dfn>
|
||
<td><p>This error occurs if the parser encounters a U+003E (>) <a id=parse-errors:code-point-2 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> in the
|
||
<a href=syntax.html#syntax-doctype id=parse-errors:syntax-doctype>DOCTYPE</a> public identifier (e.g., <code><!DOCTYPE html PUBLIC "foo></code>). In such a case, if the DOCTYPE is correctly
|
||
placed as a document preamble, the parser sets the <code id=parse-errors:document><a href=dom.html#document>Document</a></code> to <a id=parse-errors:quirks-mode href=https://dom.spec.whatwg.org/#concept-document-quirks data-x-internal=quirks-mode>quirks
|
||
mode</a>.</p>
|
||
|
||
<tr><td><dfn id=parse-error-abrupt-doctype-system-identifier>abrupt-doctype-system-identifier</dfn>
|
||
<td><p>This error occurs if the parser encounters a U+003E (>) <a id=parse-errors:code-point-3 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> in the
|
||
<a href=syntax.html#syntax-doctype id=parse-errors:syntax-doctype-2>DOCTYPE</a> system identifier (e.g., <code><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "foo></code>). In such a case,
|
||
if the DOCTYPE is correctly placed as a document preamble, the parser sets the
|
||
<code id=parse-errors:document-2><a href=dom.html#document>Document</a></code> to <a id=parse-errors:quirks-mode-2 href=https://dom.spec.whatwg.org/#concept-document-quirks data-x-internal=quirks-mode>quirks mode</a>.</p>
|
||
|
||
<tr><td><dfn id=parse-error-absence-of-digits-in-numeric-character-reference>absence-of-digits-in-numeric-character-reference</dfn>
|
||
<td><p>This error occurs if the parser encounters a numeric <a href=syntax.html#syntax-charref id=parse-errors:syntax-charref>character reference</a> that doesn't contain any digits (e.g., <code>&#qux;</code>). In this case the parser doesn't resolve the character
|
||
reference.</p>
|
||
|
||
<tr><td><dfn id=parse-error-cdata-in-html-content>cdata-in-html-content</dfn>
|
||
<td><p>This error occurs if the parser encounters a <a href=syntax.html#syntax-cdata id=parse-errors:syntax-cdata>CDATA
|
||
section</a> outside of foreign content (SVG or MathML). The parser treats such CDATA
|
||
sections (including leading "<code>[CDATA[</code>" and trailing "<code>]]</code>" strings) as comments.</p>
|
||
|
||
<tr><td><dfn id=parse-error-character-reference-outside-unicode-range>character-reference-outside-unicode-range</dfn>
|
||
<td><p>This error occurs if the parser encounters a numeric <a href=syntax.html#syntax-charref id=parse-errors:syntax-charref-2>character reference</a> that references a <a id=parse-errors:code-point-4 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a>
|
||
that is greater than the valid Unicode range. The parser resolves such a character reference to
|
||
a U+FFFD REPLACEMENT CHARACTER.</p>
|
||
|
||
<tr><td><dfn id=parse-error-control-character-in-input-stream>control-character-in-input-stream</dfn>
|
||
<td><p>This error occurs if the <a href=#input-stream id=parse-errors:input-stream>input stream</a> contains a <a href=https://infra.spec.whatwg.org/#control id=parse-errors:control data-x-internal=control>control</a> <a id=parse-errors:code-point-5 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> that is not <a id=parse-errors:space-characters href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII
|
||
whitespace</a> or U+0000 NULL. Such code points are parsed as-is and usually, where parsing
|
||
rules don't apply any additional restrictions, make their way into the DOM.</p>
|
||
|
||
<tr><td><dfn id=parse-error-control-character-reference>control-character-reference</dfn>
|
||
<td><p>This error occurs if the parser encounters a numeric <a href=syntax.html#syntax-charref id=parse-errors:syntax-charref-3>character reference</a> that references a <a href=https://infra.spec.whatwg.org/#control id=parse-errors:control-2 data-x-internal=control>control</a> <a id=parse-errors:code-point-6 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> that is not <a id=parse-errors:space-characters-2 href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII
|
||
whitespace</a>, a U+000D CARRIAGE RETURN, or U+0000 NULL. The parser resolves such character
|
||
references as-is except C1 control references that are replaced according to the <a href=#numeric-character-reference-end-state id=parse-errors:numeric-character-reference-end-state>numeric
|
||
character reference end state</a>.</p>
|
||
|
||
<tr><td><dfn id=parse-error-end-tag-with-attributes>end-tag-with-attributes</dfn>
|
||
<td><p>This error occurs if the parser encounters an <a href=syntax.html#syntax-end-tag id=parse-errors:syntax-end-tag>end
|
||
tag</a> with <a href=syntax.html#syntax-attributes id=parse-errors:syntax-attributes>attributes</a>. Attributes in end tags are
|
||
completely ignored and do not make their way into the DOM.</p>
|
||
|
||
<tr><td><dfn id=parse-error-duplicate-attribute>duplicate-attribute</dfn>
|
||
<td><p>This error occurs if the parser encounters an <a href=syntax.html#syntax-attributes id=parse-errors:syntax-attributes-2>attribute</a> in a tag that already has an attribute with the
|
||
same name. The parser ignores all such duplicate occurrences of the attribute.
|
||
|
||
<tr><td><dfn id=parse-error-end-tag-with-trailing-solidus>end-tag-with-trailing-solidus</dfn>
|
||
<td><p>This error occurs if the parser encounters an <a href=syntax.html#syntax-end-tag id=parse-errors:syntax-end-tag-2>end
|
||
tag</a> that has a U+002F (/) <a id=parse-errors:code-point-7 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> right before the closing U+003E (>)
|
||
code point (e.g., <code></div/></code>). Such a tag is treated as a regular end
|
||
tag.</p>
|
||
|
||
<tr><td><dfn id=parse-error-eof-before-tag-name>eof-before-tag-name</dfn>
|
||
<td><p>This error occurs if the parser encounters the end of the <a href=#input-stream id=parse-errors:input-stream-2>input stream</a>
|
||
where a tag name is expected. In this case the parser treats the beginning of a <a href=syntax.html#syntax-start-tag id=parse-errors:syntax-start-tag>start tag</a> (i.e., <code><</code>) or an <a href=syntax.html#syntax-end-tag id=parse-errors:syntax-end-tag-3>end tag</a> (i.e., <code></</code>) as text
|
||
content.</p>
|
||
|
||
<tr><td><dfn id=parse-error-eof-in-cdata>eof-in-cdata</dfn>
|
||
<td><p>This error occurs if the parser encounters the end of the <a href=#input-stream id=parse-errors:input-stream-3>input stream</a> in a
|
||
<a href=syntax.html#syntax-cdata id=parse-errors:syntax-cdata-2>CDATA section</a>. The parser treats such CDATA sections as if
|
||
they are closed immediately before the end of the input stream.</p>
|
||
|
||
<tr><td><dfn id=parse-error-eof-in-comment>eof-in-comment</dfn>
|
||
<td><p>This error occurs if the parser encounters the end of the <a href=#input-stream id=parse-errors:input-stream-4>input stream</a> in a
|
||
<a href=syntax.html#syntax-comments id=parse-errors:syntax-comments-2>comment</a>. The parser treats such comments as if they are
|
||
closed immediately before the end of the input stream.</p>
|
||
|
||
<tr><td><dfn id=parse-error-eof-in-doctype>eof-in-doctype</dfn>
|
||
<td><p>This error occurs if the parser encounters the end of the input stream in a <a href=syntax.html#syntax-doctype id=parse-errors:syntax-doctype-3>DOCTYPE</a>. In such a case, if the DOCTYPE is correctly placed as a
|
||
document preamble, the parser sets the <code id=parse-errors:document-3><a href=dom.html#document>Document</a></code> to <a id=parse-errors:quirks-mode-3 href=https://dom.spec.whatwg.org/#concept-document-quirks data-x-internal=quirks-mode>quirks mode</a>.</p>
|
||
|
||
<tr><td><dfn id=parse-error-eof-in-script-html-comment-like-text>eof-in-script-html-comment-like-text</dfn>
|
||
<td>
|
||
<p>This error occurs if the parser encounters the end of the <a href=#input-stream id=parse-errors:input-stream-5>input stream</a> in text
|
||
that resembles an <a href=syntax.html#syntax-comments id=parse-errors:syntax-comments-3>HTML comment</a> inside
|
||
<code id=parse-errors:the-script-element><a href=scripting.html#the-script-element>script</a></code> element content (e.g., <code><script><!-- foo</code>).</p>
|
||
|
||
<p class=note>Syntactic structures that resemble HTML comments in <code id=parse-errors:the-script-element-2><a href=scripting.html#the-script-element>script</a></code>
|
||
elements are parsed as text content. They can be a part of a scripting language-specific
|
||
syntactic structure or be treated as an HTML-like comment, if the scripting language supports
|
||
them (e.g., parsing rules for HTML-like comments can be found in Annex B of the JavaScript
|
||
specification). The common reason for this error is a violation of the <a href=scripting.html#restrictions-for-contents-of-script-elements id=parse-errors:restrictions-for-contents-of-script-elements>restrictions for contents of <code>script</code> elements</a>. <a href=references.html#refsJAVASCRIPT>[JAVASCRIPT]</a></p>
|
||
|
||
<tr><td><dfn id=parse-error-eof-in-tag>eof-in-tag</dfn>
|
||
<td><p>This error occurs if the parser encounters the end of the <a href=#input-stream id=parse-errors:input-stream-6>input stream</a> in a
|
||
<a href=syntax.html#syntax-start-tag id=parse-errors:syntax-start-tag-2>start tag</a> or an <a href=syntax.html#syntax-end-tag id=parse-errors:syntax-end-tag-4>end
|
||
tag</a> (e.g., <code><div id=</code>). Such a tag is completely ignored.</p>
|
||
|
||
<tr><td><dfn id=parse-error-incorrectly-closed-comment>incorrectly-closed-comment</dfn>
|
||
<td><p>This error occurs if the parser encounters a <a href=syntax.html#syntax-comments id=parse-errors:syntax-comments-4>comment</a> that is closed by the "<code>--!></code>"
|
||
<a id=parse-errors:code-point-8 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> sequence. The parser treats such comments as if they are correctly
|
||
closed by the "<code>--></code>" code point sequence.</p>
|
||
|
||
<tr><td><dfn id=parse-error-incorrectly-opened-comment>incorrectly-opened-comment</dfn>
|
||
<td>
|
||
<p>This error occurs if the parser encounters the "<code><!</code>" <a id=parse-errors:code-point-9 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code
|
||
point</a> sequence that is not immidiately followed by two U+002D (-) code points and that
|
||
is not the start of a <a href=syntax.html#syntax-doctype id=parse-errors:syntax-doctype-4>DOCTYPE</a> or a <a href=syntax.html#syntax-cdata id=parse-errors:syntax-cdata-3>CDATA section</a>. All content that follows the "<code><!</code>" code point sequence up to a U+003E (>) code point (if present) or to
|
||
the end of the <a href=#input-stream id=parse-errors:input-stream-7>input stream</a> is treated as a comment.</p>
|
||
|
||
<p class=note>One possible cause of this error is using an XML markup declaration (e.g.,
|
||
<code><!ELEMENT br EMPTY></code>) in HTML.</p>
|
||
|
||
<tr><td><dfn id=parse-error-invalid-character-sequence-after-doctype-name>invalid-character-sequence-after-doctype-name</dfn>
|
||
<td><p>This error occurs if the parser encounters any <a id=parse-errors:code-point-10 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> sequence other
|
||
than "<code>PUBLIC</code>" and "<code>SYSTEM</code>" keywords after a <a href=syntax.html#syntax-doctype id=parse-errors:syntax-doctype-5>DOCTYPE</a> name. In such a case, the parser ignores any following
|
||
public or system identifiers, and if the DOCTYPE is correctly placed as a document preamble,
|
||
sets the <code id=parse-errors:document-4><a href=dom.html#document>Document</a></code> to <a id=parse-errors:quirks-mode-4 href=https://dom.spec.whatwg.org/#concept-document-quirks data-x-internal=quirks-mode>quirks mode</a>.</p>
|
||
|
||
<tr><td><dfn id=parse-error-invalid-first-character-of-tag-name>invalid-first-character-of-tag-name</dfn>
|
||
<td>
|
||
<p>This error occurs if the parser encounters a <a id=parse-errors:code-point-11 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> that is not an
|
||
<a id=parse-errors:ascii-letters href=https://infra.spec.whatwg.org/#ascii-alpha data-x-internal=ascii-letters>ASCII alpha</a> where first code point of a <a href=syntax.html#syntax-start-tag id=parse-errors:syntax-start-tag-3>start
|
||
tag</a> name or an <a href=syntax.html#syntax-end-tag id=parse-errors:syntax-end-tag-5>end tag</a> name is expected. If a
|
||
start tag was expected such code point and a preceding U+003C (<) is treated as text
|
||
content, and all content that follows is treated as markup. Whereas, if an end tag was
|
||
expected, such code point and all content that follows up to a U+003E (>) code point (if
|
||
present) or to the end of the <a href=#input-stream id=parse-errors:input-stream-8>input stream</a> is treated as a comment.</p>
|
||
|
||
<div class=example>
|
||
<p>For example, consider the following markup:</p>
|
||
|
||
<pre><42></42></pre>
|
||
|
||
<p>This will be parsed into:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=parse-errors:the-html-element><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=parse-errors:the-head-element><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=parse-errors:the-body-element><a href=sections.html#the-body-element>body</a></code><ul><li class=t3><code id=parse-errors:text><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span><42></span><li class=t8><code id=parse-errors:comment-2><a data-x-internal=comment-2 href=https://dom.spec.whatwg.org/#interface-comment>#comment</a></code>: <span>42</span></ul></ul></ul>
|
||
</div>
|
||
|
||
<p class=note>While the first code point of a tag name is limited to an <a id=parse-errors:ascii-letters-2 href=https://infra.spec.whatwg.org/#ascii-alpha data-x-internal=ascii-letters>ASCII
|
||
alpha</a>, a wide range of code points (including <a id=parse-errors:ascii-digits href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>) is allowed in
|
||
subsequent positions.</p>
|
||
|
||
<tr><td><dfn id=parse-error-missing-attribute-value>missing-attribute-value</dfn>
|
||
<td><p>This error occurs if the parser encounters a U+003E (>) <a id=parse-errors:code-point-12 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> where an
|
||
<a href=syntax.html#syntax-attributes id=parse-errors:syntax-attributes-3>attribute</a> value is expected (e.g., <code><div id=></code>). The parser treats the attribute as having an empty value.</p>
|
||
|
||
<tr><td><dfn id=parse-error-missing-doctype-name>missing-doctype-name</dfn>
|
||
<td><p>This error occurs if the parser encounters a <a href=syntax.html#syntax-doctype id=parse-errors:syntax-doctype-6>DOCTYPE</a> that is missing a name (e.g., <code><!DOCTYPE></code>). In such a case, if the DOCTYPE is correctly placed as a
|
||
document preamble, the parser sets the <code id=parse-errors:document-5><a href=dom.html#document>Document</a></code> to <a id=parse-errors:quirks-mode-5 href=https://dom.spec.whatwg.org/#concept-document-quirks data-x-internal=quirks-mode>quirks mode</a>.</p>
|
||
|
||
<tr><td><dfn id=parse-error-missing-doctype-public-identifier>missing-doctype-public-identifier</dfn>
|
||
<td><p>This error occurs if the parser encounters a U+003E (>) <a id=parse-errors:code-point-13 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> where
|
||
start of the <a href=syntax.html#syntax-doctype id=parse-errors:syntax-doctype-7>DOCTYPE</a> public identifier is expected (e.g.,
|
||
<code><!DOCTYPE html PUBLIC ></code>). In such a case, if the DOCTYPE is correctly
|
||
placed as a document preamble, the parser sets the <code id=parse-errors:document-6><a href=dom.html#document>Document</a></code> to <a id=parse-errors:quirks-mode-6 href=https://dom.spec.whatwg.org/#concept-document-quirks data-x-internal=quirks-mode>quirks
|
||
mode</a>.</p>
|
||
|
||
<tr><td><dfn id=parse-error-missing-doctype-system-identifier>missing-doctype-system-identifier</dfn>
|
||
<td><p>This error occurs if the parser encounters a U+003E (>) <a id=parse-errors:code-point-14 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> where
|
||
start of the <a href=syntax.html#syntax-doctype id=parse-errors:syntax-doctype-8>DOCTYPE</a> system identifier is expected (e.g.,
|
||
<code><!DOCTYPE html SYSTEM ></code>). In such a case, if the DOCTYPE is correctly
|
||
placed as a document preamble, the parser sets the <code id=parse-errors:document-7><a href=dom.html#document>Document</a></code> to <a id=parse-errors:quirks-mode-7 href=https://dom.spec.whatwg.org/#concept-document-quirks data-x-internal=quirks-mode>quirks
|
||
mode</a>.</p>
|
||
|
||
<tr><td><dfn id=parse-error-missing-end-tag-name>missing-end-tag-name</dfn>
|
||
<td><p>This error occurs if the parser encounters a U+003E (>) <a id=parse-errors:code-point-15 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> where an
|
||
<a href=syntax.html#syntax-end-tag id=parse-errors:syntax-end-tag-6>end tag</a> name is expected, i.e., <code></></code>. The parser completely ignores whole "<code></></code>"
|
||
code point sequence.</p>
|
||
|
||
<tr><td><dfn id=parse-error-missing-quote-before-doctype-public-identifier>missing-quote-before-doctype-public-identifier</dfn>
|
||
<td><p>This error occurs if the parser encounters the <a href=syntax.html#syntax-doctype id=parse-errors:syntax-doctype-9>DOCTYPE</a> public identifier that is not preceded by a quote (e.g.,
|
||
<code><!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01//EN"></code>). In such a case,
|
||
the parser ignores the public identifier, and if the DOCTYPE is correctly placed as a document
|
||
preamble, sets the <code id=parse-errors:document-8><a href=dom.html#document>Document</a></code> to <a id=parse-errors:quirks-mode-8 href=https://dom.spec.whatwg.org/#concept-document-quirks data-x-internal=quirks-mode>quirks mode</a>.</p>
|
||
|
||
<tr><td><dfn id=parse-error-missing-quote-before-doctype-system-identifier>missing-quote-before-doctype-system-identifier</dfn>
|
||
<td><p>This error occurs if the parser encounters the <a href=syntax.html#syntax-doctype id=parse-errors:syntax-doctype-10>DOCTYPE</a> system identifier that is not preceded by a quote (e.g.,
|
||
<code><!DOCTYPE html SYSTEM
|
||
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></code>). In such a case, the parser
|
||
ignores the system identifier, and if the DOCTYPE is correctly placed as a document preamble,
|
||
sets the <code id=parse-errors:document-9><a href=dom.html#document>Document</a></code> to <a id=parse-errors:quirks-mode-9 href=https://dom.spec.whatwg.org/#concept-document-quirks data-x-internal=quirks-mode>quirks mode</a>.</p>
|
||
|
||
<tr><td><dfn id=parse-error-missing-semicolon-after-character-reference>missing-semicolon-after-character-reference</dfn>
|
||
<td>
|
||
<p>This error occurs if the parser encounters a <a href=syntax.html#syntax-charref id=parse-errors:syntax-charref-4>character
|
||
reference</a> that is not terminated by a U+003B (;) <a id=parse-errors:code-point-16 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a>. Usually the
|
||
parser behaves as if character reference is terminated by the U+003B (;) code point; however,
|
||
there are some ambiguous cases in which the parser includes subsequent code points in the
|
||
character reference.</p>
|
||
|
||
<p class=example>For example, <code>&not;in</code> will be parsed as "<code>¬in</code>" whereas <code>&notin</code> will be parsed as "<code>∉</code>".</p>
|
||
|
||
<tr><td><dfn id=parse-error-missing-whitespace-after-doctype-public-keyword>missing-whitespace-after-doctype-public-keyword</dfn>
|
||
<td><p>This error occurs if the parser encounters a <a href=syntax.html#syntax-doctype id=parse-errors:syntax-doctype-11>DOCTYPE</a> whose "<code>PUBLIC</code>" keyword and public
|
||
identifier are not separated by <a id=parse-errors:space-characters-3 href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a>. In this case the parser behaves
|
||
as if ASCII whitespace is present.</p>
|
||
|
||
<tr><td><dfn id=parse-error-missing-whitespace-after-doctype-system-keyword>missing-whitespace-after-doctype-system-keyword</dfn>
|
||
<td><p>This error occurs if the parser encounters a <a href=syntax.html#syntax-doctype id=parse-errors:syntax-doctype-12>DOCTYPE</a> whose "<code>SYSTEM</code>" keyword and system
|
||
identifier are not separated by <a id=parse-errors:space-characters-4 href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a>. In this case the parser behaves
|
||
as if ASCII whitespace is present.</p>
|
||
|
||
<tr><td><dfn id=parse-error-missing-whitespace-before-doctype-name>missing-whitespace-before-doctype-name</dfn>
|
||
<td><p>This error occurs if the parser encounters a <a href=syntax.html#syntax-doctype id=parse-errors:syntax-doctype-13>DOCTYPE</a> whose "<code>DOCTYPE</code>" keyword and name
|
||
are not separated by <a id=parse-errors:space-characters-5 href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a>. In this case the parser behaves as if ASCII
|
||
whitespace is present.</p>
|
||
|
||
<tr><td><dfn id=parse-error-missing-whitespace-between-attributes>missing-whitespace-between-attributes</dfn>
|
||
<td><p>This error occurs if the parser encounters <a href=syntax.html#syntax-attributes id=parse-errors:syntax-attributes-4>attributes</a> that are not separated by <a id=parse-errors:space-characters-6 href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII
|
||
whitespace</a> (e.g., <code><div id="foo"class="bar"></code>). In this case the
|
||
parser behaves as if ASCII whitespace is present.</p>
|
||
|
||
<tr><td><dfn id=parse-error-missing-whitespace-between-doctype-public-and-system-identifiers>missing-whitespace-between-doctype-public-and-system-identifiers</dfn>
|
||
<td><p>This error occurs if the parser encounters a <a href=syntax.html#syntax-doctype id=parse-errors:syntax-doctype-14>DOCTYPE</a> whose public and system identifiers are not separated by
|
||
<a id=parse-errors:space-characters-7 href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a>. In this case the parser behaves as if ASCII whitespace is
|
||
present.</p>
|
||
|
||
<tr><td><dfn id=parse-error-nested-comment>nested-comment</dfn>
|
||
<td><p>This error occurs if the parser encounters a nested <a href=syntax.html#syntax-comments id=parse-errors:syntax-comments-5>comment</a> (e.g., <code><!-- <!-- nested -->
|
||
--></code>). Such a comment will be closed by the first occuring "<code>--></code>"
|
||
<a id=parse-errors:code-point-17 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> sequence and everything that follows will be treated as markup.</p>
|
||
|
||
<tr><td><dfn id=parse-error-noncharacter-character-reference>noncharacter-character-reference</dfn>
|
||
<td><p>This error occurs if the parser encounters a numeric <a href=syntax.html#syntax-charref id=parse-errors:syntax-charref-5>character reference</a> that references a <a id=parse-errors:noncharacter href=https://infra.spec.whatwg.org/#noncharacter data-x-internal=noncharacter>noncharacter</a>.
|
||
The parser resolves such character references as-is.</p>
|
||
|
||
<tr><td><dfn id=parse-error-noncharacter-in-input-stream>noncharacter-in-input-stream</dfn>
|
||
<td><p>This error occurs if the <a href=#input-stream id=parse-errors:input-stream-9>input stream</a> contains a <a id=parse-errors:noncharacter-2 href=https://infra.spec.whatwg.org/#noncharacter data-x-internal=noncharacter>noncharacter</a>.
|
||
Such <a href=https://infra.spec.whatwg.org/#code-point id=parse-errors:code-point-18 data-x-internal=code-point>code points</a> are parsed as-is and usually, where parsing
|
||
rules don't apply any additional restrictions, make their way into the DOM.</p>
|
||
|
||
<tr><td><dfn id=parse-error-non-void-html-element-start-tag-with-trailing-solidus>non-void-html-element-start-tag-with-trailing-solidus</dfn>
|
||
<td>
|
||
<p>This error occurs if the parser encounters a <a href=syntax.html#syntax-start-tag id=parse-errors:syntax-start-tag-4>start
|
||
tag</a> for an element that is not in the list of <a id=parse-errors:void-elements href=syntax.html#void-elements>void elements</a> or is not a
|
||
part of foreign content (i.e., not an SVG or MathML element) that has a U+002F (/) <a id=parse-errors:code-point-19 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code
|
||
point</a> right before the closing U+003E (>) code point. The parser behaves as if the
|
||
U+002F (/) is not present.</p>
|
||
|
||
<div class=example>
|
||
<p>For example, consider the following markup:</p>
|
||
|
||
<pre><div/><span></span><span></span></pre>
|
||
|
||
<p>This will be parsed into:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=parse-errors:the-html-element-2><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=parse-errors:the-head-element-2><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=parse-errors:the-body-element-2><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=parse-errors:the-div-element><a href=grouping-content.html#the-div-element>div</a></code><ul><li class=t1><code id=parse-errors:the-span-element><a href=text-level-semantics.html#the-span-element>span</a></code><li class=t1><code id=parse-errors:the-span-element-2><a href=text-level-semantics.html#the-span-element>span</a></code></ul></ul></ul></ul>
|
||
</div>
|
||
|
||
<p class=note>The trailing U+002F (/) in a start tag name can be used only in foreign
|
||
content to specify self-closing tags. (Self-closing tags don't exist in HTML.) It is also
|
||
allowed for void elements, but doesn't have any effect in this case.</p>
|
||
|
||
<tr><td><dfn id=parse-error-null-character-reference>null-character-reference</dfn>
|
||
<td><p>This error occurs if the parser encounters a numeric <a href=syntax.html#syntax-charref id=parse-errors:syntax-charref-6>character reference</a> that references a U+0000 NULL <a id=parse-errors:code-point-20 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code
|
||
point</a>. The parser resolves such character references to a U+FFFD REPLACEMENT
|
||
CHARACTER.</p>
|
||
|
||
<tr><td><dfn id=parse-error-surrogate-character-reference>surrogate-character-reference</dfn>
|
||
<td><p>This error occurs if the parser encounters a numeric <a href=syntax.html#syntax-charref id=parse-errors:syntax-charref-7>character reference</a> that references a <a id=parse-errors:surrogate href=https://infra.spec.whatwg.org/#surrogate data-x-internal=surrogate>surrogate</a>.
|
||
The parser resolves such character references to a U+FFFD REPLACEMENT CHARACTER.</p>
|
||
|
||
<tr><td><dfn id=parse-error-surrogate-in-input-stream>surrogate-in-input-stream</dfn>
|
||
<td>
|
||
<p>This error occurs if the <a href=#input-stream id=parse-errors:input-stream-10>input stream</a> contains a <a href=https://infra.spec.whatwg.org/#surrogate id=parse-errors:surrogate-2 data-x-internal=surrogate>surrogate</a>. Such <a href=https://infra.spec.whatwg.org/#code-point id=parse-errors:code-point-21 data-x-internal=code-point>code points</a> are
|
||
parsed as-is and usually, where parsing rules don't apply any additional restrictions, make
|
||
their way into the DOM.</p>
|
||
|
||
<p class=note>Surrogates can only find their way into the input stream via script APIs such
|
||
as <code id=parse-errors:dom-document-write-2><a href=dynamic-markup-insertion.html#dom-document-write-2>document.write()</a></code>.</p>
|
||
|
||
<tr><td><dfn id=parse-error-unexpected-character-after-doctype-system-identifier>unexpected-character-after-doctype-system-identifier</dfn>
|
||
<td><p>This error occurs if the parser encounters any <a href=https://infra.spec.whatwg.org/#code-point id=parse-errors:code-point-22 data-x-internal=code-point>code
|
||
points</a> other than <a id=parse-errors:space-characters-8 href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a> or closing U+003E (>) after the <a href=syntax.html#syntax-doctype id=parse-errors:syntax-doctype-15>DOCTYPE</a> system identifier. The parser ignores these code
|
||
points.</p>
|
||
|
||
<tr><td><dfn id=parse-error-unexpected-character-in-attribute-name>unexpected-character-in-attribute-name</dfn>
|
||
<td>
|
||
<p>This error occurs if the parser encounters a U+0022 ("), U+0027 ('), or U+003C (<)
|
||
<a id=parse-errors:code-point-23 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> in an <a href=syntax.html#syntax-attribute-name id=parse-errors:syntax-attribute-name>attribute name</a>. The
|
||
parser includes such code points in the attribute name.</p>
|
||
|
||
<p class=note>Code points that trigger this error are usually a part of another syntactic
|
||
construct and can be a sign of a typo around the attribute name.</p>
|
||
|
||
<div class=example>
|
||
<p>For example, consider the following markup:</p>
|
||
|
||
<pre><div foo<div></pre>
|
||
|
||
<p>Due to a forgotten U+003E (>) code point after <code>foo</code> the parser
|
||
treats this markup as a single <code id=parse-errors:the-div-element-2><a href=grouping-content.html#the-div-element>div</a></code> element with a "<code>foo<div</code>" attribute.</p>
|
||
|
||
<p>As another example of this error, consider the following markup:</p>
|
||
|
||
<pre><div id'bar'></pre>
|
||
|
||
<p>Due to a forgotten U+003D (=) code point between an attribute name and value the parser
|
||
treats this markup as a <code id=parse-errors:the-div-element-3><a href=grouping-content.html#the-div-element>div</a></code> element with the attribute "<code>id'bar'</code>" that has an empty value.</p>
|
||
</div>
|
||
|
||
<tr><td><dfn id=parse-error-unexpected-character-in-unquoted-attribute-value>unexpected-character-in-unquoted-attribute-value</dfn>
|
||
<td>
|
||
<p>This error occurs if the parser encounters a U+0022 ("), U+0027 ('), U+003C (<), U+003D
|
||
(=), or U+0060 (`) <a id=parse-errors:code-point-24 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> in an unquoted <a href=syntax.html#syntax-attribute-value id=parse-errors:syntax-attribute-value>attribute value</a>. The parser includes such code points
|
||
in the attribute value.</p>
|
||
|
||
<p class=note>Code points that trigger this error are usually a part of another syntactic
|
||
construct and can be a sign of a typo around the attribute value.</p>
|
||
|
||
<p class=note>U+0060 (`) is in the list of code points that trigger this error because
|
||
certain legacy user agents treat it as a quote.</p>
|
||
|
||
<div class=example>
|
||
<p>For example, consider the following markup:</p>
|
||
|
||
<pre><div foo=b'ar'></pre>
|
||
|
||
<p>Due to a misplaced U+0027 (') code point the parser sets the value of the "<code>foo</code>" attribute to "<code>b'ar'</code>".</p>
|
||
</div>
|
||
|
||
<tr><td><dfn id=parse-error-unexpected-equals-sign-before-attribute-name>unexpected-equals-sign-before-attribute-name</dfn>
|
||
<td>
|
||
<p>This error occurs if the parser encounters a U+003D (=) <a id=parse-errors:code-point-25 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> before an
|
||
attribute name. In this case the parser treats U+003D (=) as the first code point of the
|
||
attribute name.</p>
|
||
|
||
<p class=note>The common reason for this error is a forgotten attribute name.</p>
|
||
|
||
<div class=example>
|
||
<p>For example, consider the following markup:</p>
|
||
|
||
<pre><div foo="bar" ="baz"></pre>
|
||
|
||
<p>Due to a forgotten attribute name the parser treats this markup as a <code id=parse-errors:the-div-element-4><a href=grouping-content.html#the-div-element>div</a></code>
|
||
element with two attributes: a "<code>foo</code>" attribute with a "<code>bar</code>" value and a "<code>="baz"</code>" attribute with an empty
|
||
value.</p>
|
||
</div>
|
||
|
||
<tr><td><dfn id=parse-error-unexpected-null-character>unexpected-null-character</dfn>
|
||
<td><p>This error occurs if the parser encounters a U+0000 NULL <a id=parse-errors:code-point-26 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> in the
|
||
<a href=#input-stream id=parse-errors:input-stream-11>input stream</a> in certain positions. In general, such code points are either
|
||
completely ignored or, for security reasons, replaced with a U+FFFD REPLACEMENT CHARACTER.</p>
|
||
|
||
<tr><td><dfn id=parse-error-unexpected-question-mark-instead-of-tag-name>unexpected-question-mark-instead-of-tag-name</dfn>
|
||
<td>
|
||
<p>This error occurs if the parser encounters a U+003F (?) <a id=parse-errors:code-point-27 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> where first
|
||
code point of a <a href=syntax.html#syntax-start-tag id=parse-errors:syntax-start-tag-5>start tag</a> name is expected. The U+003F
|
||
(?) and all content that follows up to a U+003E (>) code point (if present) or to the end of
|
||
the <a href=#input-stream id=parse-errors:input-stream-12>input stream</a> is treated as a comment.</p>
|
||
|
||
<div class=example>
|
||
<p>For example, consider the following markup:</p>
|
||
|
||
<pre><?xml-stylesheet type="text/css" href="style.css"?></pre>
|
||
|
||
<p>This will be parsed into:</p>
|
||
|
||
<ul class=domTree><li class=t8><code id=parse-errors:comment-2-2><a data-x-internal=comment-2 href=https://dom.spec.whatwg.org/#interface-comment>#comment</a></code>: <span>?xml-stylesheet type="text/css" href="style.css"?</span><li class=t1><code id=parse-errors:the-html-element-3><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=parse-errors:the-head-element-3><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=parse-errors:the-body-element-3><a href=sections.html#the-body-element>body</a></code></ul></ul>
|
||
</div>
|
||
|
||
<p class=note>The common reason for this error is an XML processing instruction (e.g., <code><?xml-stylesheet type="text/css" href="style.css"?></code>) or an XML declaration
|
||
(e.g., <code><?xml version="1.0" encoding="UTF-8"?></code>) being used in
|
||
HTML.</p>
|
||
|
||
<tr><td><dfn id=parse-error-unexpected-solidus-in-tag>unexpected-solidus-in-tag</dfn>
|
||
<td><p>This error occurs if the parser encounters a U+002F (/) <a id=parse-errors:code-point-28 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> that is
|
||
not a part of a quoted <a href=syntax.html#syntax-attributes id=parse-errors:syntax-attributes-5>attribute</a> value and not
|
||
immediately followed by a U+003E (>) code point in a tag (e.g., <code><div /
|
||
id="foo"></code>). In this case the parser behaves as if it encountered <a id=parse-errors:space-characters-9 href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII
|
||
whitespace</a>.</p>
|
||
|
||
<tr><td><dfn id=parse-error-unknown-named-character-reference>unknown-named-character-reference</dfn>
|
||
<td><p>This error occurs if the parser encounters an <a href=syntax.html#syntax-ambiguous-ampersand id=parse-errors:syntax-ambiguous-ampersand>ambiguous ampersand</a>. In this case the parser doesn't
|
||
resolve the <a href=syntax.html#syntax-charref id=parse-errors:syntax-charref-8>character reference</a>.</p>
|
||
|
||
</table>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h4 id=the-input-byte-stream><span class=secno>12.2.3</span> The <dfn>input byte stream</dfn><a href=#the-input-byte-stream class=self-link></a></h4>
|
||
|
||
<p>The stream of code points that comprises the input to the tokenization stage will be initially
|
||
seen by the user agent as a stream of bytes (typically coming over the network or from the local
|
||
file system). The bytes encode the actual characters according to a particular <i>character
|
||
encoding</i>, which the user agent uses to decode the bytes into characters.</p>
|
||
|
||
<p class=note>For XML documents, the algorithm user agents are required to use to determine the
|
||
character encoding is given by the XML specification. This section does not apply to XML
|
||
documents. <a href=references.html#refsXML>[XML]</a></p>
|
||
|
||
<p>Usually, the <a href=#encoding-sniffing-algorithm id=the-input-byte-stream:encoding-sniffing-algorithm>encoding sniffing algorithm</a> defined below is used to determine the
|
||
character encoding.</p>
|
||
|
||
<p>Given a character encoding, the bytes in the <a href=#the-input-byte-stream id=the-input-byte-stream:the-input-byte-stream>input byte stream</a> must be converted
|
||
to characters for the tokenizer's <a href=#input-stream id=the-input-byte-stream:input-stream>input stream</a>, by passing the <a href=#the-input-byte-stream id=the-input-byte-stream:the-input-byte-stream-2>input byte
|
||
stream</a> and character encoding to <a id=the-input-byte-stream:decode href=https://encoding.spec.whatwg.org/#decode data-x-internal=decode>decode</a>.</p>
|
||
|
||
<p class=note>A leading Byte Order Mark (BOM) causes the character encoding argument to be
|
||
ignored and will itself be skipped.</p>
|
||
|
||
<p class=note>Bytes or sequences of bytes in the original byte stream that did not conform to
|
||
the Encoding standard (e.g. invalid UTF-8 byte sequences in a UTF-8 input byte stream) are errors
|
||
that conformance checkers are expected to report. <a href=references.html#refsENCODING>[ENCODING]</a></p>
|
||
|
||
<p class=warning>The decoder algorithms describe how to handle invalid input; for security
|
||
reasons, it is imperative that those rules be followed precisely. Differences in how invalid byte
|
||
sequences are handled can result in, amongst other problems, script injection vulnerabilities
|
||
("XSS").</p>
|
||
|
||
<p>When the HTML parser is decoding an input byte stream, it uses a character encoding and a <dfn id=concept-encoding-confidence>confidence</dfn>. The confidence is either <i>tentative</i>,
|
||
<i>certain</i>, or <i>irrelevant</i>. The encoding used, and whether the confidence in that
|
||
encoding is <i>tentative</i> or <i>certain</i>, is <a href=#meta-charset-during-parse>used
|
||
during the parsing</a> to determine whether to <a href=#change-the-encoding id=the-input-byte-stream:change-the-encoding>change the encoding</a>. If no encoding is
|
||
necessary, e.g. because the parser is operating on a Unicode stream and doesn't have to use a
|
||
character encoding at all, then the <a href=#concept-encoding-confidence id=the-input-byte-stream:concept-encoding-confidence>confidence</a> is
|
||
<i>irrelevant</i>.</p>
|
||
|
||
<p class=note>Some algorithms feed the parser by directly adding characters to the <a href=#input-stream id=the-input-byte-stream:input-stream-2>input
|
||
stream</a> rather than adding bytes to the <a href=#the-input-byte-stream id=the-input-byte-stream:the-input-byte-stream-3>input byte stream</a>.</p>
|
||
|
||
|
||
|
||
<h5 id=parsing-with-a-known-character-encoding><span class=secno>12.2.3.1</span> Parsing with a known character encoding<a href=#parsing-with-a-known-character-encoding class=self-link></a></h5>
|
||
|
||
<p>When the HTML parser is to operate on an input byte stream that has <dfn id=a-known-definite-encoding data-export="">a known
|
||
definite encoding</dfn>, then the character encoding is that encoding and the <a href=#concept-encoding-confidence id=parsing-with-a-known-character-encoding:concept-encoding-confidence>confidence</a> is <i>certain</i>.</p>
|
||
|
||
|
||
<h5 id=determining-the-character-encoding><span class=secno>12.2.3.2</span> Determining the character encoding<a href=#determining-the-character-encoding class=self-link></a></h5>
|
||
|
||
<p>In some cases, it might be impractical to unambiguously determine the encoding before parsing
|
||
the document. Because of this, this specification provides for a two-pass mechanism with an
|
||
optional pre-scan. Implementations are allowed, as described below, to apply a simplified parsing
|
||
algorithm to whatever bytes they have available before beginning to parse the document. Then, the
|
||
real parser is started, using a tentative encoding derived from this pre-parse and other
|
||
out-of-band metadata. If, while the document is being loaded, the user agent discovers a character
|
||
encoding declaration that conflicts with this information, then the parser can get reinvoked to
|
||
perform a parse of the document with the real encoding.</p>
|
||
|
||
<p id=documentEncoding>User agents must use the following algorithm, called the <dfn id=encoding-sniffing-algorithm>encoding
|
||
sniffing algorithm</dfn>, to determine the character encoding to use when decoding a document in
|
||
the first pass. This algorithm takes as input any out-of-band metadata available to the user agent
|
||
(e.g. the <a href=urls-and-fetching.html#content-type id=determining-the-character-encoding:content-type>Content-Type metadata</a> of the document) and all the
|
||
bytes available so far, and returns a character encoding and a <a href=#concept-encoding-confidence id=determining-the-character-encoding:concept-encoding-confidence>confidence</a> that is either <i>tentative</i> or
|
||
<i>certain</i>.</p>
|
||
|
||
<ol><li>
|
||
|
||
<p>If the user has explicitly instructed the user agent to override the document's character
|
||
encoding with a specific encoding, optionally return that encoding with the <a href=#concept-encoding-confidence id=determining-the-character-encoding:concept-encoding-confidence-2>confidence</a> <i>certain</i> and abort these steps.</p>
|
||
|
||
<p class=note>Typically, user agents remember such user requests across sessions, and in some
|
||
cases apply them to documents in <code id=determining-the-character-encoding:the-iframe-element><a href=iframe-embed-object.html#the-iframe-element>iframe</a></code>s as well.</p>
|
||
|
||
<li>
|
||
|
||
<p>The user agent may wait for more bytes of the resource to be available, either in this step
|
||
or at any later step in this algorithm. For instance, a user agent might wait 500ms or 1024
|
||
bytes, whichever came first. In general preparsing the source to find the encoding improves
|
||
performance, as it reduces the need to throw away the data structures used when parsing upon
|
||
finding the encoding information. However, if the user agent delays too long to obtain data to
|
||
determine the encoding, then the cost of the delay could outweigh any performance improvements
|
||
from the preparse.</p>
|
||
|
||
<p class=note>The authoring conformance requirements for character encoding declarations limit
|
||
them to only appearing <a href=semantics.html#charset1024>in the first 1024 bytes</a>. User agents are
|
||
therefore encouraged to use the prescan algorithm below (as invoked by these steps) on the first
|
||
1024 bytes, but not to stall beyond that.</p>
|
||
|
||
<li><p>If the transport layer specifies a character encoding, and it is supported, return that
|
||
encoding with the <a href=#concept-encoding-confidence id=determining-the-character-encoding:concept-encoding-confidence-3>confidence</a> <i>certain</i>, and
|
||
abort these steps.<li>
|
||
|
||
<p>Optionally <a href=#prescan-a-byte-stream-to-determine-its-encoding id=determining-the-character-encoding:prescan-a-byte-stream-to-determine-its-encoding>prescan the byte
|
||
stream to determine its encoding</a>. The <var>end condition</var> is that the user
|
||
agent decides that scanning further bytes would not be efficient. User agents are encouraged to
|
||
only prescan the first 1024 bytes. User agents may decide that scanning <em>any</em> bytes is
|
||
not efficient, in which case these substeps are entirely skipped.</p>
|
||
|
||
<p>The aforementioned algorithm either aborts unsuccessfully or returns a character encoding. If
|
||
it returns a character encoding, then this algorithm must be aborted, returning the same
|
||
encoding, with <a href=#concept-encoding-confidence id=determining-the-character-encoding:concept-encoding-confidence-4>confidence</a> <i>tentative</i>.</p>
|
||
|
||
<li>
|
||
|
||
<p>If the <a href=#html-parser id=determining-the-character-encoding:html-parser>HTML parser</a> for which this algorithm is being run is associated with a
|
||
<code id=determining-the-character-encoding:document><a href=dom.html#document>Document</a></code> that is itself in a <a id=determining-the-character-encoding:nested-browsing-context href=browsers.html#nested-browsing-context>nested browsing context</a>, run these
|
||
substeps:</p>
|
||
|
||
<ol><li><p>Let <var>new document</var> be the <code id=determining-the-character-encoding:document-2><a href=dom.html#document>Document</a></code> with which the
|
||
<a href=#html-parser id=determining-the-character-encoding:html-parser-2>HTML parser</a> is associated.<li><p>Let <var>parent document</var> be the <code id=determining-the-character-encoding:document-3><a href=dom.html#document>Document</a></code> <a href=browsers.html#browsing-context-nested-through id=determining-the-character-encoding:browsing-context-nested-through>through which <var>new document</var> is
|
||
nested</a> (the <a id=determining-the-character-encoding:active-document href=browsers.html#active-document>active document</a> of the <a id=determining-the-character-encoding:parent-browsing-context href=browsers.html#parent-browsing-context>parent browsing context</a> of
|
||
<var>new document</var>).<li><p>If <var>parent document</var>'s <a id=determining-the-character-encoding:concept-origin href=origin.html#concept-origin>origin</a> is not the <a id=determining-the-character-encoding:same-origin href=origin.html#same-origin>same
|
||
origin</a> as <var>new document</var>'s <a id=determining-the-character-encoding:concept-origin-2 href=origin.html#concept-origin>origin</a>, then abort these
|
||
substeps.<li><p>If <var>parent document</var>'s <a href=https://dom.spec.whatwg.org/#concept-document-encoding id="determining-the-character-encoding:document's-character-encoding" data-x-internal="document's-character-encoding">character encoding</a> is not an <a id=determining-the-character-encoding:ascii-compatible-encoding href=infrastructure.html#ascii-compatible-encoding>ASCII-compatible encoding</a>, then
|
||
abort these substeps.<li><p>Return <var>parent document</var>'s <a href=https://dom.spec.whatwg.org/#concept-document-encoding id="determining-the-character-encoding:document's-character-encoding-2" data-x-internal="document's-character-encoding">character encoding</a>, with the <a href=#concept-encoding-confidence id=determining-the-character-encoding:concept-encoding-confidence-5>confidence</a> <i>tentative</i>, and abort the
|
||
<a href=#encoding-sniffing-algorithm id=determining-the-character-encoding:encoding-sniffing-algorithm>encoding sniffing algorithm</a>'s steps.</ol>
|
||
|
||
<li><p>Otherwise, if the user agent has information on the likely encoding for this page, e.g.
|
||
based on the encoding of the page when it was last visited, then return that encoding, with the
|
||
<a href=#concept-encoding-confidence id=determining-the-character-encoding:concept-encoding-confidence-6>confidence</a> <i>tentative</i>, and abort these
|
||
steps.<li>
|
||
|
||
<p>The user agent may attempt to autodetect the character encoding from applying frequency
|
||
analysis or other algorithms to the data stream. Such algorithms may use information about the
|
||
resource other than the resource's contents, including the address of the resource. If
|
||
autodetection succeeds in determining a character encoding, and that encoding is a supported
|
||
encoding, then return that encoding, with the <a href=#concept-encoding-confidence id=determining-the-character-encoding:concept-encoding-confidence-7>confidence</a> <i>tentative</i>, and abort these steps.
|
||
<a href=references.html#refsUNIVCHARDET>[UNIVCHARDET]</a></p>
|
||
|
||
<p class=note>User agents are generally discouraged from attempting to autodetect encodings
|
||
for resources obtained over the network, since doing so involves inherently non-interoperable
|
||
heuristics. Attempting to detect encodings based on an HTML document's preamble is especially
|
||
tricky since HTML markup typically uses only ASCII characters, and HTML documents tend to begin
|
||
with a lot of markup rather than with text content.</p>
|
||
|
||
<p class=note>The UTF-8 encoding has a highly detectable bit pattern. Files from the local
|
||
file system that contain bytes with values greater than 0x7F which match the UTF-8 pattern are
|
||
very likely to be UTF-8, while documents with byte sequences that do not match it are very
|
||
likely not. When a user agent can examine the whole file, rather than just the preamble,
|
||
detecting for UTF-8 specifically can be especially effective. <a href=references.html#refsPPUTF8>[PPUTF8]</a> <a href=references.html#refsUTF8DET>[UTF8DET]</a></p>
|
||
|
||
<li>
|
||
|
||
<p>Otherwise, return an implementation-defined or user-specified default character encoding,
|
||
with the <a href=#concept-encoding-confidence id=determining-the-character-encoding:concept-encoding-confidence-8>confidence</a> <i>tentative</i>.</p>
|
||
|
||
<p>In controlled environments or in environments where the encoding of documents can be
|
||
prescribed (for example, for user agents intended for dedicated use in new networks), the
|
||
comprehensive <code>UTF-8</code> encoding is suggested.</p>
|
||
|
||
<p>In other environments, the default encoding is typically dependent on the user's locale (an
|
||
approximation of the languages, and thus often encodings, of the pages that the user is likely
|
||
to frequent). The following table gives suggested defaults based on the user's locale, for
|
||
compatibility with legacy content. Locales are identified by BCP 47 language tags. <a href=references.html#refsBCP47>[BCP47]</a> <a href=references.html#refsENCODING>[ENCODING]</a></p>
|
||
|
||
|
||
|
||
<table><thead><tr><th colspan=2>Locale language
|
||
<th>Suggested default encoding
|
||
<tbody><tr><td>ar
|
||
<td>Arabic
|
||
<td><a id=determining-the-character-encoding:windows-1256 href=https://encoding.spec.whatwg.org/#windows-1256 data-x-internal=windows-1256>windows-1256</a>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>ba
|
||
<td>Bashkir
|
||
<td><a id=determining-the-character-encoding:windows-1251 href=https://encoding.spec.whatwg.org/#windows-1251 data-x-internal=windows-1251>windows-1251</a>
|
||
|
||
|
||
|
||
<tr><td>be
|
||
<td>Belarusian
|
||
<td><a id=determining-the-character-encoding:windows-1251-2 href=https://encoding.spec.whatwg.org/#windows-1251 data-x-internal=windows-1251>windows-1251</a>
|
||
|
||
|
||
|
||
<tr><td>bg
|
||
<td>Bulgarian
|
||
<td><a id=determining-the-character-encoding:windows-1251-3 href=https://encoding.spec.whatwg.org/#windows-1251 data-x-internal=windows-1251>windows-1251</a>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>cs
|
||
<td>Czech
|
||
<td><a id=determining-the-character-encoding:windows-1250 href=https://encoding.spec.whatwg.org/#windows-1250 data-x-internal=windows-1250>windows-1250</a>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>el
|
||
<td>Greek
|
||
<td><a id=determining-the-character-encoding:iso-8859-7 href=https://encoding.spec.whatwg.org/#iso-8859-7 data-x-internal=iso-8859-7>ISO-8859-7</a>
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>et
|
||
<td>Estonian
|
||
<td><a id=determining-the-character-encoding:windows-1257 href=https://encoding.spec.whatwg.org/#windows-1257 data-x-internal=windows-1257>windows-1257</a>
|
||
|
||
|
||
|
||
<tr><td>fa
|
||
<td>Persian
|
||
<td><a id=determining-the-character-encoding:windows-1256-2 href=https://encoding.spec.whatwg.org/#windows-1256 data-x-internal=windows-1256>windows-1256</a>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>he
|
||
<td>Hebrew
|
||
<td><a id=determining-the-character-encoding:windows-1255 href=https://encoding.spec.whatwg.org/#windows-1255 data-x-internal=windows-1255>windows-1255</a>
|
||
|
||
|
||
|
||
<tr><td>hr
|
||
<td>Croatian
|
||
<td><a id=determining-the-character-encoding:windows-1250-2 href=https://encoding.spec.whatwg.org/#windows-1250 data-x-internal=windows-1250>windows-1250</a>
|
||
|
||
<tr><td>hu
|
||
<td>Hungarian
|
||
<td><a id=determining-the-character-encoding:iso-8859-2 href=https://encoding.spec.whatwg.org/#iso-8859-2 data-x-internal=iso-8859-2>ISO-8859-2</a>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>ja
|
||
<td>Japanese
|
||
<td><a id=determining-the-character-encoding:shift_jis href=https://encoding.spec.whatwg.org/#shift_jis data-x-internal=shift_jis>Shift_JIS</a>
|
||
|
||
|
||
|
||
<tr><td>kk
|
||
<td>Kazakh
|
||
<td><a id=determining-the-character-encoding:windows-1251-4 href=https://encoding.spec.whatwg.org/#windows-1251 data-x-internal=windows-1251>windows-1251</a>
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>ko
|
||
<td>Korean
|
||
<td><a id=determining-the-character-encoding:euc-kr href=https://encoding.spec.whatwg.org/#euc-kr data-x-internal=euc-kr>EUC-KR</a>
|
||
|
||
<tr><td>ku
|
||
<td>Kurdish
|
||
<td><a id=determining-the-character-encoding:windows-1254 href=https://encoding.spec.whatwg.org/#windows-1254 data-x-internal=windows-1254>windows-1254</a>
|
||
|
||
|
||
|
||
<tr><td>ky
|
||
<td>Kyrgyz
|
||
<td><a id=determining-the-character-encoding:windows-1251-5 href=https://encoding.spec.whatwg.org/#windows-1251 data-x-internal=windows-1251>windows-1251</a>
|
||
|
||
|
||
|
||
<tr><td>lt
|
||
<td>Lithuanian
|
||
<td><a id=determining-the-character-encoding:windows-1257-2 href=https://encoding.spec.whatwg.org/#windows-1257 data-x-internal=windows-1257>windows-1257</a>
|
||
|
||
<tr><td>lv
|
||
<td>Latvian
|
||
<td><a id=determining-the-character-encoding:windows-1257-3 href=https://encoding.spec.whatwg.org/#windows-1257 data-x-internal=windows-1257>windows-1257</a>
|
||
|
||
|
||
|
||
<tr><td>mk
|
||
<td>Macedonian
|
||
<td><a id=determining-the-character-encoding:windows-1251-6 href=https://encoding.spec.whatwg.org/#windows-1251 data-x-internal=windows-1251>windows-1251</a>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>pl
|
||
<td>Polish
|
||
<td><a id=determining-the-character-encoding:iso-8859-2-2 href=https://encoding.spec.whatwg.org/#iso-8859-2 data-x-internal=iso-8859-2>ISO-8859-2</a>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>ru
|
||
<td>Russian
|
||
<td><a id=determining-the-character-encoding:windows-1251-7 href=https://encoding.spec.whatwg.org/#windows-1251 data-x-internal=windows-1251>windows-1251</a>
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>sah
|
||
<td>Yakut
|
||
<td><a id=determining-the-character-encoding:windows-1251-8 href=https://encoding.spec.whatwg.org/#windows-1251 data-x-internal=windows-1251>windows-1251</a>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>sk
|
||
<td>Slovak
|
||
<td><a id=determining-the-character-encoding:windows-1250-3 href=https://encoding.spec.whatwg.org/#windows-1250 data-x-internal=windows-1250>windows-1250</a>
|
||
|
||
<tr><td>sl
|
||
<td>Slovenian
|
||
<td><a id=determining-the-character-encoding:iso-8859-2-3 href=https://encoding.spec.whatwg.org/#iso-8859-2 data-x-internal=iso-8859-2>ISO-8859-2</a>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>sr
|
||
<td>Serbian
|
||
<td><a id=determining-the-character-encoding:windows-1251-9 href=https://encoding.spec.whatwg.org/#windows-1251 data-x-internal=windows-1251>windows-1251</a>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>tg
|
||
<td>Tajik
|
||
<td><a id=determining-the-character-encoding:windows-1251-10 href=https://encoding.spec.whatwg.org/#windows-1251 data-x-internal=windows-1251>windows-1251</a>
|
||
|
||
<tr><td>th
|
||
<td>Thai
|
||
<td><a id=determining-the-character-encoding:windows-874 href=https://encoding.spec.whatwg.org/#windows-874 data-x-internal=windows-874>windows-874</a>
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>tr
|
||
<td>Turkish
|
||
<td><a id=determining-the-character-encoding:windows-1254-2 href=https://encoding.spec.whatwg.org/#windows-1254 data-x-internal=windows-1254>windows-1254</a>
|
||
|
||
|
||
|
||
<tr><td>tt
|
||
<td>Tatar
|
||
<td><a id=determining-the-character-encoding:windows-1251-11 href=https://encoding.spec.whatwg.org/#windows-1251 data-x-internal=windows-1251>windows-1251</a>
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>uk
|
||
<td>Ukrainian
|
||
<td><a id=determining-the-character-encoding:windows-1251-12 href=https://encoding.spec.whatwg.org/#windows-1251 data-x-internal=windows-1251>windows-1251</a>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>vi
|
||
<td>Vietnamese
|
||
<td><a id=determining-the-character-encoding:windows-1258 href=https://encoding.spec.whatwg.org/#windows-1258 data-x-internal=windows-1258>windows-1258</a>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>zh-CN
|
||
<td>Chinese (People's Republic of China)
|
||
<td><a id=determining-the-character-encoding:gb18030 href=https://encoding.spec.whatwg.org/#gb18030 data-x-internal=gb18030>gb18030</a>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<tr><td>zh-TW
|
||
<td>Chinese (Taiwan)
|
||
<td><a id=determining-the-character-encoding:big5 href=https://encoding.spec.whatwg.org/#big5 data-x-internal=big5>Big5</a>
|
||
|
||
|
||
|
||
<tr><td colspan=2>All other locales
|
||
<td><a id=determining-the-character-encoding:windows-1252 href=https://encoding.spec.whatwg.org/#windows-1252 data-x-internal=windows-1252>windows-1252</a>
|
||
|
||
</table>
|
||
|
||
<p class=tablenote><small>The contents of this table are derived from the intersection of
|
||
Windows, Chrome, and Firefox defaults.</small></p>
|
||
|
||
</ol>
|
||
|
||
<p>The <a id="determining-the-character-encoding:document's-character-encoding-3" href=https://dom.spec.whatwg.org/#concept-document-encoding data-x-internal="document's-character-encoding">document's character encoding</a> must immediately be set to the value returned
|
||
from this algorithm, at the same time as the user agent uses the returned value to select the
|
||
decoder to use for the input byte stream.</p>
|
||
|
||
<hr>
|
||
|
||
<p>When an algorithm requires a user agent to <dfn id=prescan-a-byte-stream-to-determine-its-encoding data-export="">prescan a byte stream to
|
||
determine its encoding</dfn>, given some defined <var>end condition</var>, then it must run the
|
||
following steps. These steps either abort unsuccessfully or return a character encoding. If at any
|
||
point during these steps (including during instances of the <a href=#concept-get-attributes-when-sniffing id=determining-the-character-encoding:concept-get-attributes-when-sniffing>get an attribute</a> algorithm invoked by this
|
||
one) the user agent either runs out of bytes (meaning the <var>position</var> pointer
|
||
created in the first step below goes beyond the end of the byte stream obtained so far) or reaches
|
||
its <var>end condition</var>, then abort the <a href=#prescan-a-byte-stream-to-determine-its-encoding id=determining-the-character-encoding:prescan-a-byte-stream-to-determine-its-encoding-2>prescan a byte stream to determine its
|
||
encoding</a> algorithm unsuccessfully.</p>
|
||
|
||
<ol><li>
|
||
|
||
<p>Let <var>position</var> be a pointer to a byte in the input byte stream, initially
|
||
pointing at the first byte.</p>
|
||
|
||
<li>
|
||
|
||
<p><i>Loop</i>: If <var>position</var> points to:</p>
|
||
|
||
<dl class=switch><dt>A sequence of bytes starting with: 0x3C 0x21 0x2D 0x2D (`<code><!--</code>`)<dd>
|
||
|
||
<p>Advance the <var>position</var> pointer so that it points at the first 0x3E byte
|
||
which is preceded by two 0x2D bytes (i.e. at the end of an ASCII '-->' sequence) and comes
|
||
after the 0x3C byte that was found. (The two 0x2D bytes can be the same as those in the
|
||
'<!--' sequence.)</p>
|
||
|
||
<dt>A sequence of bytes starting with: 0x3C, 0x4D or 0x6D, 0x45 or 0x65, 0x54 or 0x74, 0x41 or 0x61, and one of 0x09, 0x0A, 0x0C, 0x0D, 0x20, 0x2F (case-insensitive ASCII '<meta' followed by a space or slash)<dd>
|
||
|
||
<ol><li><p>Advance the <var>position</var> pointer so that it points at the next 0x09,
|
||
0x0A, 0x0C, 0x0D, 0x20, or 0x2F byte (the one in sequence of characters matched
|
||
above).<li><p>Let <var>attribute list</var> be an empty list of strings.<li><p>Let <var>got pragma</var> be false.<li><p>Let <var>need pragma</var> be null.<li><p>Let <var>charset</var> be the null value (which, for the purposes of this
|
||
algorithm, is distinct from an unrecognized encoding or the empty string).<li><p><i>Attributes</i>: <a href=#concept-get-attributes-when-sniffing id=determining-the-character-encoding:concept-get-attributes-when-sniffing-2>Get an
|
||
attribute</a> and its value. If no attribute was sniffed, then jump to the
|
||
<i>processing</i> step below.<li><p>If the attribute's name is already in <var>attribute list</var>, then return
|
||
to the step labeled <i>attributes</i>.</p>
|
||
|
||
<li><p>Add the attribute's name to <var>attribute list</var>.</p>
|
||
|
||
<li>
|
||
|
||
<p>Run the appropriate step from the following list, if one applies:</p>
|
||
|
||
<dl class=switch><dt>If the attribute's name is "<code>http-equiv</code>"<dd><p>If the attribute's value is "<code>content-type</code>", then set <var>got pragma</var> to true.<dt>If the attribute's name is "<code>content</code>"<dd><p>Apply the <a id=determining-the-character-encoding:algorithm-for-extracting-a-character-encoding-from-a-meta-element href=urls-and-fetching.html#algorithm-for-extracting-a-character-encoding-from-a-meta-element>algorithm for extracting a character encoding from a
|
||
<code>meta</code> element</a>, giving the attribute's value as the string to parse. If a
|
||
character encoding is returned, and if <var>charset</var> is still set to null,
|
||
let <var>charset</var> be the encoding returned, and set <var>need
|
||
pragma</var> to true.<dt>If the attribute's name is "<code>charset</code>"<dd><p>Let <var>charset</var> be the result of <a id=determining-the-character-encoding:getting-an-encoding href=https://encoding.spec.whatwg.org/#concept-encoding-get data-x-internal=getting-an-encoding>getting an encoding</a>
|
||
from the attribute's value, and set <var>need pragma</var> to false.</dl>
|
||
|
||
<li><p>Return to the step labeled <i>attributes</i>.<li><p><i>Processing</i>: If <var>need pragma</var> is null, then jump to the step
|
||
below labeled <i>next byte</i>.<li><p>If <var>need pragma</var> is true but <var>got pragma</var> is
|
||
false, then jump to the step below labeled <i>next byte</i>.<li><p>If <var>charset</var> is failure, then jump to the step below labeled <i>next
|
||
byte</i>.<li><p>If <var>charset</var> is a <a id=determining-the-character-encoding:utf-16-encoding href=infrastructure.html#utf-16-encoding>UTF-16 encoding</a>, then set <var>charset</var>
|
||
to <a id=determining-the-character-encoding:utf-8 href=https://encoding.spec.whatwg.org/#utf-8 data-x-internal=utf-8>UTF-8</a>.
|
||
|
||
<li><p>If <var>charset</var> is <a id=determining-the-character-encoding:x-user-defined href=https://encoding.spec.whatwg.org/#x-user-defined data-x-internal=x-user-defined>x-user-defined</a>, then set <var>charset</var> to
|
||
<a id=determining-the-character-encoding:windows-1252-2 href=https://encoding.spec.whatwg.org/#windows-1252 data-x-internal=windows-1252>windows-1252</a>.<li><p>Abort the <a href=#prescan-a-byte-stream-to-determine-its-encoding id=determining-the-character-encoding:prescan-a-byte-stream-to-determine-its-encoding-3>prescan a byte stream to determine its encoding</a> algorithm,
|
||
returning the encoding given by <var>charset</var>.</ol>
|
||
|
||
<dt>A sequence of bytes starting with a 0x3C byte (<), optionally a 0x2F byte (/), and
|
||
finally a byte in the range 0x41-0x5A or 0x61-0x7A (A-Z or a-z)<dd>
|
||
|
||
<ol><li><p>Advance the <var>position</var> pointer so that it points at the next 0x09 (HT),
|
||
0x0A (LF), 0x0C (FF), 0x0D (CR), 0x20 (SP), or 0x3E (>) byte.<li><p>Repeatedly <a href=#concept-get-attributes-when-sniffing id=determining-the-character-encoding:concept-get-attributes-when-sniffing-3>get an attribute</a>
|
||
until no further attributes can be found, then jump to the step below labeled <i>next
|
||
byte</i>.</ol>
|
||
|
||
<dt>A sequence of bytes starting with: 0x3C 0x21 (`<code><!</code>`)<dt>A sequence of bytes starting with: 0x3C 0x2F (`<code></</code>`)<dt>A sequence of bytes starting with: 0x3C 0x3F (`<code><?</code>`)<dd>
|
||
|
||
<p>Advance the <var>position</var> pointer so that it points at the first 0x3E byte (>) that
|
||
comes after the 0x3C byte that was found.</p>
|
||
|
||
<dt>Any other byte<dd>
|
||
|
||
<p>Do nothing with that byte.</p>
|
||
|
||
</dl>
|
||
|
||
<li><i>Next byte</i>: Move <var>position</var> so it points at the next byte in the
|
||
input byte stream, and return to the step above labeled <i>loop</i>.</ol>
|
||
|
||
<p>When the <a href=#prescan-a-byte-stream-to-determine-its-encoding id=determining-the-character-encoding:prescan-a-byte-stream-to-determine-its-encoding-4>prescan a byte stream to determine its encoding</a> algorithm says to <dfn id=concept-get-attributes-when-sniffing>get an attribute</dfn>, it means doing this:</p>
|
||
|
||
<ol><li><p>If the byte at <var>position</var> is one of 0x09 (HT), 0x0A (LF), 0x0C (FF), 0x0D (CR),
|
||
0x20 (SP), or 0x2F (/) then advance <var>position</var> to the next byte and redo this
|
||
step.<li><p>If the byte at <var>position</var> is 0x3E (>), then abort the <a href=#concept-get-attributes-when-sniffing id=determining-the-character-encoding:concept-get-attributes-when-sniffing-4>get an attribute</a> algorithm. There isn't
|
||
one.<li><p>Otherwise, the byte at <var>position</var> is the start of the attribute name.
|
||
Let <var>attribute name</var> and <var>attribute value</var> be the empty
|
||
string.<li><p>Process the byte at <var>position</var> as follows:</p>
|
||
|
||
<dl class=switch><dt>If it is 0x3D (=), and the <var>attribute name</var> is longer than the empty string<dd>Advance <var>position</var> to the next byte and jump to the step below labeled
|
||
<i>value</i>.<dt>If it is 0x09 (HT), 0x0A (LF), 0x0C (FF), 0x0D (CR), or 0x20 (SP)<dd>Jump to the step below labeled <i>spaces</i>.<dt>If it is 0x2F (/) or 0x3E (>)<dd>Abort the <a href=#concept-get-attributes-when-sniffing id=determining-the-character-encoding:concept-get-attributes-when-sniffing-5>get an attribute</a>
|
||
algorithm. The attribute's name is the value of <var>attribute name</var>, its value
|
||
is the empty string.<dt>If it is in the range 0x41 (A) to 0x5A (Z)<dd>Append the code point <var>b</var>+0x20 to <var>attribute name</var>
|
||
(where <var>b</var> is the value of the byte at <var>position</var>). (This converts the input
|
||
to lowercase.)<dt>Anything else<dd>Append the code point with the same value as the byte at <var>position</var> to
|
||
<var>attribute name</var>. (It doesn't actually matter how bytes outside the ASCII range are
|
||
handled here, since only ASCII bytes can contribute to the detection of a character
|
||
encoding.)</dl>
|
||
|
||
<li><p>Advance <var>position</var> to the next byte and return to the previous
|
||
step.<li><p><i>Spaces</i>: If the byte at <var>position</var> is one of 0x09 (HT), 0x0A (LF), 0x0C
|
||
(FF), 0x0D (CR), or 0x20 (SP) then advance <var>position</var> to the next byte, then, repeat
|
||
this step.<li><p>If the byte at <var>position</var> is <em>not</em> 0x3D (=), abort the <a href=#concept-get-attributes-when-sniffing id=determining-the-character-encoding:concept-get-attributes-when-sniffing-6>get an attribute</a> algorithm. The attribute's
|
||
name is the value of <var>attribute name</var>, its value is the empty string.<li><p>Advance <var>position</var> past the 0x3D (=) byte.<li><p><i>Value</i>: If the byte at <var>position</var> is one of 0x09 (HT), 0x0A (LF), 0x0C
|
||
(FF), 0x0D (CR), or 0x20 (SP) then advance <var>position</var> to the next byte, then, repeat
|
||
this step.<li><p>Process the byte at <var>position</var> as follows:</p>
|
||
|
||
<dl class=switch><dt>If it is 0x22 (") or 0x27 (')<dd>
|
||
|
||
<ol><li>Let <var>b</var> be the value of the byte at <var>position</var>.<li><i>Quote loop</i>: Advance <var>position</var> to the next byte.<li>If the value of the byte at <var>position</var> is the value of <var>b</var>, then advance <var>position</var> to the next byte and abort the
|
||
"get an attribute" algorithm. The attribute's name is the value of <var>attribute
|
||
name</var>, and its value is the value of <var>attribute value</var>.<li>Otherwise, if the value of the byte at <var>position</var> is in the range 0x41 (A) to
|
||
0x5A (Z), then append a code point to <var>attribute value</var> whose value is 0x20 more
|
||
than the value of the byte at <var>position</var>.<li>Otherwise, append a code point to <var>attribute value</var> whose value is the same as
|
||
the value of the byte at <var>position</var>.<li>Return to the step above labeled <i>quote loop</i>.</ol>
|
||
|
||
<dt>If it is 0x3E (>)<dd>Abort the <a href=#concept-get-attributes-when-sniffing id=determining-the-character-encoding:concept-get-attributes-when-sniffing-7>get an attribute</a>
|
||
algorithm. The attribute's name is the value of <var>attribute name</var>, its value
|
||
is the empty string.<dt>If it is in the range 0x41 (A) to 0x5A (Z)<dd>Append a code point <var>b</var>+0x20 to <var>attribute value</var>
|
||
(where <var>b</var> is the value of the byte at <var>position</var>). Advance
|
||
<var>position</var> to the next byte.<dt>Anything else<dd>Append a code point with the same value as the byte at <var>position</var> to
|
||
<var>attribute value</var>. Advance <var>position</var> to the next byte.</dl>
|
||
|
||
<li><p>Process the byte at <var>position</var> as
|
||
follows:</p>
|
||
|
||
<dl class=switch><dt>If it is 0x09 (HT), 0x0A (LF), 0x0C (FF), 0x0D (CR), 0x20 (SP), or 0x3E (>)<dd>Abort the <a href=#concept-get-attributes-when-sniffing id=determining-the-character-encoding:concept-get-attributes-when-sniffing-8>get an attribute</a>
|
||
algorithm. The attribute's name is the value of <var>attribute name</var> and its
|
||
value is the value of <var>attribute value</var>.<dt>If it is in the range 0x41 (A) to 0x5A (Z)<dd>Append a code point <var>b</var>+0x20 to <var>attribute value</var>
|
||
(where <var>b</var> is the value of the byte at <var>position</var>).<dt>Anything else<dd>Append a code point with the same value as the byte at <var>position</var> to
|
||
<var>attribute value</var>.</dl>
|
||
|
||
<li><p>Advance <var>position</var> to the next byte and return to the previous
|
||
step.</ol>
|
||
|
||
<p>For the sake of interoperability, user agents should not use a pre-scan algorithm that returns
|
||
different results than the one described above. (But, if you do, please at least let us know, so
|
||
that we can improve this algorithm and benefit everyone...)</p>
|
||
|
||
|
||
|
||
|
||
|
||
<h5 id=character-encodings><span class=secno>12.2.3.3</span> Character encodings<a href=#character-encodings class=self-link></a></h5>
|
||
|
||
<p>User agents must support the encodings defined in the WHATWG Encoding standard, including, but
|
||
not limited to,
|
||
<dfn id=utf-8><a href=https://encoding.spec.whatwg.org/#utf-8>UTF-8</a></dfn>,
|
||
<dfn id=iso-8859-2><a href=https://encoding.spec.whatwg.org/#iso-8859-2>ISO-8859-2</a></dfn>,
|
||
<dfn id=iso-8859-7><a href=https://encoding.spec.whatwg.org/#iso-8859-7>ISO-8859-7</a></dfn>,
|
||
<dfn id=iso-8859-8><a href=https://encoding.spec.whatwg.org/#iso-8859-8>ISO-8859-8</a></dfn>,
|
||
<dfn id=windows-874><a href=https://encoding.spec.whatwg.org/#windows-874>windows-874</a></dfn>,
|
||
<dfn id=windows-1250><a href=https://encoding.spec.whatwg.org/#windows-1250>windows-1250</a></dfn>,
|
||
<dfn id=windows-1251><a href=https://encoding.spec.whatwg.org/#windows-1251>windows-1251</a></dfn>,
|
||
<dfn id=windows-1252><a href=https://encoding.spec.whatwg.org/#windows-1252>windows-1252</a></dfn>,
|
||
<dfn id=windows-1254><a href=https://encoding.spec.whatwg.org/#windows-1254>windows-1254</a></dfn>,
|
||
<dfn id=windows-1255><a href=https://encoding.spec.whatwg.org/#windows-1255>windows-1255</a></dfn>,
|
||
<dfn id=windows-1256><a href=https://encoding.spec.whatwg.org/#windows-1256>windows-1256</a></dfn>,
|
||
<dfn id=windows-1257><a href=https://encoding.spec.whatwg.org/#windows-1257>windows-1257</a></dfn>,
|
||
<dfn id=windows-1258><a href=https://encoding.spec.whatwg.org/#windows-1258>windows-1258</a></dfn>,
|
||
<dfn id=gb18030><a href=https://encoding.spec.whatwg.org/#gb18030>gb18030</a></dfn>,
|
||
<dfn id=big5><a href=https://encoding.spec.whatwg.org/#big5>Big5</a></dfn>,
|
||
<dfn id=iso-2022-jp><a href=https://encoding.spec.whatwg.org/#iso-2022-jp>ISO-2022-JP</a></dfn>,
|
||
<dfn id=shift_jis><a href=https://encoding.spec.whatwg.org/#shift_jis>Shift_JIS</a></dfn>,
|
||
<dfn id=euc-kr><a href=https://encoding.spec.whatwg.org/#euc-kr>EUC-KR</a></dfn>,
|
||
<dfn id=utf-16be><a href=https://encoding.spec.whatwg.org/#utf-16be>UTF-16BE</a></dfn>,
|
||
<dfn id=utf-16le><a href=https://encoding.spec.whatwg.org/#utf-16le>UTF-16LE</a></dfn>, and
|
||
<dfn id=x-user-defined><a href=https://encoding.spec.whatwg.org/#x-user-defined>x-user-defined</a></dfn>.
|
||
User agents must not support other encodings.</p>
|
||
|
||
<p class=note>The above prohibits supporting, for example, CESU-8, UTF-7, BOCU-1, SCSU, EBCDIC,
|
||
and UTF-32. This specification does not make any attempt to support prohibited encodings in its
|
||
algorithms; support and use of prohibited encodings would thus lead to unexpected behavior. <a href=references.html#refsCESU8>[CESU8]</a> <a href=references.html#refsUTF7>[UTF7]</a> <a href=references.html#refsBOCU1>[BOCU1]</a> <a href=references.html#refsSCSU>[SCSU]</a></p>
|
||
|
||
|
||
<h5 id=changing-the-encoding-while-parsing><span class=secno>12.2.3.4</span> Changing the encoding while parsing<a href=#changing-the-encoding-while-parsing class=self-link></a></h5>
|
||
|
||
<p>When the parser requires the user agent to <dfn id=change-the-encoding>change the encoding</dfn>, it must run the
|
||
following steps. This might happen if the <a href=#encoding-sniffing-algorithm id=changing-the-encoding-while-parsing:encoding-sniffing-algorithm>encoding sniffing algorithm</a> described above
|
||
failed to find a character encoding, or if it found a character encoding that was not the actual
|
||
encoding of the file.</p>
|
||
|
||
<ol><li><p>If the encoding that is already being used to interpret the input stream is a <a id=changing-the-encoding-while-parsing:utf-16-encoding href=infrastructure.html#utf-16-encoding>UTF-16
|
||
encoding</a>, then set the <a href=#concept-encoding-confidence id=changing-the-encoding-while-parsing:concept-encoding-confidence>confidence</a> to
|
||
<i>certain</i> and abort these steps. The new encoding is ignored; if it was anything but the
|
||
same encoding, then it would be clearly incorrect.<li><p>If the new encoding is a <a id=changing-the-encoding-while-parsing:utf-16-encoding-2 href=infrastructure.html#utf-16-encoding>UTF-16 encoding</a>, then change it to
|
||
<a id=changing-the-encoding-while-parsing:utf-8 href=https://encoding.spec.whatwg.org/#utf-8 data-x-internal=utf-8>UTF-8</a>.<li><p>If the new encoding is <a id=changing-the-encoding-while-parsing:x-user-defined href=https://encoding.spec.whatwg.org/#x-user-defined data-x-internal=x-user-defined>x-user-defined</a>, then change it to
|
||
<a id=changing-the-encoding-while-parsing:windows-1252 href=https://encoding.spec.whatwg.org/#windows-1252 data-x-internal=windows-1252>windows-1252</a>.<li><p>If the new encoding is identical or equivalent to the encoding that is already being used
|
||
to interpret the input stream, then set the <a href=#concept-encoding-confidence id=changing-the-encoding-while-parsing:concept-encoding-confidence-2>confidence</a> to <i>certain</i> and abort these steps.
|
||
This happens when the encoding information found in the file matches what the <a href=#encoding-sniffing-algorithm id=changing-the-encoding-while-parsing:encoding-sniffing-algorithm-2>encoding
|
||
sniffing algorithm</a> determined to be the encoding, and in the second pass through the
|
||
parser if the first pass found that the encoding sniffing algorithm described in the earlier
|
||
section failed to find the right encoding.<li><p>If all the bytes up to the last byte converted by the current decoder have the same
|
||
Unicode interpretations in both the current encoding and the new encoding, and if the user agent
|
||
supports changing the converter on the fly, then the user agent may change to the new converter
|
||
for the encoding on the fly. Set the <a id="changing-the-encoding-while-parsing:document's-character-encoding" href=https://dom.spec.whatwg.org/#concept-document-encoding data-x-internal="document's-character-encoding">document's character encoding</a> and the encoding
|
||
used to convert the input stream to the new encoding, set the <a href=#concept-encoding-confidence id=changing-the-encoding-while-parsing:concept-encoding-confidence-3>confidence</a> to <i>certain</i>, and abort these
|
||
steps.<li><p>Otherwise, <a id=changing-the-encoding-while-parsing:navigate href=browsing-the-web.html#navigate>navigate</a> to the document again, with
|
||
<a id=changing-the-encoding-while-parsing:replacement-enabled href=browsing-the-web.html#replacement-enabled>replacement enabled</a>, and using the same <a id=changing-the-encoding-while-parsing:source-browsing-context href=browsing-the-web.html#source-browsing-context>source browsing context</a>, but
|
||
this time skip the <a href=#encoding-sniffing-algorithm id=changing-the-encoding-while-parsing:encoding-sniffing-algorithm-3>encoding sniffing algorithm</a> and instead just set the encoding to
|
||
the new encoding and the <a href=#concept-encoding-confidence id=changing-the-encoding-while-parsing:concept-encoding-confidence-4>confidence</a> to
|
||
<i>certain</i>. Whenever possible, this should be done without actually contacting the network
|
||
layer (the bytes should be re-parsed from memory), even if, e.g., the document is marked as not
|
||
being cacheable. If this is not possible and contacting the network layer would involve repeating
|
||
a request that uses a method other than `<code>GET</code>`), then instead set the <a href=#concept-encoding-confidence id=changing-the-encoding-while-parsing:concept-encoding-confidence-5>confidence</a> to <i>certain</i> and ignore the new
|
||
encoding. The resource will be misinterpreted. User agents may notify the user of the situation,
|
||
to aid in application development.</ol>
|
||
|
||
<p class=note>This algorithm is only invoked when a new encoding is found declared on a
|
||
<code id=changing-the-encoding-while-parsing:the-meta-element><a href=semantics.html#the-meta-element>meta</a></code> element.</p>
|
||
|
||
|
||
<h5 id=preprocessing-the-input-stream><span class=secno>12.2.3.5</span> Preprocessing the input stream<a href=#preprocessing-the-input-stream class=self-link></a></h5>
|
||
|
||
<p>The <dfn id=input-stream>input stream</dfn> consists of the characters pushed into it as the <a href=#the-input-byte-stream id=preprocessing-the-input-stream:the-input-byte-stream>input byte
|
||
stream</a> is decoded or from the various APIs that directly manipulate the input stream.</p>
|
||
|
||
<p>Any occurrences of <a href=https://infra.spec.whatwg.org/#surrogate id=preprocessing-the-input-stream:surrogate data-x-internal=surrogate>surrogates</a> are <a href=#parse-error-surrogate-in-input-stream id=preprocessing-the-input-stream:parse-error-surrogate-in-input-stream>surrogate-in-input-stream</a>
|
||
<a href=#parse-errors id=preprocessing-the-input-stream:parse-errors>parse errors</a>. Any occurrences of <a href=https://infra.spec.whatwg.org/#noncharacter id=preprocessing-the-input-stream:noncharacter data-x-internal=noncharacter>noncharacters</a> are <a href=#parse-error-noncharacter-in-input-stream id=preprocessing-the-input-stream:parse-error-noncharacter-in-input-stream>noncharacter-in-input-stream</a>
|
||
<a href=#parse-errors id=preprocessing-the-input-stream:parse-errors-2>parse errors</a> and any occurrences of <a href=https://infra.spec.whatwg.org/#control id=preprocessing-the-input-stream:control data-x-internal=control>controls</a> other than <a id=preprocessing-the-input-stream:space-characters href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a> and U+0000 NULL
|
||
characters are <a href=#parse-error-control-character-in-input-stream id=preprocessing-the-input-stream:parse-error-control-character-in-input-stream>control-character-in-input-stream</a>
|
||
<a href=#parse-errors id=preprocessing-the-input-stream:parse-errors-3>parse errors</a>.</p>
|
||
|
||
<p class=note>The handling of U+0000 NULL characters varies based on where the characters are
|
||
found and happens at the later stages of the parsing. They are either ignored or, for security
|
||
reasons, replaced with a U+FFFD REPLACEMENT CHARACTER. This handling is, by necessity, spread
|
||
across both the tokenization stage and the tree construction stage.</p>
|
||
|
||
<p>U+000D CARRIAGE RETURN (CR) characters and U+000A LINE FEED (LF) characters are treated
|
||
specially. Any LF character that immediately follows a CR character must be ignored, and all CR
|
||
characters must then be converted to LF characters. Thus, newlines in HTML DOMs are represented by
|
||
LF characters, and there are never any CR characters in the input to the <a href=#tokenization id=preprocessing-the-input-stream:tokenization>tokenization</a>
|
||
stage.</p>
|
||
|
||
<p>The <dfn id=next-input-character>next input character</dfn> is the first character in the <a href=#input-stream id=preprocessing-the-input-stream:input-stream>input stream</a>
|
||
that has not yet been <dfn>consumed</dfn> or explicitly ignored by the requirements in
|
||
this section. Initially, the <i id=preprocessing-the-input-stream:next-input-character><a href=#next-input-character>next input character</a></i> is the
|
||
first character in the input. The <dfn id=current-input-character>current input character</dfn> is the last character to have
|
||
been <i>consumed</i>.</p>
|
||
|
||
<p>The <dfn id=insertion-point>insertion point</dfn> is the position (just before a character or just before the end
|
||
of the input stream) where content inserted using <code id=preprocessing-the-input-stream:dom-document-write-2><a href=dynamic-markup-insertion.html#dom-document-write-2>document.write()</a></code> is actually inserted. The insertion point is
|
||
relative to the position of the character immediately after it, it is not an absolute offset into
|
||
the input stream. Initially, the insertion point is undefined.</p>
|
||
|
||
<p>The "EOF" character in the tables below is a conceptual character representing the end of the
|
||
<a href=#input-stream id=preprocessing-the-input-stream:input-stream-2>input stream</a>. If the parser is a <a id=preprocessing-the-input-stream:script-created-parser href=dynamic-markup-insertion.html#script-created-parser>script-created parser</a>, then the end of
|
||
the <a href=#input-stream id=preprocessing-the-input-stream:input-stream-3>input stream</a> is reached when an <dfn id=explicit-eof-character>explicit "EOF" character</dfn> (inserted by
|
||
the <code id=preprocessing-the-input-stream:dom-document-close-2><a href=dynamic-markup-insertion.html#dom-document-close-2>document.close()</a></code> method) is consumed. Otherwise, the
|
||
"EOF" character is not a real character in the stream, but rather the lack of any further
|
||
characters.</p>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h4 id=parse-state><span class=secno>12.2.4</span> Parse state<a href=#parse-state class=self-link></a></h4>
|
||
|
||
<h5 id=the-insertion-mode><span class=secno>12.2.4.1</span> The insertion mode<a href=#the-insertion-mode class=self-link></a></h5>
|
||
|
||
<p>The <dfn id=insertion-mode>insertion mode</dfn> is a state variable that controls the primary operation of the
|
||
tree construction stage.</p>
|
||
|
||
<p>Initially, the <a href=#insertion-mode id=the-insertion-mode:insertion-mode>insertion mode</a> is "<a href=#the-initial-insertion-mode id=the-insertion-mode:the-initial-insertion-mode>initial</a>". It can change to "<a href=#the-before-html-insertion-mode id=the-insertion-mode:the-before-html-insertion-mode>before
|
||
html</a>", "<a href=#the-before-head-insertion-mode id=the-insertion-mode:the-before-head-insertion-mode>before head</a>", "<a href=#parsing-main-inhead id=the-insertion-mode:parsing-main-inhead>in head</a>", "<a href=#parsing-main-inheadnoscript id=the-insertion-mode:parsing-main-inheadnoscript>in head noscript</a>", "<a href=#the-after-head-insertion-mode id=the-insertion-mode:the-after-head-insertion-mode>after head</a>",
|
||
"<a href=#parsing-main-inbody id=the-insertion-mode:parsing-main-inbody>in body</a>", "<a href=#parsing-main-incdata id=the-insertion-mode:parsing-main-incdata>text</a>", "<a href=#parsing-main-intable id=the-insertion-mode:parsing-main-intable>in table</a>", "<a href=#parsing-main-intabletext id=the-insertion-mode:parsing-main-intabletext>in table text</a>", "<a href=#parsing-main-incaption id=the-insertion-mode:parsing-main-incaption>in caption</a>", "<a href=#parsing-main-incolgroup id=the-insertion-mode:parsing-main-incolgroup>in column
|
||
group</a>", "<a href=#parsing-main-intbody id=the-insertion-mode:parsing-main-intbody>in table body</a>", "<a href=#parsing-main-intr id=the-insertion-mode:parsing-main-intr>in row</a>", "<a href=#parsing-main-intd id=the-insertion-mode:parsing-main-intd>in
|
||
cell</a>", "<a href=#parsing-main-inselect id=the-insertion-mode:parsing-main-inselect>in select</a>", "<a href=#parsing-main-inselectintable id=the-insertion-mode:parsing-main-inselectintable>in select in table</a>", "<a href=#parsing-main-intemplate id=the-insertion-mode:parsing-main-intemplate>in template</a>", "<a href=#parsing-main-afterbody id=the-insertion-mode:parsing-main-afterbody>after body</a>",
|
||
"<a href=#parsing-main-inframeset id=the-insertion-mode:parsing-main-inframeset>in frameset</a>", "<a href=#parsing-main-afterframeset id=the-insertion-mode:parsing-main-afterframeset>after frameset</a>", "<a href=#the-after-after-body-insertion-mode id=the-insertion-mode:the-after-after-body-insertion-mode>after
|
||
after body</a>", and "<a href=#the-after-after-frameset-insertion-mode id=the-insertion-mode:the-after-after-frameset-insertion-mode>after after
|
||
frameset</a>" during the course of the parsing, as described in the <a href=#tree-construction id=the-insertion-mode:tree-construction>tree
|
||
construction</a> stage. The insertion mode affects how tokens are processed and whether CDATA
|
||
sections are supported.</p>
|
||
|
||
<p>Several of these modes, namely "<a href=#parsing-main-inhead id=the-insertion-mode:parsing-main-inhead-2>in head</a>", "<a href=#parsing-main-inbody id=the-insertion-mode:parsing-main-inbody-2>in body</a>", "<a href=#parsing-main-intable id=the-insertion-mode:parsing-main-intable-2>in
|
||
table</a>", and "<a href=#parsing-main-inselect id=the-insertion-mode:parsing-main-inselect-2>in select</a>", are special, in
|
||
that the other modes defer to them at various times. When the algorithm below says that the user
|
||
agent is to do something "<dfn id=using-the-rules-for>using the rules for</dfn> the <var>m</var> insertion
|
||
mode", where <var>m</var> is one of these modes, the user agent must use the rules
|
||
described under the <var>m</var> <a href=#insertion-mode id=the-insertion-mode:insertion-mode-2>insertion mode</a>'s section, but must leave
|
||
the <a href=#insertion-mode id=the-insertion-mode:insertion-mode-3>insertion mode</a> unchanged unless the rules in <var>m</var> themselves
|
||
switch the <a href=#insertion-mode id=the-insertion-mode:insertion-mode-4>insertion mode</a> to a new value.</p>
|
||
|
||
<p>When the insertion mode is switched to "<a href=#parsing-main-incdata id=the-insertion-mode:parsing-main-incdata-2>text</a>" or
|
||
"<a href=#parsing-main-intabletext id=the-insertion-mode:parsing-main-intabletext-2>in table text</a>", the <dfn id=original-insertion-mode>original insertion
|
||
mode</dfn> is also set. This is the insertion mode to which the tree construction stage will
|
||
return.</p>
|
||
|
||
<p>Similarly, to parse nested <code id=the-insertion-mode:the-template-element><a href=scripting.html#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 id=the-insertion-mode: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>
|
||
|
||
<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>
|
||
|
||
<ol><li><p>Let <var>last</var> be false.<li><p>Let <var>node</var> be the last node in the <a href=#stack-of-open-elements id=the-insertion-mode:stack-of-open-elements>stack of open
|
||
elements</a>.<li><p><i>Loop</i>: If <var>node</var> is the first node in the stack of open elements,
|
||
then set <var>last</var> to true, and, if the parser was originally created as part of
|
||
the <a href=#html-fragment-parsing-algorithm id=the-insertion-mode:html-fragment-parsing-algorithm>HTML fragment parsing algorithm</a> (<a href=#fragment-case id=the-insertion-mode:fragment-case>fragment case</a>), set <var>node</var> to the <var id=the-insertion-mode:concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var>
|
||
element passed to that algorithm.<li>
|
||
|
||
<p>If <var>node</var> is a <code id=the-insertion-mode:the-select-element><a href=form-elements.html#the-select-element>select</a></code> element, run these substeps:</p>
|
||
|
||
<ol><li><p>If <var>last</var> is true, jump to the step below labeled
|
||
<i>done</i>.<li><p>Let <var>ancestor</var> be <var>node</var>.<li><p><i>Loop</i>: If <var>ancestor</var> is the first node in the <a href=#stack-of-open-elements id=the-insertion-mode:stack-of-open-elements-2>stack of
|
||
open elements</a>, jump to the step below labeled <i>done</i>.<li><p>Let <var>ancestor</var> be the node before <var>ancestor</var> in the
|
||
<a href=#stack-of-open-elements id=the-insertion-mode:stack-of-open-elements-3>stack of open elements</a>.<li><p>If <var>ancestor</var> is a <code id=the-insertion-mode:the-template-element-2><a href=scripting.html#the-template-element>template</a></code> node, jump to the step below
|
||
labeled <i>done</i>.<li><p>If <var>ancestor</var> is a <code id=the-insertion-mode:the-table-element><a href=tables.html#the-table-element>table</a></code> node, switch the <a href=#insertion-mode id=the-insertion-mode:insertion-mode-5>insertion
|
||
mode</a> to "<a href=#parsing-main-inselectintable id=the-insertion-mode:parsing-main-inselectintable-2>in select in table</a>" and
|
||
abort these steps.<li><p>Jump back to the step labeled <i>loop</i>.<li><p><i>Done</i>: Switch the <a href=#insertion-mode id=the-insertion-mode:insertion-mode-6>insertion mode</a> to "<a href=#parsing-main-inselect id=the-insertion-mode:parsing-main-inselect-3>in select</a>" and abort these steps.</ol>
|
||
|
||
<li><p>If <var>node</var> is a <code id=the-insertion-mode:the-td-element><a href=tables.html#the-td-element>td</a></code> or <code id=the-insertion-mode:the-th-element><a href=tables.html#the-th-element>th</a></code> element and <var>last</var> is false, then switch the <a href=#insertion-mode id=the-insertion-mode:insertion-mode-7>insertion mode</a> to "<a href=#parsing-main-intd id=the-insertion-mode:parsing-main-intd-2>in cell</a>" and abort these steps.<li><p>If <var>node</var> is a <code id=the-insertion-mode:the-tr-element><a href=tables.html#the-tr-element>tr</a></code> element, then switch the <a href=#insertion-mode id=the-insertion-mode:insertion-mode-8>insertion
|
||
mode</a> to "<a href=#parsing-main-intr id=the-insertion-mode:parsing-main-intr-2>in row</a>" and abort these
|
||
steps.<li><p>If <var>node</var> is a <code id=the-insertion-mode:the-tbody-element><a href=tables.html#the-tbody-element>tbody</a></code>, <code id=the-insertion-mode:the-thead-element><a href=tables.html#the-thead-element>thead</a></code>, or
|
||
<code id=the-insertion-mode:the-tfoot-element><a href=tables.html#the-tfoot-element>tfoot</a></code> element, then switch the <a href=#insertion-mode id=the-insertion-mode:insertion-mode-9>insertion mode</a> to "<a href=#parsing-main-intbody id=the-insertion-mode:parsing-main-intbody-2>in table body</a>" and abort these steps.<li><p>If <var>node</var> is a <code id=the-insertion-mode:the-caption-element><a href=tables.html#the-caption-element>caption</a></code> element, then switch the
|
||
<a href=#insertion-mode id=the-insertion-mode:insertion-mode-10>insertion mode</a> to "<a href=#parsing-main-incaption id=the-insertion-mode:parsing-main-incaption-2>in caption</a>" and
|
||
abort these steps.<li><p>If <var>node</var> is a <code id=the-insertion-mode:the-colgroup-element><a href=tables.html#the-colgroup-element>colgroup</a></code> element, then switch the
|
||
<a href=#insertion-mode id=the-insertion-mode:insertion-mode-11>insertion mode</a> to "<a href=#parsing-main-incolgroup id=the-insertion-mode:parsing-main-incolgroup-2>in column
|
||
group</a>" and abort these steps.<li><p>If <var>node</var> is a <code id=the-insertion-mode:the-table-element-2><a href=tables.html#the-table-element>table</a></code> element, then switch the
|
||
<a href=#insertion-mode id=the-insertion-mode:insertion-mode-12>insertion mode</a> to "<a href=#parsing-main-intable id=the-insertion-mode:parsing-main-intable-3>in table</a>" and abort
|
||
these steps.<li><p>If <var>node</var> is a <code id=the-insertion-mode:the-template-element-3><a href=scripting.html#the-template-element>template</a></code> element, then switch the
|
||
<a href=#insertion-mode id=the-insertion-mode:insertion-mode-13>insertion mode</a> to the <a href=#current-template-insertion-mode id=the-insertion-mode:current-template-insertion-mode>current template insertion mode</a> and abort these
|
||
steps.<li><p>If <var>node</var> is a <code id=the-insertion-mode:the-head-element><a href=semantics.html#the-head-element>head</a></code> element and <var>last</var> is
|
||
false, then switch the <a href=#insertion-mode id=the-insertion-mode:insertion-mode-14>insertion mode</a> to "<a href=#parsing-main-inhead id=the-insertion-mode:parsing-main-inhead-3>in
|
||
head</a>" and abort these steps.<li><p>If <var>node</var> is a <code id=the-insertion-mode:the-body-element><a href=sections.html#the-body-element>body</a></code> element, then switch the
|
||
<a href=#insertion-mode id=the-insertion-mode:insertion-mode-15>insertion mode</a> to "<a href=#parsing-main-inbody id=the-insertion-mode:parsing-main-inbody-3>in body</a>" and abort
|
||
these steps.<li><p>If <var>node</var> is a <code id=the-insertion-mode:frameset><a href=obsolete.html#frameset>frameset</a></code> element, then switch the
|
||
<a href=#insertion-mode id=the-insertion-mode:insertion-mode-16>insertion mode</a> to "<a href=#parsing-main-inframeset id=the-insertion-mode:parsing-main-inframeset-2>in frameset</a>" and
|
||
abort these steps. (<a href=#fragment-case id=the-insertion-mode:fragment-case-2>fragment case</a>)<li>
|
||
|
||
<p>If <var>node</var> is an <code id=the-insertion-mode:the-html-element><a href=semantics.html#the-html-element>html</a></code> element, run these substeps:</p>
|
||
|
||
<ol><li><p>If the <a href=#head-element-pointer id=the-insertion-mode:head-element-pointer><code>head</code> element pointer</a> is null, switch the
|
||
<a href=#insertion-mode id=the-insertion-mode:insertion-mode-17>insertion mode</a> to "<a href=#the-before-head-insertion-mode id=the-insertion-mode:the-before-head-insertion-mode-2>before head</a>"
|
||
and abort these steps. (<a href=#fragment-case id=the-insertion-mode:fragment-case-3>fragment case</a>)<li><p>Otherwise, the <a href=#head-element-pointer id=the-insertion-mode:head-element-pointer-2><code>head</code> element pointer</a> is not null, switch the
|
||
<a href=#insertion-mode id=the-insertion-mode:insertion-mode-18>insertion mode</a> to "<a href=#the-after-head-insertion-mode id=the-insertion-mode:the-after-head-insertion-mode-2>after head</a>" and
|
||
abort these steps.</ol>
|
||
|
||
<li><p>If <var>last</var> is true, then switch the <a href=#insertion-mode id=the-insertion-mode:insertion-mode-19>insertion mode</a> to "<a href=#parsing-main-inbody id=the-insertion-mode:parsing-main-inbody-4>in body</a>" and abort these steps. (<a href=#fragment-case id=the-insertion-mode:fragment-case-4>fragment
|
||
case</a>)<li><p>Let <var>node</var> now be the node before <var>node</var> in the
|
||
<a href=#stack-of-open-elements id=the-insertion-mode:stack-of-open-elements-4>stack of open elements</a>.<li><p>Return to the step labeled <i>loop</i>.</ol>
|
||
|
||
|
||
<h5 id=the-stack-of-open-elements><span class=secno>12.2.4.2</span> The stack of open elements<a href=#the-stack-of-open-elements class=self-link></a></h5>
|
||
|
||
<p>Initially, the <dfn id=stack-of-open-elements>stack of open elements</dfn> is empty. The stack grows downwards; the
|
||
topmost node on the stack is the first one added to the stack, and the bottommost node of the
|
||
stack is the most recently added node in the stack (notwithstanding when the stack is manipulated
|
||
in a random access fashion as part of <a href=#adoptionAgency>the handling for misnested
|
||
tags</a>).</p>
|
||
|
||
<p class=note>The "<a href=#the-before-html-insertion-mode id=the-stack-of-open-elements:the-before-html-insertion-mode>before html</a>"
|
||
<a href=#insertion-mode id=the-stack-of-open-elements:insertion-mode>insertion mode</a> creates the <code id=the-stack-of-open-elements:the-html-element><a href=semantics.html#the-html-element>html</a></code> <a id=the-stack-of-open-elements:document-element href=https://dom.spec.whatwg.org/#document-element data-x-internal=document-element>document element</a>, which is
|
||
then added to the stack.</p>
|
||
|
||
<p class=note>In the <a href=#fragment-case id=the-stack-of-open-elements:fragment-case>fragment case</a>, the <a href=#stack-of-open-elements id=the-stack-of-open-elements:stack-of-open-elements>stack of open elements</a> is
|
||
initialized to contain an <code id=the-stack-of-open-elements:the-html-element-2><a href=semantics.html#the-html-element>html</a></code> element that is created as part of <a href=#html-fragment-parsing-algorithm id=the-stack-of-open-elements:html-fragment-parsing-algorithm>that algorithm</a>. (The <a href=#fragment-case id=the-stack-of-open-elements:fragment-case-2>fragment case</a> skips the
|
||
"<a href=#the-before-html-insertion-mode id=the-stack-of-open-elements:the-before-html-insertion-mode-2>before html</a>" <a href=#insertion-mode id=the-stack-of-open-elements:insertion-mode-2>insertion mode</a>.)</p>
|
||
|
||
<p>The <code id=the-stack-of-open-elements:the-html-element-3><a href=semantics.html#the-html-element>html</a></code> node, however it is created, is the topmost node of the stack. It only
|
||
gets popped off the stack when the parser <a href=#stop-parsing id=the-stack-of-open-elements:stop-parsing>finishes</a>.</p>
|
||
|
||
<p>The <dfn id=current-node>current node</dfn> is the bottommost node in this <a href=#stack-of-open-elements id=the-stack-of-open-elements:stack-of-open-elements-2>stack of open
|
||
elements</a>.</p>
|
||
|
||
<p>The <dfn id=adjusted-current-node>adjusted current node</dfn> is the <i id=the-stack-of-open-elements:concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></i>
|
||
element if the parser was created by the <a href=#html-fragment-parsing-algorithm id=the-stack-of-open-elements:html-fragment-parsing-algorithm-2>HTML fragment parsing algorithm</a> and the
|
||
<a href=#stack-of-open-elements id=the-stack-of-open-elements:stack-of-open-elements-3>stack of open elements</a> has only one element in it (<a href=#fragment-case id=the-stack-of-open-elements:fragment-case-3>fragment case</a>);
|
||
otherwise, the <a href=#adjusted-current-node id=the-stack-of-open-elements:adjusted-current-node>adjusted current node</a> is the <a href=#current-node id=the-stack-of-open-elements:current-node>current node</a>.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=bugs><strong>Spec bugs:</strong> <a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=27314" title="Parser: "adjusted current node" not clear enough">27314</a></div>
|
||
|
||
<p>Elements in the <a href=#stack-of-open-elements id=the-stack-of-open-elements:stack-of-open-elements-4>stack of open elements</a> fall into the following categories:</p>
|
||
|
||
<dl><dt><dfn id=special>Special</dfn><dd>
|
||
<p>The following elements have varying levels of special parsing rules: HTML's
|
||
<code id=the-stack-of-open-elements:the-address-element><a href=sections.html#the-address-element>address</a></code>, <code id=the-stack-of-open-elements:applet><a href=obsolete.html#applet>applet</a></code>, <code id=the-stack-of-open-elements:the-area-element><a href=image-maps.html#the-area-element>area</a></code>, <code id=the-stack-of-open-elements:the-article-element><a href=sections.html#the-article-element>article</a></code>,
|
||
<code id=the-stack-of-open-elements:the-aside-element><a href=sections.html#the-aside-element>aside</a></code>, <code id=the-stack-of-open-elements:the-base-element><a href=semantics.html#the-base-element>base</a></code>, <code id=the-stack-of-open-elements:basefont><a href=obsolete.html#basefont>basefont</a></code>, <code id=the-stack-of-open-elements:bgsound><a href=obsolete.html#bgsound>bgsound</a></code>,
|
||
<code id=the-stack-of-open-elements:the-blockquote-element><a href=grouping-content.html#the-blockquote-element>blockquote</a></code>, <code id=the-stack-of-open-elements:the-body-element><a href=sections.html#the-body-element>body</a></code>, <code id=the-stack-of-open-elements:the-br-element><a href=text-level-semantics.html#the-br-element>br</a></code>, <code id=the-stack-of-open-elements:the-button-element><a href=form-elements.html#the-button-element>button</a></code>,
|
||
<code id=the-stack-of-open-elements:the-caption-element><a href=tables.html#the-caption-element>caption</a></code>, <code id=the-stack-of-open-elements:center><a href=obsolete.html#center>center</a></code>, <code id=the-stack-of-open-elements:the-col-element><a href=tables.html#the-col-element>col</a></code>, <code id=the-stack-of-open-elements:the-colgroup-element><a href=tables.html#the-colgroup-element>colgroup</a></code>,
|
||
<code id=the-stack-of-open-elements:the-dd-element><a href=grouping-content.html#the-dd-element>dd</a></code>, <code id=the-stack-of-open-elements:the-details-element><a href=interactive-elements.html#the-details-element>details</a></code>, <code id=the-stack-of-open-elements:dir><a href=obsolete.html#dir>dir</a></code>, <code id=the-stack-of-open-elements:the-div-element><a href=grouping-content.html#the-div-element>div</a></code>, <code id=the-stack-of-open-elements:the-dl-element><a href=grouping-content.html#the-dl-element>dl</a></code>,
|
||
<code id=the-stack-of-open-elements:the-dt-element><a href=grouping-content.html#the-dt-element>dt</a></code>, <code id=the-stack-of-open-elements:the-embed-element><a href=iframe-embed-object.html#the-embed-element>embed</a></code>, <code id=the-stack-of-open-elements:the-fieldset-element><a href=form-elements.html#the-fieldset-element>fieldset</a></code>, <code id=the-stack-of-open-elements:the-figcaption-element><a href=grouping-content.html#the-figcaption-element>figcaption</a></code>,
|
||
<code id=the-stack-of-open-elements:the-figure-element><a href=grouping-content.html#the-figure-element>figure</a></code>, <code id=the-stack-of-open-elements:the-footer-element><a href=sections.html#the-footer-element>footer</a></code>, <code id=the-stack-of-open-elements:the-form-element><a href=forms.html#the-form-element>form</a></code>, <code id=the-stack-of-open-elements:frame><a href=obsolete.html#frame>frame</a></code>,
|
||
<code id=the-stack-of-open-elements:frameset><a href=obsolete.html#frameset>frameset</a></code>, <code id=the-stack-of-open-elements:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements><a href=sections.html#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>, <code id=the-stack-of-open-elements:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2><a href=sections.html#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>, <code id=the-stack-of-open-elements:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3><a href=sections.html#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h3</a></code>, <code id=the-stack-of-open-elements:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4><a href=sections.html#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h4</a></code>,
|
||
<code id=the-stack-of-open-elements:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-5><a href=sections.html#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h5</a></code>, <code id=the-stack-of-open-elements:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-6><a href=sections.html#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code>, <code id=the-stack-of-open-elements:the-head-element><a href=semantics.html#the-head-element>head</a></code>, <code id=the-stack-of-open-elements:the-header-element><a href=sections.html#the-header-element>header</a></code>, <code id=the-stack-of-open-elements:the-hgroup-element><a href=sections.html#the-hgroup-element>hgroup</a></code>,
|
||
<code id=the-stack-of-open-elements:the-hr-element><a href=grouping-content.html#the-hr-element>hr</a></code>, <code id=the-stack-of-open-elements:the-html-element-4><a href=semantics.html#the-html-element>html</a></code>, <code id=the-stack-of-open-elements:the-iframe-element><a href=iframe-embed-object.html#the-iframe-element>iframe</a></code>,
|
||
<code id=the-stack-of-open-elements:the-img-element><a href=embedded-content.html#the-img-element>img</a></code>, <code id=the-stack-of-open-elements:the-input-element><a href=input.html#the-input-element>input</a></code>, <code id=the-stack-of-open-elements:keygen><a href=obsolete.html#keygen>keygen</a></code>, <code id=the-stack-of-open-elements:the-li-element><a href=grouping-content.html#the-li-element>li</a></code>, <code id=the-stack-of-open-elements:the-link-element><a href=semantics.html#the-link-element>link</a></code>,
|
||
<code id=the-stack-of-open-elements:listing><a href=obsolete.html#listing>listing</a></code>, <code id=the-stack-of-open-elements:the-main-element><a href=grouping-content.html#the-main-element>main</a></code>, <code id=the-stack-of-open-elements:the-marquee-element><a href=obsolete.html#the-marquee-element>marquee</a></code>, <code id=the-stack-of-open-elements:the-menu-element><a href=grouping-content.html#the-menu-element>menu</a></code>,
|
||
<code id=the-stack-of-open-elements:the-meta-element><a href=semantics.html#the-meta-element>meta</a></code>, <code id=the-stack-of-open-elements:the-nav-element><a href=sections.html#the-nav-element>nav</a></code>, <code id=the-stack-of-open-elements:noembed><a href=obsolete.html#noembed>noembed</a></code>, <code id=the-stack-of-open-elements:noframes><a href=obsolete.html#noframes>noframes</a></code>,
|
||
<code id=the-stack-of-open-elements:the-noscript-element><a href=scripting.html#the-noscript-element>noscript</a></code>, <code id=the-stack-of-open-elements:the-object-element><a href=iframe-embed-object.html#the-object-element>object</a></code>, <code id=the-stack-of-open-elements:the-ol-element><a href=grouping-content.html#the-ol-element>ol</a></code>, <code id=the-stack-of-open-elements:the-p-element><a href=grouping-content.html#the-p-element>p</a></code>, <code id=the-stack-of-open-elements:the-param-element><a href=iframe-embed-object.html#the-param-element>param</a></code>,
|
||
<code id=the-stack-of-open-elements:plaintext><a href=obsolete.html#plaintext>plaintext</a></code>, <code id=the-stack-of-open-elements:the-pre-element><a href=grouping-content.html#the-pre-element>pre</a></code>, <code id=the-stack-of-open-elements:the-script-element><a href=scripting.html#the-script-element>script</a></code>, <code id=the-stack-of-open-elements:the-section-element><a href=sections.html#the-section-element>section</a></code>,
|
||
<code id=the-stack-of-open-elements:the-select-element><a href=form-elements.html#the-select-element>select</a></code>, <code id=the-stack-of-open-elements:the-source-element><a href=embedded-content.html#the-source-element>source</a></code>, <code id=the-stack-of-open-elements:the-style-element><a href=semantics.html#the-style-element>style</a></code>, <code id=the-stack-of-open-elements:the-summary-element><a href=interactive-elements.html#the-summary-element>summary</a></code>,
|
||
<code id=the-stack-of-open-elements:the-table-element><a href=tables.html#the-table-element>table</a></code>, <code id=the-stack-of-open-elements:the-tbody-element><a href=tables.html#the-tbody-element>tbody</a></code>, <code id=the-stack-of-open-elements:the-td-element><a href=tables.html#the-td-element>td</a></code>, <code id=the-stack-of-open-elements:the-template-element><a href=scripting.html#the-template-element>template</a></code>,
|
||
<code id=the-stack-of-open-elements:the-textarea-element><a href=form-elements.html#the-textarea-element>textarea</a></code>, <code id=the-stack-of-open-elements:the-tfoot-element><a href=tables.html#the-tfoot-element>tfoot</a></code>, <code id=the-stack-of-open-elements:the-th-element><a href=tables.html#the-th-element>th</a></code>, <code id=the-stack-of-open-elements:the-thead-element><a href=tables.html#the-thead-element>thead</a></code>,
|
||
<code id=the-stack-of-open-elements:the-title-element><a href=semantics.html#the-title-element>title</a></code>, <code id=the-stack-of-open-elements:the-tr-element><a href=tables.html#the-tr-element>tr</a></code>, <code id=the-stack-of-open-elements:the-track-element><a href=media.html#the-track-element>track</a></code>, <code id=the-stack-of-open-elements:the-ul-element><a href=grouping-content.html#the-ul-element>ul</a></code>, <code id=the-stack-of-open-elements:the-wbr-element><a href=text-level-semantics.html#the-wbr-element>wbr</a></code>,
|
||
<code id=the-stack-of-open-elements:xmp><a href=obsolete.html#xmp>xmp</a></code>; <a id=the-stack-of-open-elements:mathml-mi href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mi data-x-internal=mathml-mi>MathML <code>mi</code></a>, <a id=the-stack-of-open-elements:mathml-mo href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mo data-x-internal=mathml-mo>MathML <code>mo</code></a>,
|
||
<a id=the-stack-of-open-elements:mathml-mn href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mn data-x-internal=mathml-mn>MathML <code>mn</code></a>, <a id=the-stack-of-open-elements:mathml-ms href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.ms data-x-internal=mathml-ms>MathML <code>ms</code></a>, <a id=the-stack-of-open-elements:mathml-mtext href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mtext data-x-internal=mathml-mtext>MathML
|
||
<code>mtext</code></a>, and <a id=the-stack-of-open-elements:mathml-annotation-xml href=https://www.w3.org/Math/draft-spec/chapter5.html#mixing.elements.annotation.xml data-x-internal=mathml-annotation-xml>MathML <code>annotation-xml</code></a>; and <a id=the-stack-of-open-elements:svg-foreignobject href=https://www.w3.org/TR/SVG11/extend.html#ForeignObjectElement data-x-internal=svg-foreignobject>SVG
|
||
<code>foreignObject</code></a>, <a id=the-stack-of-open-elements:svg-desc href=https://www.w3.org/TR/SVG11/struct.html#DescElement data-x-internal=svg-desc>SVG <code>desc</code></a>, and <a id=the-stack-of-open-elements:svg-title href=https://www.w3.org/TR/SVG11/struct.html#TitleElement data-x-internal=svg-title>SVG
|
||
<code>title</code></a>.</p>
|
||
|
||
<p class=note>An <code>image</code> start tag token is handled by the tree builder,
|
||
but it is not in this list because it is not an element; it gets turned into an <code id=the-stack-of-open-elements:the-img-element-2><a href=embedded-content.html#the-img-element>img</a></code>
|
||
element.</p>
|
||
<dt><dfn id=formatting>Formatting</dfn><dd><p>The following HTML elements are those that end up in the <a href=#list-of-active-formatting-elements id=the-stack-of-open-elements:list-of-active-formatting-elements>list of active formatting
|
||
elements</a>: <code id=the-stack-of-open-elements:the-a-element><a href=text-level-semantics.html#the-a-element>a</a></code>, <code id=the-stack-of-open-elements:the-b-element><a href=text-level-semantics.html#the-b-element>b</a></code>, <code id=the-stack-of-open-elements:big><a href=obsolete.html#big>big</a></code>, <code id=the-stack-of-open-elements:the-code-element><a href=text-level-semantics.html#the-code-element>code</a></code>,
|
||
<code id=the-stack-of-open-elements:the-em-element><a href=text-level-semantics.html#the-em-element>em</a></code>, <code id=the-stack-of-open-elements:font><a href=obsolete.html#font>font</a></code>, <code id=the-stack-of-open-elements:the-i-element><a href=text-level-semantics.html#the-i-element>i</a></code>, <code id=the-stack-of-open-elements:nobr><a href=obsolete.html#nobr>nobr</a></code>, <code id=the-stack-of-open-elements:the-s-element><a href=text-level-semantics.html#the-s-element>s</a></code>,
|
||
<code id=the-stack-of-open-elements:the-small-element><a href=text-level-semantics.html#the-small-element>small</a></code>, <code id=the-stack-of-open-elements:strike><a href=obsolete.html#strike>strike</a></code>, <code id=the-stack-of-open-elements:the-strong-element><a href=text-level-semantics.html#the-strong-element>strong</a></code>, <code id=the-stack-of-open-elements:tt><a href=obsolete.html#tt>tt</a></code>, and
|
||
<code id=the-stack-of-open-elements:the-u-element><a href=text-level-semantics.html#the-u-element>u</a></code>.<dt><dfn id=ordinary>Ordinary</dfn><dd><p>All other elements found while parsing an HTML document.</dl>
|
||
|
||
<p class=note>Typically, the <a href=#special id=the-stack-of-open-elements:special>special</a> elements have the start and end tag tokens
|
||
handled specifically, while <a href=#ordinary id=the-stack-of-open-elements:ordinary>ordinary</a> elements' tokens fall into "any other start tag"
|
||
and "any other end tag" clauses, and some parts of the tree builder check if a particular element
|
||
in the <a href=#stack-of-open-elements id=the-stack-of-open-elements:stack-of-open-elements-5>stack of open elements</a> is in the <a href=#special id=the-stack-of-open-elements:special-2>special</a> category. However, some
|
||
elements (e.g., the <code id=the-stack-of-open-elements:the-option-element><a href=form-elements.html#the-option-element>option</a></code> element) have their start or end tag tokens handled
|
||
specifically, but are still not in the <a href=#special id=the-stack-of-open-elements:special-3>special</a> category, so that they get the
|
||
<a href=#ordinary id=the-stack-of-open-elements:ordinary-2>ordinary</a> handling elsewhere.</p>
|
||
|
||
<p>The <a href=#stack-of-open-elements id=the-stack-of-open-elements:stack-of-open-elements-6>stack of open elements</a> is said to <dfn id=has-an-element-in-the-specific-scope>have an element <var>target node</var> in a specific scope</dfn> consisting of a
|
||
list of element types <var>list</var> when the following algorithm terminates in a match
|
||
state:</p>
|
||
|
||
<ol><li><p>Initialize <var>node</var> to be the <a href=#current-node id=the-stack-of-open-elements:current-node-2>current node</a> (the bottommost
|
||
node of the stack).<li><p>If <var>node</var> is the target node, terminate in a match state.<li><p>Otherwise, if <var>node</var> is one of the element types in <var>list</var>, terminate in a failure state.<li><p>Otherwise, set <var>node</var> to the previous entry in the <a href=#stack-of-open-elements id=the-stack-of-open-elements:stack-of-open-elements-7>stack of open
|
||
elements</a> and return to step 2. (This will never fail, since the loop will always terminate
|
||
in the previous step if the top of the stack — an <code id=the-stack-of-open-elements:the-html-element-5><a href=semantics.html#the-html-element>html</a></code> element — is
|
||
reached.)</ol>
|
||
|
||
<p>The <a href=#stack-of-open-elements id=the-stack-of-open-elements:stack-of-open-elements-8>stack of open elements</a> is said to <dfn id=has-an-element-in-scope>have a
|
||
particular element in scope</dfn> when it <a href=#has-an-element-in-the-specific-scope id=the-stack-of-open-elements:has-an-element-in-the-specific-scope>has
|
||
that element in the specific scope</a> consisting of the following element types:</p>
|
||
|
||
<ul class=brief><li><code id=the-stack-of-open-elements:applet-2><a href=obsolete.html#applet>applet</a></code><li><code id=the-stack-of-open-elements:the-caption-element-2><a href=tables.html#the-caption-element>caption</a></code><li><code id=the-stack-of-open-elements:the-html-element-6><a href=semantics.html#the-html-element>html</a></code><li><code id=the-stack-of-open-elements:the-table-element-2><a href=tables.html#the-table-element>table</a></code><li><code id=the-stack-of-open-elements:the-td-element-2><a href=tables.html#the-td-element>td</a></code><li><code id=the-stack-of-open-elements:the-th-element-2><a href=tables.html#the-th-element>th</a></code><li><code id=the-stack-of-open-elements:the-marquee-element-2><a href=obsolete.html#the-marquee-element>marquee</a></code><li><code id=the-stack-of-open-elements:the-object-element-2><a href=iframe-embed-object.html#the-object-element>object</a></code><li><code id=the-stack-of-open-elements:the-template-element-2><a href=scripting.html#the-template-element>template</a></code><li><a id=the-stack-of-open-elements:mathml-mi-2 href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mi data-x-internal=mathml-mi>MathML <code>mi</code></a><li><a id=the-stack-of-open-elements:mathml-mo-2 href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mo data-x-internal=mathml-mo>MathML <code>mo</code></a><li><a id=the-stack-of-open-elements:mathml-mn-2 href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mn data-x-internal=mathml-mn>MathML <code>mn</code></a><li><a id=the-stack-of-open-elements:mathml-ms-2 href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.ms data-x-internal=mathml-ms>MathML <code>ms</code></a><li><a id=the-stack-of-open-elements:mathml-mtext-2 href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mtext data-x-internal=mathml-mtext>MathML <code>mtext</code></a><li><a id=the-stack-of-open-elements:mathml-annotation-xml-2 href=https://www.w3.org/Math/draft-spec/chapter5.html#mixing.elements.annotation.xml data-x-internal=mathml-annotation-xml>MathML <code>annotation-xml</code></a><li><a id=the-stack-of-open-elements:svg-foreignobject-2 href=https://www.w3.org/TR/SVG11/extend.html#ForeignObjectElement data-x-internal=svg-foreignobject>SVG <code>foreignObject</code></a><li><a id=the-stack-of-open-elements:svg-desc-2 href=https://www.w3.org/TR/SVG11/struct.html#DescElement data-x-internal=svg-desc>SVG <code>desc</code></a><li><a id=the-stack-of-open-elements:svg-title-2 href=https://www.w3.org/TR/SVG11/struct.html#TitleElement data-x-internal=svg-title>SVG <code>title</code></a></ul>
|
||
|
||
<p>The <a href=#stack-of-open-elements id=the-stack-of-open-elements:stack-of-open-elements-9>stack of open elements</a> is said to <dfn id=has-an-element-in-list-item-scope>have a particular element in list item scope</dfn> when it <a href=#has-an-element-in-the-specific-scope id=the-stack-of-open-elements:has-an-element-in-the-specific-scope-2>has that element in the specific scope</a> consisting of the following
|
||
element types:</p>
|
||
|
||
<ul class=brief><li>All the element types listed above for the <i id=the-stack-of-open-elements:has-an-element-in-scope><a href=#has-an-element-in-scope>has an element in scope</a></i> algorithm.<li><code id=the-stack-of-open-elements:the-ol-element-2><a href=grouping-content.html#the-ol-element>ol</a></code> in the <a id=the-stack-of-open-elements:html-namespace-2 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a><li><code id=the-stack-of-open-elements:the-ul-element-2><a href=grouping-content.html#the-ul-element>ul</a></code> in the <a id=the-stack-of-open-elements:html-namespace-2-2 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a></ul>
|
||
|
||
<p>The <a href=#stack-of-open-elements id=the-stack-of-open-elements:stack-of-open-elements-10>stack of open elements</a> is said to <dfn id=has-an-element-in-button-scope>have a particular element in button scope</dfn> when it <a href=#has-an-element-in-the-specific-scope id=the-stack-of-open-elements:has-an-element-in-the-specific-scope-3>has that element in the specific scope</a> consisting of the following element
|
||
types:</p>
|
||
|
||
<ul class=brief><li>All the element types listed above for the <i id=the-stack-of-open-elements:has-an-element-in-scope-2><a href=#has-an-element-in-scope>has an element in scope</a></i> algorithm.<li><code id=the-stack-of-open-elements:the-button-element-2><a href=form-elements.html#the-button-element>button</a></code> in the <a id=the-stack-of-open-elements:html-namespace-2-3 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a></ul>
|
||
|
||
<p>The <a href=#stack-of-open-elements id=the-stack-of-open-elements:stack-of-open-elements-11>stack of open elements</a> is said to <dfn id=has-an-element-in-table-scope>have a particular element in table scope</dfn> when it <a href=#has-an-element-in-the-specific-scope id=the-stack-of-open-elements:has-an-element-in-the-specific-scope-4>has that element in the specific scope</a> consisting of the following element
|
||
types:</p>
|
||
|
||
<ul class=brief><li><code id=the-stack-of-open-elements:the-html-element-7><a href=semantics.html#the-html-element>html</a></code> in the <a id=the-stack-of-open-elements:html-namespace-2-4 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a><li><code id=the-stack-of-open-elements:the-table-element-3><a href=tables.html#the-table-element>table</a></code> in the <a id=the-stack-of-open-elements:html-namespace-2-5 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a><li><code id=the-stack-of-open-elements:the-template-element-3><a href=scripting.html#the-template-element>template</a></code> in the <a id=the-stack-of-open-elements:html-namespace-2-6 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a></ul>
|
||
|
||
<p>The <a href=#stack-of-open-elements id=the-stack-of-open-elements:stack-of-open-elements-12>stack of open elements</a> is said to <dfn id=has-an-element-in-select-scope>have a particular element in select scope</dfn> when it <a href=#has-an-element-in-the-specific-scope id=the-stack-of-open-elements:has-an-element-in-the-specific-scope-5>has that element in the specific scope</a> consisting of all element types
|
||
<em>except</em> the following:</p>
|
||
|
||
<ul class=brief><li><code id=the-stack-of-open-elements:the-optgroup-element><a href=form-elements.html#the-optgroup-element>optgroup</a></code> in the <a id=the-stack-of-open-elements:html-namespace-2-7 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a><li><code id=the-stack-of-open-elements:the-option-element-2><a href=form-elements.html#the-option-element>option</a></code> in the <a id=the-stack-of-open-elements:html-namespace-2-8 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a></ul>
|
||
|
||
<p>Nothing happens if at any time any of the elements in the <a href=#stack-of-open-elements id=the-stack-of-open-elements:stack-of-open-elements-13>stack of open elements</a>
|
||
are moved to a new location in, or removed from, the <code id=the-stack-of-open-elements:document><a href=dom.html#document>Document</a></code> tree. In particular,
|
||
the stack is not changed in this situation. This can cause, amongst other strange effects, content
|
||
to be appended to nodes that are no longer in the DOM.</p>
|
||
|
||
<p class=note>In some cases (namely, when <a href=#adoptionAgency>closing misnested formatting
|
||
elements</a>), the stack is manipulated in a random-access fashion.</p>
|
||
|
||
|
||
<h5 id=the-list-of-active-formatting-elements><span class=secno>12.2.4.3</span> The list of active formatting elements<a href=#the-list-of-active-formatting-elements class=self-link></a></h5>
|
||
|
||
<p>Initially, the <dfn id=list-of-active-formatting-elements>list of active formatting elements</dfn> is empty. It is used to handle
|
||
mis-nested <a href=#formatting id=the-list-of-active-formatting-elements:formatting>formatting element tags</a>.</p>
|
||
|
||
<p>The list contains elements in the <a href=#formatting id=the-list-of-active-formatting-elements:formatting-2>formatting</a> category, and <a href=#concept-parser-marker id=the-list-of-active-formatting-elements:concept-parser-marker>markers</a>. The <dfn id=concept-parser-marker>markers</dfn> are inserted when entering <code id=the-list-of-active-formatting-elements:applet><a href=obsolete.html#applet>applet</a></code>,
|
||
<code id=the-list-of-active-formatting-elements:the-object-element><a href=iframe-embed-object.html#the-object-element>object</a></code>, <code id=the-list-of-active-formatting-elements:the-marquee-element><a href=obsolete.html#the-marquee-element>marquee</a></code>, <code id=the-list-of-active-formatting-elements:the-template-element><a href=scripting.html#the-template-element>template</a></code>, <code id=the-list-of-active-formatting-elements:the-td-element><a href=tables.html#the-td-element>td</a></code>,
|
||
<code id=the-list-of-active-formatting-elements:the-th-element><a href=tables.html#the-th-element>th</a></code>, and <code id=the-list-of-active-formatting-elements:the-caption-element><a href=tables.html#the-caption-element>caption</a></code> elements, and are used to prevent formatting from
|
||
"leaking" <em>into</em> <code id=the-list-of-active-formatting-elements:applet-2><a href=obsolete.html#applet>applet</a></code>, <code id=the-list-of-active-formatting-elements:the-object-element-2><a href=iframe-embed-object.html#the-object-element>object</a></code>, <code id=the-list-of-active-formatting-elements:the-marquee-element-2><a href=obsolete.html#the-marquee-element>marquee</a></code>,
|
||
<code id=the-list-of-active-formatting-elements:the-template-element-2><a href=scripting.html#the-template-element>template</a></code>, <code id=the-list-of-active-formatting-elements:the-td-element-2><a href=tables.html#the-td-element>td</a></code>, <code id=the-list-of-active-formatting-elements:the-th-element-2><a href=tables.html#the-th-element>th</a></code>, and <code id=the-list-of-active-formatting-elements:the-caption-element-2><a href=tables.html#the-caption-element>caption</a></code> elements.</p>
|
||
|
||
<p>In addition, each element in the <a href=#list-of-active-formatting-elements id=the-list-of-active-formatting-elements:list-of-active-formatting-elements>list of active formatting elements</a> is associated
|
||
with the token for which it was created, so that further elements can be created for that token if
|
||
necessary.</p>
|
||
|
||
<p>When the steps below require the UA to <dfn id=push-onto-the-list-of-active-formatting-elements>push onto the list of active formatting
|
||
elements</dfn> an element <var>element</var>, the UA must perform the following
|
||
steps:</p>
|
||
|
||
<ol id=noah><li><p>If there are already three elements in the <a href=#list-of-active-formatting-elements id=the-list-of-active-formatting-elements:list-of-active-formatting-elements-2>list of active formatting elements</a>
|
||
after the last <a href=#concept-parser-marker id=the-list-of-active-formatting-elements:concept-parser-marker-2>marker</a>, if any, or anywhere in the
|
||
list if there are no <a href=#concept-parser-marker id=the-list-of-active-formatting-elements:concept-parser-marker-3>markers</a>, that have the same tag
|
||
name, namespace, and attributes as <var>element</var>, then remove the earliest such
|
||
element from the <a href=#list-of-active-formatting-elements id=the-list-of-active-formatting-elements:list-of-active-formatting-elements-3>list of active formatting elements</a>. For these purposes, the
|
||
attributes must be compared as they were when the elements were created by the parser; two
|
||
elements have the same attributes if all their parsed attributes can be paired such that the two
|
||
attributes in each pair have identical names, namespaces, and values (the order of the attributes
|
||
does not matter).</p>
|
||
|
||
<p class=note>This is the Noah's Ark clause. But with three per family instead of two.<li><p>Add <var>element</var> to the <a href=#list-of-active-formatting-elements id=the-list-of-active-formatting-elements:list-of-active-formatting-elements-4>list of active formatting
|
||
elements</a>.</ol>
|
||
|
||
<p>When the steps below require the UA to <dfn id=reconstruct-the-active-formatting-elements>reconstruct the active formatting elements</dfn>,
|
||
the UA must perform the following steps:</p>
|
||
|
||
<ol><li><p>If there are no entries in the <a href=#list-of-active-formatting-elements id=the-list-of-active-formatting-elements:list-of-active-formatting-elements-5>list of active formatting elements</a>, then there
|
||
is nothing to reconstruct; stop this algorithm.<li><p>If the last (most recently added) entry in the <a href=#list-of-active-formatting-elements id=the-list-of-active-formatting-elements:list-of-active-formatting-elements-6>list of active formatting
|
||
elements</a> is a <a href=#concept-parser-marker id=the-list-of-active-formatting-elements:concept-parser-marker-4>marker</a>, or if it is an element
|
||
that is in the <a href=#stack-of-open-elements id=the-list-of-active-formatting-elements:stack-of-open-elements>stack of open elements</a>, then there is nothing to reconstruct; stop
|
||
this algorithm.<li><p>Let <var>entry</var> be the last (most recently added) element in the <a href=#list-of-active-formatting-elements id=the-list-of-active-formatting-elements:list-of-active-formatting-elements-7>list
|
||
of active formatting elements</a>.<li><p><i>Rewind</i>: If there are no entries before <var>entry</var> in the <a href=#list-of-active-formatting-elements id=the-list-of-active-formatting-elements:list-of-active-formatting-elements-8>list
|
||
of active formatting elements</a>, then jump to the step labeled <i>create</i>.<li><p>Let <var>entry</var> be the entry one earlier than <var>entry</var> in
|
||
the <a href=#list-of-active-formatting-elements id=the-list-of-active-formatting-elements:list-of-active-formatting-elements-9>list of active formatting elements</a>.<li><p>If <var>entry</var> is neither a <a href=#concept-parser-marker id=the-list-of-active-formatting-elements:concept-parser-marker-5>marker</a> nor an element that is also in the <a href=#stack-of-open-elements id=the-list-of-active-formatting-elements:stack-of-open-elements-2>stack of
|
||
open elements</a>, go to the step labeled <i>rewind</i>.<li><p><i>Advance</i>: Let <var>entry</var> be the element one later than <var>entry</var> in the <a href=#list-of-active-formatting-elements id=the-list-of-active-formatting-elements:list-of-active-formatting-elements-10>list of active formatting elements</a>.<li><p><i>Create</i>: <a href=#insert-an-html-element id=the-list-of-active-formatting-elements:insert-an-html-element>Insert an HTML element</a> for the token for which the element
|
||
<var>entry</var> was created, to obtain <var>new element</var>.<li><p>Replace the entry for <var>entry</var> in the list with an entry for <var>new element</var>.<li><p>If the entry for <var>new element</var> in the <a href=#list-of-active-formatting-elements id=the-list-of-active-formatting-elements:list-of-active-formatting-elements-11>list of active formatting
|
||
elements</a> is not the last entry in the list, return to the step labeled
|
||
<i>advance</i>.</ol>
|
||
|
||
<p>This has the effect of reopening all the formatting elements that were opened in the current
|
||
body, cell, or caption (whichever is youngest) that haven't been explicitly closed.</p>
|
||
|
||
<p class=note>The way this specification is written, the <a href=#list-of-active-formatting-elements id=the-list-of-active-formatting-elements:list-of-active-formatting-elements-12>list of active formatting
|
||
elements</a> always consists of elements in chronological order with the least recently added
|
||
element first and the most recently added element last (except for while steps 7 to 10 of the
|
||
above algorithm are being executed, of course).</p>
|
||
|
||
<p>When the steps below require the UA to <dfn id=clear-the-list-of-active-formatting-elements-up-to-the-last-marker>clear the list of active formatting elements up to
|
||
the last marker</dfn>, the UA must perform the following steps:</p>
|
||
|
||
<ol><li><p>Let <var>entry</var> be the last (most recently added) entry in the <a href=#list-of-active-formatting-elements id=the-list-of-active-formatting-elements:list-of-active-formatting-elements-13>list of
|
||
active formatting elements</a>.<li><p>Remove <var>entry</var> from the <a href=#list-of-active-formatting-elements id=the-list-of-active-formatting-elements:list-of-active-formatting-elements-14>list of active formatting
|
||
elements</a>.<li><p>If <var>entry</var> was a <a href=#concept-parser-marker id=the-list-of-active-formatting-elements:concept-parser-marker-6>marker</a>,
|
||
then stop the algorithm at this point. The list has been cleared up to the last <a href=#concept-parser-marker id=the-list-of-active-formatting-elements:concept-parser-marker-7>marker</a>.<li><p>Go to step 1.</ol>
|
||
|
||
|
||
<h5 id=the-element-pointers><span class=secno>12.2.4.4</span> The element pointers<a href=#the-element-pointers class=self-link></a></h5>
|
||
|
||
<p>Initially, the <dfn id=head-element-pointer><code>head</code> element pointer</dfn> and the <dfn id=form-element-pointer><code>form</code> element pointer</dfn> are both null.</p>
|
||
|
||
<p>Once a <code id=the-element-pointers:the-head-element><a href=semantics.html#the-head-element>head</a></code> element has been parsed (whether implicitly or explicitly) the
|
||
<a href=#head-element-pointer id=the-element-pointers:head-element-pointer><code>head</code> element pointer</a> gets set to point to this node.</p>
|
||
|
||
<p>The <a href=#form-element-pointer id=the-element-pointers:form-element-pointer><code>form</code> element pointer</a> points to the last
|
||
<code id=the-element-pointers:the-form-element><a href=forms.html#the-form-element>form</a></code> element that was opened and whose end tag has not yet been seen. It is used to
|
||
make form controls associate with forms in the face of dramatically bad markup, for historical
|
||
reasons. It is ignored inside <code id=the-element-pointers:the-template-element><a href=scripting.html#the-template-element>template</a></code> elements.</p>
|
||
|
||
|
||
<h5 id=other-parsing-state-flags><span class=secno>12.2.4.5</span> Other parsing state flags<a href=#other-parsing-state-flags class=self-link></a></h5>
|
||
|
||
<p>The <dfn id=scripting-flag>scripting flag</dfn> is set to "enabled" if <a href=webappapis.html#concept-n-script id=other-parsing-state-flags:concept-n-script>scripting
|
||
was enabled</a> for the <code id=other-parsing-state-flags:document><a href=dom.html#document>Document</a></code> with which the parser is associated when the
|
||
parser was created, and "disabled" otherwise.</p>
|
||
|
||
<p class=note>The <a href=#scripting-flag id=other-parsing-state-flags:scripting-flag>scripting flag</a> can be enabled even when the parser was originally
|
||
created for the <a href=#html-fragment-parsing-algorithm id=other-parsing-state-flags:html-fragment-parsing-algorithm>HTML fragment parsing algorithm</a>, even though <code id=other-parsing-state-flags:the-script-element><a href=scripting.html#the-script-element>script</a></code>
|
||
elements don't execute in that case.</p>
|
||
|
||
<p>The <dfn id=frameset-ok-flag>frameset-ok flag</dfn> is set to "ok" when the parser is created. It is set to "not
|
||
ok" after certain tokens are seen.</p>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h4 id=tokenization><span class=secno>12.2.5</span> <dfn>Tokenization</dfn><a href=#tokenization class=self-link></a></h4>
|
||
|
||
<p>Implementations must act as if they used the following state machine to tokenize HTML. The
|
||
state machine must start in the <a href=#data-state id=tokenization:data-state>data state</a>. Most states consume a single character,
|
||
which may have various side-effects, and either switches the state machine to a new state to
|
||
<a href=#reconsume id=tokenization:reconsume>reconsume</a> the <a href=#current-input-character id=tokenization:current-input-character>current input character</a>, or switches it to a new state to
|
||
consume the <a href=#next-input-character id=tokenization:next-input-character>next character</a>, or stays in the same state
|
||
to consume the next character. Some states have more complicated behavior and can consume several
|
||
characters before switching to another state. In some cases, the tokenizer state is also changed
|
||
by the tree construction stage.</p>
|
||
|
||
<p>When a state says to <dfn id=reconsume>reconsume</dfn> a matched character in a specified state, that means
|
||
to switch to that state, but when it attempts to consume the <a href=#next-input-character id=tokenization:next-input-character-2>next input character</a>,
|
||
provide it with the <a href=#current-input-character id=tokenization:current-input-character-2>current input character</a> instead.</p>
|
||
|
||
<p>The exact behavior of certain states depends on the <a href=#insertion-mode id=tokenization:insertion-mode>insertion mode</a> and the
|
||
<a href=#stack-of-open-elements id=tokenization:stack-of-open-elements>stack of open elements</a>. Certain states also use a <dfn id=temporary-buffer><var>temporary buffer</var></dfn> to track progress, and the <a href=#character-reference-state id=tokenization:character-reference-state>character reference
|
||
state</a> uses a <dfn id=return-state><var>return state</var></dfn> to return to the
|
||
state it was invoked from.</p>
|
||
|
||
<p>The output of the tokenization step is a series of zero or more of the following tokens:
|
||
DOCTYPE, start tag, end tag, comment, character, end-of-file. DOCTYPE tokens have a name, a public
|
||
identifier, a system identifier, and a <dfn id=force-quirks-flag><i>force-quirks flag</i></dfn>. When a DOCTYPE token
|
||
is created, its name, public identifier, and system identifier must be marked as missing (which is
|
||
a distinct state from the empty string), and the <i id=tokenization:force-quirks-flag><a href=#force-quirks-flag>force-quirks flag</a></i> must be set to
|
||
<i>off</i> (its other state is <i>on</i>). Start and end tag tokens have a tag name, a <dfn id=self-closing-flag>self-closing flag</dfn>, and a list of attributes, each of which has a
|
||
name and a value. When a start or end tag token is created, its <i id=tokenization:self-closing-flag><a href=#self-closing-flag>self-closing flag</a></i> must be unset (its other state is that it be set), and its attributes
|
||
list must be empty. Comment and character tokens have data.</p>
|
||
|
||
<p>When a token is emitted, it must immediately be handled by the <a href=#tree-construction id=tokenization:tree-construction>tree construction</a>
|
||
stage. The tree construction stage can affect the state of the tokenization stage, and can insert
|
||
additional characters into the stream. (For example, the <code id=tokenization:the-script-element><a href=scripting.html#the-script-element>script</a></code> element can result in
|
||
scripts executing and using the <a id=tokenization:dynamic-markup-insertion href=dynamic-markup-insertion.html#dynamic-markup-insertion>dynamic markup insertion</a> APIs to insert characters
|
||
into the stream being tokenized.)</p>
|
||
|
||
<p class=note>Creating a token and emitting it are distinct actions. It is possible for a token
|
||
to be created but implicitly abandoned (never emitted), e.g. if the file ends unexpectedly while
|
||
processing the characters that are being parsed into a start tag token.</p>
|
||
|
||
<p>When a start tag token is emitted with its <i id=tokenization:self-closing-flag-2><a href=#self-closing-flag>self-closing flag</a></i> set, if the flag is not
|
||
<dfn id=acknowledge-self-closing-flag>acknowledged</dfn> when it is processed by the tree
|
||
construction stage, that is a <a href=#parse-error-non-void-html-element-start-tag-with-trailing-solidus id=tokenization:parse-error-non-void-html-element-start-tag-with-trailing-solidus>non-void-html-element-start-tag-with-trailing-solidus</a>
|
||
<a href=#parse-errors id=tokenization:parse-errors>parse error</a>.</p>
|
||
|
||
<p>When an end tag token is emitted with attributes, that is an <a href=#parse-error-end-tag-with-attributes id=tokenization:parse-error-end-tag-with-attributes>end-tag-with-attributes</a> <a href=#parse-errors id=tokenization:parse-errors-2>parse
|
||
error</a>.</p>
|
||
|
||
<p>When an end tag token is emitted with its <i id=tokenization:self-closing-flag-3><a href=#self-closing-flag>self-closing flag</a></i>
|
||
set, that is an <a href=#parse-error-end-tag-with-trailing-solidus id=tokenization:parse-error-end-tag-with-trailing-solidus>end-tag-with-trailing-solidus</a>
|
||
<a href=#parse-errors id=tokenization:parse-errors-3>parse error</a>.</p>
|
||
|
||
<p>An <dfn id=appropriate-end-tag-token>appropriate end tag token</dfn> is an end tag token whose tag name matches the tag name
|
||
of the last start tag to have been emitted from this tokenizer, if any. If no start tag has been
|
||
emitted from this tokenizer, then no end tag token is appropriate.</p>
|
||
|
||
<p>A <a href=syntax.html#syntax-charref id=tokenization:syntax-charref>character reference</a> is said to be <dfn id=charref-in-attribute>consumed as part of an attribute</dfn> if the <var id=tokenization:return-state><a href=#return-state>return state</a></var> is either <a href=#attribute-value-(double-quoted)-state id=tokenization:attribute-value-(double-quoted)-state>attribute value (double-quoted) state</a>,
|
||
<a href=#attribute-value-(single-quoted)-state id=tokenization:attribute-value-(single-quoted)-state>attribute value (single-quoted) state</a> or <a href=#attribute-value-(unquoted)-state id=tokenization:attribute-value-(unquoted)-state>attribute value (unquoted)
|
||
state</a>.</p>
|
||
|
||
<p>When a state says to <dfn id=flush-code-points-consumed-as-a-character-reference>flush code points consumed as a character reference</dfn>, it means
|
||
that for each <a id=tokenization:code-point href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code point</a> in the <var id=tokenization:temporary-buffer><a href=#temporary-buffer>temporary
|
||
buffer</a></var> (in the order they were added to the buffer) user agent must append the code point
|
||
from the buffer to the current attribute's value if the character reference was <a href=#charref-in-attribute id=tokenization:charref-in-attribute>consumed as part of an attribute</a>, or emit the code point as a
|
||
character token otherwise.</p>
|
||
|
||
<p id=check-parser-pause-flag>Before each step of the tokenizer, the user agent must first check
|
||
the <a href=#parser-pause-flag id=tokenization:parser-pause-flag>parser pause flag</a>. If it is true, then the tokenizer must abort the processing of
|
||
any nested invocations of the tokenizer, yielding control back to the caller.</p>
|
||
|
||
<p>The tokenizer state machine consists of the states defined in the following subsections.</p>
|
||
|
||
|
||
|
||
|
||
|
||
<h5 id=data-state><span class=secno>12.2.5.1</span> <dfn>Data state</dfn><a href=#data-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=data-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0026 AMPERSAND (&)<dd>Set the <var id=data-state:return-state><a href=#return-state>return state</a></var> to the <a href=#data-state id=data-state:data-state>data state</a>.
|
||
Switch to the <a href=#character-reference-state id=data-state:character-reference-state>character reference state</a>.<dt>U+003C LESS-THAN SIGN (<)<dd>Switch to the <a href=#tag-open-state id=data-state:tag-open-state>tag open state</a>.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=data-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=data-state:parse-errors>parse
|
||
error</a>. Emit the <a href=#current-input-character id=data-state:current-input-character>current input character</a> as a character token.<dt>EOF<dd>Emit an end-of-file token.<dt>Anything else<dd>Emit the <a href=#current-input-character id=data-state:current-input-character-2>current input character</a> as a character token.</dl>
|
||
|
||
|
||
<h5 id=rcdata-state><span class=secno>12.2.5.2</span> <dfn>RCDATA state</dfn><a href=#rcdata-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=rcdata-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0026 AMPERSAND (&)<dd>Set the <var id=rcdata-state:return-state><a href=#return-state>return state</a></var> to the <a href=#rcdata-state id=rcdata-state:rcdata-state>RCDATA state</a>.
|
||
Switch to the <a href=#character-reference-state id=rcdata-state:character-reference-state>character reference state</a>.<dt>U+003C LESS-THAN SIGN (<)<dd>Switch to the <a href=#rcdata-less-than-sign-state id=rcdata-state:rcdata-less-than-sign-state>RCDATA less-than sign state</a>.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=rcdata-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=rcdata-state:parse-errors>parse
|
||
error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.<dt>EOF<dd>Emit an end-of-file token.<dt>Anything else<dd>Emit the <a href=#current-input-character id=rcdata-state:current-input-character>current input character</a> as a character token.</dl>
|
||
|
||
|
||
<h5 id=rawtext-state><span class=secno>12.2.5.3</span> <dfn>RAWTEXT state</dfn><a href=#rawtext-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=rawtext-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+003C LESS-THAN SIGN (<)<dd>Switch to the <a href=#rawtext-less-than-sign-state id=rawtext-state:rawtext-less-than-sign-state>RAWTEXT less-than sign state</a>.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=rawtext-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=rawtext-state:parse-errors>parse
|
||
error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.<dt>EOF<dd>Emit an end-of-file token.<dt>Anything else<dd>Emit the <a href=#current-input-character id=rawtext-state:current-input-character>current input character</a> as a character token.</dl>
|
||
|
||
|
||
<h5 id=script-data-state><span class=secno>12.2.5.4</span> <dfn>Script data state</dfn><a href=#script-data-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+003C LESS-THAN SIGN (<)<dd>Switch to the <a href=#script-data-less-than-sign-state id=script-data-state:script-data-less-than-sign-state>script data less-than sign state</a>.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=script-data-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=script-data-state:parse-errors>parse
|
||
error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.<dt>EOF<dd>Emit an end-of-file token.<dt>Anything else<dd>Emit the <a href=#current-input-character id=script-data-state:current-input-character>current input character</a> as a character token.</dl>
|
||
|
||
|
||
<h5 id=plaintext-state><span class=secno>12.2.5.5</span> <dfn>PLAINTEXT state</dfn><a href=#plaintext-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=plaintext-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=plaintext-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=plaintext-state:parse-errors>parse
|
||
error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.<dt>EOF<dd>Emit an end-of-file token.<dt>Anything else<dd>Emit the <a href=#current-input-character id=plaintext-state:current-input-character>current input character</a> as a character token.</dl>
|
||
|
||
|
||
<h5 id=tag-open-state><span class=secno>12.2.5.6</span> <dfn>Tag open state</dfn><a href=#tag-open-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=tag-open-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0021 EXCLAMATION MARK (!)<dd>Switch to the <a href=#markup-declaration-open-state id=tag-open-state:markup-declaration-open-state>markup declaration open state</a>.<dt>U+002F SOLIDUS (/)<dd>Switch to the <a href=#end-tag-open-state id=tag-open-state:end-tag-open-state>end tag open state</a>.<dt><a id=tag-open-state:ascii-letters href=https://infra.spec.whatwg.org/#ascii-alpha data-x-internal=ascii-letters>ASCII alpha</a><dd>Create a new start tag token, set its tag name to the empty string. <a href=#reconsume id=tag-open-state:reconsume>Reconsume</a> in
|
||
the <a href=#tag-name-state id=tag-open-state:tag-name-state>tag name state</a>.
|
||
|
||
<dt>U+003F QUESTION MARK (?)<dd>This is an <a href=#parse-error-unexpected-question-mark-instead-of-tag-name id=tag-open-state:parse-error-unexpected-question-mark-instead-of-tag-name>unexpected-question-mark-instead-of-tag-name</a>
|
||
<a href=#parse-errors id=tag-open-state:parse-errors>parse error</a>. Create a comment token whose data is the empty string.
|
||
<a href=#reconsume id=tag-open-state:reconsume-2>Reconsume</a> in the <a href=#bogus-comment-state id=tag-open-state:bogus-comment-state>bogus comment state</a>.<dt>EOF<dd>This is an <a href=#parse-error-eof-before-tag-name id=tag-open-state:parse-error-eof-before-tag-name>eof-before-tag-name</a>
|
||
<a href=#parse-errors id=tag-open-state:parse-errors-2>parse error</a>. Emit a U+003C LESS-THAN SIGN character token and an end-of-file
|
||
token.<dt>Anything else<dd>This is an <a href=#parse-error-invalid-first-character-of-tag-name id=tag-open-state:parse-error-invalid-first-character-of-tag-name>invalid-first-character-of-tag-name</a>
|
||
<a href=#parse-errors id=tag-open-state:parse-errors-3>parse error</a>. Emit a U+003C LESS-THAN SIGN character token. <a href=#reconsume id=tag-open-state:reconsume-3>Reconsume</a> in
|
||
the <a href=#data-state id=tag-open-state:data-state>data state</a>.</dl>
|
||
|
||
<h5 id=end-tag-open-state><span class=secno>12.2.5.7</span> <dfn>End tag open state</dfn><a href=#end-tag-open-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=end-tag-open-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt><a id=end-tag-open-state:ascii-letters href=https://infra.spec.whatwg.org/#ascii-alpha data-x-internal=ascii-letters>ASCII alpha</a><dd>Create a new end tag token, set its tag name to the empty string. <a href=#reconsume id=end-tag-open-state:reconsume>Reconsume</a> in
|
||
the <a href=#tag-name-state id=end-tag-open-state:tag-name-state>tag name state</a>.
|
||
|
||
<dt>U+003E GREATER-THAN SIGN (>)<dd>This is a <a href=#parse-error-missing-end-tag-name id=end-tag-open-state:parse-error-missing-end-tag-name>missing-end-tag-name</a>
|
||
<a href=#parse-errors id=end-tag-open-state:parse-errors>parse error</a>. Switch to the <a href=#data-state id=end-tag-open-state:data-state>data state</a>.<dt>EOF<dd>This is an <a href=#parse-error-eof-before-tag-name id=end-tag-open-state:parse-error-eof-before-tag-name>eof-before-tag-name</a>
|
||
<a href=#parse-errors id=end-tag-open-state:parse-errors-2>parse error</a>. Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
|
||
character token and an end-of-file token.
|
||
|
||
<dt>Anything else<dd>This is an <a href=#parse-error-invalid-first-character-of-tag-name id=end-tag-open-state:parse-error-invalid-first-character-of-tag-name>invalid-first-character-of-tag-name</a>
|
||
<a href=#parse-errors id=end-tag-open-state:parse-errors-3>parse error</a>. Create a comment token whose data is the empty string.
|
||
<a href=#reconsume id=end-tag-open-state:reconsume-2>Reconsume</a> in the <a href=#bogus-comment-state id=end-tag-open-state:bogus-comment-state>bogus comment state</a>.</dl>
|
||
|
||
|
||
<h5 id=tag-name-state><span class=secno>12.2.5.8</span> <dfn>Tag name state</dfn><a href=#tag-name-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=tag-name-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Switch to the <a href=#before-attribute-name-state id=tag-name-state:before-attribute-name-state>before attribute name state</a>.<dt>U+002F SOLIDUS (/)<dd>Switch to the <a href=#self-closing-start-tag-state id=tag-name-state:self-closing-start-tag-state>self-closing start tag state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=tag-name-state:data-state>data state</a>. Emit the current tag token.<dt><a id=tag-name-state:uppercase-ascii-letters href=https://infra.spec.whatwg.org/#ascii-upper-alpha data-x-internal=uppercase-ascii-letters>ASCII upper alpha</a><dd>Append the lowercase version of the <a href=#current-input-character id=tag-name-state:current-input-character>current input character</a> (add 0x0020 to the
|
||
character's code point) to the current tag token's tag name.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=tag-name-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=tag-name-state:parse-errors>parse
|
||
error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current tag token's tag
|
||
name.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-tag id=tag-name-state:parse-error-eof-in-tag>eof-in-tag</a> <a href=#parse-errors id=tag-name-state:parse-errors-2>parse error</a>.
|
||
Emit an end-of-file token.<dt>Anything else<dd>Append the <a href=#current-input-character id=tag-name-state:current-input-character-2>current input character</a> to the current tag token's tag name.</dl>
|
||
|
||
|
||
<h5 id=rcdata-less-than-sign-state><span class=secno>12.2.5.9</span> <dfn>RCDATA less-than sign state</dfn><a href=#rcdata-less-than-sign-state class=self-link></a></h5>
|
||
|
||
|
||
<p>Consume the <a href=#next-input-character id=rcdata-less-than-sign-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002F SOLIDUS (/)<dd>Set the <var id=rcdata-less-than-sign-state:temporary-buffer><a href=#temporary-buffer>temporary buffer</a></var> to the empty string. Switch to
|
||
the <a href=#rcdata-end-tag-open-state id=rcdata-less-than-sign-state:rcdata-end-tag-open-state>RCDATA end tag open state</a>.<dt>Anything else<dd>Emit a U+003C LESS-THAN SIGN character token. <a href=#reconsume id=rcdata-less-than-sign-state:reconsume>Reconsume</a> in the <a href=#rcdata-state id=rcdata-less-than-sign-state:rcdata-state>RCDATA
|
||
state</a>.</dl>
|
||
|
||
|
||
<h5 id=rcdata-end-tag-open-state><span class=secno>12.2.5.10</span> <dfn>RCDATA end tag open state</dfn><a href=#rcdata-end-tag-open-state class=self-link></a></h5>
|
||
|
||
|
||
<p>Consume the <a href=#next-input-character id=rcdata-end-tag-open-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt><a id=rcdata-end-tag-open-state:ascii-letters href=https://infra.spec.whatwg.org/#ascii-alpha data-x-internal=ascii-letters>ASCII alpha</a><dd>Create a new end tag token, set its tag name to the empty string. <a href=#reconsume id=rcdata-end-tag-open-state:reconsume>Reconsume</a> in
|
||
the <a href=#rcdata-end-tag-name-state id=rcdata-end-tag-open-state:rcdata-end-tag-name-state>RCDATA end tag name state</a>.
|
||
|
||
<dt>Anything else<dd>Emit a U+003C LESS-THAN SIGN character token and a U+002F SOLIDUS character token.
|
||
<a href=#reconsume id=rcdata-end-tag-open-state:reconsume-2>Reconsume</a> in the <a href=#rcdata-state id=rcdata-end-tag-open-state:rcdata-state>RCDATA state</a>.</dl>
|
||
|
||
|
||
<h5 id=rcdata-end-tag-name-state><span class=secno>12.2.5.11</span> <dfn>RCDATA end tag name state</dfn><a href=#rcdata-end-tag-name-state class=self-link></a></h5>
|
||
|
||
|
||
<p>Consume the <a href=#next-input-character id=rcdata-end-tag-name-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>If the current end tag token is an <a href=#appropriate-end-tag-token id=rcdata-end-tag-name-state:appropriate-end-tag-token>appropriate end tag token</a>, then switch to the
|
||
<a href=#before-attribute-name-state id=rcdata-end-tag-name-state:before-attribute-name-state>before attribute name state</a>. Otherwise, treat it as per the "anything else" entry
|
||
below.<dt>U+002F SOLIDUS (/)<dd>If the current end tag token is an <a href=#appropriate-end-tag-token id=rcdata-end-tag-name-state:appropriate-end-tag-token-2>appropriate end tag token</a>, then switch to the
|
||
<a href=#self-closing-start-tag-state id=rcdata-end-tag-name-state:self-closing-start-tag-state>self-closing start tag state</a>. Otherwise, treat it as per the "anything else" entry
|
||
below.<dt>U+003E GREATER-THAN SIGN (>)<dd>If the current end tag token is an <a href=#appropriate-end-tag-token id=rcdata-end-tag-name-state:appropriate-end-tag-token-3>appropriate end tag token</a>, then switch to the
|
||
<a href=#data-state id=rcdata-end-tag-name-state:data-state>data state</a> and emit the current tag token. Otherwise, treat it as per the "anything
|
||
else" entry below.<dt><a id=rcdata-end-tag-name-state:uppercase-ascii-letters href=https://infra.spec.whatwg.org/#ascii-upper-alpha data-x-internal=uppercase-ascii-letters>ASCII upper alpha</a><dd>Append the lowercase version of the <a href=#current-input-character id=rcdata-end-tag-name-state:current-input-character>current input character</a> (add 0x0020 to the
|
||
character's code point) to the current tag token's tag name. Append the <a href=#current-input-character id=rcdata-end-tag-name-state:current-input-character-2>current input
|
||
character</a> to the <var id=rcdata-end-tag-name-state:temporary-buffer><a href=#temporary-buffer>temporary buffer</a></var>.<dt><a id=rcdata-end-tag-name-state:lowercase-ascii-letters href=https://infra.spec.whatwg.org/#ascii-lower-alpha data-x-internal=lowercase-ascii-letters>ASCII lower alpha</a><dd>Append the <a href=#current-input-character id=rcdata-end-tag-name-state:current-input-character-3>current input character</a> to the current tag token's tag name. Append
|
||
the <a href=#current-input-character id=rcdata-end-tag-name-state:current-input-character-4>current input character</a> to the <var id=rcdata-end-tag-name-state:temporary-buffer-2><a href=#temporary-buffer>temporary
|
||
buffer</a></var>.<dt>Anything else<dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS character token, and a
|
||
character token for each of the characters in the <var id=rcdata-end-tag-name-state:temporary-buffer-3><a href=#temporary-buffer>temporary
|
||
buffer</a></var> (in the order they were added to the buffer). <a href=#reconsume id=rcdata-end-tag-name-state:reconsume>Reconsume</a> in the
|
||
<a href=#rcdata-state id=rcdata-end-tag-name-state:rcdata-state>RCDATA state</a>.</dl>
|
||
|
||
|
||
<h5 id=rawtext-less-than-sign-state><span class=secno>12.2.5.12</span> <dfn>RAWTEXT less-than sign state</dfn><a href=#rawtext-less-than-sign-state class=self-link></a></h5>
|
||
|
||
|
||
<p>Consume the <a href=#next-input-character id=rawtext-less-than-sign-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002F SOLIDUS (/)<dd>Set the <var id=rawtext-less-than-sign-state:temporary-buffer><a href=#temporary-buffer>temporary buffer</a></var> to the empty string. Switch to
|
||
the <a href=#rawtext-end-tag-open-state id=rawtext-less-than-sign-state:rawtext-end-tag-open-state>RAWTEXT end tag open state</a>.<dt>Anything else<dd>Emit a U+003C LESS-THAN SIGN character token. <a href=#reconsume id=rawtext-less-than-sign-state:reconsume>Reconsume</a> in the <a href=#rawtext-state id=rawtext-less-than-sign-state:rawtext-state>RAWTEXT
|
||
state</a>.</dl>
|
||
|
||
|
||
<h5 id=rawtext-end-tag-open-state><span class=secno>12.2.5.13</span> <dfn>RAWTEXT end tag open state</dfn><a href=#rawtext-end-tag-open-state class=self-link></a></h5>
|
||
|
||
|
||
<p>Consume the <a href=#next-input-character id=rawtext-end-tag-open-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt><a id=rawtext-end-tag-open-state:ascii-letters href=https://infra.spec.whatwg.org/#ascii-alpha data-x-internal=ascii-letters>ASCII alpha</a><dd>Create a new end tag token, set its tag name to the empty string. <a href=#reconsume id=rawtext-end-tag-open-state:reconsume>Reconsume</a> in
|
||
the <a href=#rawtext-end-tag-name-state id=rawtext-end-tag-open-state:rawtext-end-tag-name-state>RAWTEXT end tag name state</a>.
|
||
|
||
<dt>Anything else<dd>Emit a U+003C LESS-THAN SIGN character token and a U+002F SOLIDUS character token.
|
||
<a href=#reconsume id=rawtext-end-tag-open-state:reconsume-2>Reconsume</a> in the <a href=#rawtext-state id=rawtext-end-tag-open-state:rawtext-state>RAWTEXT state</a>.</dl>
|
||
|
||
|
||
<h5 id=rawtext-end-tag-name-state><span class=secno>12.2.5.14</span> <dfn>RAWTEXT end tag name state</dfn><a href=#rawtext-end-tag-name-state class=self-link></a></h5>
|
||
|
||
|
||
<p>Consume the <a href=#next-input-character id=rawtext-end-tag-name-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>If the current end tag token is an <a href=#appropriate-end-tag-token id=rawtext-end-tag-name-state:appropriate-end-tag-token>appropriate end tag token</a>, then switch to the
|
||
<a href=#before-attribute-name-state id=rawtext-end-tag-name-state:before-attribute-name-state>before attribute name state</a>. Otherwise, treat it as per the "anything else" entry
|
||
below.<dt>U+002F SOLIDUS (/)<dd>If the current end tag token is an <a href=#appropriate-end-tag-token id=rawtext-end-tag-name-state:appropriate-end-tag-token-2>appropriate end tag token</a>, then switch to the
|
||
<a href=#self-closing-start-tag-state id=rawtext-end-tag-name-state:self-closing-start-tag-state>self-closing start tag state</a>. Otherwise, treat it as per the "anything else" entry
|
||
below.<dt>U+003E GREATER-THAN SIGN (>)<dd>If the current end tag token is an <a href=#appropriate-end-tag-token id=rawtext-end-tag-name-state:appropriate-end-tag-token-3>appropriate end tag token</a>, then switch to the
|
||
<a href=#data-state id=rawtext-end-tag-name-state:data-state>data state</a> and emit the current tag token. Otherwise, treat it as per the "anything
|
||
else" entry below.<dt><a id=rawtext-end-tag-name-state:uppercase-ascii-letters href=https://infra.spec.whatwg.org/#ascii-upper-alpha data-x-internal=uppercase-ascii-letters>ASCII upper alpha</a><dd>Append the lowercase version of the <a href=#current-input-character id=rawtext-end-tag-name-state:current-input-character>current input character</a> (add 0x0020 to the
|
||
character's code point) to the current tag token's tag name. Append the <a href=#current-input-character id=rawtext-end-tag-name-state:current-input-character-2>current input
|
||
character</a> to the <var id=rawtext-end-tag-name-state:temporary-buffer><a href=#temporary-buffer>temporary buffer</a></var>.<dt><a id=rawtext-end-tag-name-state:lowercase-ascii-letters href=https://infra.spec.whatwg.org/#ascii-lower-alpha data-x-internal=lowercase-ascii-letters>ASCII lower alpha</a><dd>Append the <a href=#current-input-character id=rawtext-end-tag-name-state:current-input-character-3>current input character</a> to the current tag token's tag name. Append
|
||
the <a href=#current-input-character id=rawtext-end-tag-name-state:current-input-character-4>current input character</a> to the <var id=rawtext-end-tag-name-state:temporary-buffer-2><a href=#temporary-buffer>temporary
|
||
buffer</a></var>.<dt>Anything else<dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS character token, and a
|
||
character token for each of the characters in the <var id=rawtext-end-tag-name-state:temporary-buffer-3><a href=#temporary-buffer>temporary
|
||
buffer</a></var> (in the order they were added to the buffer). <a href=#reconsume id=rawtext-end-tag-name-state:reconsume>Reconsume</a> in the
|
||
<a href=#rawtext-state id=rawtext-end-tag-name-state:rawtext-state>RAWTEXT state</a>.</dl>
|
||
|
||
|
||
<h5 id=script-data-less-than-sign-state><span class=secno>12.2.5.15</span> <dfn>Script data less-than sign state</dfn><a href=#script-data-less-than-sign-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-less-than-sign-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002F SOLIDUS (/)<dd>Set the <var id=script-data-less-than-sign-state:temporary-buffer><a href=#temporary-buffer>temporary buffer</a></var> to the empty string. Switch to
|
||
the <a href=#script-data-end-tag-open-state id=script-data-less-than-sign-state:script-data-end-tag-open-state>script data end tag open state</a>.<dt>U+0021 EXCLAMATION MARK (!)<dd>Switch to the <a href=#script-data-escape-start-state id=script-data-less-than-sign-state:script-data-escape-start-state>script data escape start state</a>. Emit a U+003C LESS-THAN SIGN
|
||
character token and a U+0021 EXCLAMATION MARK character token.<dt>Anything else<dd>Emit a U+003C LESS-THAN SIGN character token. <a href=#reconsume id=script-data-less-than-sign-state:reconsume>Reconsume</a> in the <a href=#script-data-state id=script-data-less-than-sign-state:script-data-state>script data
|
||
state</a>.</dl>
|
||
|
||
|
||
<h5 id=script-data-end-tag-open-state><span class=secno>12.2.5.16</span> <dfn>Script data end tag open state</dfn><a href=#script-data-end-tag-open-state class=self-link></a></h5>
|
||
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-end-tag-open-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt><a id=script-data-end-tag-open-state:ascii-letters href=https://infra.spec.whatwg.org/#ascii-alpha data-x-internal=ascii-letters>ASCII alpha</a><dd>Create a new end tag token, set its tag name to the empty string. <a href=#reconsume id=script-data-end-tag-open-state:reconsume>Reconsume</a> in
|
||
the <a href=#script-data-end-tag-name-state id=script-data-end-tag-open-state:script-data-end-tag-name-state>script data end tag name state</a>.
|
||
|
||
<dt>Anything else<dd>Emit a U+003C LESS-THAN SIGN character token and a U+002F SOLIDUS character token.
|
||
<a href=#reconsume id=script-data-end-tag-open-state:reconsume-2>Reconsume</a> in the <a href=#script-data-state id=script-data-end-tag-open-state:script-data-state>script data state</a>.</dl>
|
||
|
||
|
||
<h5 id=script-data-end-tag-name-state><span class=secno>12.2.5.17</span> <dfn>Script data end tag name state</dfn><a href=#script-data-end-tag-name-state class=self-link></a></h5>
|
||
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-end-tag-name-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>If the current end tag token is an <a href=#appropriate-end-tag-token id=script-data-end-tag-name-state:appropriate-end-tag-token>appropriate end tag token</a>, then switch to the
|
||
<a href=#before-attribute-name-state id=script-data-end-tag-name-state:before-attribute-name-state>before attribute name state</a>. Otherwise, treat it as per the "anything else" entry
|
||
below.<dt>U+002F SOLIDUS (/)<dd>If the current end tag token is an <a href=#appropriate-end-tag-token id=script-data-end-tag-name-state:appropriate-end-tag-token-2>appropriate end tag token</a>, then switch to the
|
||
<a href=#self-closing-start-tag-state id=script-data-end-tag-name-state:self-closing-start-tag-state>self-closing start tag state</a>. Otherwise, treat it as per the "anything else" entry
|
||
below.<dt>U+003E GREATER-THAN SIGN (>)<dd>If the current end tag token is an <a href=#appropriate-end-tag-token id=script-data-end-tag-name-state:appropriate-end-tag-token-3>appropriate end tag token</a>, then switch to the
|
||
<a href=#data-state id=script-data-end-tag-name-state:data-state>data state</a> and emit the current tag token. Otherwise, treat it as per the "anything
|
||
else" entry below.<dt><a id=script-data-end-tag-name-state:uppercase-ascii-letters href=https://infra.spec.whatwg.org/#ascii-upper-alpha data-x-internal=uppercase-ascii-letters>ASCII upper alpha</a><dd>Append the lowercase version of the <a href=#current-input-character id=script-data-end-tag-name-state:current-input-character>current input character</a> (add 0x0020 to the
|
||
character's code point) to the current tag token's tag name. Append the <a href=#current-input-character id=script-data-end-tag-name-state:current-input-character-2>current input
|
||
character</a> to the <var id=script-data-end-tag-name-state:temporary-buffer><a href=#temporary-buffer>temporary buffer</a></var>.<dt><a id=script-data-end-tag-name-state:lowercase-ascii-letters href=https://infra.spec.whatwg.org/#ascii-lower-alpha data-x-internal=lowercase-ascii-letters>ASCII lower alpha</a><dd>Append the <a href=#current-input-character id=script-data-end-tag-name-state:current-input-character-3>current input character</a> to the current tag token's tag name. Append
|
||
the <a href=#current-input-character id=script-data-end-tag-name-state:current-input-character-4>current input character</a> to the <var id=script-data-end-tag-name-state:temporary-buffer-2><a href=#temporary-buffer>temporary
|
||
buffer</a></var>.<dt>Anything else<dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS character token, and a
|
||
character token for each of the characters in the <var id=script-data-end-tag-name-state:temporary-buffer-3><a href=#temporary-buffer>temporary
|
||
buffer</a></var> (in the order they were added to the buffer). <a href=#reconsume id=script-data-end-tag-name-state:reconsume>Reconsume</a> in the
|
||
<a href=#script-data-state id=script-data-end-tag-name-state:script-data-state>script data state</a>.</dl>
|
||
|
||
|
||
<h5 id=script-data-escape-start-state><span class=secno>12.2.5.18</span> <dfn>Script data escape start state</dfn><a href=#script-data-escape-start-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-escape-start-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002D HYPHEN-MINUS (-)<dd>Switch to the <a href=#script-data-escape-start-dash-state id=script-data-escape-start-state:script-data-escape-start-dash-state>script data escape start dash state</a>. Emit a U+002D HYPHEN-MINUS
|
||
character token.<dt>Anything else<dd><a href=#reconsume id=script-data-escape-start-state:reconsume>Reconsume</a> in the <a href=#script-data-state id=script-data-escape-start-state:script-data-state>script data state</a>.</dl>
|
||
|
||
|
||
<h5 id=script-data-escape-start-dash-state><span class=secno>12.2.5.19</span> <dfn>Script data escape start dash state</dfn><a href=#script-data-escape-start-dash-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-escape-start-dash-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002D HYPHEN-MINUS (-)<dd>Switch to the <a href=#script-data-escaped-dash-dash-state id=script-data-escape-start-dash-state:script-data-escaped-dash-dash-state>script data escaped dash dash state</a>. Emit a U+002D HYPHEN-MINUS
|
||
character token.<dt>Anything else<dd><a href=#reconsume id=script-data-escape-start-dash-state:reconsume>Reconsume</a> in the <a href=#script-data-state id=script-data-escape-start-dash-state:script-data-state>script data state</a>.</dl>
|
||
|
||
|
||
<h5 id=script-data-escaped-state><span class=secno>12.2.5.20</span> <dfn>Script data escaped state</dfn><a href=#script-data-escaped-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-escaped-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002D HYPHEN-MINUS (-)<dd>Switch to the <a href=#script-data-escaped-dash-state id=script-data-escaped-state:script-data-escaped-dash-state>script data escaped dash state</a>. Emit a U+002D HYPHEN-MINUS
|
||
character token.<dt>U+003C LESS-THAN SIGN (<)<dd>Switch to the <a href=#script-data-escaped-less-than-sign-state id=script-data-escaped-state:script-data-escaped-less-than-sign-state>script data escaped less-than sign state</a>.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=script-data-escaped-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=script-data-escaped-state:parse-errors>parse
|
||
error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-script-html-comment-like-text id=script-data-escaped-state:parse-error-eof-in-script-html-comment-like-text>eof-in-script-html-comment-like-text</a>
|
||
<a href=#parse-errors id=script-data-escaped-state:parse-errors-2>parse error</a>. Emit an end-of-file token.<dt>Anything else<dd>Emit the <a href=#current-input-character id=script-data-escaped-state:current-input-character>current input character</a> as a character token.</dl>
|
||
|
||
|
||
<h5 id=script-data-escaped-dash-state><span class=secno>12.2.5.21</span> <dfn>Script data escaped dash state</dfn><a href=#script-data-escaped-dash-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-escaped-dash-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002D HYPHEN-MINUS (-)<dd>Switch to the <a href=#script-data-escaped-dash-dash-state id=script-data-escaped-dash-state:script-data-escaped-dash-dash-state>script data escaped dash dash state</a>. Emit a U+002D HYPHEN-MINUS
|
||
character token.<dt>U+003C LESS-THAN SIGN (<)<dd>Switch to the <a href=#script-data-escaped-less-than-sign-state id=script-data-escaped-dash-state:script-data-escaped-less-than-sign-state>script data escaped less-than sign state</a>.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=script-data-escaped-dash-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=script-data-escaped-dash-state:parse-errors>parse
|
||
error</a>. Switch to the <a href=#script-data-escaped-state id=script-data-escaped-dash-state:script-data-escaped-state>script data escaped state</a>. Emit a U+FFFD REPLACEMENT
|
||
CHARACTER character token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-script-html-comment-like-text id=script-data-escaped-dash-state:parse-error-eof-in-script-html-comment-like-text>eof-in-script-html-comment-like-text</a>
|
||
<a href=#parse-errors id=script-data-escaped-dash-state:parse-errors-2>parse error</a>. Emit an end-of-file token.<dt>Anything else<dd>Switch to the <a href=#script-data-escaped-state id=script-data-escaped-dash-state:script-data-escaped-state-2>script data escaped state</a>. Emit the <a href=#current-input-character id=script-data-escaped-dash-state:current-input-character>current input
|
||
character</a> as a character token.</dl>
|
||
|
||
|
||
<h5 id=script-data-escaped-dash-dash-state><span class=secno>12.2.5.22</span> <dfn>Script data escaped dash dash state</dfn><a href=#script-data-escaped-dash-dash-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-escaped-dash-dash-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002D HYPHEN-MINUS (-)<dd>Emit a U+002D HYPHEN-MINUS character token.<dt>U+003C LESS-THAN SIGN (<)<dd>Switch to the <a href=#script-data-escaped-less-than-sign-state id=script-data-escaped-dash-dash-state:script-data-escaped-less-than-sign-state>script data escaped less-than sign state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#script-data-state id=script-data-escaped-dash-dash-state:script-data-state>script data state</a>. Emit a U+003E GREATER-THAN SIGN character
|
||
token.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=script-data-escaped-dash-dash-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=script-data-escaped-dash-dash-state:parse-errors>parse
|
||
error</a>. Switch to the <a href=#script-data-escaped-state id=script-data-escaped-dash-dash-state:script-data-escaped-state>script data escaped state</a>. Emit a U+FFFD REPLACEMENT
|
||
CHARACTER character token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-script-html-comment-like-text id=script-data-escaped-dash-dash-state:parse-error-eof-in-script-html-comment-like-text>eof-in-script-html-comment-like-text</a>
|
||
<a href=#parse-errors id=script-data-escaped-dash-dash-state:parse-errors-2>parse error</a>. Emit an end-of-file token.<dt>Anything else<dd>Switch to the <a href=#script-data-escaped-state id=script-data-escaped-dash-dash-state:script-data-escaped-state-2>script data escaped state</a>. Emit the <a href=#current-input-character id=script-data-escaped-dash-dash-state:current-input-character>current input
|
||
character</a> as a character token.</dl>
|
||
|
||
|
||
<h5 id=script-data-escaped-less-than-sign-state><span class=secno>12.2.5.23</span> <dfn>Script data escaped less-than sign state</dfn><a href=#script-data-escaped-less-than-sign-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-escaped-less-than-sign-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002F SOLIDUS (/)<dd>Set the <var id=script-data-escaped-less-than-sign-state:temporary-buffer><a href=#temporary-buffer>temporary buffer</a></var> to the empty string. Switch to
|
||
the <a href=#script-data-escaped-end-tag-open-state id=script-data-escaped-less-than-sign-state:script-data-escaped-end-tag-open-state>script data escaped end tag open state</a>.<dt><a id=script-data-escaped-less-than-sign-state:ascii-letters href=https://infra.spec.whatwg.org/#ascii-alpha data-x-internal=ascii-letters>ASCII alpha</a><dd>Set the <var id=script-data-escaped-less-than-sign-state:temporary-buffer-2><a href=#temporary-buffer>temporary buffer</a></var> to the empty string. Emit a
|
||
U+003C LESS-THAN SIGN character token. <a href=#reconsume id=script-data-escaped-less-than-sign-state:reconsume>Reconsume</a> in the <a href=#script-data-double-escape-start-state id=script-data-escaped-less-than-sign-state:script-data-double-escape-start-state>script data double
|
||
escape start state</a>.<dt>Anything else<dd>Emit a U+003C LESS-THAN SIGN character token. <a href=#reconsume id=script-data-escaped-less-than-sign-state:reconsume-2>Reconsume</a> in the <a href=#script-data-escaped-state id=script-data-escaped-less-than-sign-state:script-data-escaped-state>script data
|
||
escaped state</a>.</dl>
|
||
|
||
|
||
<h5 id=script-data-escaped-end-tag-open-state><span class=secno>12.2.5.24</span> <dfn>Script data escaped end tag open state</dfn><a href=#script-data-escaped-end-tag-open-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-escaped-end-tag-open-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt><a id=script-data-escaped-end-tag-open-state:ascii-letters href=https://infra.spec.whatwg.org/#ascii-alpha data-x-internal=ascii-letters>ASCII alpha</a><dd>Create a new end tag token. <a href=#reconsume id=script-data-escaped-end-tag-open-state:reconsume>Reconsume</a> in the <a href=#script-data-escaped-end-tag-name-state id=script-data-escaped-end-tag-open-state:script-data-escaped-end-tag-name-state>script data escaped end tag
|
||
name state</a>. (Don't emit the token yet; further details will be filled in before it is
|
||
emitted.)<dt>Anything else<dd>Emit a U+003C LESS-THAN SIGN character token and a U+002F SOLIDUS character token.
|
||
<a href=#reconsume id=script-data-escaped-end-tag-open-state:reconsume-2>Reconsume</a> in the <a href=#script-data-escaped-state id=script-data-escaped-end-tag-open-state:script-data-escaped-state>script data escaped state</a>.</dl>
|
||
|
||
|
||
<h5 id=script-data-escaped-end-tag-name-state><span class=secno>12.2.5.25</span> <dfn>Script data escaped end tag name state</dfn><a href=#script-data-escaped-end-tag-name-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-escaped-end-tag-name-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>If the current end tag token is an <a href=#appropriate-end-tag-token id=script-data-escaped-end-tag-name-state:appropriate-end-tag-token>appropriate end tag token</a>, then switch to the
|
||
<a href=#before-attribute-name-state id=script-data-escaped-end-tag-name-state:before-attribute-name-state>before attribute name state</a>. Otherwise, treat it as per the "anything else" entry
|
||
below.<dt>U+002F SOLIDUS (/)<dd>If the current end tag token is an <a href=#appropriate-end-tag-token id=script-data-escaped-end-tag-name-state:appropriate-end-tag-token-2>appropriate end tag token</a>, then switch to the
|
||
<a href=#self-closing-start-tag-state id=script-data-escaped-end-tag-name-state:self-closing-start-tag-state>self-closing start tag state</a>. Otherwise, treat it as per the "anything else" entry
|
||
below.<dt>U+003E GREATER-THAN SIGN (>)<dd>If the current end tag token is an <a href=#appropriate-end-tag-token id=script-data-escaped-end-tag-name-state:appropriate-end-tag-token-3>appropriate end tag token</a>, then switch to the
|
||
<a href=#data-state id=script-data-escaped-end-tag-name-state:data-state>data state</a> and emit the current tag token. Otherwise, treat it as per the "anything
|
||
else" entry below.<dt><a id=script-data-escaped-end-tag-name-state:uppercase-ascii-letters href=https://infra.spec.whatwg.org/#ascii-upper-alpha data-x-internal=uppercase-ascii-letters>ASCII upper alpha</a><dd>Append the lowercase version of the <a href=#current-input-character id=script-data-escaped-end-tag-name-state:current-input-character>current input character</a> (add 0x0020 to the
|
||
character's code point) to the current tag token's tag name. Append the <a href=#current-input-character id=script-data-escaped-end-tag-name-state:current-input-character-2>current input
|
||
character</a> to the <var id=script-data-escaped-end-tag-name-state:temporary-buffer><a href=#temporary-buffer>temporary buffer</a></var>.<dt><a id=script-data-escaped-end-tag-name-state:lowercase-ascii-letters href=https://infra.spec.whatwg.org/#ascii-lower-alpha data-x-internal=lowercase-ascii-letters>ASCII lower alpha</a><dd>Append the <a href=#current-input-character id=script-data-escaped-end-tag-name-state:current-input-character-3>current input character</a> to the current tag token's tag name. Append
|
||
the <a href=#current-input-character id=script-data-escaped-end-tag-name-state:current-input-character-4>current input character</a> to the <var id=script-data-escaped-end-tag-name-state:temporary-buffer-2><a href=#temporary-buffer>temporary
|
||
buffer</a></var>.<dt>Anything else<dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS character token, and a
|
||
character token for each of the characters in the <var id=script-data-escaped-end-tag-name-state:temporary-buffer-3><a href=#temporary-buffer>temporary buffer
|
||
</a></var> (in the order they were added to the buffer). <a href=#reconsume id=script-data-escaped-end-tag-name-state:reconsume>Reconsume</a> in the <a href=#script-data-escaped-state id=script-data-escaped-end-tag-name-state:script-data-escaped-state>script
|
||
data escaped state</a>.</dl>
|
||
|
||
|
||
<h5 id=script-data-double-escape-start-state><span class=secno>12.2.5.26</span> <dfn>Script data double escape start state</dfn><a href=#script-data-double-escape-start-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-double-escape-start-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dt>U+002F SOLIDUS (/)<dt>U+003E GREATER-THAN SIGN (>)<dd>If the <var id=script-data-double-escape-start-state:temporary-buffer><a href=#temporary-buffer>temporary buffer</a></var> is the string "<code>script</code>", then switch to the <a href=#script-data-double-escaped-state id=script-data-double-escape-start-state:script-data-double-escaped-state>script data double escaped state</a>.
|
||
Otherwise, switch to the <a href=#script-data-escaped-state id=script-data-double-escape-start-state:script-data-escaped-state>script data escaped state</a>. Emit the <a href=#current-input-character id=script-data-double-escape-start-state:current-input-character>current input
|
||
character</a> as a character token.<dt><a id=script-data-double-escape-start-state:uppercase-ascii-letters href=https://infra.spec.whatwg.org/#ascii-upper-alpha data-x-internal=uppercase-ascii-letters>ASCII upper alpha</a><dd>Append the lowercase version of the <a href=#current-input-character id=script-data-double-escape-start-state:current-input-character-2>current input character</a> (add 0x0020 to the
|
||
character's code point) to the <var id=script-data-double-escape-start-state:temporary-buffer-2><a href=#temporary-buffer>temporary buffer</a></var>. Emit the
|
||
<a href=#current-input-character id=script-data-double-escape-start-state:current-input-character-3>current input character</a> as a character token.<dt><a id=script-data-double-escape-start-state:lowercase-ascii-letters href=https://infra.spec.whatwg.org/#ascii-lower-alpha data-x-internal=lowercase-ascii-letters>ASCII lower alpha</a><dd>Append the <a href=#current-input-character id=script-data-double-escape-start-state:current-input-character-4>current input character</a> to the <var id=script-data-double-escape-start-state:temporary-buffer-3><a href=#temporary-buffer>temporary buffer</a></var>. Emit the <a href=#current-input-character id=script-data-double-escape-start-state:current-input-character-5>current input character</a> as a character
|
||
token.<dt>Anything else<dd><a href=#reconsume id=script-data-double-escape-start-state:reconsume>Reconsume</a> in the <a href=#script-data-escaped-state id=script-data-double-escape-start-state:script-data-escaped-state-2>script data escaped state</a>.</dl>
|
||
|
||
|
||
<h5 id=script-data-double-escaped-state><span class=secno>12.2.5.27</span> <dfn>Script data double escaped state</dfn><a href=#script-data-double-escaped-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-double-escaped-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002D HYPHEN-MINUS (-)<dd>Switch to the <a href=#script-data-double-escaped-dash-state id=script-data-double-escaped-state:script-data-double-escaped-dash-state>script data double escaped dash state</a>. Emit a U+002D HYPHEN-MINUS
|
||
character token.<dt>U+003C LESS-THAN SIGN (<)<dd>Switch to the <a href=#script-data-double-escaped-less-than-sign-state id=script-data-double-escaped-state:script-data-double-escaped-less-than-sign-state>script data double escaped less-than sign state</a>. Emit a U+003C
|
||
LESS-THAN SIGN character token.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=script-data-double-escaped-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=script-data-double-escaped-state:parse-errors>parse
|
||
error</a>. Emit a U+FFFD REPLACEMENT CHARACTER character token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-script-html-comment-like-text id=script-data-double-escaped-state:parse-error-eof-in-script-html-comment-like-text>eof-in-script-html-comment-like-text</a>
|
||
<a href=#parse-errors id=script-data-double-escaped-state:parse-errors-2>parse error</a>. Emit an end-of-file token.<dt>Anything else<dd>Emit the <a href=#current-input-character id=script-data-double-escaped-state:current-input-character>current input character</a> as a character token.</dl>
|
||
|
||
|
||
<h5 id=script-data-double-escaped-dash-state><span class=secno>12.2.5.28</span> <dfn>Script data double escaped dash state</dfn><a href=#script-data-double-escaped-dash-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-double-escaped-dash-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002D HYPHEN-MINUS (-)<dd>Switch to the <a href=#script-data-double-escaped-dash-dash-state id=script-data-double-escaped-dash-state:script-data-double-escaped-dash-dash-state>script data double escaped dash dash state</a>. Emit a U+002D
|
||
HYPHEN-MINUS character token.<dt>U+003C LESS-THAN SIGN (<)<dd>Switch to the <a href=#script-data-double-escaped-less-than-sign-state id=script-data-double-escaped-dash-state:script-data-double-escaped-less-than-sign-state>script data double escaped less-than sign state</a>. Emit a U+003C
|
||
LESS-THAN SIGN character token.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=script-data-double-escaped-dash-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=script-data-double-escaped-dash-state:parse-errors>parse
|
||
error</a>. Switch to the <a href=#script-data-double-escaped-state id=script-data-double-escaped-dash-state:script-data-double-escaped-state>script data double escaped state</a>. Emit a U+FFFD
|
||
REPLACEMENT CHARACTER character token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-script-html-comment-like-text id=script-data-double-escaped-dash-state:parse-error-eof-in-script-html-comment-like-text>eof-in-script-html-comment-like-text</a>
|
||
<a href=#parse-errors id=script-data-double-escaped-dash-state:parse-errors-2>parse error</a>. Emit an end-of-file token.<dt>Anything else<dd>Switch to the <a href=#script-data-double-escaped-state id=script-data-double-escaped-dash-state:script-data-double-escaped-state-2>script data double escaped state</a>. Emit the <a href=#current-input-character id=script-data-double-escaped-dash-state:current-input-character>current input
|
||
character</a> as a character token.</dl>
|
||
|
||
|
||
<h5 id=script-data-double-escaped-dash-dash-state><span class=secno>12.2.5.29</span> <dfn>Script data double escaped dash dash state</dfn><a href=#script-data-double-escaped-dash-dash-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-double-escaped-dash-dash-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002D HYPHEN-MINUS (-)<dd>Emit a U+002D HYPHEN-MINUS character token.<dt>U+003C LESS-THAN SIGN (<)<dd>Switch to the <a href=#script-data-double-escaped-less-than-sign-state id=script-data-double-escaped-dash-dash-state:script-data-double-escaped-less-than-sign-state>script data double escaped less-than sign state</a>. Emit a U+003C
|
||
LESS-THAN SIGN character token.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#script-data-state id=script-data-double-escaped-dash-dash-state:script-data-state>script data state</a>. Emit a U+003E GREATER-THAN SIGN character
|
||
token.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=script-data-double-escaped-dash-dash-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=script-data-double-escaped-dash-dash-state:parse-errors>parse
|
||
error</a>. Switch to the <a href=#script-data-double-escaped-state id=script-data-double-escaped-dash-dash-state:script-data-double-escaped-state>script data double escaped state</a>. Emit a U+FFFD
|
||
REPLACEMENT CHARACTER character token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-script-html-comment-like-text id=script-data-double-escaped-dash-dash-state:parse-error-eof-in-script-html-comment-like-text>eof-in-script-html-comment-like-text</a>
|
||
<a href=#parse-errors id=script-data-double-escaped-dash-dash-state:parse-errors-2>parse error</a>. Emit an end-of-file token.<dt>Anything else<dd>Switch to the <a href=#script-data-double-escaped-state id=script-data-double-escaped-dash-dash-state:script-data-double-escaped-state-2>script data double escaped state</a>. Emit the <a href=#current-input-character id=script-data-double-escaped-dash-dash-state:current-input-character>current input
|
||
character</a> as a character token.</dl>
|
||
|
||
|
||
<h5 id=script-data-double-escaped-less-than-sign-state><span class=secno>12.2.5.30</span> <dfn>Script data double escaped less-than sign state</dfn><a href=#script-data-double-escaped-less-than-sign-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-double-escaped-less-than-sign-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002F SOLIDUS (/)<dd>Set the <var id=script-data-double-escaped-less-than-sign-state:temporary-buffer><a href=#temporary-buffer>temporary buffer</a></var> to the empty string. Switch to
|
||
the <a href=#script-data-double-escape-end-state id=script-data-double-escaped-less-than-sign-state:script-data-double-escape-end-state>script data double escape end state</a>. Emit a U+002F SOLIDUS character token.<dt>Anything else<dd><a href=#reconsume id=script-data-double-escaped-less-than-sign-state:reconsume>Reconsume</a> in the <a href=#script-data-double-escaped-state id=script-data-double-escaped-less-than-sign-state:script-data-double-escaped-state>script data double escaped state</a>.</dl>
|
||
|
||
|
||
<h5 id=script-data-double-escape-end-state><span class=secno>12.2.5.31</span> <dfn>Script data double escape end state</dfn><a href=#script-data-double-escape-end-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=script-data-double-escape-end-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dt>U+002F SOLIDUS (/)<dt>U+003E GREATER-THAN SIGN (>)<dd>If the <var id=script-data-double-escape-end-state:temporary-buffer><a href=#temporary-buffer>temporary buffer</a></var> is the string "<code>script</code>", then switch to the <a href=#script-data-escaped-state id=script-data-double-escape-end-state:script-data-escaped-state>script data escaped state</a>. Otherwise,
|
||
switch to the <a href=#script-data-double-escaped-state id=script-data-double-escape-end-state:script-data-double-escaped-state>script data double escaped state</a>. Emit the <a href=#current-input-character id=script-data-double-escape-end-state:current-input-character>current input
|
||
character</a> as a character token.<dt><a id=script-data-double-escape-end-state:uppercase-ascii-letters href=https://infra.spec.whatwg.org/#ascii-upper-alpha data-x-internal=uppercase-ascii-letters>ASCII upper alpha</a><dd>Append the lowercase version of the <a href=#current-input-character id=script-data-double-escape-end-state:current-input-character-2>current input character</a> (add 0x0020 to the
|
||
character's code point) to the <var id=script-data-double-escape-end-state:temporary-buffer-2><a href=#temporary-buffer>temporary buffer</a></var>. Emit the
|
||
<a href=#current-input-character id=script-data-double-escape-end-state:current-input-character-3>current input character</a> as a character token.<dt><a id=script-data-double-escape-end-state:lowercase-ascii-letters href=https://infra.spec.whatwg.org/#ascii-lower-alpha data-x-internal=lowercase-ascii-letters>ASCII lower alpha</a><dd>Append the <a href=#current-input-character id=script-data-double-escape-end-state:current-input-character-4>current input character</a> to the <var id=script-data-double-escape-end-state:temporary-buffer-3><a href=#temporary-buffer>temporary buffer</a></var>. Emit the <a href=#current-input-character id=script-data-double-escape-end-state:current-input-character-5>current input character</a> as a character
|
||
token.<dt>Anything else<dd><a href=#reconsume id=script-data-double-escape-end-state:reconsume>Reconsume</a> in the <a href=#script-data-double-escaped-state id=script-data-double-escape-end-state:script-data-double-escaped-state-2>script data double escaped state</a>.</dl>
|
||
|
||
|
||
<h5 id=before-attribute-name-state><span class=secno>12.2.5.32</span> <dfn>Before attribute name state</dfn><a href=#before-attribute-name-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=before-attribute-name-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<dt>U+002F SOLIDUS (/)<dt>U+003E GREATER-THAN SIGN (>)<dt>EOF<dd><a href=#reconsume id=before-attribute-name-state:reconsume>Reconsume</a> in the <a href=#after-attribute-name-state id=before-attribute-name-state:after-attribute-name-state>after attribute name state</a>.<dt>U+003D EQUALS SIGN (=)<dd>This is an <a href=#parse-error-unexpected-equals-sign-before-attribute-name id=before-attribute-name-state:parse-error-unexpected-equals-sign-before-attribute-name>unexpected-equals-sign-before-attribute-name</a>
|
||
<a href=#parse-errors id=before-attribute-name-state:parse-errors>parse error</a>. Start a new attribute in the current tag token. Set that attribute's
|
||
name to the <a href=#current-input-character id=before-attribute-name-state:current-input-character>current input character</a>, and its value to the empty string. Switch to
|
||
the <a href=#attribute-name-state id=before-attribute-name-state:attribute-name-state>attribute name state</a>.<dt>Anything else<dd>Start a new attribute in the current tag token. Set that attribute name and value to the
|
||
empty string. <a href=#reconsume id=before-attribute-name-state:reconsume-2>Reconsume</a> in the <a href=#attribute-name-state id=before-attribute-name-state:attribute-name-state-2>attribute name state</a>.</dl>
|
||
|
||
|
||
<h5 id=attribute-name-state><span class=secno>12.2.5.33</span> <dfn>Attribute name state</dfn><a href=#attribute-name-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=attribute-name-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dt>U+002F SOLIDUS (/)<dt>U+003E GREATER-THAN SIGN (>)<dt>EOF<dd><a href=#reconsume id=attribute-name-state:reconsume>Reconsume</a> in the <a href=#after-attribute-name-state id=attribute-name-state:after-attribute-name-state>after attribute name state</a>.<dt>U+003D EQUALS SIGN (=)<dd>Switch to the <a href=#before-attribute-value-state id=attribute-name-state:before-attribute-value-state>before attribute value state</a>.<dt><a id=attribute-name-state:uppercase-ascii-letters href=https://infra.spec.whatwg.org/#ascii-upper-alpha data-x-internal=uppercase-ascii-letters>ASCII upper alpha</a><dd>Append the lowercase version of the <a href=#current-input-character id=attribute-name-state:current-input-character>current input character</a> (add 0x0020 to the
|
||
character's code point) to the current attribute's name.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=attribute-name-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=attribute-name-state:parse-errors>parse
|
||
error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current attribute's
|
||
name.<dt>U+0022 QUOTATION MARK (")<dt>U+0027 APOSTROPHE (')<dt>U+003C LESS-THAN SIGN (<)<dd>This is an <a href=#parse-error-unexpected-character-in-attribute-name id=attribute-name-state:parse-error-unexpected-character-in-attribute-name>unexpected-character-in-attribute-name</a>
|
||
<a href=#parse-errors id=attribute-name-state:parse-errors-2>parse error</a>. Treat it as per the "anything else" entry below.<dt>Anything else<dd>Append the <a href=#current-input-character id=attribute-name-state:current-input-character-2>current input character</a> to the current attribute's name.</dl>
|
||
|
||
<p>When the user agent leaves the attribute name state (and before emitting the tag token, if
|
||
appropriate), the complete attribute's name must be compared to the other attributes on the same
|
||
token; if there is already an attribute on the token with the exact same name, then this is a
|
||
<a href=#parse-error-duplicate-attribute id=attribute-name-state:parse-error-duplicate-attribute>duplicate-attribute</a> <a href=#parse-errors id=attribute-name-state:parse-errors-3>parse error</a>
|
||
and the new attribute must be removed from the token.</p>
|
||
|
||
<p class=note>If an attribute is so removed from a token, it, and the value that gets associated
|
||
with it, if any, are never subsequently used by the parser, and are therefore effectively
|
||
discarded. Removing the attribute in this way does not change its status as the "current
|
||
attribute" for the purposes of the tokenizer, however.</p>
|
||
|
||
|
||
<h5 id=after-attribute-name-state><span class=secno>12.2.5.34</span> <dfn>After attribute name state</dfn><a href=#after-attribute-name-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=after-attribute-name-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<dt>U+002F SOLIDUS (/)<dd>Switch to the <a href=#self-closing-start-tag-state id=after-attribute-name-state:self-closing-start-tag-state>self-closing start tag state</a>.<dt>U+003D EQUALS SIGN (=)<dd>Switch to the <a href=#before-attribute-value-state id=after-attribute-name-state:before-attribute-value-state>before attribute value state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=after-attribute-name-state:data-state>data state</a>. Emit the current tag token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-tag id=after-attribute-name-state:parse-error-eof-in-tag>eof-in-tag</a>
|
||
<a href=#parse-errors id=after-attribute-name-state:parse-errors>parse error</a>. Emit an end-of-file token.<dt>Anything else<dd>Start a new attribute in the current tag token. Set that attribute name and value to the
|
||
empty string. <a href=#reconsume id=after-attribute-name-state:reconsume>Reconsume</a> in the <a href=#attribute-name-state id=after-attribute-name-state:attribute-name-state>attribute name state</a>.</dl>
|
||
|
||
|
||
<h5 id=before-attribute-value-state><span class=secno>12.2.5.35</span> <dfn>Before attribute value state</dfn><a href=#before-attribute-value-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=before-attribute-value-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<dt>U+0022 QUOTATION MARK (")<dd>Switch to the <a href=#attribute-value-(double-quoted)-state id=before-attribute-value-state:attribute-value-(double-quoted)-state>attribute value (double-quoted) state</a>.<dt>U+0027 APOSTROPHE (')<dd>Switch to the <a href=#attribute-value-(single-quoted)-state id=before-attribute-value-state:attribute-value-(single-quoted)-state>attribute value (single-quoted) state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd>This is a <a href=#parse-error-missing-attribute-value id=before-attribute-value-state:parse-error-missing-attribute-value>missing-attribute-value</a>
|
||
<a href=#parse-errors id=before-attribute-value-state:parse-errors>parse error</a>. Switch to the <a href=#data-state id=before-attribute-value-state:data-state>data state</a>. Emit the current tag token.<dt>Anything else<dd><a href=#reconsume id=before-attribute-value-state:reconsume>Reconsume</a> in the <a href=#attribute-value-(unquoted)-state id=before-attribute-value-state:attribute-value-(unquoted)-state>attribute value (unquoted) state</a>.</dl>
|
||
|
||
|
||
<h5 id=attribute-value-(double-quoted)-state><span class=secno>12.2.5.36</span> <dfn>Attribute value (double-quoted) state</dfn><a href=#attribute-value-(double-quoted)-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=attribute-value-(double-quoted)-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0022 QUOTATION MARK (")<dd>Switch to the <a href=#after-attribute-value-(quoted)-state id=attribute-value-(double-quoted)-state:after-attribute-value-(quoted)-state>after attribute value (quoted) state</a>.<dt>U+0026 AMPERSAND (&)<dd>Set the <var id=attribute-value-(double-quoted)-state:return-state><a href=#return-state>return state</a></var> to the <a href=#attribute-value-(double-quoted)-state id=attribute-value-(double-quoted)-state:attribute-value-(double-quoted)-state>attribute value
|
||
(double-quoted) state</a>. Switch to the <a href=#character-reference-state id=attribute-value-(double-quoted)-state:character-reference-state>character reference state</a>.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=attribute-value-(double-quoted)-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=attribute-value-(double-quoted)-state:parse-errors>parse
|
||
error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current attribute's
|
||
value.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-tag id=attribute-value-(double-quoted)-state:parse-error-eof-in-tag>eof-in-tag</a> <a href=#parse-errors id=attribute-value-(double-quoted)-state:parse-errors-2>parse error</a>.
|
||
Emit an end-of-file token.<dt>Anything else<dd>Append the <a href=#current-input-character id=attribute-value-(double-quoted)-state:current-input-character>current input character</a> to the current attribute's value.</dl>
|
||
|
||
|
||
<h5 id=attribute-value-(single-quoted)-state><span class=secno>12.2.5.37</span> <dfn>Attribute value (single-quoted) state</dfn><a href=#attribute-value-(single-quoted)-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=attribute-value-(single-quoted)-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0027 APOSTROPHE (')<dd>Switch to the <a href=#after-attribute-value-(quoted)-state id=attribute-value-(single-quoted)-state:after-attribute-value-(quoted)-state>after attribute value (quoted) state</a>.<dt>U+0026 AMPERSAND (&)<dd>Set the <var id=attribute-value-(single-quoted)-state:return-state><a href=#return-state>return state</a></var> to the <a href=#attribute-value-(single-quoted)-state id=attribute-value-(single-quoted)-state:attribute-value-(single-quoted)-state>attribute value
|
||
(single-quoted) state</a>. Switch to the <a href=#character-reference-state id=attribute-value-(single-quoted)-state:character-reference-state>character reference state</a>.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=attribute-value-(single-quoted)-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=attribute-value-(single-quoted)-state:parse-errors>parse
|
||
error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current attribute's
|
||
value.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-tag id=attribute-value-(single-quoted)-state:parse-error-eof-in-tag>eof-in-tag</a> <a href=#parse-errors id=attribute-value-(single-quoted)-state:parse-errors-2>parse error</a>.
|
||
Emit an end-of-file token.<dt>Anything else<dd>Append the <a href=#current-input-character id=attribute-value-(single-quoted)-state:current-input-character>current input character</a> to the current attribute's value.</dl>
|
||
|
||
|
||
<h5 id=attribute-value-(unquoted)-state><span class=secno>12.2.5.38</span> <dfn>Attribute value (unquoted) state</dfn><a href=#attribute-value-(unquoted)-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=attribute-value-(unquoted)-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Switch to the <a href=#before-attribute-name-state id=attribute-value-(unquoted)-state:before-attribute-name-state>before attribute name state</a>.<dt>U+0026 AMPERSAND (&)<dd>Set the <var id=attribute-value-(unquoted)-state:return-state><a href=#return-state>return state</a></var> to the <a href=#attribute-value-(unquoted)-state id=attribute-value-(unquoted)-state:attribute-value-(unquoted)-state>attribute value
|
||
(unquoted) state</a>. Switch to the <a href=#character-reference-state id=attribute-value-(unquoted)-state:character-reference-state>character reference state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=attribute-value-(unquoted)-state:data-state>data state</a>. Emit the current tag token.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=attribute-value-(unquoted)-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=attribute-value-(unquoted)-state:parse-errors>parse
|
||
error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current attribute's
|
||
value.<dt>U+0022 QUOTATION MARK (")<dt>U+0027 APOSTROPHE (')<dt>U+003C LESS-THAN SIGN (<)<dt>U+003D EQUALS SIGN (=)<dt>U+0060 GRAVE ACCENT (`)<dd>This is an <a href=#parse-error-unexpected-character-in-unquoted-attribute-value id=attribute-value-(unquoted)-state:parse-error-unexpected-character-in-unquoted-attribute-value>unexpected-character-in-unquoted-attribute-value</a>
|
||
<a href=#parse-errors id=attribute-value-(unquoted)-state:parse-errors-2>parse error</a>. Treat it as per the "anything else" entry below.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-tag id=attribute-value-(unquoted)-state:parse-error-eof-in-tag>eof-in-tag</a>
|
||
<a href=#parse-errors id=attribute-value-(unquoted)-state:parse-errors-3>parse error</a>. Emit an end-of-file token.<dt>Anything else<dd>Append the <a href=#current-input-character id=attribute-value-(unquoted)-state:current-input-character>current input character</a> to the current attribute's value.</dl>
|
||
|
||
|
||
<h5 id=after-attribute-value-(quoted)-state><span class=secno>12.2.5.39</span> <dfn>After attribute value (quoted) state</dfn><a href=#after-attribute-value-(quoted)-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=after-attribute-value-(quoted)-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Switch to the <a href=#before-attribute-name-state id=after-attribute-value-(quoted)-state:before-attribute-name-state>before attribute name state</a>.<dt>U+002F SOLIDUS (/)<dd>Switch to the <a href=#self-closing-start-tag-state id=after-attribute-value-(quoted)-state:self-closing-start-tag-state>self-closing start tag state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=after-attribute-value-(quoted)-state:data-state>data state</a>. Emit the current tag token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-tag id=after-attribute-value-(quoted)-state:parse-error-eof-in-tag>eof-in-tag</a> <a href=#parse-errors id=after-attribute-value-(quoted)-state:parse-errors>parse error</a>.
|
||
Emit an end-of-file token.<dt>Anything else<dd>This is a <a href=#parse-error-missing-whitespace-between-attributes id=after-attribute-value-(quoted)-state:parse-error-missing-whitespace-between-attributes>missing-whitespace-between-attributes</a>
|
||
<a href=#parse-errors id=after-attribute-value-(quoted)-state:parse-errors-2>parse error</a>. <a href=#reconsume id=after-attribute-value-(quoted)-state:reconsume>Reconsume</a> in the <a href=#before-attribute-name-state id=after-attribute-value-(quoted)-state:before-attribute-name-state-2>before attribute name state</a>.
|
||
</dl>
|
||
|
||
|
||
<h5 id=self-closing-start-tag-state><span class=secno>12.2.5.40</span> <dfn>Self-closing start tag state</dfn><a href=#self-closing-start-tag-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=self-closing-start-tag-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+003E GREATER-THAN SIGN (>)<dd>Set the <i id=self-closing-start-tag-state:self-closing-flag><a href=#self-closing-flag>self-closing flag</a></i> of the current tag token. Switch
|
||
to the <a href=#data-state id=self-closing-start-tag-state:data-state>data state</a>. Emit the current tag token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-tag id=self-closing-start-tag-state:parse-error-eof-in-tag>eof-in-tag</a>
|
||
<a href=#parse-errors id=self-closing-start-tag-state:parse-errors>parse error</a>. Emit an end-of-file token.<dt>Anything else<dd>This is an <a href=#parse-error-unexpected-solidus-in-tag id=self-closing-start-tag-state:parse-error-unexpected-solidus-in-tag>unexpected-solidus-in-tag</a> <a href=#parse-errors id=self-closing-start-tag-state:parse-errors-2>parse
|
||
error</a>. <a href=#reconsume id=self-closing-start-tag-state:reconsume>Reconsume</a> in the <a href=#before-attribute-name-state id=self-closing-start-tag-state:before-attribute-name-state>before attribute name state</a>.</dl>
|
||
|
||
|
||
<h5 id=bogus-comment-state><span class=secno>12.2.5.41</span> <dfn>Bogus comment state</dfn><a href=#bogus-comment-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=bogus-comment-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=bogus-comment-state:data-state>data state</a>. Emit the comment token.<dt>EOF<dd>Emit the comment. Emit an end-of-file token.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=bogus-comment-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=bogus-comment-state:parse-errors>parse
|
||
error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the comment token's data.<dt>Anything else<dd>Append the <a href=#current-input-character id=bogus-comment-state:current-input-character>current input character</a> to the comment token's data.</dl>
|
||
|
||
|
||
<h5 id=markup-declaration-open-state><span class=secno>12.2.5.42</span> <dfn>Markup declaration open state</dfn><a href=#markup-declaration-open-state class=self-link></a></h5>
|
||
|
||
<p>If the next few characters are:<p>
|
||
|
||
<dl class=switch><dt>Two U+002D HYPHEN-MINUS characters (-)<dd>Consume those two characters, create a comment token whose data is the empty string, and
|
||
switch to the <a href=#comment-start-state id=markup-declaration-open-state:comment-start-state>comment start state</a>.<dt><a id=markup-declaration-open-state:ascii-case-insensitive href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> match for the word "DOCTYPE"<dd>Consume those characters and switch to the <a href=#doctype-state id=markup-declaration-open-state:doctype-state>DOCTYPE state</a>.<dt><a id=markup-declaration-open-state:case-sensitive href=infrastructure.html#case-sensitive>Case-sensitive</a> match for the string "[CDATA[" (the five uppercase letters
|
||
"CDATA" with a U+005B LEFT SQUARE BRACKET character before and after)<dd>Consume those characters. If there is an <a href=#adjusted-current-node id=markup-declaration-open-state:adjusted-current-node>adjusted current node</a> and it is not
|
||
an element in the <a id=markup-declaration-open-state:html-namespace-2 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a>, then switch to the <a href=#cdata-section-state id=markup-declaration-open-state:cdata-section-state>CDATA section
|
||
state</a>. Otherwise, this is a <a href=#parse-error-cdata-in-html-content id=markup-declaration-open-state:parse-error-cdata-in-html-content>cdata-in-html-content</a> <a href=#parse-errors id=markup-declaration-open-state:parse-errors>parse
|
||
error</a>. Create a comment token whose data is the "[CDATA[" string. Switch to the
|
||
<a href=#bogus-comment-state id=markup-declaration-open-state:bogus-comment-state>bogus comment state</a>.<dt>Anything else<dd>This is an <a href=#parse-error-incorrectly-opened-comment id=markup-declaration-open-state:parse-error-incorrectly-opened-comment>incorrectly-opened-comment</a>
|
||
<a href=#parse-errors id=markup-declaration-open-state:parse-errors-2>parse error</a>. Create a comment token whose data is the empty string. Switch to the
|
||
<a href=#bogus-comment-state id=markup-declaration-open-state:bogus-comment-state-2>bogus comment state</a> (don't consume anything in the current state).</dl>
|
||
|
||
|
||
<h5 id=comment-start-state><span class=secno>12.2.5.43</span> <dfn>Comment start state</dfn><a href=#comment-start-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=comment-start-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002D HYPHEN-MINUS (-)<dd>Switch to the <a href=#comment-start-dash-state id=comment-start-state:comment-start-dash-state>comment start dash state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd>This is an <a href=#parse-error-abrupt-closing-of-empty-comment id=comment-start-state:parse-error-abrupt-closing-of-empty-comment>abrupt-closing-of-empty-comment</a> <a href=#parse-errors id=comment-start-state:parse-errors>parse
|
||
error</a>. Switch to the <a href=#data-state id=comment-start-state:data-state>data state</a>. Emit the comment token.<dt>Anything else<dd><a href=#reconsume id=comment-start-state:reconsume>Reconsume</a> in the <a href=#comment-state id=comment-start-state:comment-state>comment state</a>.</dl>
|
||
|
||
|
||
<h5 id=comment-start-dash-state><span class=secno>12.2.5.44</span> <dfn>Comment start dash state</dfn><a href=#comment-start-dash-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=comment-start-dash-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002D HYPHEN-MINUS (-)<dd>Switch to the <a href=#comment-end-state id=comment-start-dash-state:comment-end-state>comment end state</a><dt>U+003E GREATER-THAN SIGN (>)<dd>This is an <a href=#parse-error-abrupt-closing-of-empty-comment id=comment-start-dash-state:parse-error-abrupt-closing-of-empty-comment>abrupt-closing-of-empty-comment</a> <a href=#parse-errors id=comment-start-dash-state:parse-errors>parse
|
||
error</a>. Switch to the <a href=#data-state id=comment-start-dash-state:data-state>data state</a>. Emit the comment token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-comment id=comment-start-dash-state:parse-error-eof-in-comment>eof-in-comment</a> <a href=#parse-errors id=comment-start-dash-state:parse-errors-2>parse
|
||
error</a>. Emit the comment token. Emit an end-of-file token.<dt>Anything else<dd>Append a U+002D HYPHEN-MINUS character (-) to the comment token's data.
|
||
<a href=#reconsume id=comment-start-dash-state:reconsume>Reconsume</a> in the <a href=#comment-state id=comment-start-dash-state:comment-state>comment state</a>.</dl>
|
||
|
||
|
||
<h5 id=comment-state><span class=secno>12.2.5.45</span> <dfn id=comment>Comment state</dfn><a href=#comment-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=comment-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+003C LESS-THAN SIGN (<)<dd>Append the <a href=#current-input-character id=comment-state:current-input-character>current input character</a> to the comment token's data. Switch to the
|
||
<a href=#comment-less-than-sign-state id=comment-state:comment-less-than-sign-state>comment less-than sign state</a>.<dt>U+002D HYPHEN-MINUS (-)<dd>Switch to the <a href=#comment-end-dash-state id=comment-state:comment-end-dash-state>comment end dash state</a>.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=comment-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=comment-state:parse-errors>parse
|
||
error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the comment token's data.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-comment id=comment-state:parse-error-eof-in-comment>eof-in-comment</a> <a href=#parse-errors id=comment-state:parse-errors-2>parse
|
||
error</a>. Emit the comment token. Emit an end-of-file token.<dt>Anything else<dd>Append the <a href=#current-input-character id=comment-state:current-input-character-2>current input character</a> to the comment token's data.</dl>
|
||
|
||
|
||
<h5 id=comment-less-than-sign-state><span class=secno>12.2.5.46</span> <dfn>Comment less-than sign state</dfn><a href=#comment-less-than-sign-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=comment-less-than-sign-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0021 EXCLAMATION MARK (!)<dd>Append the <a href=#current-input-character id=comment-less-than-sign-state:current-input-character>current input character</a> to the comment token's data. Switch to the
|
||
<a href=#comment-less-than-sign-bang-state id=comment-less-than-sign-state:comment-less-than-sign-bang-state>comment less-than sign bang state</a>.<dt>U+003C LESS-THAN SIGN (<)<dd>Append the <a href=#current-input-character id=comment-less-than-sign-state:current-input-character-2>current input character</a> to the comment token's data.<dt>Anything else<dd><a href=#reconsume id=comment-less-than-sign-state:reconsume>Reconsume</a> in the <a href=#comment-state id=comment-less-than-sign-state:comment-state>comment state</a>.</dl>
|
||
|
||
|
||
<h5 id=comment-less-than-sign-bang-state><span class=secno>12.2.5.47</span> <dfn>Comment less-than sign bang state</dfn><a href=#comment-less-than-sign-bang-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=comment-less-than-sign-bang-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002D HYPHEN-MINUS (-)<dd>Switch to the <a href=#comment-less-than-sign-bang-dash-state id=comment-less-than-sign-bang-state:comment-less-than-sign-bang-dash-state>comment less-than sign bang dash state</a>.<dt>Anything else<dd><a href=#reconsume id=comment-less-than-sign-bang-state:reconsume>Reconsume</a> in the <a href=#comment-state id=comment-less-than-sign-bang-state:comment-state>comment state</a>.</dl>
|
||
|
||
|
||
<h5 id=comment-less-than-sign-bang-dash-state><span class=secno>12.2.5.48</span> <dfn>Comment less-than sign bang dash state</dfn><a href=#comment-less-than-sign-bang-dash-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=comment-less-than-sign-bang-dash-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002D HYPHEN-MINUS (-)<dd>Switch to the <a href=#comment-less-than-sign-bang-dash-dash-state id=comment-less-than-sign-bang-dash-state:comment-less-than-sign-bang-dash-dash-state>comment less-than sign bang dash dash state</a>.<dt>Anything else<dd><a href=#reconsume id=comment-less-than-sign-bang-dash-state:reconsume>Reconsume</a> in the <a href=#comment-end-dash-state id=comment-less-than-sign-bang-dash-state:comment-end-dash-state>comment end dash state</a>.</dl>
|
||
|
||
|
||
<h5 id=comment-less-than-sign-bang-dash-dash-state><span class=secno>12.2.5.49</span> <dfn>Comment less-than sign bang dash dash state</dfn><a href=#comment-less-than-sign-bang-dash-dash-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=comment-less-than-sign-bang-dash-dash-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+003E GREATER-THAN SIGN (>)<dt>EOF<dd><a href=#reconsume id=comment-less-than-sign-bang-dash-dash-state:reconsume>Reconsume</a> in the <a href=#comment-end-state id=comment-less-than-sign-bang-dash-dash-state:comment-end-state>comment end state</a>.<dt>Anything else<dd>This is a <a href=#parse-error-nested-comment id=comment-less-than-sign-bang-dash-dash-state:parse-error-nested-comment>nested-comment</a> <a href=#parse-errors id=comment-less-than-sign-bang-dash-dash-state:parse-errors>parse
|
||
error</a>. <a href=#reconsume id=comment-less-than-sign-bang-dash-dash-state:reconsume-2>Reconsume</a> in the <a href=#comment-end-state id=comment-less-than-sign-bang-dash-dash-state:comment-end-state-2>comment end state</a>.</dl>
|
||
|
||
|
||
<h5 id=comment-end-dash-state><span class=secno>12.2.5.50</span> <dfn>Comment end dash state</dfn><a href=#comment-end-dash-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=comment-end-dash-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002D HYPHEN-MINUS (-)<dd>Switch to the <a href=#comment-end-state id=comment-end-dash-state:comment-end-state>comment end state</a><dt>EOF<dd>This is an <a href=#parse-error-eof-in-comment id=comment-end-dash-state:parse-error-eof-in-comment>eof-in-comment</a> <a href=#parse-errors id=comment-end-dash-state:parse-errors>parse
|
||
error</a>. Emit the comment token. Emit an end-of-file token.<dt>Anything else<dd>Append a U+002D HYPHEN-MINUS character (-) to the comment token's data.
|
||
<a href=#reconsume id=comment-end-dash-state:reconsume>Reconsume</a> in the <a href=#comment-state id=comment-end-dash-state:comment-state>comment state</a>.</dl>
|
||
|
||
|
||
<h5 id=comment-end-state><span class=secno>12.2.5.51</span> <dfn>Comment end state</dfn><a href=#comment-end-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=comment-end-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=comment-end-state:data-state>data state</a>. Emit the comment token.<dt>U+0021 EXCLAMATION MARK (!)<dd>Switch to the <a href=#comment-end-bang-state id=comment-end-state:comment-end-bang-state>comment end bang state</a>.<dt>U+002D HYPHEN-MINUS (-)<dd>Append a U+002D HYPHEN-MINUS character (-) to the comment token's data.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-comment id=comment-end-state:parse-error-eof-in-comment>eof-in-comment</a> <a href=#parse-errors id=comment-end-state:parse-errors>parse
|
||
error</a>. Emit the comment token. Emit an end-of-file token.<dt>Anything else<dd>Append two U+002D HYPHEN-MINUS characters (-) to the comment token's data.
|
||
<a href=#reconsume id=comment-end-state:reconsume>Reconsume</a> in the <a href=#comment-state id=comment-end-state:comment-state>comment state</a>.</dl>
|
||
|
||
|
||
<h5 id=comment-end-bang-state><span class=secno>12.2.5.52</span> <dfn>Comment end bang state</dfn><a href=#comment-end-bang-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=comment-end-bang-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+002D HYPHEN-MINUS (-)<dd>Append two U+002D HYPHEN-MINUS characters (-) and a U+0021 EXCLAMATION MARK character (!) to
|
||
the comment token's data. Switch to the <a href=#comment-end-dash-state id=comment-end-bang-state:comment-end-dash-state>comment end dash state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd>This is an <a href=#parse-error-incorrectly-closed-comment id=comment-end-bang-state:parse-error-incorrectly-closed-comment>incorrectly-closed-comment</a> <a href=#parse-errors id=comment-end-bang-state:parse-errors>parse
|
||
error</a>. Switch to the <a href=#data-state id=comment-end-bang-state:data-state>data state</a>. Emit the comment token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-comment id=comment-end-bang-state:parse-error-eof-in-comment>eof-in-comment</a> <a href=#parse-errors id=comment-end-bang-state:parse-errors-2>parse
|
||
error</a>. Emit the comment token. Emit an end-of-file token.<dt>Anything else<dd>Append two U+002D HYPHEN-MINUS characters (-) and a U+0021 EXCLAMATION MARK character (!) to
|
||
the comment token's data. <a href=#reconsume id=comment-end-bang-state:reconsume>Reconsume</a> in the <a href=#comment-state id=comment-end-bang-state:comment-state>comment state</a>.</dl>
|
||
|
||
|
||
<h5 id=doctype-state><span class=secno>12.2.5.53</span> <dfn>DOCTYPE state</dfn><a href=#doctype-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=doctype-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Switch to the <a href=#before-doctype-name-state id=doctype-state:before-doctype-name-state>before DOCTYPE name state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd><a href=#reconsume id=doctype-state:reconsume>Reconsume</a> in the <a href=#before-doctype-name-state id=doctype-state:before-doctype-name-state-2>before DOCTYPE name state</a>.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-doctype id=doctype-state:parse-error-eof-in-doctype>eof-in-doctype</a> <a href=#parse-errors id=doctype-state:parse-errors>parse
|
||
error</a>. Create a new DOCTYPE token. Set its <i id=doctype-state:force-quirks-flag><a href=#force-quirks-flag>force-quirks
|
||
flag</a></i> to <i>on</i>. Emit the token. Emit an end-of-file token.<dt>Anything else<dd>This is a <a href=#parse-error-missing-whitespace-before-doctype-name id=doctype-state:parse-error-missing-whitespace-before-doctype-name>missing-whitespace-before-doctype-name</a>
|
||
<a href=#parse-errors id=doctype-state:parse-errors-2>parse error</a>. <a href=#reconsume id=doctype-state:reconsume-2>Reconsume</a> in the <a href=#before-doctype-name-state id=doctype-state:before-doctype-name-state-3>before DOCTYPE name state</a>.
|
||
</dl>
|
||
|
||
|
||
<h5 id=before-doctype-name-state><span class=secno>12.2.5.54</span> <dfn>Before DOCTYPE name state</dfn><a href=#before-doctype-name-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=before-doctype-name-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<dt><a id=before-doctype-name-state:uppercase-ascii-letters href=https://infra.spec.whatwg.org/#ascii-upper-alpha data-x-internal=uppercase-ascii-letters>ASCII upper alpha</a><dd>Create a new DOCTYPE token. Set the token's name to the lowercase version of the
|
||
<a href=#current-input-character id=before-doctype-name-state:current-input-character>current input character</a> (add 0x0020 to the character's code point). Switch to the
|
||
<a href=#doctype-name-state id=before-doctype-name-state:doctype-name-state>DOCTYPE name state</a>.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=before-doctype-name-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=before-doctype-name-state:parse-errors>parse
|
||
error</a>. Create a new DOCTYPE token. Set the token's name to a U+FFFD REPLACEMENT CHARACTER
|
||
character. Switch to the <a href=#doctype-name-state id=before-doctype-name-state:doctype-name-state-2>DOCTYPE name state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd>This is a <a href=#parse-error-missing-doctype-name id=before-doctype-name-state:parse-error-missing-doctype-name>missing-doctype-name</a>
|
||
<a href=#parse-errors id=before-doctype-name-state:parse-errors-2>parse error</a>. Create a new DOCTYPE token. Set its <i id=before-doctype-name-state:force-quirks-flag><a href=#force-quirks-flag>force-quirks flag</a></i> to <i>on</i>. Switch to the <a href=#data-state id=before-doctype-name-state:data-state>data
|
||
state</a>. Emit the token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-doctype id=before-doctype-name-state:parse-error-eof-in-doctype>eof-in-doctype</a> <a href=#parse-errors id=before-doctype-name-state:parse-errors-3>parse
|
||
error</a>. Create a new DOCTYPE token. Set its <i id=before-doctype-name-state:force-quirks-flag-2><a href=#force-quirks-flag> force-quirks
|
||
flag</a></i> to <i>on</i>. Emit the token. Emit an end-of-file token.<dt>Anything else<dd>Create a new DOCTYPE token. Set the token's name to the <a href=#current-input-character id=before-doctype-name-state:current-input-character-2>current input character</a>.
|
||
Switch to the <a href=#doctype-name-state id=before-doctype-name-state:doctype-name-state-3>DOCTYPE name state</a>.</dl>
|
||
|
||
|
||
<h5 id=doctype-name-state><span class=secno>12.2.5.55</span> <dfn>DOCTYPE name state</dfn><a href=#doctype-name-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=doctype-name-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Switch to the <a href=#after-doctype-name-state id=doctype-name-state:after-doctype-name-state>after DOCTYPE name state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=doctype-name-state:data-state>data state</a>. Emit the current DOCTYPE token.<dt><a id=doctype-name-state:uppercase-ascii-letters href=https://infra.spec.whatwg.org/#ascii-upper-alpha data-x-internal=uppercase-ascii-letters>ASCII upper alpha</a><dd>Append the lowercase version of the <a href=#current-input-character id=doctype-name-state:current-input-character>current input character</a> (add 0x0020 to the
|
||
character's code point) to the current DOCTYPE token's name.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=doctype-name-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=doctype-name-state:parse-errors>parse
|
||
error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current DOCTYPE token's
|
||
name.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-doctype id=doctype-name-state:parse-error-eof-in-doctype>eof-in-doctype</a> <a href=#parse-errors id=doctype-name-state:parse-errors-2>parse
|
||
error</a>. Set the DOCTYPE token's <i id=doctype-name-state:force-quirks-flag><a href=#force-quirks-flag>force-quirks flag</a></i> to
|
||
<i>on</i>. Emit that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<dd>Append the <a href=#current-input-character id=doctype-name-state:current-input-character-2>current input character</a> to the current DOCTYPE token's name.</dl>
|
||
|
||
|
||
<h5 id=after-doctype-name-state><span class=secno>12.2.5.56</span> <dfn>After DOCTYPE name state</dfn><a href=#after-doctype-name-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=after-doctype-name-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=after-doctype-name-state:data-state>data state</a>. Emit the current DOCTYPE token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-doctype id=after-doctype-name-state:parse-error-eof-in-doctype>eof-in-doctype</a> <a href=#parse-errors id=after-doctype-name-state:parse-errors>parse
|
||
error</a>. Set the DOCTYPE token's <i id=after-doctype-name-state:force-quirks-flag><a href=#force-quirks-flag>force-quirks flag</a></i> to
|
||
<i>on</i>. Emit that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<dd>
|
||
|
||
<p>If the six characters starting from the <a href=#current-input-character id=after-doctype-name-state:current-input-character>current input character</a> are an
|
||
<a id=after-doctype-name-state:ascii-case-insensitive href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> match for the word "PUBLIC", then consume those characters
|
||
and switch to the <a href=#after-doctype-public-keyword-state id=after-doctype-name-state:after-doctype-public-keyword-state>after DOCTYPE public keyword state</a>.</p>
|
||
|
||
<p>Otherwise, if the six characters starting from the <a href=#current-input-character id=after-doctype-name-state:current-input-character-2>current input character</a> are
|
||
an <a id=after-doctype-name-state:ascii-case-insensitive-2 href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> match for the word "SYSTEM", then consume those
|
||
characters and switch to the <a href=#after-doctype-system-keyword-state id=after-doctype-name-state:after-doctype-system-keyword-state>after DOCTYPE system keyword state</a>.</p>
|
||
|
||
<p>Otherwise, this is an <a href=#parse-error-invalid-character-sequence-after-doctype-name id=after-doctype-name-state:parse-error-invalid-character-sequence-after-doctype-name>invalid-character-sequence-after-doctype-name</a>
|
||
<a href=#parse-errors id=after-doctype-name-state:parse-errors-2>parse error</a>. Set the DOCTYPE token's <i id=after-doctype-name-state:force-quirks-flag-2><a href=#force-quirks-flag>force-quirks
|
||
flag</a></i> to <i>on</i>. <a href=#reconsume id=after-doctype-name-state:reconsume>Reconsume</a> in the <a href=#bogus-doctype-state id=after-doctype-name-state:bogus-doctype-state>bogus DOCTYPE state</a>.</p>
|
||
|
||
</dl>
|
||
|
||
|
||
<h5 id=after-doctype-public-keyword-state><span class=secno>12.2.5.57</span> <dfn>After DOCTYPE public keyword state</dfn><a href=#after-doctype-public-keyword-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=after-doctype-public-keyword-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Switch to the <a href=#before-doctype-public-identifier-state id=after-doctype-public-keyword-state:before-doctype-public-identifier-state>before DOCTYPE public identifier state</a>.<dt>U+0022 QUOTATION MARK (")<dd>This is a <a href=#parse-error-missing-whitespace-after-doctype-public-keyword id=after-doctype-public-keyword-state:parse-error-missing-whitespace-after-doctype-public-keyword>missing-whitespace-after-doctype-public-keyword</a>
|
||
<a href=#parse-errors id=after-doctype-public-keyword-state:parse-errors>parse error</a>. Set the DOCTYPE token's public identifier to the empty string (not
|
||
missing), then switch to the <a href=#doctype-public-identifier-(double-quoted)-state id=after-doctype-public-keyword-state:doctype-public-identifier-(double-quoted)-state>DOCTYPE public identifier (double-quoted) state</a>.<dt>U+0027 APOSTROPHE (')<dd>This is a <a href=#parse-error-missing-whitespace-after-doctype-public-keyword id=after-doctype-public-keyword-state:parse-error-missing-whitespace-after-doctype-public-keyword-2>missing-whitespace-after-doctype-public-keyword</a>
|
||
<a href=#parse-errors id=after-doctype-public-keyword-state:parse-errors-2>parse error</a>. Set the DOCTYPE token's public identifier to the empty string (not
|
||
missing), then switch to the <a href=#doctype-public-identifier-(single-quoted)-state id=after-doctype-public-keyword-state:doctype-public-identifier-(single-quoted)-state>DOCTYPE public identifier (single-quoted) state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd>This is a <a href=#parse-error-missing-doctype-public-identifier id=after-doctype-public-keyword-state:parse-error-missing-doctype-public-identifier>missing-doctype-public-identifier</a> <a href=#parse-errors id=after-doctype-public-keyword-state:parse-errors-3>parse
|
||
error</a>. Set the DOCTYPE token's <i id=after-doctype-public-keyword-state:force-quirks-flag><a href=#force-quirks-flag>force-quirks flag</a></i> to
|
||
<i>on</i>. Switch to the <a href=#data-state id=after-doctype-public-keyword-state:data-state>data state</a>. Emit that DOCTYPE token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-doctype id=after-doctype-public-keyword-state:parse-error-eof-in-doctype>eof-in-doctype</a> <a href=#parse-errors id=after-doctype-public-keyword-state:parse-errors-4>parse
|
||
error</a>. Set the DOCTYPE token's <i id=after-doctype-public-keyword-state:force-quirks-flag-2><a href=#force-quirks-flag>force-quirks flag</a></i> to
|
||
<i>on</i>. Emit that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<dd>This is a <a href=#parse-error-missing-quote-before-doctype-public-identifier id=after-doctype-public-keyword-state:parse-error-missing-quote-before-doctype-public-identifier>missing-quote-before-doctype-public-identifier</a>
|
||
<a href=#parse-errors id=after-doctype-public-keyword-state:parse-errors-5>parse error</a>. Set the DOCTYPE token's <i id=after-doctype-public-keyword-state:force-quirks-flag-3><a href=#force-quirks-flag>force-quirks
|
||
flag</a></i> to <i>on</i>. <a href=#reconsume id=after-doctype-public-keyword-state:reconsume>Reconsume</a> in the <a href=#bogus-doctype-state id=after-doctype-public-keyword-state:bogus-doctype-state>bogus DOCTYPE state</a>.</dl>
|
||
|
||
|
||
<h5 id=before-doctype-public-identifier-state><span class=secno>12.2.5.58</span> <dfn>Before DOCTYPE public identifier state</dfn><a href=#before-doctype-public-identifier-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=before-doctype-public-identifier-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<dt>U+0022 QUOTATION MARK (")<dd>Set the DOCTYPE token's public identifier to the empty string (not missing), then switch to
|
||
the <a href=#doctype-public-identifier-(double-quoted)-state id=before-doctype-public-identifier-state:doctype-public-identifier-(double-quoted)-state>DOCTYPE public identifier (double-quoted) state</a>.<dt>U+0027 APOSTROPHE (')<dd>Set the DOCTYPE token's public identifier to the empty string (not missing), then switch to
|
||
the <a href=#doctype-public-identifier-(single-quoted)-state id=before-doctype-public-identifier-state:doctype-public-identifier-(single-quoted)-state>DOCTYPE public identifier (single-quoted) state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd>This is a <a href=#parse-error-missing-doctype-public-identifier id=before-doctype-public-identifier-state:parse-error-missing-doctype-public-identifier>missing-doctype-public-identifier</a>
|
||
<a href=#parse-errors id=before-doctype-public-identifier-state:parse-errors>parse error</a>. Set the DOCTYPE token's <i id=before-doctype-public-identifier-state:force-quirks-flag><a href=#force-quirks-flag>force-quirks
|
||
flag</a></i> to <i>on</i>. Switch to the <a href=#data-state id=before-doctype-public-identifier-state:data-state>data state</a>. Emit that DOCTYPE token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-doctype id=before-doctype-public-identifier-state:parse-error-eof-in-doctype>eof-in-doctype</a>
|
||
<a href=#parse-errors id=before-doctype-public-identifier-state:parse-errors-2>parse error</a>. Set the DOCTYPE token's <i id=before-doctype-public-identifier-state:force-quirks-flag-2><a href=#force-quirks-flag>force-quirks
|
||
flag</a></i> to <i>on</i>. Emit that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<dd>This is a <a href=#parse-error-missing-quote-before-doctype-public-identifier id=before-doctype-public-identifier-state:parse-error-missing-quote-before-doctype-public-identifier>missing-quote-before-doctype-public-identifier</a>
|
||
<a href=#parse-errors id=before-doctype-public-identifier-state:parse-errors-3>parse error</a>. Set the DOCTYPE token's <i id=before-doctype-public-identifier-state:force-quirks-flag-3><a href=#force-quirks-flag>force-quirks
|
||
flag</a></i> to <i>on</i>. <a href=#reconsume id=before-doctype-public-identifier-state:reconsume>Reconsume</a> in the <a href=#bogus-doctype-state id=before-doctype-public-identifier-state:bogus-doctype-state>bogus DOCTYPE state</a>.</dl>
|
||
|
||
|
||
<h5 id=doctype-public-identifier-(double-quoted)-state><span class=secno>12.2.5.59</span> <dfn>DOCTYPE public identifier (double-quoted) state</dfn><a href=#doctype-public-identifier-(double-quoted)-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=doctype-public-identifier-(double-quoted)-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0022 QUOTATION MARK (")<dd>Switch to the <a href=#after-doctype-public-identifier-state id=doctype-public-identifier-(double-quoted)-state:after-doctype-public-identifier-state>after DOCTYPE public identifier state</a>.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=doctype-public-identifier-(double-quoted)-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=doctype-public-identifier-(double-quoted)-state:parse-errors>parse
|
||
error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current DOCTYPE token's
|
||
public identifier.<dt>U+003E GREATER-THAN SIGN (>)<dd>This is an <a href=#parse-error-abrupt-doctype-public-identifier id=doctype-public-identifier-(double-quoted)-state:parse-error-abrupt-doctype-public-identifier>abrupt-doctype-public-identifier</a>
|
||
<a href=#parse-errors id=doctype-public-identifier-(double-quoted)-state:parse-errors-2>parse error</a>. Set the DOCTYPE token's <i id=doctype-public-identifier-(double-quoted)-state:force-quirks-flag><a href=#force-quirks-flag>force-quirks
|
||
flag</a></i> to <i>on</i>. Switch to the <a href=#data-state id=doctype-public-identifier-(double-quoted)-state:data-state>data state</a>. Emit that DOCTYPE token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-doctype id=doctype-public-identifier-(double-quoted)-state:parse-error-eof-in-doctype>eof-in-doctype</a> <a href=#parse-errors id=doctype-public-identifier-(double-quoted)-state:parse-errors-3>parse
|
||
error</a>. Set the DOCTYPE token's <i id=doctype-public-identifier-(double-quoted)-state:force-quirks-flag-2><a href=#force-quirks-flag>force-quirks flag</a></i> to
|
||
<i>on</i>. Emit that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<dd>Append the <a href=#current-input-character id=doctype-public-identifier-(double-quoted)-state:current-input-character>current input character</a> to the current DOCTYPE token's public
|
||
identifier.</dl>
|
||
|
||
|
||
<h5 id=doctype-public-identifier-(single-quoted)-state><span class=secno>12.2.5.60</span> <dfn>DOCTYPE public identifier (single-quoted) state</dfn><a href=#doctype-public-identifier-(single-quoted)-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=doctype-public-identifier-(single-quoted)-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0027 APOSTROPHE (')<dd>Switch to the <a href=#after-doctype-public-identifier-state id=doctype-public-identifier-(single-quoted)-state:after-doctype-public-identifier-state>after DOCTYPE public identifier state</a>.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=doctype-public-identifier-(single-quoted)-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=doctype-public-identifier-(single-quoted)-state:parse-errors>parse
|
||
error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current DOCTYPE token's
|
||
public identifier.<dt>U+003E GREATER-THAN SIGN (>)<dd>This is an <a href=#parse-error-abrupt-doctype-public-identifier id=doctype-public-identifier-(single-quoted)-state:parse-error-abrupt-doctype-public-identifier>abrupt-doctype-public-identifier</a>
|
||
<a href=#parse-errors id=doctype-public-identifier-(single-quoted)-state:parse-errors-2>parse error</a>. Set the DOCTYPE token's <i id=doctype-public-identifier-(single-quoted)-state:force-quirks-flag><a href=#force-quirks-flag>force-quirks
|
||
flag</a></i> to <i>on</i>. Switch to the <a href=#data-state id=doctype-public-identifier-(single-quoted)-state:data-state>data state</a>. Emit that DOCTYPE token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-doctype id=doctype-public-identifier-(single-quoted)-state:parse-error-eof-in-doctype>eof-in-doctype</a> <a href=#parse-errors id=doctype-public-identifier-(single-quoted)-state:parse-errors-3>parse
|
||
error</a>. Set the DOCTYPE token's <i id=doctype-public-identifier-(single-quoted)-state:force-quirks-flag-2><a href=#force-quirks-flag>force-quirks flag</a></i> to
|
||
<i>on</i>. Emit that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<dd>Append the <a href=#current-input-character id=doctype-public-identifier-(single-quoted)-state:current-input-character>current input character</a> to the current DOCTYPE token's public
|
||
identifier.</dl>
|
||
|
||
|
||
<h5 id=after-doctype-public-identifier-state><span class=secno>12.2.5.61</span> <dfn>After DOCTYPE public identifier state</dfn><a href=#after-doctype-public-identifier-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=after-doctype-public-identifier-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Switch to the <a href=#between-doctype-public-and-system-identifiers-state id=after-doctype-public-identifier-state:between-doctype-public-and-system-identifiers-state>between DOCTYPE public and system identifiers state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=after-doctype-public-identifier-state:data-state>data state</a>. Emit the current DOCTYPE token.<dt>U+0022 QUOTATION MARK (")<dd>This is a <a href=#parse-error-missing-whitespace-between-doctype-public-and-system-identifiers id=after-doctype-public-identifier-state:parse-error-missing-whitespace-between-doctype-public-and-system-identifiers>missing-whitespace-between-doctype-public-and-system-identifiers</a>
|
||
<a href=#parse-errors id=after-doctype-public-identifier-state:parse-errors>parse error</a>. Set the DOCTYPE token's system identifier to the empty string (not
|
||
missing), then switch to the <a href=#doctype-system-identifier-(double-quoted)-state id=after-doctype-public-identifier-state:doctype-system-identifier-(double-quoted)-state>DOCTYPE system identifier (double-quoted) state</a>.<dt>U+0027 APOSTROPHE (')<dd>This is a <a href=#parse-error-missing-whitespace-between-doctype-public-and-system-identifiers id=after-doctype-public-identifier-state:parse-error-missing-whitespace-between-doctype-public-and-system-identifiers-2>missing-whitespace-between-doctype-public-and-system-identifiers</a>
|
||
<a href=#parse-errors id=after-doctype-public-identifier-state:parse-errors-2>parse error</a>. Set the DOCTYPE token's system identifier to the empty string (not
|
||
missing), then switch to the <a href=#doctype-system-identifier-(single-quoted)-state id=after-doctype-public-identifier-state:doctype-system-identifier-(single-quoted)-state>DOCTYPE system identifier (single-quoted) state</a>.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-doctype id=after-doctype-public-identifier-state:parse-error-eof-in-doctype>eof-in-doctype</a> <a href=#parse-errors id=after-doctype-public-identifier-state:parse-errors-3>parse
|
||
error</a>. Set the DOCTYPE token's <i id=after-doctype-public-identifier-state:force-quirks-flag><a href=#force-quirks-flag>force-quirks flag</a></i> to
|
||
<i>on</i>. Emit that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<dd>This is a <a href=#parse-error-missing-quote-before-doctype-system-identifier id=after-doctype-public-identifier-state:parse-error-missing-quote-before-doctype-system-identifier>missing-quote-before-doctype-system-identifier</a>
|
||
<a href=#parse-errors id=after-doctype-public-identifier-state:parse-errors-4>parse error</a>. Set the DOCTYPE token's <i id=after-doctype-public-identifier-state:force-quirks-flag-2><a href=#force-quirks-flag>force-quirks
|
||
flag</a></i> to <i>on</i>. <a href=#reconsume id=after-doctype-public-identifier-state:reconsume>Reconsume</a> in the <a href=#bogus-doctype-state id=after-doctype-public-identifier-state:bogus-doctype-state>bogus DOCTYPE state</a>.</dl>
|
||
|
||
|
||
<h5 id=between-doctype-public-and-system-identifiers-state><span class=secno>12.2.5.62</span> <dfn>Between DOCTYPE public and system identifiers state</dfn><a href=#between-doctype-public-and-system-identifiers-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=between-doctype-public-and-system-identifiers-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=between-doctype-public-and-system-identifiers-state:data-state>data state</a>. Emit the current DOCTYPE token.<dt>U+0022 QUOTATION MARK (")<dd>Set the DOCTYPE token's system identifier to the empty string (not missing), then switch to
|
||
the <a href=#doctype-system-identifier-(double-quoted)-state id=between-doctype-public-and-system-identifiers-state:doctype-system-identifier-(double-quoted)-state>DOCTYPE system identifier (double-quoted) state</a>.<dt>U+0027 APOSTROPHE (')<dd>Set the DOCTYPE token's system identifier to the empty string (not missing), then switch to
|
||
the <a href=#doctype-system-identifier-(single-quoted)-state id=between-doctype-public-and-system-identifiers-state:doctype-system-identifier-(single-quoted)-state>DOCTYPE system identifier (single-quoted) state</a>.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-doctype id=between-doctype-public-and-system-identifiers-state:parse-error-eof-in-doctype>eof-in-doctype</a> <a href=#parse-errors id=between-doctype-public-and-system-identifiers-state:parse-errors>parse
|
||
error</a>. Set the DOCTYPE token's <i id=between-doctype-public-and-system-identifiers-state:force-quirks-flag><a href=#force-quirks-flag>force-quirks flag</a></i> to
|
||
<i>on</i>. Emit that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<dd>This is a <a href=#parse-error-missing-quote-before-doctype-system-identifier id=between-doctype-public-and-system-identifiers-state:parse-error-missing-quote-before-doctype-system-identifier>missing-quote-before-doctype-system-identifier</a>
|
||
<a href=#parse-errors id=between-doctype-public-and-system-identifiers-state:parse-errors-2>parse error</a>. Set the DOCTYPE token's <i id=between-doctype-public-and-system-identifiers-state:force-quirks-flag-2><a href=#force-quirks-flag>force-quirks
|
||
flag</a></i> to <i>on</i>. <a href=#reconsume id=between-doctype-public-and-system-identifiers-state:reconsume>Reconsume</a> in the <a href=#bogus-doctype-state id=between-doctype-public-and-system-identifiers-state:bogus-doctype-state>bogus DOCTYPE state</a>.</dl>
|
||
|
||
|
||
<h5 id=after-doctype-system-keyword-state><span class=secno>12.2.5.63</span> <dfn>After DOCTYPE system keyword state</dfn><a href=#after-doctype-system-keyword-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=after-doctype-system-keyword-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Switch to the <a href=#before-doctype-system-identifier-state id=after-doctype-system-keyword-state:before-doctype-system-identifier-state>before DOCTYPE system identifier state</a>.<dt>U+0022 QUOTATION MARK (")<dd>This is a <a href=#parse-error-missing-whitespace-after-doctype-system-keyword id=after-doctype-system-keyword-state:parse-error-missing-whitespace-after-doctype-system-keyword>missing-whitespace-after-doctype-system-keyword</a>
|
||
<a href=#parse-errors id=after-doctype-system-keyword-state:parse-errors>parse error</a>. Set the DOCTYPE token's system identifier to the empty string (not
|
||
missing), then switch to the <a href=#doctype-system-identifier-(double-quoted)-state id=after-doctype-system-keyword-state:doctype-system-identifier-(double-quoted)-state>DOCTYPE system identifier (double-quoted) state</a>.<dt>U+0027 APOSTROPHE (')<dd>This is a <a href=#parse-error-missing-whitespace-after-doctype-system-keyword id=after-doctype-system-keyword-state:parse-error-missing-whitespace-after-doctype-system-keyword-2>missing-whitespace-after-doctype-system-keyword</a>
|
||
<a href=#parse-errors id=after-doctype-system-keyword-state:parse-errors-2>parse error</a>. Set the DOCTYPE token's system identifier to the empty string (not
|
||
missing), then switch to the <a href=#doctype-system-identifier-(single-quoted)-state id=after-doctype-system-keyword-state:doctype-system-identifier-(single-quoted)-state>DOCTYPE system identifier (single-quoted) state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd>This is a <a href=#parse-error-missing-doctype-system-identifier id=after-doctype-system-keyword-state:parse-error-missing-doctype-system-identifier>missing-doctype-system-identifier</a>
|
||
<a href=#parse-errors id=after-doctype-system-keyword-state:parse-errors-3>parse error</a>. Set the DOCTYPE token's <i id=after-doctype-system-keyword-state:force-quirks-flag><a href=#force-quirks-flag>force-quirks
|
||
flag</a></i> to <i>on</i>. Switch to the <a href=#data-state id=after-doctype-system-keyword-state:data-state>data state</a>. Emit that DOCTYPE token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-doctype id=after-doctype-system-keyword-state:parse-error-eof-in-doctype>eof-in-doctype</a> <a href=#parse-errors id=after-doctype-system-keyword-state:parse-errors-4>parse
|
||
error</a>. Set the DOCTYPE token's <i id=after-doctype-system-keyword-state:force-quirks-flag-2><a href=#force-quirks-flag>force-quirks flag</a></i> to
|
||
<i>on</i>. Emit that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<dd>This is a <a href=#parse-error-missing-quote-before-doctype-system-identifier id=after-doctype-system-keyword-state:parse-error-missing-quote-before-doctype-system-identifier>missing-quote-before-doctype-system-identifier</a>
|
||
<a href=#parse-errors id=after-doctype-system-keyword-state:parse-errors-5>parse error</a>. Set the DOCTYPE token's <i id=after-doctype-system-keyword-state:force-quirks-flag-3><a href=#force-quirks-flag>force-quirks
|
||
flag</a></i> to <i>on</i>. <a href=#reconsume id=after-doctype-system-keyword-state:reconsume>Reconsume</a> in the <a href=#bogus-doctype-state id=after-doctype-system-keyword-state:bogus-doctype-state>bogus DOCTYPE state</a>.</dl>
|
||
|
||
|
||
<h5 id=before-doctype-system-identifier-state><span class=secno>12.2.5.64</span> <dfn>Before DOCTYPE system identifier state</dfn><a href=#before-doctype-system-identifier-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=before-doctype-system-identifier-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<dt>U+0022 QUOTATION MARK (")<dd>Set the DOCTYPE token's system identifier to the empty string (not missing), then switch to
|
||
the <a href=#doctype-system-identifier-(double-quoted)-state id=before-doctype-system-identifier-state:doctype-system-identifier-(double-quoted)-state>DOCTYPE system identifier (double-quoted) state</a>.<dt>U+0027 APOSTROPHE (')<dd>Set the DOCTYPE token's system identifier to the empty string (not missing), then switch to
|
||
the <a href=#doctype-system-identifier-(single-quoted)-state id=before-doctype-system-identifier-state:doctype-system-identifier-(single-quoted)-state>DOCTYPE system identifier (single-quoted) state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd>This is a <a href=#parse-error-missing-doctype-system-identifier id=before-doctype-system-identifier-state:parse-error-missing-doctype-system-identifier>missing-doctype-system-identifier</a> <a href=#parse-errors id=before-doctype-system-identifier-state:parse-errors>parse
|
||
error</a>. Set the DOCTYPE token's <i id=before-doctype-system-identifier-state:force-quirks-flag><a href=#force-quirks-flag>force-quirks flag</a></i> to
|
||
<i>on</i>. Switch to the <a href=#data-state id=before-doctype-system-identifier-state:data-state>data state</a>. Emit that DOCTYPE token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-doctype id=before-doctype-system-identifier-state:parse-error-eof-in-doctype>eof-in-doctype</a> <a href=#parse-errors id=before-doctype-system-identifier-state:parse-errors-2>parse
|
||
error</a>. Set the DOCTYPE token's <i id=before-doctype-system-identifier-state:force-quirks-flag-2><a href=#force-quirks-flag>force-quirks flag</a></i> to
|
||
<i>on</i>. Emit that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<dd>This is a <a href=#parse-error-missing-quote-before-doctype-system-identifier id=before-doctype-system-identifier-state:parse-error-missing-quote-before-doctype-system-identifier>missing-quote-before-doctype-system-identifier</a>
|
||
<a href=#parse-errors id=before-doctype-system-identifier-state:parse-errors-3>parse error</a>. Set the DOCTYPE token's <i id=before-doctype-system-identifier-state:force-quirks-flag-3><a href=#force-quirks-flag>force-quirks
|
||
flag</a></i> to <i>on</i>. <a href=#reconsume id=before-doctype-system-identifier-state:reconsume>Reconsume</a> in the <a href=#bogus-doctype-state id=before-doctype-system-identifier-state:bogus-doctype-state>bogus DOCTYPE state</a>.</dl>
|
||
|
||
|
||
<h5 id=doctype-system-identifier-(double-quoted)-state><span class=secno>12.2.5.65</span> <dfn>DOCTYPE system identifier (double-quoted) state</dfn><a href=#doctype-system-identifier-(double-quoted)-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=doctype-system-identifier-(double-quoted)-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0022 QUOTATION MARK (")<dd>Switch to the <a href=#after-doctype-system-identifier-state id=doctype-system-identifier-(double-quoted)-state:after-doctype-system-identifier-state>after DOCTYPE system identifier state</a>.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=doctype-system-identifier-(double-quoted)-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=doctype-system-identifier-(double-quoted)-state:parse-errors>parse
|
||
error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current DOCTYPE token's
|
||
system identifier.<dt>U+003E GREATER-THAN SIGN (>)<dd>This is an <a href=#parse-error-abrupt-doctype-system-identifier id=doctype-system-identifier-(double-quoted)-state:parse-error-abrupt-doctype-system-identifier>abrupt-doctype-system-identifier</a>
|
||
<a href=#parse-errors id=doctype-system-identifier-(double-quoted)-state:parse-errors-2>parse error</a>. Set the DOCTYPE token's <i id=doctype-system-identifier-(double-quoted)-state:force-quirks-flag><a href=#force-quirks-flag>force-quirks
|
||
flag</a></i> to <i>on</i>. Switch to the <a href=#data-state id=doctype-system-identifier-(double-quoted)-state:data-state>data state</a>. Emit that DOCTYPE token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-doctype id=doctype-system-identifier-(double-quoted)-state:parse-error-eof-in-doctype>eof-in-doctype</a> <a href=#parse-errors id=doctype-system-identifier-(double-quoted)-state:parse-errors-3>parse
|
||
error</a>. Set the DOCTYPE token's <i id=doctype-system-identifier-(double-quoted)-state:force-quirks-flag-2><a href=#force-quirks-flag>force-quirks flag</a></i> to
|
||
<i>on</i>. Emit that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<dd>Append the <a href=#current-input-character id=doctype-system-identifier-(double-quoted)-state:current-input-character>current input character</a> to the current DOCTYPE token's system
|
||
identifier.</dl>
|
||
|
||
|
||
<h5 id=doctype-system-identifier-(single-quoted)-state><span class=secno>12.2.5.66</span> <dfn>DOCTYPE system identifier (single-quoted) state</dfn><a href=#doctype-system-identifier-(single-quoted)-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=doctype-system-identifier-(single-quoted)-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0027 APOSTROPHE (')<dd>Switch to the <a href=#after-doctype-system-identifier-state id=doctype-system-identifier-(single-quoted)-state:after-doctype-system-identifier-state>after DOCTYPE system identifier state</a>.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=doctype-system-identifier-(single-quoted)-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=doctype-system-identifier-(single-quoted)-state:parse-errors>parse
|
||
error</a>. Append a U+FFFD REPLACEMENT CHARACTER character to the current DOCTYPE token's
|
||
system identifier.<dt>U+003E GREATER-THAN SIGN (>)<dd>This is an <a href=#parse-error-abrupt-doctype-system-identifier id=doctype-system-identifier-(single-quoted)-state:parse-error-abrupt-doctype-system-identifier>abrupt-doctype-system-identifier</a>
|
||
<a href=#parse-errors id=doctype-system-identifier-(single-quoted)-state:parse-errors-2>parse error</a>. Set the DOCTYPE token's <i id=doctype-system-identifier-(single-quoted)-state:force-quirks-flag><a href=#force-quirks-flag>force-quirks
|
||
flag</a></i> to <i>on</i>. Switch to the <a href=#data-state id=doctype-system-identifier-(single-quoted)-state:data-state>data state</a>. Emit that DOCTYPE token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-doctype id=doctype-system-identifier-(single-quoted)-state:parse-error-eof-in-doctype>eof-in-doctype</a> <a href=#parse-errors id=doctype-system-identifier-(single-quoted)-state:parse-errors-3>parse
|
||
error</a>. Set the DOCTYPE token's <i id=doctype-system-identifier-(single-quoted)-state:force-quirks-flag-2><a href=#force-quirks-flag>force-quirks flag</a></i> to
|
||
<i>on</i>. Emit that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<dd>Append the <a href=#current-input-character id=doctype-system-identifier-(single-quoted)-state:current-input-character>current input character</a> to the current DOCTYPE token's system
|
||
identifier.</dl>
|
||
|
||
|
||
<h5 id=after-doctype-system-identifier-state><span class=secno>12.2.5.67</span> <dfn>After DOCTYPE system identifier state</dfn><a href=#after-doctype-system-identifier-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=after-doctype-system-identifier-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0009 CHARACTER TABULATION (tab)<dt>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=after-doctype-system-identifier-state:data-state>data state</a>. Emit the current DOCTYPE token.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-doctype id=after-doctype-system-identifier-state:parse-error-eof-in-doctype>eof-in-doctype</a> <a href=#parse-errors id=after-doctype-system-identifier-state:parse-errors>parse
|
||
error</a>. Set the DOCTYPE token's <i id=after-doctype-system-identifier-state:force-quirks-flag><a href=#force-quirks-flag>force-quirks flag</a></i> to
|
||
<i>on</i>. Emit that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<dd>This is an <a href=#parse-error-unexpected-character-after-doctype-system-identifier id=after-doctype-system-identifier-state:parse-error-unexpected-character-after-doctype-system-identifier>unexpected-character-after-doctype-system-identifier</a>
|
||
<a href=#parse-errors id=after-doctype-system-identifier-state:parse-errors-2>parse error</a>. <a href=#reconsume id=after-doctype-system-identifier-state:reconsume>Reconsume</a> in the <a href=#bogus-doctype-state id=after-doctype-system-identifier-state:bogus-doctype-state>bogus DOCTYPE state</a>. (This
|
||
does <em>not</em> set the DOCTYPE token's <i id=after-doctype-system-identifier-state:force-quirks-flag-2><a href=#force-quirks-flag>force-quirks flag</a></i> to
|
||
<i>on</i>.)</dl>
|
||
|
||
|
||
<h5 id=bogus-doctype-state><span class=secno>12.2.5.68</span> <dfn>Bogus DOCTYPE state</dfn><a href=#bogus-doctype-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=bogus-doctype-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=bogus-doctype-state:data-state>data state</a>. Emit the DOCTYPE token.<dt>U+0000 NULL<dd>This is an <a href=#parse-error-unexpected-null-character id=bogus-doctype-state:parse-error-unexpected-null-character>unexpected-null-character</a> <a href=#parse-errors id=bogus-doctype-state:parse-errors>parse
|
||
error</a>. Ignore the character.<dt>EOF<dd>Emit the DOCTYPE token. Emit an end-of-file token.<dt>Anything else<dd>Ignore the character.</dl>
|
||
|
||
|
||
<h5 id=cdata-section-state><span class=secno>12.2.5.69</span> <dfn>CDATA section state</dfn><a href=#cdata-section-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=cdata-section-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+005D RIGHT SQUARE BRACKET (])<dd>Switch to the <a href=#cdata-section-bracket-state id=cdata-section-state:cdata-section-bracket-state>CDATA section bracket state</a>.<dt>EOF<dd>This is an <a href=#parse-error-eof-in-cdata id=cdata-section-state:parse-error-eof-in-cdata>eof-in-cdata</a> <a href=#parse-errors id=cdata-section-state:parse-errors>parse
|
||
error</a>. Emit an end-of-file token.<dt>Anything else<dd>Emit the <a href=#current-input-character id=cdata-section-state:current-input-character>current input character</a> as a character token.</dl>
|
||
|
||
<p class=note>U+0000 NULL characters are handled in the tree construction stage, as part of the
|
||
<a href=#parsing-main-inforeign id=cdata-section-state:parsing-main-inforeign>in foreign content</a> insertion mode, which
|
||
is the only place where CDATA sections can appear.</p>
|
||
|
||
<h5 id=cdata-section-bracket-state><span class=secno>12.2.5.70</span> <dfn>CDATA section bracket state</dfn><a href=#cdata-section-bracket-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=cdata-section-bracket-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+005D RIGHT SQUARE BRACKET (])<dd>Switch to the <a href=#cdata-section-end-state id=cdata-section-bracket-state:cdata-section-end-state>CDATA section end state</a>.<dt>Anything else<dd>Emit a U+005D RIGHT SQUARE BRACKET character token. <a href=#reconsume id=cdata-section-bracket-state:reconsume>Reconsume</a> in the
|
||
<a href=#cdata-section-state id=cdata-section-bracket-state:cdata-section-state>CDATA section state</a>.</dl>
|
||
|
||
|
||
<h5 id=cdata-section-end-state><span class=secno>12.2.5.71</span> <dfn>CDATA section end state</dfn><a href=#cdata-section-end-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=cdata-section-end-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+005D RIGHT SQUARE BRACKET (])<dd>Emit a U+005D RIGHT SQUARE BRACKET character token.<dt>U+003E GREATER-THAN SIGN character<dd>Switch to the <a href=#data-state id=cdata-section-end-state:data-state>data state</a>.<dt>Anything else<dd>Emit two U+005D RIGHT SQUARE BRACKET character tokens. <a href=#reconsume id=cdata-section-end-state:reconsume>Reconsume</a> in the
|
||
<a href=#cdata-section-state id=cdata-section-end-state:cdata-section-state>CDATA section state</a>.</dl>
|
||
|
||
|
||
|
||
<h5 id=character-reference-state><span class=secno>12.2.5.72</span> <dfn>Character reference state</dfn><a href=#character-reference-state class=self-link></a></h5>
|
||
|
||
<p>Set the <var id=character-reference-state:temporary-buffer><a href=#temporary-buffer>temporary buffer</a></var> to the empty string. Append
|
||
a U+0026 AMPERSAND (&) character to the <var id=character-reference-state:temporary-buffer-2><a href=#temporary-buffer>temporary
|
||
buffer</a></var>. Consume the <a href=#next-input-character id=character-reference-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt><a href=https://infra.spec.whatwg.org/#ascii-alphanumeric id=character-reference-state:alphanumeric-ascii-characters data-x-internal=alphanumeric-ascii-characters>ASCII alphanumeric</a><dd><a href=#reconsume id=character-reference-state:reconsume>Reconsume</a> in the <a href=#named-character-reference-state id=character-reference-state:named-character-reference-state>named character reference state</a>.<dt>U+0023 NUMBER SIGN (#)<dd>Append the <a href=#current-input-character id=character-reference-state:current-input-character>current input character</a> to the
|
||
<var id=character-reference-state:temporary-buffer-3><a href=#temporary-buffer>temporary buffer</a></var>. Switch to the <a href=#numeric-character-reference-state id=character-reference-state:numeric-character-reference-state>numeric character
|
||
reference state</a>.<dt>Anything else<dd><a href=#flush-code-points-consumed-as-a-character-reference id=character-reference-state:flush-code-points-consumed-as-a-character-reference>Flush code points consumed as a character reference</a>. <a href=#reconsume id=character-reference-state:reconsume-2>Reconsume</a> in
|
||
the <var id=character-reference-state:return-state><a href=#return-state>return state</a></var>.</dl>
|
||
|
||
|
||
<h5 id=named-character-reference-state><span class=secno>12.2.5.73</span> <dfn>Named character reference state</dfn><a href=#named-character-reference-state class=self-link></a></h5>
|
||
|
||
<p>Consume the maximum number of characters possible, with the consumed characters matching one
|
||
of the identifiers in the first column of the <a id=named-character-reference-state:named-character-references href=named-characters.html#named-character-references>named character references</a> table (in
|
||
a <a id=named-character-reference-state:case-sensitive href=infrastructure.html#case-sensitive>case-sensitive</a> manner). Append each character to the <var id=named-character-reference-state:temporary-buffer><a href=#temporary-buffer>temporary buffer</a></var> when it's consumed.</p>
|
||
|
||
<dl class=switch><dt>If there is a match<dd>
|
||
<p>If the character reference was <a href=#charref-in-attribute id=named-character-reference-state:charref-in-attribute>consumed as part of an
|
||
attribute</a>, and the last character matched is not a U+003B SEMICOLON character (;), and
|
||
the <a href=#next-input-character id=named-character-reference-state:next-input-character>next input character</a> is either a U+003D EQUALS SIGN character (=) or an
|
||
<a id=named-character-reference-state:alphanumeric-ascii-characters href=https://infra.spec.whatwg.org/#ascii-alphanumeric data-x-internal=alphanumeric-ascii-characters>ASCII alphanumeric</a>, then, for historical reasons, <a href=#flush-code-points-consumed-as-a-character-reference id=named-character-reference-state:flush-code-points-consumed-as-a-character-reference>flush code points consumed
|
||
as a character reference</a> and switch to the <var id=named-character-reference-state:return-state><a href=#return-state>return state</a></var>.
|
||
</p>
|
||
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
<ol><li><p>If the last character matched is not a U+003B SEMICOLON character (;), then this is a
|
||
<a href=#parse-error-missing-semicolon-after-character-reference id=named-character-reference-state:parse-error-missing-semicolon-after-character-reference>missing-semicolon-after-character-reference</a>
|
||
<a href=#parse-errors id=named-character-reference-state:parse-errors>parse error</a>.<li><p>Set the <var id=named-character-reference-state:temporary-buffer-2><a href=#temporary-buffer>temporary buffer</a></var> to the empty string.
|
||
Append one or two characters corresponding to the character reference name (as given by the
|
||
second column of the <a id=named-character-reference-state:named-character-references-2 href=named-characters.html#named-character-references>named character references</a> table) to the <var id=named-character-reference-state:temporary-buffer-3><a href=#temporary-buffer>temporary buffer</a></var>.<li><a href=#flush-code-points-consumed-as-a-character-reference id=named-character-reference-state:flush-code-points-consumed-as-a-character-reference-2>Flush code points consumed as a character reference</a>. Switch to the <var id=named-character-reference-state:return-state-2><a href=#return-state>return state</a></var>.</ol>
|
||
<dt>Otherwise<dd><a href=#flush-code-points-consumed-as-a-character-reference id=named-character-reference-state:flush-code-points-consumed-as-a-character-reference-3>Flush code points consumed as a character reference</a>. Switch to the
|
||
<a href=#ambiguous-ampersand-state id=named-character-reference-state:ambiguous-ampersand-state>ambiguous ampersand state</a>.</dl>
|
||
|
||
<div class=example>
|
||
|
||
<p>If the markup contains (not in an attribute) the string <code>I'm &notit; I
|
||
tell you</code>, the character reference is parsed as "not", as in, <code>I'm ¬it;
|
||
I tell you</code> (and this is a parse error). But if the markup was <code>I'm
|
||
&notin; I tell you</code>, the character reference would be parsed as "notin;", resulting
|
||
in <code>I'm ∉ I tell you</code> (and no parse error).</p>
|
||
|
||
<p>However, if the markup contains the string <code>I'm &notit; I tell you</code>
|
||
in an attribute, no character reference is parsed and string remains intact (and there is no
|
||
parse error).</p>
|
||
|
||
</div>
|
||
|
||
|
||
<h5 id=ambiguous-ampersand-state><span class=secno>12.2.5.74</span> <dfn>Ambiguous ampersand state</dfn><a href=#ambiguous-ampersand-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=ambiguous-ampersand-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt><a href=https://infra.spec.whatwg.org/#ascii-alphanumeric id=ambiguous-ampersand-state:alphanumeric-ascii-characters data-x-internal=alphanumeric-ascii-characters>ASCII alphanumeric</a><dd>If the character reference was <a href=#charref-in-attribute id=ambiguous-ampersand-state:charref-in-attribute>consumed as part of an
|
||
attribute</a>, then append the <a href=#current-input-character id=ambiguous-ampersand-state:current-input-character>current input character</a> to the current
|
||
attribute's value. Otherwise, emit the <a href=#current-input-character id=ambiguous-ampersand-state:current-input-character-2>current input character</a> as a character
|
||
token.<dt>U+003B SEMICOLON (;)<dd>This is an <a href=#parse-error-unknown-named-character-reference id=ambiguous-ampersand-state:parse-error-unknown-named-character-reference>unknown-named-character-reference</a>
|
||
<a href=#parse-errors id=ambiguous-ampersand-state:parse-errors>parse error</a>. <a href=#reconsume id=ambiguous-ampersand-state:reconsume>Reconsume</a> in the <var id=ambiguous-ampersand-state:return-state><a href=#return-state>return
|
||
state</a></var>.
|
||
|
||
<dt>Anything else<dd><a href=#reconsume id=ambiguous-ampersand-state:reconsume-2>Reconsume</a> in the <var id=ambiguous-ampersand-state:return-state-2><a href=#return-state>return state</a></var>.</dl>
|
||
|
||
<h5 id=numeric-character-reference-state><span class=secno>12.2.5.75</span> <dfn>Numeric character reference state</dfn><a href=#numeric-character-reference-state class=self-link></a></h5>
|
||
|
||
<p>Set the <dfn id=character-reference-code><var>character reference code</var></dfn> to
|
||
zero (0).</p>
|
||
|
||
<p>Consume the <a href=#next-input-character id=numeric-character-reference-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt>U+0078 LATIN SMALL LETTER X<dt>U+0058 LATIN CAPITAL LETTER X<dd>Append the <a href=#current-input-character id=numeric-character-reference-state:current-input-character>current input character</a> to the <var id=numeric-character-reference-state:temporary-buffer><a href=#temporary-buffer>temporary buffer</a></var>. Switch to the <a href=#hexademical-character-reference-start-state id=numeric-character-reference-state:hexademical-character-reference-start-state>hexademical character reference start
|
||
state</a>.<dt>Anything else<dd><a href=#reconsume id=numeric-character-reference-state:reconsume>Reconsume</a> in the <a href=#decimal-character-reference-start-state id=numeric-character-reference-state:decimal-character-reference-start-state>decimal character reference start state</a>.</dl>
|
||
|
||
|
||
<h5 id=hexademical-character-reference-start-state><span class=secno>12.2.5.76</span> <dfn>Hexademical character reference start state</dfn><a href=#hexademical-character-reference-start-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=hexademical-character-reference-start-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt><a href=https://infra.spec.whatwg.org/#ascii-hex-digit id=hexademical-character-reference-start-state:ascii-hex-digits data-x-internal=ascii-hex-digits>ASCII hex digit</a><dd><a href=#reconsume id=hexademical-character-reference-start-state:reconsume>Reconsume</a> in the <a href=#hexademical-character-reference-state id=hexademical-character-reference-start-state:hexademical-character-reference-state>hexademical character reference state</a>.<dt>Anything else<dd>This is an <a href=#parse-error-absence-of-digits-in-numeric-character-reference id=hexademical-character-reference-start-state:parse-error-absence-of-digits-in-numeric-character-reference>absence-of-digits-in-numeric-character-reference</a>
|
||
<a href=#parse-errors id=hexademical-character-reference-start-state:parse-errors>parse error</a>. <a href=#flush-code-points-consumed-as-a-character-reference id=hexademical-character-reference-start-state:flush-code-points-consumed-as-a-character-reference>Flush code points consumed as a character reference</a>.
|
||
<a href=#reconsume id=hexademical-character-reference-start-state:reconsume-2>Reconsume</a> in the <var id=hexademical-character-reference-start-state:return-state><a href=#return-state>return state</a></var>.</dl>
|
||
|
||
|
||
<h5 id=decimal-character-reference-start-state><span class=secno>12.2.5.77</span> <dfn>Decimal character reference start state</dfn><a href=#decimal-character-reference-start-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=decimal-character-reference-start-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt><a href=https://infra.spec.whatwg.org/#ascii-digit id=decimal-character-reference-start-state:ascii-digits data-x-internal=ascii-digits>ASCII digit</a><dd><a href=#reconsume id=decimal-character-reference-start-state:reconsume>Reconsume</a> in the <a href=#decimal-character-reference-state id=decimal-character-reference-start-state:decimal-character-reference-state>decimal character reference state</a>.<dt>Anything else<dd>This is an <a href=#parse-error-absence-of-digits-in-numeric-character-reference id=decimal-character-reference-start-state:parse-error-absence-of-digits-in-numeric-character-reference>absence-of-digits-in-numeric-character-reference</a>
|
||
<a href=#parse-errors id=decimal-character-reference-start-state:parse-errors>parse error</a>. <a href=#flush-code-points-consumed-as-a-character-reference id=decimal-character-reference-start-state:flush-code-points-consumed-as-a-character-reference>Flush code points consumed as a character reference</a>.
|
||
<a href=#reconsume id=decimal-character-reference-start-state:reconsume-2>Reconsume</a> in the <var id=decimal-character-reference-start-state:return-state><a href=#return-state>return state</a></var>.</dl>
|
||
|
||
|
||
<h5 id=hexademical-character-reference-state><span class=secno>12.2.5.78</span> <dfn>Hexademical character reference state</dfn><a href=#hexademical-character-reference-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=hexademical-character-reference-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt><a href=https://infra.spec.whatwg.org/#ascii-digit id=hexademical-character-reference-state:ascii-digits data-x-internal=ascii-digits>ASCII digit</a><dd>Multiply the <var id=hexademical-character-reference-state:character-reference-code><a href=#character-reference-code>character reference code</a></var> by 16.
|
||
Add a numeric version of the <a href=#current-input-character id=hexademical-character-reference-state:current-input-character>current input character</a> (subtract 0x0030 from the
|
||
character's code point) to the <var id=hexademical-character-reference-state:character-reference-code-2><a href=#character-reference-code>character reference
|
||
code</a></var>.<dt><a id=hexademical-character-reference-state:uppercase-ascii-hex-digits href=https://infra.spec.whatwg.org/#ascii-upper-hex-digit data-x-internal=uppercase-ascii-hex-digits>ASCII upper hex digit</a><dd>Multiply the <var id=hexademical-character-reference-state:character-reference-code-3><a href=#character-reference-code>character reference code</a></var> by 16.
|
||
Add a numeric version of the <a href=#current-input-character id=hexademical-character-reference-state:current-input-character-2>current input character</a> as a hexademical digit
|
||
(subtract 0x0037 from the character's code point) to the <var id=hexademical-character-reference-state:character-reference-code-4><a href=#character-reference-code>character reference code</a></var>.<dt><a id=hexademical-character-reference-state:lowercase-ascii-hex-digits href=https://infra.spec.whatwg.org/#ascii-lower-hex-digit data-x-internal=lowercase-ascii-hex-digits>ASCII lower hex digit</a><dd>Multiply the <var id=hexademical-character-reference-state:character-reference-code-5><a href=#character-reference-code>character reference code</a></var> by 16.
|
||
Add a numeric version of the <a href=#current-input-character id=hexademical-character-reference-state:current-input-character-3>current input character</a> as a hexademical digit
|
||
(subtract 0x0057 from the character's code point) to the <var id=hexademical-character-reference-state:character-reference-code-6><a href=#character-reference-code>character reference code</a></var>.<dt>U+003B SEMICOLON<dd>Switch to the <a href=#numeric-character-reference-end-state id=hexademical-character-reference-state:numeric-character-reference-end-state>numeric character reference end state</a>.<dt>Anything else<dd>This is a <a href=#parse-error-missing-semicolon-after-character-reference id=hexademical-character-reference-state:parse-error-missing-semicolon-after-character-reference>missing-semicolon-after-character-reference</a>
|
||
<a href=#parse-errors id=hexademical-character-reference-state:parse-errors>parse error</a>. <a href=#reconsume id=hexademical-character-reference-state:reconsume>Reconsume</a> in the <a href=#numeric-character-reference-end-state id=hexademical-character-reference-state:numeric-character-reference-end-state-2>numeric character reference end
|
||
state</a>.</dl>
|
||
|
||
|
||
<h5 id=decimal-character-reference-state><span class=secno>12.2.5.79</span> <dfn>Decimal character reference state</dfn><a href=#decimal-character-reference-state class=self-link></a></h5>
|
||
|
||
<p>Consume the <a href=#next-input-character id=decimal-character-reference-state:next-input-character>next input character</a>:</p>
|
||
|
||
<dl class=switch><dt><a href=https://infra.spec.whatwg.org/#ascii-digit id=decimal-character-reference-state:ascii-digits data-x-internal=ascii-digits>ASCII digit</a><dd>Multiply the <var id=decimal-character-reference-state:character-reference-code><a href=#character-reference-code>character reference code</a></var> by 10.
|
||
Add a numeric version of the <a href=#current-input-character id=decimal-character-reference-state:current-input-character>current input character</a> (subtract 0x0030 from the
|
||
character's code point) to the <var id=decimal-character-reference-state:character-reference-code-2><a href=#character-reference-code>character reference
|
||
code</a></var>.<dt>U+003B SEMICOLON<dd>Switch to the <a href=#numeric-character-reference-end-state id=decimal-character-reference-state:numeric-character-reference-end-state>numeric character reference end state</a>.<dt>Anything else<dd>This is a <a href=#parse-error-missing-semicolon-after-character-reference id=decimal-character-reference-state:parse-error-missing-semicolon-after-character-reference>missing-semicolon-after-character-reference</a>
|
||
<a href=#parse-errors id=decimal-character-reference-state:parse-errors>parse error</a>. <a href=#reconsume id=decimal-character-reference-state:reconsume>Reconsume</a> in the <a href=#numeric-character-reference-end-state id=decimal-character-reference-state:numeric-character-reference-end-state-2>numeric character reference end
|
||
state</a>.</dl>
|
||
|
||
|
||
<h5 id=numeric-character-reference-end-state><span class=secno>12.2.5.80</span> <dfn>Numeric character reference end state</dfn><a href=#numeric-character-reference-end-state class=self-link></a></h5>
|
||
|
||
<p>Check the <var id=numeric-character-reference-end-state:character-reference-code><a href=#character-reference-code>character reference code</a></var>:</p>
|
||
|
||
<ul><li><p>If the number is 0x00, then this is a <a href=#parse-error-null-character-reference id=numeric-character-reference-end-state:parse-error-null-character-reference>null-character-reference</a> <a href=#parse-errors id=numeric-character-reference-end-state:parse-errors>parse
|
||
error</a>. Set the <var id=numeric-character-reference-end-state:character-reference-code-2><a href=#character-reference-code>character reference code</a></var> to
|
||
0xFFFD.<li><p>If the number is greater than 0x10FFFF, then this is a <a href=#parse-error-character-reference-outside-unicode-range id=numeric-character-reference-end-state:parse-error-character-reference-outside-unicode-range>character-reference-outside-unicode-range</a>
|
||
<a href=#parse-errors id=numeric-character-reference-end-state:parse-errors-2>parse error</a>. Set the <var id=numeric-character-reference-end-state:character-reference-code-3><a href=#character-reference-code>character reference
|
||
code</a></var> to 0xFFFD.<li><p>If the number is a <a href=https://infra.spec.whatwg.org/#surrogate id=numeric-character-reference-end-state:surrogate data-x-internal=surrogate>surrogate</a>, then this is a <a href=#parse-error-surrogate-character-reference id=numeric-character-reference-end-state:parse-error-surrogate-character-reference>surrogate-character-reference</a>
|
||
<a href=#parse-errors id=numeric-character-reference-end-state:parse-errors-3>parse error</a>. Set the <var id=numeric-character-reference-end-state:character-reference-code-4><a href=#character-reference-code>character reference
|
||
code</a></var> to 0xFFFD.<li><p>If the number is a <a href=https://infra.spec.whatwg.org/#noncharacter id=numeric-character-reference-end-state:noncharacter data-x-internal=noncharacter>noncharacter</a>, then this is a
|
||
<a href=#parse-error-noncharacter-character-reference id=numeric-character-reference-end-state:parse-error-noncharacter-character-reference>noncharacter-character-reference</a>
|
||
<a href=#parse-errors id=numeric-character-reference-end-state:parse-errors-4>parse error</a>.<li><p>If the number is 0x0D, or a
|
||
<a href=https://infra.spec.whatwg.org/#control id=numeric-character-reference-end-state:control data-x-internal=control>control</a> that's not <a id=numeric-character-reference-end-state:space-characters href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a>, then this is a
|
||
<a href=#parse-error-control-character-reference id=numeric-character-reference-end-state:parse-error-control-character-reference>control-character-reference</a>
|
||
<a href=#parse-errors id=numeric-character-reference-end-state:parse-errors-5>parse error</a>. If the number is one of the numbers in the first column of the
|
||
following table, then find the row with that number in the first column, and set the <var id=numeric-character-reference-end-state:character-reference-code-5><a href=#character-reference-code>character reference code</a></var> to the number in the second
|
||
column of that row.</p>
|
||
|
||
|
||
<table id=table-charref-overrides><thead><tr><th>Number <th colspan=2>Code point
|
||
<tbody><tr><td>0x80 <td>0x20AC <td>EURO SIGN (€)
|
||
|
||
<tr><td>0x82 <td>0x201A <td>SINGLE LOW-9 QUOTATION MARK (‚)
|
||
<tr><td>0x83 <td>0x0192 <td>LATIN SMALL LETTER F WITH HOOK (ƒ)
|
||
<tr><td>0x84 <td>0x201E <td>DOUBLE LOW-9 QUOTATION MARK („)
|
||
<tr><td>0x85 <td>0x2026 <td>HORIZONTAL ELLIPSIS (…)
|
||
<tr><td>0x86 <td>0x2020 <td>DAGGER (†)
|
||
<tr><td>0x87 <td>0x2021 <td>DOUBLE DAGGER (‡)
|
||
<tr><td>0x88 <td>0x02C6 <td>MODIFIER LETTER CIRCUMFLEX ACCENT (ˆ)
|
||
<tr><td>0x89 <td>0x2030 <td>PER MILLE SIGN (‰)
|
||
<tr><td>0x8A <td>0x0160 <td>LATIN CAPITAL LETTER S WITH CARON (Š)
|
||
<tr><td>0x8B <td>0x2039 <td>SINGLE LEFT-POINTING ANGLE QUOTATION MARK (‹)
|
||
<tr><td>0x8C <td>0x0152 <td>LATIN CAPITAL LIGATURE OE (Œ)
|
||
|
||
<tr><td>0x8E <td>0x017D <td>LATIN CAPITAL LETTER Z WITH CARON (Ž)
|
||
|
||
|
||
<tr><td>0x91 <td>0x2018 <td>LEFT SINGLE QUOTATION MARK (‘)
|
||
<tr><td>0x92 <td>0x2019 <td>RIGHT SINGLE QUOTATION MARK (’)
|
||
<tr><td>0x93 <td>0x201C <td>LEFT DOUBLE QUOTATION MARK (“)
|
||
<tr><td>0x94 <td>0x201D <td>RIGHT DOUBLE QUOTATION MARK (”)
|
||
<tr><td>0x95 <td>0x2022 <td>BULLET (•)
|
||
<tr><td>0x96 <td>0x2013 <td>EN DASH (–)
|
||
<tr><td>0x97 <td>0x2014 <td>EM DASH (—)
|
||
<tr><td>0x98 <td>0x02DC <td>SMALL TILDE (˜)
|
||
<tr><td>0x99 <td>0x2122 <td>TRADE MARK SIGN (™)
|
||
<tr><td>0x9A <td>0x0161 <td>LATIN SMALL LETTER S WITH CARON (š)
|
||
<tr><td>0x9B <td>0x203A <td>SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (›)
|
||
<tr><td>0x9C <td>0x0153 <td>LATIN SMALL LIGATURE OE (œ)
|
||
|
||
<tr><td>0x9E <td>0x017E <td>LATIN SMALL LETTER Z WITH CARON (ž)
|
||
<tr><td>0x9F <td>0x0178 <td>LATIN CAPITAL LETTER Y WITH DIAERESIS (Ÿ)
|
||
</table></ul>
|
||
|
||
<p>Set the <var id=numeric-character-reference-end-state:temporary-buffer><a href=#temporary-buffer>temporary buffer</a></var> to the empty string. Append a
|
||
code point equal to the <var id=numeric-character-reference-end-state:character-reference-code-6><a href=#character-reference-code>character reference code</a></var> to
|
||
the <var id=numeric-character-reference-end-state:temporary-buffer-2><a href=#temporary-buffer>temporary buffer</a></var>. <a href=#flush-code-points-consumed-as-a-character-reference id=numeric-character-reference-end-state:flush-code-points-consumed-as-a-character-reference>Flush code points consumed as a
|
||
character reference</a>. Switch to the <var id=numeric-character-reference-end-state:return-state><a href=#return-state>return state</a></var>.</p>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h4 id=tree-construction><span class=secno>12.2.6</span> <dfn>Tree construction</dfn><a href=#tree-construction class=self-link></a></h4>
|
||
|
||
<p>The input to the tree construction stage is a sequence of tokens from the
|
||
<a href=#tokenization id=tree-construction:tokenization>tokenization</a> stage. The tree construction stage is associated with a DOM
|
||
<code id=tree-construction:document><a href=dom.html#document>Document</a></code> object when a parser is created. The "output" of this stage consists of
|
||
dynamically modifying or extending that document's DOM tree.</p>
|
||
|
||
<p>This specification does not define when an interactive user agent has to render the
|
||
<code id=tree-construction:document-2><a href=dom.html#document>Document</a></code> so that it is available to the user, or when it has to begin accepting user
|
||
input.</p>
|
||
|
||
<hr>
|
||
|
||
<p>As each token is emitted from the tokenizer, the user agent must follow the appropriate steps
|
||
from the following list, known as the <dfn id=tree-construction-dispatcher>tree construction dispatcher</dfn>:</p>
|
||
|
||
<dl class=switch><dt>If the <a href=#stack-of-open-elements id=tree-construction:stack-of-open-elements>stack of open elements</a> is empty<dt>If the <a href=#adjusted-current-node id=tree-construction:adjusted-current-node>adjusted current node</a> is an element in the <a id=tree-construction:html-namespace-2 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a><dt>If the <a href=#adjusted-current-node id=tree-construction:adjusted-current-node-2>adjusted current node</a> is a <a href=#mathml-text-integration-point id=tree-construction:mathml-text-integration-point>MathML text integration point</a> and the token is a start tag whose tag name is neither "mglyph" nor "malignmark"<dt>If the <a href=#adjusted-current-node id=tree-construction:adjusted-current-node-3>adjusted current node</a> is a <a href=#mathml-text-integration-point id=tree-construction:mathml-text-integration-point-2>MathML text integration point</a> and the token is a character token<dt>If the <a href=#adjusted-current-node id=tree-construction:adjusted-current-node-4>adjusted current node</a> is a <a id=tree-construction:mathml-annotation-xml href=https://www.w3.org/Math/draft-spec/chapter5.html#mixing.elements.annotation.xml data-x-internal=mathml-annotation-xml>MathML <code>annotation-xml</code></a> element and the token is a start tag whose tag name is "svg"<dt>If the <a href=#adjusted-current-node id=tree-construction:adjusted-current-node-5>adjusted current node</a> is an <a href=#html-integration-point id=tree-construction:html-integration-point>HTML integration point</a> and the token is a start tag<dt>If the <a href=#adjusted-current-node id=tree-construction:adjusted-current-node-6>adjusted current node</a> is an <a href=#html-integration-point id=tree-construction:html-integration-point-2>HTML integration point</a> and the token is a character token<dt>If the token is an end-of-file token<dd>Process the token according to the rules given in the section corresponding to the current
|
||
<a href=#insertion-mode id=tree-construction:insertion-mode>insertion mode</a> in HTML content.<dt>Otherwise<dd>Process the token according to the rules given in the section for parsing tokens <a href=#parsing-main-inforeign id=tree-construction:parsing-main-inforeign>in foreign content</a>.</dl>
|
||
|
||
<p>The <dfn id=next-token>next token</dfn> is the token that is about to be processed by the <a href=#tree-construction-dispatcher id=tree-construction:tree-construction-dispatcher>tree
|
||
construction dispatcher</a> (even if the token is subsequently just ignored).</p>
|
||
|
||
<p>A node is a <dfn id=mathml-text-integration-point>MathML text integration point</dfn> if it is one of the following
|
||
elements:</p>
|
||
|
||
<ul class=brief><li>A <a id=tree-construction:mathml-mi href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mi data-x-internal=mathml-mi>MathML <code>mi</code></a> element<li>A <a id=tree-construction:mathml-mo href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mo data-x-internal=mathml-mo>MathML <code>mo</code></a> element<li>A <a id=tree-construction:mathml-mn href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mn data-x-internal=mathml-mn>MathML <code>mn</code></a> element<li>A <a id=tree-construction:mathml-ms href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.ms data-x-internal=mathml-ms>MathML <code>ms</code></a> element<li>A <a id=tree-construction:mathml-mtext href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mtext data-x-internal=mathml-mtext>MathML <code>mtext</code></a> element</ul>
|
||
|
||
<p>A node is an <dfn id=html-integration-point>HTML integration point</dfn> if it is one of the following elements:</p>
|
||
|
||
<ul class=brief><li>A <a id=tree-construction:mathml-annotation-xml-2 href=https://www.w3.org/Math/draft-spec/chapter5.html#mixing.elements.annotation.xml data-x-internal=mathml-annotation-xml>MathML <code>annotation-xml</code></a> element whose start tag token had an
|
||
attribute with the name "encoding" whose value was an <a id=tree-construction:ascii-case-insensitive href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> match
|
||
for the string "<code>text/html</code>"<li>A <a id=tree-construction:mathml-annotation-xml-3 href=https://www.w3.org/Math/draft-spec/chapter5.html#mixing.elements.annotation.xml data-x-internal=mathml-annotation-xml>MathML <code>annotation-xml</code></a> element whose start tag token had an
|
||
attribute with the name "encoding" whose value was an <a id=tree-construction:ascii-case-insensitive-2 href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> match
|
||
for the string "<code>application/xhtml+xml</code>"<li>An <a id=tree-construction:svg-foreignobject href=https://www.w3.org/TR/SVG11/extend.html#ForeignObjectElement data-x-internal=svg-foreignobject>SVG <code>foreignObject</code></a> element<li>An <a id=tree-construction:svg-desc href=https://www.w3.org/TR/SVG11/struct.html#DescElement data-x-internal=svg-desc>SVG <code>desc</code></a> element<li>An <a id=tree-construction:svg-title href=https://www.w3.org/TR/SVG11/struct.html#TitleElement data-x-internal=svg-title>SVG <code>title</code></a> element</ul>
|
||
|
||
<p class=note>If the node in question is the <var id=tree-construction:concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element passed to the <a href=#html-fragment-parsing-algorithm id=tree-construction:html-fragment-parsing-algorithm>HTML fragment
|
||
parsing algorithm</a>, then the start tag token for that element is the "fake" token created
|
||
during by that <a href=#html-fragment-parsing-algorithm id=tree-construction:html-fragment-parsing-algorithm-2>HTML fragment parsing algorithm</a>.</p>
|
||
|
||
<hr>
|
||
|
||
<p class=note>Not all of the tag names mentioned below are conformant tag names in this
|
||
specification; many are included to handle legacy content. They still form part of the algorithm
|
||
that implementations are required to implement to claim conformance.</p>
|
||
|
||
<p class=note>The algorithm described below places no limit on the depth of the DOM tree
|
||
generated, or on the length of tag names, attribute names, attribute values, <code id=tree-construction:text><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code>
|
||
nodes, etc. While implementors are encouraged to avoid arbitrary limits, it is recognized that <a href=infrastructure.html#hardwareLimitations>practical concerns</a> will likely force user agents to impose nesting
|
||
depth constraints.</p>
|
||
|
||
|
||
<h5 id=creating-and-inserting-nodes><span class=secno>12.2.6.1</span> Creating and inserting nodes<a href=#creating-and-inserting-nodes class=self-link></a></h5>
|
||
|
||
<p>While the parser is processing a token, it can enable or disable <dfn id=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>
|
||
|
||
<ol><li>
|
||
|
||
<p>If there was an <i>override target</i> specified, then let <var>target</var> be the
|
||
<i>override target</i>.</p>
|
||
|
||
<p>Otherwise, let <var>target</var> be the <a href=#current-node id=creating-and-inserting-nodes:current-node>current node</a>.</p>
|
||
|
||
<li>
|
||
|
||
<p>Determine the <var>adjusted insertion location</var> using the first matching steps
|
||
from the following list:</p>
|
||
|
||
<dl class=switch><dt>If <a href=#foster-parent id=creating-and-inserting-nodes:foster-parent>foster parenting</a> is enabled and <var>target</var> is a <code id=creating-and-inserting-nodes:the-table-element><a href=tables.html#the-table-element>table</a></code>, <code id=creating-and-inserting-nodes:the-tbody-element><a href=tables.html#the-tbody-element>tbody</a></code>, <code id=creating-and-inserting-nodes:the-tfoot-element><a href=tables.html#the-tfoot-element>tfoot</a></code>,
|
||
<code id=creating-and-inserting-nodes:the-thead-element><a href=tables.html#the-thead-element>thead</a></code>, or <code id=creating-and-inserting-nodes:the-tr-element><a href=tables.html#the-tr-element>tr</a></code> element<dd>
|
||
|
||
<p class=note>Foster parenting happens when content is misnested in tables.</p>
|
||
|
||
<p>Run these substeps:</p>
|
||
|
||
<ol><li><p>Let <var>last template</var> be the last <code id=creating-and-inserting-nodes:the-template-element><a href=scripting.html#the-template-element>template</a></code> element in the
|
||
<a href=#stack-of-open-elements id=creating-and-inserting-nodes:stack-of-open-elements>stack of open elements</a>, if any.</p>
|
||
|
||
<li><p>Let <var>last table</var> be the last <code id=creating-and-inserting-nodes:the-table-element-2><a href=tables.html#the-table-element>table</a></code> element in the
|
||
<a href=#stack-of-open-elements id=creating-and-inserting-nodes:stack-of-open-elements-2>stack of open elements</a>, if any.</p>
|
||
|
||
<li><p>If there is a <var>last template</var> and either there is no <var>last table</var>, or there is one, but <var>last template</var> is lower
|
||
(more recently added) than <var>last table</var> in the <a href=#stack-of-open-elements id=creating-and-inserting-nodes:stack-of-open-elements-3>stack of open
|
||
elements</a>, then: let <var>adjusted insertion location</var> be inside <var>last template</var>'s <a id=creating-and-inserting-nodes:template-contents href=scripting.html#template-contents>template contents</a>, after its last child (if any),
|
||
and abort these substeps.<li><p>If there is no <var>last table</var>, then let <var>adjusted insertion
|
||
location</var> be inside the first element in the <a href=#stack-of-open-elements id=creating-and-inserting-nodes:stack-of-open-elements-4>stack of open elements</a> (the
|
||
<code id=creating-and-inserting-nodes:the-html-element><a href=semantics.html#the-html-element>html</a></code> element), after its last child (if any), and abort these substeps.
|
||
(<a href=#fragment-case id=creating-and-inserting-nodes:fragment-case>fragment case</a>)</p>
|
||
|
||
|
||
|
||
<li><p>If <var>last table</var> has a parent node, then let <var>adjusted insertion location</var> be inside <var>last table</var>'s parent
|
||
node, immediately before <var>last table</var>, and abort these
|
||
substeps.<li><p>Let <var>previous element</var> be the element immediately above <var>last table</var> in the <a href=#stack-of-open-elements id=creating-and-inserting-nodes:stack-of-open-elements-5>stack of open elements</a>.<li><p>Let <var>adjusted insertion location</var> be inside <var>previous
|
||
element</var>, after its last child (if any).</ol>
|
||
|
||
<p class=note>These steps are involved in part because it's possible for elements, the
|
||
<code id=creating-and-inserting-nodes:the-table-element-3><a href=tables.html#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>
|
||
|
||
<dt>Otherwise<dd>
|
||
|
||
<p>Let <var>adjusted insertion location</var> be inside <var>target</var>,
|
||
after its last child (if any).</p>
|
||
|
||
</dl>
|
||
|
||
<li>
|
||
|
||
<p>If the <var>adjusted insertion location</var> is inside a <code id=creating-and-inserting-nodes:the-template-element-2><a href=scripting.html#the-template-element>template</a></code>
|
||
element, let it instead be inside the <code id=creating-and-inserting-nodes:the-template-element-3><a href=scripting.html#the-template-element>template</a></code> element's <a id=creating-and-inserting-nodes:template-contents-2 href=scripting.html#template-contents>template
|
||
contents</a>, after its last child (if any).</p>
|
||
|
||
<li>
|
||
|
||
<p>Return the <var>adjusted insertion location</var>.</p>
|
||
|
||
</ol>
|
||
|
||
<hr>
|
||
|
||
<p>When the steps below require the UA to <dfn id=create-an-element-for-the-token>create an
|
||
element for a token</dfn> in a particular <var>given namespace</var> and with a
|
||
particular <var>intended parent</var>, the UA must run the following steps:</p>
|
||
|
||
<ol><li><p>Let <var>document</var> be <var>intended parent</var>'s <a id=creating-and-inserting-nodes:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>.<li><p>Let <var>local name</var> be the tag name of the token.<li><p>Let <var>is</var> be the value of the "<code id=creating-and-inserting-nodes:attr-is><a href=custom-elements.html#attr-is>is</a></code>" attribute in the
|
||
given token, if such an attribute exists, or null otherwise.<li><p>Let <var>definition</var> be the result of <a href=custom-elements.html#look-up-a-custom-element-definition id=creating-and-inserting-nodes:look-up-a-custom-element-definition>looking up a custom element definition</a> given <var>document</var>, <var>given
|
||
namespace</var>, <var>local name</var>, and <var>is</var>.<li><p>If <var>definition</var> is non-null and the parser was not originally created for the
|
||
<a href=#html-fragment-parsing-algorithm id=creating-and-inserting-nodes:html-fragment-parsing-algorithm>HTML fragment parsing algorithm</a>, then let <var>will execute script</var> be true.
|
||
Otherwise, let it be false.<li>
|
||
<p>If <var>will execute script</var> is true, then:</p>
|
||
|
||
<ol><li><p>Increment <var>document</var>'s <a id=creating-and-inserting-nodes:throw-on-dynamic-markup-insertion-counter href=dynamic-markup-insertion.html#throw-on-dynamic-markup-insertion-counter>throw-on-dynamic-markup-insertion
|
||
counter</a>.<li><p>If the <a id=creating-and-inserting-nodes:javascript-execution-context-stack href=https://tc39.github.io/ecma262/#execution-context-stack data-x-internal=javascript-execution-context-stack>JavaScript execution context stack</a> is empty, then <a id=creating-and-inserting-nodes:perform-a-microtask-checkpoint href=webappapis.html#perform-a-microtask-checkpoint>perform a
|
||
microtask checkpoint</a>.<li><p>Push a new <a id=creating-and-inserting-nodes:element-queue href=custom-elements.html#element-queue>element queue</a> onto the <a id=creating-and-inserting-nodes:custom-element-reactions-stack href=custom-elements.html#custom-element-reactions-stack>custom element reactions
|
||
stack</a>.</ol>
|
||
<li>
|
||
<p>Let <var>element</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-create-element id=creating-and-inserting-nodes:create-an-element data-x-internal=create-an-element>creating an
|
||
element</a> given <var>document</var>, <var>localName</var>, <var>given
|
||
namespace</var>, null, and <var>is</var>. If <var>will execute script</var> is true, set the
|
||
<var>synchronous custom elements flag</var>; otherwise, leave it unset.</p>
|
||
|
||
<p class=note>This will cause <a href=custom-elements.html#custom-element-constructor id=creating-and-inserting-nodes:custom-element-constructor>custom element
|
||
constructors</a> to run, if <var>will execute script</var> is true. However, since we
|
||
incremented the <a id=creating-and-inserting-nodes:throw-on-dynamic-markup-insertion-counter-2 href=dynamic-markup-insertion.html#throw-on-dynamic-markup-insertion-counter>throw-on-dynamic-markup-insertion counter</a>, this cannot cause <a href=dynamic-markup-insertion.html#dom-document-write-2 id=creating-and-inserting-nodes:dom-document-write-2>new characters to be inserted into the tokenizer</a>, or <a href=dynamic-markup-insertion.html#dom-document-open id=creating-and-inserting-nodes:dom-document-open>the document to be blown away</a>.</p>
|
||
<li>
|
||
<p><a href=https://dom.spec.whatwg.org/#concept-element-attributes-append id=creating-and-inserting-nodes:concept-element-attributes-append data-x-internal=concept-element-attributes-append>Append</a> each attribute in the given
|
||
token to <var>element</var>.</p>
|
||
|
||
<p class=note>This can <a id=creating-and-inserting-nodes:enqueue-a-custom-element-callback-reaction href=custom-elements.html#enqueue-a-custom-element-callback-reaction>enqueue a custom element callback reaction</a> for the
|
||
<code>attributeChangedCallback</code>, which might run immediately (in the next
|
||
step).</p>
|
||
|
||
<p class=note>Even though the <code id=creating-and-inserting-nodes:attr-is-2><a href=custom-elements.html#attr-is>is</a></code> attribute governs the <a href=https://dom.spec.whatwg.org/#concept-create-element id=creating-and-inserting-nodes:create-an-element-2 data-x-internal=create-an-element>creation</a> of a <a id=creating-and-inserting-nodes:customized-built-in-element href=custom-elements.html#customized-built-in-element>customized built-in element</a>, it is
|
||
not present during the execution of the relevant <a id=creating-and-inserting-nodes:custom-element-constructor-2 href=custom-elements.html#custom-element-constructor>custom element constructor</a>; it is
|
||
appended in this step, along with all other attributes.</p>
|
||
<li>
|
||
<p>If <var>will execute script</var> is true, then:</p>
|
||
|
||
<ol><li><p>Let <var>queue</var> be the result of popping the <a id=creating-and-inserting-nodes:current-element-queue href=custom-elements.html#current-element-queue>current element queue</a>
|
||
from the <a id=creating-and-inserting-nodes:custom-element-reactions-stack-2 href=custom-elements.html#custom-element-reactions-stack>custom element reactions stack</a>. (This will be the same <a id=creating-and-inserting-nodes:element-queue-2 href=custom-elements.html#element-queue>element
|
||
queue</a> as was pushed above.)<li><p><a id=creating-and-inserting-nodes:invoke-custom-element-reactions href=custom-elements.html#invoke-custom-element-reactions>Invoke custom element reactions</a> in <var>queue</var>.<li><p>Decrement <var>document</var>'s <a id=creating-and-inserting-nodes:throw-on-dynamic-markup-insertion-counter-3 href=dynamic-markup-insertion.html#throw-on-dynamic-markup-insertion-counter>throw-on-dynamic-markup-insertion
|
||
counter</a>.</ol>
|
||
<li><p>If <var>element</var> has an <code>xmlns</code> attribute <em>in the <a id=creating-and-inserting-nodes:xmlns-namespace href=https://infra.spec.whatwg.org/#xmlns-namespace data-x-internal=xmlns-namespace>XMLNS
|
||
namespace</a></em> whose value is not exactly the same as the element's namespace, that is a
|
||
<a href=#parse-errors id=creating-and-inserting-nodes:parse-errors>parse error</a>. Similarly, if <var>element</var> has an <code>xmlns:xlink</code> attribute in the <a id=creating-and-inserting-nodes:xmlns-namespace-2 href=https://infra.spec.whatwg.org/#xmlns-namespace data-x-internal=xmlns-namespace>XMLNS namespace</a> whose value is not the
|
||
<a id=creating-and-inserting-nodes:xlink-namespace href=https://infra.spec.whatwg.org/#xlink-namespace data-x-internal=xlink-namespace>XLink Namespace</a>, that is a <a href=#parse-errors id=creating-and-inserting-nodes:parse-errors-2>parse error</a>.<li><p>If <var>element</var> is a <a href=forms.html#category-reset id=creating-and-inserting-nodes:category-reset>resettable element</a>, invoke
|
||
its <a href=form-control-infrastructure.html#concept-form-reset-control id=creating-and-inserting-nodes:concept-form-reset-control>reset algorithm</a>. (This initializes the
|
||
element's <a href=form-control-infrastructure.html#concept-fe-value id=creating-and-inserting-nodes:concept-fe-value>value</a> and <a href=form-control-infrastructure.html#concept-fe-checked id=creating-and-inserting-nodes:concept-fe-checked>checkedness</a> based on the element's attributes.)<li><p>If <var>element</var> is a <a id=creating-and-inserting-nodes:form-associated-element href=forms.html#form-associated-element>form-associated element</a>, the <a href=#form-element-pointer id=creating-and-inserting-nodes:form-element-pointer><code>form</code> element pointer</a> is not null, there is no <code id=creating-and-inserting-nodes:the-template-element-4><a href=scripting.html#the-template-element>template</a></code>
|
||
element on the <a href=#stack-of-open-elements id=creating-and-inserting-nodes:stack-of-open-elements-6>stack of open elements</a>, <var>element</var> is either not <a href=forms.html#category-listed id=creating-and-inserting-nodes:category-listed>listed</a> or doesn't have a <code id=creating-and-inserting-nodes:attr-fae-form><a href=form-control-infrastructure.html#attr-fae-form>form</a></code> attribute, and the <var>intended parent</var> is in the same
|
||
<a id=creating-and-inserting-nodes:tree href=https://dom.spec.whatwg.org/#concept-tree data-x-internal=tree>tree</a> as the element pointed to by the <a href=#form-element-pointer id=creating-and-inserting-nodes:form-element-pointer-2><code>form</code> element
|
||
pointer</a>, then <a href=form-control-infrastructure.html#concept-form-association id=creating-and-inserting-nodes:concept-form-association>associate</a> <var>element</var>
|
||
with the <code id=creating-and-inserting-nodes:the-form-element><a href=forms.html#the-form-element>form</a></code> element pointed to by the <a href=#form-element-pointer id=creating-and-inserting-nodes:form-element-pointer-3><code>form</code> element
|
||
pointer</a> and set <var>element</var>'s <a id=creating-and-inserting-nodes:parser-inserted-flag href=form-control-infrastructure.html#parser-inserted-flag>parser inserted flag</a>.<li><p>Return <var>element</var>.</ol>
|
||
|
||
<hr>
|
||
|
||
|
||
|
||
<p>When the steps below require the user agent to <dfn id=insert-a-foreign-element>insert a foreign element</dfn> for a token
|
||
in a given namespace, the user agent must run these steps:</p>
|
||
|
||
<ol><li><p>Let the <var>adjusted insertion location</var> be the <a href=#appropriate-place-for-inserting-a-node id=creating-and-inserting-nodes:appropriate-place-for-inserting-a-node>appropriate place for
|
||
inserting a node</a>.<li><p>Let <var>element</var> be the result of <a href=#create-an-element-for-the-token id=creating-and-inserting-nodes:create-an-element-for-the-token>creating an element for the token</a> in the given namespace, with the intended
|
||
parent being the element in which the <var>adjusted insertion location</var> finds
|
||
itself.<li>
|
||
<p>If it is possible to insert <var>element</var> at the <var>adjusted insertion location</var>,
|
||
then:</p>
|
||
|
||
<ol><li><p>Push a new <a id=creating-and-inserting-nodes:element-queue-3 href=custom-elements.html#element-queue>element queue</a> onto the <a id=creating-and-inserting-nodes:custom-element-reactions-stack-3 href=custom-elements.html#custom-element-reactions-stack>custom element reactions
|
||
stack</a>.<li><p>Insert <var>element</var> at the <var>adjusted insertion location</var>.<li><p>Pop the <a id=creating-and-inserting-nodes:element-queue-4 href=custom-elements.html#element-queue>element queue</a> from the <a id=creating-and-inserting-nodes:custom-element-reactions-stack-4 href=custom-elements.html#custom-element-reactions-stack>custom element reactions stack</a>,
|
||
and <a id=creating-and-inserting-nodes:invoke-custom-element-reactions-2 href=custom-elements.html#invoke-custom-element-reactions>invoke custom element reactions</a> in that queue.</ol>
|
||
|
||
<p class=note>If the <var>adjusted insertion location</var> cannot accept more
|
||
elements, e.g. because it's a <code id=creating-and-inserting-nodes:document><a href=dom.html#document>Document</a></code> that already has an element child, then
|
||
<var>element</var> is dropped on the floor.</p>
|
||
<li><p>Push <var>element</var> onto the <a href=#stack-of-open-elements id=creating-and-inserting-nodes:stack-of-open-elements-7>stack of open elements</a> so that it is the new
|
||
<a href=#current-node id=creating-and-inserting-nodes:current-node-2>current node</a>.<li><p>Return <var>element</var>.</ol>
|
||
|
||
<p>When the steps below require the user agent to <dfn id=insert-an-html-element>insert an HTML element</dfn> for a token,
|
||
the user agent must <a href=#insert-a-foreign-element id=creating-and-inserting-nodes:insert-a-foreign-element>insert a foreign element</a> for the token, in the <a id=creating-and-inserting-nodes:html-namespace-2 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML
|
||
namespace</a>.</p>
|
||
|
||
<hr>
|
||
|
||
<p>When the steps below require the user agent to <dfn id=adjust-mathml-attributes>adjust MathML attributes</dfn> for a token,
|
||
then, if the token has an attribute named <code>definitionurl</code>, change its name to
|
||
<code>definitionURL</code> (note the case difference).</p>
|
||
|
||
<p>When the steps below require the user agent to <dfn id=adjust-svg-attributes>adjust SVG attributes</dfn> for a token,
|
||
then, for each attribute on the token whose attribute name is one of the ones in the first column
|
||
of the following table, change the attribute's name to the name given in the corresponding cell in
|
||
the second column. (This fixes the case of SVG attributes that are not all lowercase.)</p>
|
||
|
||
<table><thead><tr><th> Attribute name on token <th> Attribute name on element
|
||
<tbody><tr><td> <code>attributename</code> <td> <code>attributeName</code>
|
||
<tr><td> <code>attributetype</code> <td> <code>attributeType</code>
|
||
<tr><td> <code>basefrequency</code> <td> <code>baseFrequency</code>
|
||
<tr><td> <code>baseprofile</code> <td> <code>baseProfile</code>
|
||
<tr><td> <code>calcmode</code> <td> <code>calcMode</code>
|
||
<tr><td> <code>clippathunits</code> <td> <code>clipPathUnits</code>
|
||
<tr><td> <code>diffuseconstant</code> <td> <code>diffuseConstant</code>
|
||
<tr><td> <code>edgemode</code> <td> <code>edgeMode</code>
|
||
<tr><td> <code>filterunits</code> <td> <code>filterUnits</code>
|
||
<tr><td> <code>glyphref</code> <td> <code>glyphRef</code>
|
||
<tr><td> <code>gradienttransform</code> <td> <code>gradientTransform</code>
|
||
<tr><td> <code>gradientunits</code> <td> <code>gradientUnits</code>
|
||
<tr><td> <code>kernelmatrix</code> <td> <code>kernelMatrix</code>
|
||
<tr><td> <code>kernelunitlength</code> <td> <code>kernelUnitLength</code>
|
||
<tr><td> <code>keypoints</code> <td> <code>keyPoints</code>
|
||
<tr><td> <code>keysplines</code> <td> <code>keySplines</code>
|
||
<tr><td> <code>keytimes</code> <td> <code>keyTimes</code>
|
||
<tr><td> <code>lengthadjust</code> <td> <code>lengthAdjust</code>
|
||
<tr><td> <code>limitingconeangle</code> <td> <code>limitingConeAngle</code>
|
||
<tr><td> <code>markerheight</code> <td> <code>markerHeight</code>
|
||
<tr><td> <code>markerunits</code> <td> <code>markerUnits</code>
|
||
<tr><td> <code>markerwidth</code> <td> <code>markerWidth</code>
|
||
<tr><td> <code>maskcontentunits</code> <td> <code>maskContentUnits</code>
|
||
<tr><td> <code>maskunits</code> <td> <code>maskUnits</code>
|
||
<tr><td> <code>numoctaves</code> <td> <code>numOctaves</code>
|
||
<tr><td> <code>pathlength</code> <td> <code>pathLength</code>
|
||
<tr><td> <code>patterncontentunits</code> <td> <code>patternContentUnits</code>
|
||
<tr><td> <code>patterntransform</code> <td> <code>patternTransform</code>
|
||
<tr><td> <code>patternunits</code> <td> <code>patternUnits</code>
|
||
<tr><td> <code>pointsatx</code> <td> <code>pointsAtX</code>
|
||
<tr><td> <code>pointsaty</code> <td> <code>pointsAtY</code>
|
||
<tr><td> <code>pointsatz</code> <td> <code>pointsAtZ</code>
|
||
<tr><td> <code>preservealpha</code> <td> <code>preserveAlpha</code>
|
||
<tr><td> <code>preserveaspectratio</code> <td> <code>preserveAspectRatio</code>
|
||
<tr><td> <code>primitiveunits</code> <td> <code>primitiveUnits</code>
|
||
<tr><td> <code>refx</code> <td> <code>refX</code>
|
||
<tr><td> <code>refy</code> <td> <code>refY</code>
|
||
<tr><td> <code>repeatcount</code> <td> <code>repeatCount</code>
|
||
<tr><td> <code>repeatdur</code> <td> <code>repeatDur</code>
|
||
<tr><td> <code>requiredextensions</code> <td> <code>requiredExtensions</code>
|
||
<tr><td> <code>requiredfeatures</code> <td> <code>requiredFeatures</code>
|
||
<tr><td> <code>specularconstant</code> <td> <code>specularConstant</code>
|
||
<tr><td> <code>specularexponent</code> <td> <code>specularExponent</code>
|
||
<tr><td> <code>spreadmethod</code> <td> <code>spreadMethod</code>
|
||
<tr><td> <code>startoffset</code> <td> <code>startOffset</code>
|
||
<tr><td> <code>stddeviation</code> <td> <code>stdDeviation</code>
|
||
<tr><td> <code>stitchtiles</code> <td> <code>stitchTiles</code>
|
||
<tr><td> <code>surfacescale</code> <td> <code>surfaceScale</code>
|
||
<tr><td> <code>systemlanguage</code> <td> <code>systemLanguage</code>
|
||
<tr><td> <code>tablevalues</code> <td> <code>tableValues</code>
|
||
<tr><td> <code>targetx</code> <td> <code>targetX</code>
|
||
<tr><td> <code>targety</code> <td> <code>targetY</code>
|
||
<tr><td> <code>textlength</code> <td> <code>textLength</code>
|
||
<tr><td> <code>viewbox</code> <td> <code>viewBox</code>
|
||
<tr><td> <code>viewtarget</code> <td> <code>viewTarget</code>
|
||
<tr><td> <code>xchannelselector</code> <td> <code>xChannelSelector</code>
|
||
<tr><td> <code>ychannelselector</code> <td> <code>yChannelSelector</code>
|
||
<tr><td> <code>zoomandpan</code> <td> <code>zoomAndPan</code>
|
||
</table>
|
||
|
||
<p>When the steps below require the user agent to <dfn id=adjust-foreign-attributes>adjust foreign attributes</dfn> for a
|
||
token, then, if any of the attributes on the token match the strings given in the first column of
|
||
the following table, let the attribute be a namespaced attribute, with the prefix being the string
|
||
given in the corresponding cell in the second column, the local name being the string given in the
|
||
corresponding cell in the third column, and the namespace being the namespace given in the
|
||
corresponding cell in the fourth column. (This fixes the use of namespaced attributes, in
|
||
particular <a href=dom.html#attr-xml-lang id=creating-and-inserting-nodes:attr-xml-lang><code>lang</code> attributes in the <span>XML
|
||
namespace</span></a>.)</p>
|
||
|
||
<table><thead><tr><th> Attribute name <th> Prefix <th> Local name <th> Namespace
|
||
<tbody><tr><td> <code>xlink:actuate</code> <td> <code>xlink</code> <td> <code>actuate</code> <td> <a id=creating-and-inserting-nodes:xlink-namespace-2 href=https://infra.spec.whatwg.org/#xlink-namespace data-x-internal=xlink-namespace>XLink namespace</a>
|
||
<tr><td> <code>xlink:arcrole</code> <td> <code>xlink</code> <td> <code>arcrole</code> <td> <a id=creating-and-inserting-nodes:xlink-namespace-3 href=https://infra.spec.whatwg.org/#xlink-namespace data-x-internal=xlink-namespace>XLink namespace</a>
|
||
<tr><td> <code>xlink:href</code> <td> <code>xlink</code> <td> <code>href</code> <td> <a id=creating-and-inserting-nodes:xlink-namespace-4 href=https://infra.spec.whatwg.org/#xlink-namespace data-x-internal=xlink-namespace>XLink namespace</a>
|
||
<tr><td> <code>xlink:role</code> <td> <code>xlink</code> <td> <code>role</code> <td> <a id=creating-and-inserting-nodes:xlink-namespace-5 href=https://infra.spec.whatwg.org/#xlink-namespace data-x-internal=xlink-namespace>XLink namespace</a>
|
||
<tr><td> <code>xlink:show</code> <td> <code>xlink</code> <td> <code>show</code> <td> <a id=creating-and-inserting-nodes:xlink-namespace-6 href=https://infra.spec.whatwg.org/#xlink-namespace data-x-internal=xlink-namespace>XLink namespace</a>
|
||
<tr><td> <code>xlink:title</code> <td> <code>xlink</code> <td> <code>title</code> <td> <a id=creating-and-inserting-nodes:xlink-namespace-7 href=https://infra.spec.whatwg.org/#xlink-namespace data-x-internal=xlink-namespace>XLink namespace</a>
|
||
<tr><td> <code>xlink:type</code> <td> <code>xlink</code> <td> <code>type</code> <td> <a id=creating-and-inserting-nodes:xlink-namespace-8 href=https://infra.spec.whatwg.org/#xlink-namespace data-x-internal=xlink-namespace>XLink namespace</a>
|
||
<tr><td> <code>xml:lang</code> <td> <code>xml</code> <td> <code>lang</code> <td> <a id=creating-and-inserting-nodes:xml-namespace href=https://infra.spec.whatwg.org/#xml-namespace data-x-internal=xml-namespace>XML namespace</a>
|
||
<tr><td> <code>xml:space</code> <td> <code>xml</code> <td> <code>space</code> <td> <a id=creating-and-inserting-nodes:xml-namespace-2 href=https://infra.spec.whatwg.org/#xml-namespace data-x-internal=xml-namespace>XML namespace</a>
|
||
<tr><td> <code>xmlns</code> <td> (none) <td> <code>xmlns</code> <td> <a id=creating-and-inserting-nodes:xmlns-namespace-3 href=https://infra.spec.whatwg.org/#xmlns-namespace data-x-internal=xmlns-namespace>XMLNS namespace</a>
|
||
<tr><td> <code>xmlns:xlink</code> <td> <code>xmlns</code> <td> <code>xlink</code> <td> <a id=creating-and-inserting-nodes:xmlns-namespace-4 href=https://infra.spec.whatwg.org/#xmlns-namespace data-x-internal=xmlns-namespace>XMLNS namespace</a>
|
||
</table>
|
||
|
||
<hr>
|
||
|
||
<p>When the steps below require the user agent to <dfn id=insert-a-character>insert a character</dfn> while processing a
|
||
token, the user agent must run the following steps:</p>
|
||
|
||
<ol><li><p>Let <var>data</var> be the characters passed to the algorithm, or, if no
|
||
characters were explicitly specified, the character of the character token being
|
||
processed.<li><p>Let the <var>adjusted insertion location</var> be the <a href=#appropriate-place-for-inserting-a-node id=creating-and-inserting-nodes:appropriate-place-for-inserting-a-node-2>appropriate
|
||
place for inserting a node</a>.<li>
|
||
|
||
<p>If the <var>adjusted insertion location</var> is in a <code id=creating-and-inserting-nodes:document-2><a href=dom.html#document>Document</a></code> node,
|
||
then abort these steps.
|
||
|
||
<p class=note>The DOM will not let <code id=creating-and-inserting-nodes:document-3><a href=dom.html#document>Document</a></code> nodes have <code id=creating-and-inserting-nodes:text><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node
|
||
children, so they are dropped on the floor.</p>
|
||
|
||
<li>
|
||
|
||
<p>If there is a <code id=creating-and-inserting-nodes:text-2><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node immediately before the <var>adjusted insertion
|
||
location</var>, then append <var>data</var> to that <code id=creating-and-inserting-nodes:text-3><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node's data.</p>
|
||
|
||
<p>Otherwise, create a new <code id=creating-and-inserting-nodes:text-4><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node whose data is <var>data</var> and
|
||
whose <a id=creating-and-inserting-nodes:node-document-2 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> is the same as that of the
|
||
element in which the <var>adjusted insertion location</var> finds itself, and insert
|
||
the newly created node at the <var>adjusted insertion location</var>.</p>
|
||
|
||
</ol>
|
||
|
||
<div class=example>
|
||
|
||
<p>Here are some sample inputs to the parser and the corresponding number of <code id=creating-and-inserting-nodes:text-5><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code>
|
||
nodes that they result in, assuming a user agent that executes scripts.</p>
|
||
|
||
<table><thead><tr><th>Input <th>Number of <code id=creating-and-inserting-nodes:text-6><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> nodes
|
||
<tbody><tr><td><pre>A<script>
|
||
var script = document.getElementsByTagName('script')[0];
|
||
document.body.removeChild(script);
|
||
</script>B</pre>
|
||
<td>One <code id=creating-and-inserting-nodes:text-7><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node in the document, containing "AB".
|
||
<tr><td><pre>A<script>
|
||
var text = document.createTextNode('B');
|
||
document.body.appendChild(text);
|
||
</script>C</pre>
|
||
<td>Three <code id=creating-and-inserting-nodes:text-8><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> nodes; "A" before the script, the script's contents, and "BC" after the script (the parser appends to the <code id=creating-and-inserting-nodes:text-9><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node created by the script).
|
||
<tr><td><pre>A<script>
|
||
var text = document.getElementsByTagName('script')[0].firstChild;
|
||
text.data = 'B';
|
||
document.body.appendChild(text);
|
||
</script>C</pre>
|
||
<td>Two adjacent <code id=creating-and-inserting-nodes:text-10><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> nodes in the document, containing "A" and "BC".
|
||
<tr><td><pre>A<table>B<tr>C</tr>D</table></pre>
|
||
<td>One <code id=creating-and-inserting-nodes:text-11><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node before the table, containing "ABCD". (This is caused by <a href=#foster-parent id=creating-and-inserting-nodes:foster-parent-2>foster parenting</a>.)
|
||
<tr><td><pre>A<table><tr> B</tr> C</table></pre>
|
||
<td>One <code id=creating-and-inserting-nodes:text-12><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node before the table, containing "A B C" (A-space-B-space-C). (This is caused by <a href=#foster-parent id=creating-and-inserting-nodes:foster-parent-3>foster parenting</a>.)
|
||
<tr><td><pre>A<table><tr> B</tr> </em>C</table></pre>
|
||
<td>One <code id=creating-and-inserting-nodes:text-13><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node before the table, containing "A BC" (A-space-B-C), and one <code id=creating-and-inserting-nodes:text-14><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node inside the table (as a child of a <code id=creating-and-inserting-nodes:the-tbody-element-2><a href=tables.html#the-tbody-element>tbody</a></code>) with a single space character. (Space characters separated from non-space characters by non-character tokens are not affected by <a href=#foster-parent id=creating-and-inserting-nodes:foster-parent-4>foster parenting</a>, even if those other tokens then get ignored.)
|
||
</table>
|
||
|
||
</div>
|
||
|
||
<hr>
|
||
|
||
<p>When the steps below require the user agent to <dfn id=insert-a-comment>insert a comment</dfn> while processing a
|
||
comment token, optionally with an explicitly insertion position <var>position</var>, the
|
||
user agent must run the following steps:</p>
|
||
|
||
<ol><li><p>Let <var>data</var> be the data given in the comment token being
|
||
processed.<li><p>If <var>position</var> was specified, then let the <var>adjusted
|
||
insertion location</var> be <var>position</var>. Otherwise, let <var>adjusted
|
||
insertion location</var> be the <a href=#appropriate-place-for-inserting-a-node id=creating-and-inserting-nodes:appropriate-place-for-inserting-a-node-3>appropriate place for inserting a node</a>.<li><p>Create a <code id=creating-and-inserting-nodes:comment-2><a data-x-internal=comment-2 href=https://dom.spec.whatwg.org/#interface-comment>Comment</a></code> node whose <code>data</code> attribute is set to
|
||
<var>data</var> and whose <a id=creating-and-inserting-nodes:node-document-3 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> is
|
||
the same as that of the node in which the <var>adjusted insertion location</var> finds
|
||
itself.</p>
|
||
|
||
<li><p>Insert the newly created node at the <var>adjusted insertion
|
||
location</var>.</ol>
|
||
|
||
<hr>
|
||
|
||
<p id=mutation-during-parsing>DOM mutation events must not fire for changes caused by the UA
|
||
parsing the document. This includes the parsing of any content inserted using <code id=creating-and-inserting-nodes:dom-document-write-2-2><a href=dynamic-markup-insertion.html#dom-document-write-2>document.write()</a></code> and <code id=creating-and-inserting-nodes:dom-document-writeln-2><a href=dynamic-markup-insertion.html#dom-document-writeln-2>document.writeln()</a></code> calls. <a href=references.html#refsUIEVENTS>[UIEVENTS]</a></p>
|
||
|
||
<p>However, <a id=creating-and-inserting-nodes:mutation-observers href=https://dom.spec.whatwg.org/#mutation-observers data-x-internal=mutation-observers>mutation observers</a> <em>do</em> fire, as required by the WHATWG DOM
|
||
Standard.</p>
|
||
|
||
|
||
|
||
<h5 id=parsing-elements-that-contain-only-text><span class=secno>12.2.6.2</span> Parsing elements that contain only text<a href=#parsing-elements-that-contain-only-text class=self-link></a></h5>
|
||
|
||
<p>The <dfn id=generic-raw-text-element-parsing-algorithm>generic raw text element parsing algorithm</dfn> and the <dfn id=generic-rcdata-element-parsing-algorithm>generic RCDATA element
|
||
parsing algorithm</dfn> consist of the following steps. These algorithms are always invoked in
|
||
response to a start tag token.</p>
|
||
|
||
<ol><li><p><a href=#insert-an-html-element id=parsing-elements-that-contain-only-text:insert-an-html-element>Insert an HTML element</a> for the token.<li><p>If the algorithm that was invoked is the <a href=#generic-raw-text-element-parsing-algorithm id=parsing-elements-that-contain-only-text:generic-raw-text-element-parsing-algorithm>generic raw text element parsing
|
||
algorithm</a>, switch the tokenizer to the <a href=#rawtext-state id=parsing-elements-that-contain-only-text:rawtext-state>RAWTEXT state</a>; otherwise the algorithm
|
||
invoked was the <a href=#generic-rcdata-element-parsing-algorithm id=parsing-elements-that-contain-only-text:generic-rcdata-element-parsing-algorithm>generic RCDATA element parsing algorithm</a>, switch the tokenizer to
|
||
the <a href=#rcdata-state id=parsing-elements-that-contain-only-text:rcdata-state>RCDATA state</a>.<li><p>Let the <a href=#original-insertion-mode id=parsing-elements-that-contain-only-text:original-insertion-mode>original insertion mode</a> be the current <a href=#insertion-mode id=parsing-elements-that-contain-only-text:insertion-mode>insertion
|
||
mode</a>.</p>
|
||
|
||
<li><p>Then, switch the <a href=#insertion-mode id=parsing-elements-that-contain-only-text:insertion-mode-2>insertion mode</a> to "<a href=#parsing-main-incdata id=parsing-elements-that-contain-only-text:parsing-main-incdata>text</a>".</ol>
|
||
|
||
|
||
<h5 id=closing-elements-that-have-implied-end-tags><span class=secno>12.2.6.3</span> Closing elements that have implied end tags<a href=#closing-elements-that-have-implied-end-tags class=self-link></a></h5>
|
||
|
||
<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 id=closing-elements-that-have-implied-end-tags:current-node>current node</a> is a <code id=closing-elements-that-have-implied-end-tags:the-dd-element><a href=grouping-content.html#the-dd-element>dd</a></code> element, a <code id=closing-elements-that-have-implied-end-tags:the-dt-element><a href=grouping-content.html#the-dt-element>dt</a></code> element, an
|
||
<code id=closing-elements-that-have-implied-end-tags:the-li-element><a href=grouping-content.html#the-li-element>li</a></code> element, an <code id=closing-elements-that-have-implied-end-tags:the-optgroup-element><a href=form-elements.html#the-optgroup-element>optgroup</a></code> element, an <code id=closing-elements-that-have-implied-end-tags:the-option-element><a href=form-elements.html#the-option-element>option</a></code> element, a
|
||
<code id=closing-elements-that-have-implied-end-tags:the-p-element><a href=grouping-content.html#the-p-element>p</a></code> element, an <code id=closing-elements-that-have-implied-end-tags:rb><a href=obsolete.html#rb>rb</a></code> element, an <code id=closing-elements-that-have-implied-end-tags:the-rp-element><a href=text-level-semantics.html#the-rp-element>rp</a></code> element, an <code id=closing-elements-that-have-implied-end-tags:the-rt-element><a href=text-level-semantics.html#the-rt-element>rt</a></code>
|
||
element, or an <code id=closing-elements-that-have-implied-end-tags:rtc><a href=obsolete.html#rtc>rtc</a></code> element, the UA must pop the <a href=#current-node id=closing-elements-that-have-implied-end-tags:current-node-2>current node</a> off the
|
||
<a href=#stack-of-open-elements id=closing-elements-that-have-implied-end-tags:stack-of-open-elements>stack of open elements</a>.</p>
|
||
|
||
<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 id=closing-elements-that-have-implied-end-tags:current-node-3>current node</a> is a <code id=closing-elements-that-have-implied-end-tags:the-caption-element><a href=tables.html#the-caption-element>caption</a></code> element, a
|
||
<code id=closing-elements-that-have-implied-end-tags:the-colgroup-element><a href=tables.html#the-colgroup-element>colgroup</a></code> element, a <code id=closing-elements-that-have-implied-end-tags:the-dd-element-2><a href=grouping-content.html#the-dd-element>dd</a></code> element, a <code id=closing-elements-that-have-implied-end-tags:the-dt-element-2><a href=grouping-content.html#the-dt-element>dt</a></code> element, an
|
||
<code id=closing-elements-that-have-implied-end-tags:the-li-element-2><a href=grouping-content.html#the-li-element>li</a></code> element, an <code id=closing-elements-that-have-implied-end-tags:the-optgroup-element-2><a href=form-elements.html#the-optgroup-element>optgroup</a></code> element, an <code id=closing-elements-that-have-implied-end-tags:the-option-element-2><a href=form-elements.html#the-option-element>option</a></code> element, a
|
||
<code id=closing-elements-that-have-implied-end-tags:the-p-element-2><a href=grouping-content.html#the-p-element>p</a></code> element, an <code id=closing-elements-that-have-implied-end-tags:rb-2><a href=obsolete.html#rb>rb</a></code> element, an <code id=closing-elements-that-have-implied-end-tags:the-rp-element-2><a href=text-level-semantics.html#the-rp-element>rp</a></code> element, an <code id=closing-elements-that-have-implied-end-tags:the-rt-element-2><a href=text-level-semantics.html#the-rt-element>rt</a></code>
|
||
element, an <code id=closing-elements-that-have-implied-end-tags:rtc-2><a href=obsolete.html#rtc>rtc</a></code> element, a <code id=closing-elements-that-have-implied-end-tags:the-tbody-element><a href=tables.html#the-tbody-element>tbody</a></code> element, a <code id=closing-elements-that-have-implied-end-tags:the-td-element><a href=tables.html#the-td-element>td</a></code> element, a
|
||
<code id=closing-elements-that-have-implied-end-tags:the-tfoot-element><a href=tables.html#the-tfoot-element>tfoot</a></code> element, a <code id=closing-elements-that-have-implied-end-tags:the-th-element><a href=tables.html#the-th-element>th</a></code> element, a <code id=closing-elements-that-have-implied-end-tags:the-thead-element><a href=tables.html#the-thead-element>thead</a></code> element, or a
|
||
<code id=closing-elements-that-have-implied-end-tags:the-tr-element><a href=tables.html#the-tr-element>tr</a></code> element, the UA must pop the <a href=#current-node id=closing-elements-that-have-implied-end-tags:current-node-4>current node</a> off the
|
||
<a href=#stack-of-open-elements id=closing-elements-that-have-implied-end-tags:stack-of-open-elements-2>stack of open elements</a>.</p>
|
||
|
||
|
||
|
||
<h5 id=parsing-main-inhtml><span class=secno>12.2.6.4</span> The rules for parsing tokens in HTML content<a href=#parsing-main-inhtml class=self-link></a></h5>
|
||
|
||
|
||
<h6 id=the-initial-insertion-mode><span class=secno>12.2.6.4.1</span> The "<dfn>initial</dfn>" insertion mode<a href=#the-initial-insertion-mode class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#the-initial-insertion-mode id=the-initial-insertion-mode:the-initial-insertion-mode>initial</a>" <a href=#insertion-mode id=the-initial-insertion-mode: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
|
||
TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
|
||
U+000D CARRIAGE RETURN (CR), or U+0020 SPACE<dd>
|
||
<p>Ignore the token.</p>
|
||
<dt>A comment token<dd>
|
||
<p><a href=#insert-a-comment id=the-initial-insertion-mode:insert-a-comment>Insert a comment</a> as the last child of the <code id=the-initial-insertion-mode:document><a href=dom.html#document>Document</a></code> object.</p>
|
||
<dt>A DOCTYPE token<dd>
|
||
|
||
<p>If the DOCTYPE token's name is not a <a id=the-initial-insertion-mode:case-sensitive href=infrastructure.html#case-sensitive>case-sensitive</a> match for the string "<code>html</code>", or the token's public identifier is not missing, or the token's system
|
||
identifier is neither missing nor a <a id=the-initial-insertion-mode:case-sensitive-2 href=infrastructure.html#case-sensitive>case-sensitive</a> match for the string
|
||
"<code id=the-initial-insertion-mode:about:legacy-compat><a href=urls-and-fetching.html#about:legacy-compat>about:legacy-compat</a></code>", then there is a <a href=#parse-errors id=the-initial-insertion-mode:parse-errors>parse error</a>.</p>
|
||
|
||
<p>Append a <code id=the-initial-insertion-mode:documenttype><a data-x-internal=documenttype href=https://dom.spec.whatwg.org/#interface-documenttype>DocumentType</a></code> node to the <code id=the-initial-insertion-mode:document-2><a href=dom.html#document>Document</a></code> node, with the <code>name</code> attribute set to the name given in the DOCTYPE token, or the empty string
|
||
if the name was missing; the <code>publicId</code> attribute set to the public
|
||
identifier given in the DOCTYPE token, or the empty string if the public identifier was missing;
|
||
the <code>systemId</code> attribute set to the system identifier given in the DOCTYPE
|
||
token, or the empty string if the system identifier was missing; and the other attributes
|
||
specific to <code id=the-initial-insertion-mode:documenttype-2><a data-x-internal=documenttype href=https://dom.spec.whatwg.org/#interface-documenttype>DocumentType</a></code> objects set to null and empty lists as appropriate.
|
||
Associate the <code id=the-initial-insertion-mode:documenttype-3><a data-x-internal=documenttype href=https://dom.spec.whatwg.org/#interface-documenttype>DocumentType</a></code> node with the <code id=the-initial-insertion-mode:document-3><a href=dom.html#document>Document</a></code> object so that it is
|
||
returned as the value of the <code>doctype</code> attribute of the
|
||
<code id=the-initial-insertion-mode:document-4><a href=dom.html#document>Document</a></code> object.</p>
|
||
|
||
<p id=quirks-mode-doctypes>Then, if the document is <em>not</em> <a id=the-initial-insertion-mode:an-iframe-srcdoc-document href=iframe-embed-object.html#an-iframe-srcdoc-document>an <code>iframe</code>
|
||
<code>srcdoc</code> document</a>, and the DOCTYPE token matches
|
||
one of the conditions in the following list, then set the <code id=the-initial-insertion-mode:document-5><a href=dom.html#document>Document</a></code> to <a id=the-initial-insertion-mode:quirks-mode href=https://dom.spec.whatwg.org/#concept-document-quirks data-x-internal=quirks-mode>quirks
|
||
mode</a>:</p>
|
||
|
||
<ul class=brief><li> The <i id=the-initial-insertion-mode:force-quirks-flag><a href=#force-quirks-flag>force-quirks flag</a></i> is set to <i>on</i>. <li> The name is set to anything other than "<code>html</code>" (compared <a href=infrastructure.html#case-sensitive id=the-initial-insertion-mode:case-sensitive-3>case-sensitively</a>). <li> The public identifier is set to: "<code>-//W3O//DTD W3 HTML Strict 3.0//EN//</code>" <li> The public identifier is set to: "<code>-/W3C/DTD HTML 4.0 Transitional/EN</code>" <li> The public identifier is set to: "<code>HTML</code>" <li> The system identifier is set to: "<code>http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd</code>" <li> The public identifier starts with: "<code>+//Silmaril//dtd html Pro v0r11 19970101//</code>" <li> The public identifier starts with: "<code>-//AS//DTD HTML 3.0 asWedit + extensions//</code>" <li> The public identifier starts with: "<code>-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0 Level 1//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0 Level 2//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0 Strict Level 1//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0 Strict Level 2//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0 Strict//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.1E//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 3.0//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 3.2 Final//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 3.2//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 3//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Level 0//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Level 1//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Level 2//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Level 3//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Strict Level 0//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Strict Level 1//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Strict Level 2//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Strict Level 3//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Strict//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML//</code>" <li> The public identifier starts with: "<code>-//Metrius//DTD Metrius Presentational//</code>" <li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//</code>" <li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 2.0 HTML//</code>" <li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 2.0 Tables//</code>" <li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//</code>" <li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 3.0 HTML//</code>" <li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 3.0 Tables//</code>" <li> The public identifier starts with: "<code>-//Netscape Comm. Corp.//DTD HTML//</code>" <li> The public identifier starts with: "<code>-//Netscape Comm. Corp.//DTD Strict HTML//</code>" <li> The public identifier starts with: "<code>-//O'Reilly and Associates//DTD HTML 2.0//</code>" <li> The public identifier starts with: "<code>-//O'Reilly and Associates//DTD HTML Extended 1.0//</code>" <li> The public identifier starts with: "<code>-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//</code>" <li> The public identifier starts with: "<code>-//SQ//DTD HTML 2.0 HoTMetaL + extensions//</code>" <li> The public identifier starts with: "<code>-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//</code>" <li> The public identifier starts with: "<code>-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//</code>" <li> The public identifier starts with: "<code>-//Spyglass//DTD HTML 2.0 Extended//</code>" <li> The public identifier starts with: "<code>-//Sun Microsystems Corp.//DTD HotJava HTML//</code>" <li> The public identifier starts with: "<code>-//Sun Microsystems Corp.//DTD HotJava Strict HTML//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML 3 1995-03-24//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML 3.2 Draft//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML 3.2 Final//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML 3.2//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML 3.2S Draft//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML 4.0 Frameset//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML 4.0 Transitional//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML Experimental 19960712//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML Experimental 970421//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD W3 HTML//</code>" <li> The public identifier starts with: "<code>-//W3O//DTD W3 HTML 3.0//</code>" <li> The public identifier starts with: "<code>-//WebTechs//DTD Mozilla HTML 2.0//</code>" <li> The public identifier starts with: "<code>-//WebTechs//DTD Mozilla HTML//</code>" <li> The system identifier is missing and the public identifier starts with: "<code>-//W3C//DTD HTML 4.01 Frameset//</code>" <li> The system identifier is missing and the public identifier starts with: "<code>-//W3C//DTD HTML 4.01 Transitional//</code>" </ul>
|
||
|
||
<p>Otherwise, if the document is <em>not</em> <a id=the-initial-insertion-mode:an-iframe-srcdoc-document-2 href=iframe-embed-object.html#an-iframe-srcdoc-document>an <code>iframe</code> <code>srcdoc</code> document</a>, and the DOCTYPE token matches one of
|
||
the conditions in the following list, then set the <code id=the-initial-insertion-mode:document-6><a href=dom.html#document>Document</a></code> to <a id=the-initial-insertion-mode:limited-quirks-mode href=https://dom.spec.whatwg.org/#concept-document-limited-quirks data-x-internal=limited-quirks-mode>limited-quirks
|
||
mode</a>:</p>
|
||
|
||
<ul class=brief><li> The public identifier starts with: "<code>-//W3C//DTD XHTML 1.0 Frameset//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD XHTML 1.0 Transitional//</code>" <li> The system identifier is not missing and the public identifier starts with: "<code>-//W3C//DTD HTML 4.01 Frameset//</code>" <li> The system identifier is not missing and the public identifier starts with: "<code>-//W3C//DTD HTML 4.01 Transitional//</code>" </ul>
|
||
|
||
<p>The system identifier and public identifier strings must be compared to the values given in
|
||
the lists above in an <a id=the-initial-insertion-mode:ascii-case-insensitive href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> manner. A system identifier whose
|
||
value is the empty string is not considered missing for the purposes of the conditions
|
||
above.</p>
|
||
|
||
<p>Then, switch the <a href=#insertion-mode id=the-initial-insertion-mode:insertion-mode-2>insertion mode</a> to "<a href=#the-before-html-insertion-mode id=the-initial-insertion-mode:the-before-html-insertion-mode>before html</a>".</p>
|
||
|
||
<dt>Anything else<dd>
|
||
|
||
<p>If the document is <em>not</em> <a id=the-initial-insertion-mode:an-iframe-srcdoc-document-3 href=iframe-embed-object.html#an-iframe-srcdoc-document>an <code>iframe</code> <code>srcdoc</code> document</a>, then this is a <a href=#parse-errors id=the-initial-insertion-mode:parse-errors-2>parse
|
||
error</a>; set the <code id=the-initial-insertion-mode:document-7><a href=dom.html#document>Document</a></code> to <a id=the-initial-insertion-mode:quirks-mode-2 href=https://dom.spec.whatwg.org/#concept-document-quirks data-x-internal=quirks-mode>quirks mode</a>.</p>
|
||
|
||
<p>In any case, switch the <a href=#insertion-mode id=the-initial-insertion-mode:insertion-mode-3>insertion mode</a> to "<a href=#the-before-html-insertion-mode id=the-initial-insertion-mode:the-before-html-insertion-mode-2>before html</a>", then reprocess the token.</p>
|
||
|
||
</dl>
|
||
|
||
|
||
<h6 id=the-before-html-insertion-mode><span class=secno>12.2.6.4.2</span> The "<dfn>before html</dfn>" insertion mode<a href=#the-before-html-insertion-mode class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#the-before-html-insertion-mode id=the-before-html-insertion-mode:the-before-html-insertion-mode>before html</a>" <a href=#insertion-mode id=the-before-html-insertion-mode:insertion-mode>insertion mode</a>, the user agent must handle the token as
|
||
follows:</p>
|
||
|
||
<dl class=switch><dt>A DOCTYPE token<dd>
|
||
<p><a href=#parse-errors id=the-before-html-insertion-mode:parse-errors>Parse error</a>. Ignore the token.</p>
|
||
<dt>A comment token<dd>
|
||
<p><a href=#insert-a-comment id=the-before-html-insertion-mode:insert-a-comment>Insert a comment</a> as the last child of the <code id=the-before-html-insertion-mode:document><a href=dom.html#document>Document</a></code> object.</p>
|
||
<dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C
|
||
FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE<dd>
|
||
<p>Ignore the token.</p>
|
||
<dt>A start tag whose tag name is "html"<dd>
|
||
|
||
<p><a href=#create-an-element-for-the-token id=the-before-html-insertion-mode:create-an-element-for-the-token>Create an element for the token</a> in the <a id=the-before-html-insertion-mode:html-namespace-2 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a>, with the
|
||
<code id=the-before-html-insertion-mode:document-2><a href=dom.html#document>Document</a></code> as the intended parent. Append it to the <code id=the-before-html-insertion-mode:document-3><a href=dom.html#document>Document</a></code> object. Put
|
||
this element in the <a href=#stack-of-open-elements id=the-before-html-insertion-mode:stack-of-open-elements>stack of open elements</a>.</p>
|
||
|
||
<p id=parser-appcache>If the <code id=the-before-html-insertion-mode:document-4><a href=dom.html#document>Document</a></code> is being loaded as part of <a href=browsing-the-web.html#navigate id=the-before-html-insertion-mode:navigate>navigation</a> of a <a id=the-before-html-insertion-mode:browsing-context href=browsers.html#browsing-context>browsing context</a>, run these steps:</p>
|
||
|
||
<ol><li><p>If the result of running <a href=https://w3c.github.io/ServiceWorker/#scope-match-algorithm id=the-before-html-insertion-mode:scope-match-algorithm data-x-internal=scope-match-algorithm>match service worker
|
||
registration</a> for the document's <a href=https://dom.spec.whatwg.org/#concept-document-url id="the-before-html-insertion-mode:the-document's-address" data-x-internal="the-document's-address">URL</a> is
|
||
non-null, run the <a href=offline.html#concept-appcache-init id=the-before-html-insertion-mode:concept-appcache-init>application cache selection
|
||
algorithm</a> passing the <code id=the-before-html-insertion-mode:document-5><a href=dom.html#document>Document</a></code> object with no manifest.<li>
|
||
|
||
<p>Otherwise, run these substeps:</p>
|
||
|
||
<ol><li><p>If the newly created element has a <code id=the-before-html-insertion-mode:attr-html-manifest><a href=semantics.html#attr-html-manifest>manifest</a></code>
|
||
attribute whose value is not the empty string, then <a href=urls-and-fetching.html#parse-a-url id=the-before-html-insertion-mode:parse-a-url>parse</a> the value of that attribute, relative to the newly created element's
|
||
<a id=the-before-html-insertion-mode:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>, and if that is successful, run the <a href=offline.html#concept-appcache-init id=the-before-html-insertion-mode:concept-appcache-init-2>application cache selection algorithm</a> passing the
|
||
<code id=the-before-html-insertion-mode:document-6><a href=dom.html#document>Document</a></code> object with the result of applying the <a href=https://url.spec.whatwg.org/#concept-url-serializer id=the-before-html-insertion-mode:concept-url-serializer data-x-internal=concept-url-serializer>URL serializer</a> algorithm to the <a id=the-before-html-insertion-mode:resulting-url-record href=urls-and-fetching.html#resulting-url-record>resulting URL
|
||
record</a> with the <i>exclude fragment flag</i> set.<li><p>Otherwise, run the <a href=offline.html#concept-appcache-init id=the-before-html-insertion-mode:concept-appcache-init-3>application cache selection
|
||
algorithm</a> passing the <code id=the-before-html-insertion-mode:document-7><a href=dom.html#document>Document</a></code> object with no manifest.</ol>
|
||
|
||
</ol>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=the-before-html-insertion-mode:insertion-mode-2>insertion mode</a> to "<a href=#the-before-head-insertion-mode id=the-before-html-insertion-mode:the-before-head-insertion-mode>before
|
||
head</a>".</p>
|
||
|
||
<dt>An end tag whose tag name is one of: "head", "body", "html", "br"<dd>
|
||
<p>Act as described in the "anything else" entry below.</p>
|
||
<dt>Any other end tag<dd>
|
||
<p><a href=#parse-errors id=the-before-html-insertion-mode:parse-errors-2>Parse error</a>. Ignore the token.</p>
|
||
<dt>Anything else<dd>
|
||
|
||
<p>Create an <code id=the-before-html-insertion-mode:the-html-element><a href=semantics.html#the-html-element>html</a></code> element whose <a id=the-before-html-insertion-mode:node-document-2 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> is the <code id=the-before-html-insertion-mode:document-8><a href=dom.html#document>Document</a></code> object. Append
|
||
it to the <code id=the-before-html-insertion-mode:document-9><a href=dom.html#document>Document</a></code> object. Put this element in the <a href=#stack-of-open-elements id=the-before-html-insertion-mode:stack-of-open-elements-2>stack of open
|
||
elements</a>.</p>
|
||
|
||
<p>If the <code id=the-before-html-insertion-mode:document-10><a href=dom.html#document>Document</a></code> is being loaded as part of <a href=browsing-the-web.html#navigate id=the-before-html-insertion-mode:navigate-2>navigation</a> of a <a id=the-before-html-insertion-mode:browsing-context-2 href=browsers.html#browsing-context>browsing context</a>, then: run the <a href=offline.html#concept-appcache-init id=the-before-html-insertion-mode:concept-appcache-init-4>application cache selection algorithm</a> with no manifest,
|
||
passing it the <code id=the-before-html-insertion-mode:document-11><a href=dom.html#document>Document</a></code> object.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=the-before-html-insertion-mode:insertion-mode-3>insertion mode</a> to "<a href=#the-before-head-insertion-mode id=the-before-html-insertion-mode:the-before-head-insertion-mode-2>before
|
||
head</a>", then reprocess the token.</p>
|
||
|
||
</dl>
|
||
|
||
<p>The <a id=the-before-html-insertion-mode:document-element href=https://dom.spec.whatwg.org/#document-element data-x-internal=document-element>document element</a> can end up being removed from the <code id=the-before-html-insertion-mode:document-12><a href=dom.html#document>Document</a></code>
|
||
object, e.g. by scripts; nothing in particular happens in such cases, content continues being
|
||
appended to the nodes as described in the next section.</p>
|
||
|
||
|
||
<h6 id=the-before-head-insertion-mode><span class=secno>12.2.6.4.3</span> The "<dfn>before head</dfn>" insertion mode<a href=#the-before-head-insertion-mode class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#the-before-head-insertion-mode id=the-before-head-insertion-mode:the-before-head-insertion-mode>before head</a>" <a href=#insertion-mode id=the-before-head-insertion-mode: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
|
||
TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
|
||
U+000D CARRIAGE RETURN (CR), or U+0020 SPACE<dd>
|
||
<p>Ignore the token.</p>
|
||
<dt>A comment token<dd>
|
||
<p><a href=#insert-a-comment id=the-before-head-insertion-mode:insert-a-comment>Insert a comment</a>.</p>
|
||
<dt>A DOCTYPE token<dd>
|
||
<p><a href=#parse-errors id=the-before-head-insertion-mode:parse-errors>Parse error</a>. Ignore the token.</p>
|
||
<dt>A start tag whose tag name is "html"<dd>
|
||
<p>Process the token <a href=#using-the-rules-for id=the-before-head-insertion-mode:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody id=the-before-head-insertion-mode:parsing-main-inbody>in body</a>" <a href=#insertion-mode id=the-before-head-insertion-mode:insertion-mode-2>insertion mode</a>.</p>
|
||
<dt>A start tag whose tag name is "head"<dd>
|
||
|
||
<p><a href=#insert-an-html-element id=the-before-head-insertion-mode:insert-an-html-element>Insert an HTML element</a> for the token.</p>
|
||
|
||
<p>Set the <a href=#head-element-pointer id=the-before-head-insertion-mode:head-element-pointer><code>head</code> element pointer</a> to the newly created
|
||
<code id=the-before-head-insertion-mode:the-head-element><a href=semantics.html#the-head-element>head</a></code> element.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=the-before-head-insertion-mode:insertion-mode-3>insertion mode</a> to "<a href=#parsing-main-inhead id=the-before-head-insertion-mode:parsing-main-inhead>in
|
||
head</a>".</p>
|
||
|
||
<dt>An end tag whose tag name is one of: "head", "body", "html", "br"<dd>
|
||
|
||
<p>Act as described in the "anything else" entry below.</p>
|
||
|
||
<dt>Any other end tag<dd>
|
||
|
||
<p><a href=#parse-errors id=the-before-head-insertion-mode:parse-errors-2>Parse error</a>. Ignore the token.</p>
|
||
|
||
<dt>Anything else<dd>
|
||
|
||
|
||
|
||
<p><a href=#insert-an-html-element id=the-before-head-insertion-mode:insert-an-html-element-2>Insert an HTML element</a> for a "head" start tag token with no attributes.</p>
|
||
|
||
<p>Set the <a href=#head-element-pointer id=the-before-head-insertion-mode:head-element-pointer-2><code>head</code> element pointer</a> to the newly created
|
||
<code id=the-before-head-insertion-mode:the-head-element-2><a href=semantics.html#the-head-element>head</a></code> element.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=the-before-head-insertion-mode:insertion-mode-4>insertion mode</a> to "<a href=#parsing-main-inhead id=the-before-head-insertion-mode:parsing-main-inhead-2>in
|
||
head</a>".</p>
|
||
|
||
|
||
|
||
<p>Reprocess the current token.</p>
|
||
|
||
</dl>
|
||
|
||
|
||
<h6 id=parsing-main-inhead><span class=secno>12.2.6.4.4</span> The "<dfn>in head</dfn>" insertion mode<a href=#parsing-main-inhead class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-inhead id=parsing-main-inhead:parsing-main-inhead>in
|
||
head</a>" <a href=#insertion-mode id=parsing-main-inhead: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
|
||
TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
|
||
U+000D CARRIAGE RETURN (CR), or U+0020 SPACE<dd>
|
||
<p><a href=#insert-a-character id=parsing-main-inhead:insert-a-character>Insert the character</a>.</p>
|
||
<dt>A comment token<dd>
|
||
<p><a href=#insert-a-comment id=parsing-main-inhead:insert-a-comment>Insert a comment</a>.</p>
|
||
<dt>A DOCTYPE token<dd>
|
||
<p><a href=#parse-errors id=parsing-main-inhead:parse-errors>Parse error</a>. Ignore the token.</p>
|
||
<dt>A start tag whose tag name is "html"<dd>
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-inhead:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody id=parsing-main-inhead:parsing-main-inbody>in body</a>" <a href=#insertion-mode id=parsing-main-inhead:insertion-mode-2>insertion mode</a>.</p>
|
||
<dt>A start tag whose tag name is one of: "base", "basefont",
|
||
"bgsound", "link"<dd>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inhead:insert-an-html-element>Insert an HTML element</a> for the token. Immediately pop the <a href=#current-node id=parsing-main-inhead:current-node>current
|
||
node</a> off the <a href=#stack-of-open-elements id=parsing-main-inhead:stack-of-open-elements>stack of open elements</a>.</p>
|
||
|
||
<p><a href=#acknowledge-self-closing-flag id=parsing-main-inhead:acknowledge-self-closing-flag>Acknowledge the token's <i>self-closing
|
||
flag</i></a>, if it is set.</p>
|
||
|
||
<dt>A start tag whose tag name is "meta"<dd>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inhead:insert-an-html-element-2>Insert an HTML element</a> for the token. Immediately pop the <a href=#current-node id=parsing-main-inhead:current-node-2>current
|
||
node</a> off the <a href=#stack-of-open-elements id=parsing-main-inhead:stack-of-open-elements-2>stack of open elements</a>.</p>
|
||
|
||
<p><a href=#acknowledge-self-closing-flag id=parsing-main-inhead:acknowledge-self-closing-flag-2>Acknowledge the token's <i>self-closing
|
||
flag</i></a>, if it is set.</p>
|
||
|
||
<p id=meta-charset-during-parse>If the element has a <code id=parsing-main-inhead:attr-meta-charset><a href=semantics.html#attr-meta-charset>charset</a></code> attribute, and <a id=parsing-main-inhead:getting-an-encoding href=https://encoding.spec.whatwg.org/#concept-encoding-get data-x-internal=getting-an-encoding>getting an encoding</a> from
|
||
its value results in an <a id=parsing-main-inhead:encoding href=https://encoding.spec.whatwg.org/#encoding data-x-internal=encoding>encoding</a>, and the
|
||
<a href=#concept-encoding-confidence id=parsing-main-inhead:concept-encoding-confidence>confidence</a> is currently <i>tentative</i>, then
|
||
<a href=#change-the-encoding id=parsing-main-inhead:change-the-encoding>change the encoding</a> to the resulting encoding.</p>
|
||
|
||
<p>Otherwise, if the element has an <code id=parsing-main-inhead:attr-meta-http-equiv><a href=semantics.html#attr-meta-http-equiv>http-equiv</a></code>
|
||
attribute whose value is an <a id=parsing-main-inhead:ascii-case-insensitive href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code>Content-Type</code>", and the element has a <code id=parsing-main-inhead:attr-meta-content><a href=semantics.html#attr-meta-content>content</a></code> attribute, and applying the <a id=parsing-main-inhead:algorithm-for-extracting-a-character-encoding-from-a-meta-element href=urls-and-fetching.html#algorithm-for-extracting-a-character-encoding-from-a-meta-element>algorithm for
|
||
extracting a character encoding from a <code>meta</code> element</a> to that attribute's
|
||
value returns an <a id=parsing-main-inhead:encoding-2 href=https://encoding.spec.whatwg.org/#encoding data-x-internal=encoding>encoding</a>, and the
|
||
<a href=#concept-encoding-confidence id=parsing-main-inhead:concept-encoding-confidence-2>confidence</a> is currently <i>tentative</i>, then
|
||
<a href=#change-the-encoding id=parsing-main-inhead:change-the-encoding-2>change the encoding</a> to the extracted encoding.</p>
|
||
|
||
<dt>A start tag whose tag name is "title"<dd>
|
||
<p>Follow the <a href=#generic-rcdata-element-parsing-algorithm id=parsing-main-inhead:generic-rcdata-element-parsing-algorithm>generic RCDATA element parsing algorithm</a>.</p>
|
||
<dt>A start tag whose tag name is "noscript", if the <a href=#scripting-flag id=parsing-main-inhead:scripting-flag>scripting flag</a> is enabled<dt>A start tag whose tag name is one of: "noframes", "style"<dd>
|
||
<p>Follow the <a href=#generic-raw-text-element-parsing-algorithm id=parsing-main-inhead:generic-raw-text-element-parsing-algorithm>generic raw text element parsing algorithm</a>.</p>
|
||
<dt>A start tag whose tag name is "noscript", if the <a href=#scripting-flag id=parsing-main-inhead:scripting-flag-2>scripting flag</a> is disabled<dd>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inhead:insert-an-html-element-3>Insert an HTML element</a> for the token.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-inhead:insertion-mode-3>insertion mode</a> to "<a href=#parsing-main-inheadnoscript id=parsing-main-inhead:parsing-main-inheadnoscript>in
|
||
head noscript</a>".</p>
|
||
|
||
<dt id=scriptTag>A start tag whose tag name is "script"<dd>
|
||
|
||
<p>Run these steps:</p>
|
||
|
||
<ol><li><p>Let the <var>adjusted insertion location</var> be the <a href=#appropriate-place-for-inserting-a-node id=parsing-main-inhead:appropriate-place-for-inserting-a-node>appropriate place
|
||
for inserting a node</a>.<li><p><a href=#create-an-element-for-the-token id=parsing-main-inhead:create-an-element-for-the-token>Create an element for the token</a> in the <a id=parsing-main-inhead:html-namespace-2 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a>, with
|
||
the intended parent being the element in which the <var>adjusted insertion
|
||
location</var> finds itself.<li>
|
||
|
||
<p>Mark the element as being <a id=parsing-main-inhead:parser-inserted href=scripting.html#parser-inserted>"parser-inserted"</a> and unset the element's
|
||
<a id=parsing-main-inhead:non-blocking href=scripting.html#non-blocking>"non-blocking"</a> flag.</p>
|
||
|
||
<p class=note>This ensures that, if the script is external, any <code id=parsing-main-inhead:dom-document-write-2><a href=dynamic-markup-insertion.html#dom-document-write-2>document.write()</a></code> calls in the script will execute in-line,
|
||
instead of blowing the document away, as would happen in most other cases. It also prevents
|
||
the script from executing until the end tag is seen.</p>
|
||
|
||
<li><p>If the parser was originally created for the <a href=#html-fragment-parsing-algorithm id=parsing-main-inhead:html-fragment-parsing-algorithm>HTML fragment parsing
|
||
algorithm</a>, then mark the <code id=parsing-main-inhead:the-script-element><a href=scripting.html#the-script-element>script</a></code> element as <a id=parsing-main-inhead:already-started href=scripting.html#already-started>"already started"</a>.
|
||
(<a href=#fragment-case id=parsing-main-inhead:fragment-case>fragment case</a>)<li id=document-written-scripts-intervention><p>If the parser was invoked via the <code id=parsing-main-inhead:dom-document-write-2-2><a href=dynamic-markup-insertion.html#dom-document-write-2>document.write()</a></code> or <code id=parsing-main-inhead:dom-document-writeln-2><a href=dynamic-markup-insertion.html#dom-document-writeln-2>document.writeln()</a></code> methods, then optionally mark the
|
||
<code id=parsing-main-inhead:the-script-element-2><a href=scripting.html#the-script-element>script</a></code> element as <a id=parsing-main-inhead:already-started-2 href=scripting.html#already-started>"already started"</a>. (For example, the user agent
|
||
might use this clause to prevent execution of <a href=origin.html#concept-origin id=parsing-main-inhead:concept-origin>cross-origin</a> scripts
|
||
inserted via <code id=parsing-main-inhead:dom-document-write-2-3><a href=dynamic-markup-insertion.html#dom-document-write-2>document.write()</a></code> under slow network
|
||
conditions, or when the page has already taken a long time to load.)<li><p>Insert the newly created element at the <var>adjusted insertion
|
||
location</var>.<li><p>Push the element onto the <a href=#stack-of-open-elements id=parsing-main-inhead:stack-of-open-elements-3>stack of open elements</a> so that it is the new
|
||
<a href=#current-node id=parsing-main-inhead:current-node-3>current node</a>.<li><p>Switch the tokenizer to the <a href=#script-data-state id=parsing-main-inhead:script-data-state>script data state</a>.<li><p>Let the <a href=#original-insertion-mode id=parsing-main-inhead:original-insertion-mode>original insertion mode</a> be the current <a href=#insertion-mode id=parsing-main-inhead:insertion-mode-4>insertion
|
||
mode</a>.</p>
|
||
|
||
<li><p>Switch the <a href=#insertion-mode id=parsing-main-inhead:insertion-mode-5>insertion mode</a> to "<a href=#parsing-main-incdata id=parsing-main-inhead:parsing-main-incdata>text</a>".</ol>
|
||
|
||
<dt>An end tag whose tag name is "head"<dd>
|
||
|
||
<p>Pop the <a href=#current-node id=parsing-main-inhead:current-node-4>current node</a> (which will be the <code id=parsing-main-inhead:the-head-element><a href=semantics.html#the-head-element>head</a></code> element) off the
|
||
<a href=#stack-of-open-elements id=parsing-main-inhead:stack-of-open-elements-4>stack of open elements</a>.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-inhead:insertion-mode-6>insertion mode</a> to "<a href=#the-after-head-insertion-mode id=parsing-main-inhead:the-after-head-insertion-mode>after
|
||
head</a>".</p>
|
||
|
||
<dt>An end tag whose tag name is one of: "body", "html", "br"<dd>
|
||
<p>Act as described in the "anything else" entry below.</p>
|
||
<dt>A start tag whose tag name is "template"<dd>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inhead:insert-an-html-element-4>Insert an HTML element</a> for the token.</p>
|
||
|
||
<p>Insert a <a href=#concept-parser-marker id=parsing-main-inhead:concept-parser-marker>marker</a> at the end of the <a href=#list-of-active-formatting-elements id=parsing-main-inhead:list-of-active-formatting-elements>list of
|
||
active formatting elements</a>.</p>
|
||
|
||
<p>Set the <a href=#frameset-ok-flag id=parsing-main-inhead:frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-inhead:insertion-mode-7>insertion mode</a> to "<a href=#parsing-main-intemplate id=parsing-main-inhead:parsing-main-intemplate>in
|
||
template</a>".</p>
|
||
|
||
<p>Push "<a href=#parsing-main-intemplate id=parsing-main-inhead:parsing-main-intemplate-2>in template</a>" onto the <a href=#stack-of-template-insertion-modes id=parsing-main-inhead:stack-of-template-insertion-modes>stack of
|
||
template insertion modes</a> so that it is the new <a href=#current-template-insertion-mode id=parsing-main-inhead:current-template-insertion-mode>current template insertion
|
||
mode</a>.</p>
|
||
|
||
<dt>An end tag whose tag name is "template"<dd>
|
||
|
||
<p>If there is no <code id=parsing-main-inhead:the-template-element><a href=scripting.html#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements id=parsing-main-inhead:stack-of-open-elements-5>stack of open elements</a>, then
|
||
this is a <a href=#parse-errors id=parsing-main-inhead:parse-errors-2>parse error</a>; ignore the token.</p>
|
||
|
||
<p>Otherwise, run these steps:</p>
|
||
|
||
<ol><li><p><a href=#generate-all-implied-end-tags-thoroughly id=parsing-main-inhead:generate-all-implied-end-tags-thoroughly>Generate all implied end tags thoroughly</a>.<li><p>If the <a href=#current-node id=parsing-main-inhead:current-node-5>current node</a> is not a <code id=parsing-main-inhead:the-template-element-2><a href=scripting.html#the-template-element>template</a></code> element, then this is a
|
||
<a href=#parse-errors id=parsing-main-inhead:parse-errors-3>parse error</a>.<li><p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inhead:stack-of-open-elements-6>stack of open elements</a> until a <code id=parsing-main-inhead:the-template-element-3><a href=scripting.html#the-template-element>template</a></code>
|
||
element has been popped from the stack.<li><a href=#clear-the-list-of-active-formatting-elements-up-to-the-last-marker id=parsing-main-inhead: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><p>Pop the <a href=#current-template-insertion-mode id=parsing-main-inhead:current-template-insertion-mode-2>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes id=parsing-main-inhead:stack-of-template-insertion-modes-2>stack of template
|
||
insertion modes</a>.</p>
|
||
|
||
<li><p><a href=#reset-the-insertion-mode-appropriately id=parsing-main-inhead:reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</ol>
|
||
|
||
<dt>A start tag whose tag name is "head"<dt>Any other end tag<dd>
|
||
<p><a href=#parse-errors id=parsing-main-inhead:parse-errors-4>Parse error</a>. Ignore the token.</p>
|
||
<dt>Anything else<dd>
|
||
|
||
|
||
|
||
|
||
<p>Pop the <a href=#current-node id=parsing-main-inhead:current-node-6>current node</a> (which will be the <code id=parsing-main-inhead:the-head-element-2><a href=semantics.html#the-head-element>head</a></code> element) off the
|
||
<a href=#stack-of-open-elements id=parsing-main-inhead:stack-of-open-elements-7>stack of open elements</a>.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-inhead:insertion-mode-8>insertion mode</a> to "<a href=#the-after-head-insertion-mode id=parsing-main-inhead:the-after-head-insertion-mode-2>after
|
||
head</a>".</p>
|
||
|
||
|
||
<p>Reprocess the token.</p>
|
||
|
||
</dl>
|
||
|
||
|
||
<h6 id=parsing-main-inheadnoscript><span class=secno>12.2.6.4.5</span> The "<dfn>in head noscript</dfn>" insertion mode<a href=#parsing-main-inheadnoscript class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-inheadnoscript id=parsing-main-inheadnoscript:parsing-main-inheadnoscript>in head noscript</a>" <a href=#insertion-mode id=parsing-main-inheadnoscript:insertion-mode>insertion mode</a>, the user agent must handle the
|
||
token as follows:</p>
|
||
|
||
<dl class=switch><dt>A DOCTYPE token<dd>
|
||
<p><a href=#parse-errors id=parsing-main-inheadnoscript:parse-errors>Parse error</a>. Ignore the token.</p>
|
||
<dt>A start tag whose tag name is "html"<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-inheadnoscript:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody id=parsing-main-inheadnoscript:parsing-main-inbody>in body</a>" <a href=#insertion-mode id=parsing-main-inheadnoscript:insertion-mode-2>insertion mode</a>.</p>
|
||
|
||
<dt>An end tag whose tag name is "noscript"<dd>
|
||
|
||
<p>Pop the <a href=#current-node id=parsing-main-inheadnoscript:current-node>current node</a> (which will be a <code id=parsing-main-inheadnoscript:the-noscript-element><a href=scripting.html#the-noscript-element>noscript</a></code> element) from the
|
||
<a href=#stack-of-open-elements id=parsing-main-inheadnoscript:stack-of-open-elements>stack of open elements</a>; the new <a href=#current-node id=parsing-main-inheadnoscript:current-node-2>current node</a> will be a
|
||
<code id=parsing-main-inheadnoscript:the-head-element><a href=semantics.html#the-head-element>head</a></code> element.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-inheadnoscript:insertion-mode-3>insertion mode</a> to "<a href=#parsing-main-inhead id=parsing-main-inheadnoscript:parsing-main-inhead>in
|
||
head</a>".</p>
|
||
|
||
<dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C
|
||
FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE<dt>A comment token<dt>A start tag whose tag name is one of: "basefont", "bgsound", "link", "meta", "noframes",
|
||
"style"<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-inheadnoscript:using-the-rules-for-2>using the rules for</a> the "<a href=#parsing-main-inhead id=parsing-main-inheadnoscript:parsing-main-inhead-2>in head</a>" <a href=#insertion-mode id=parsing-main-inheadnoscript:insertion-mode-4>insertion mode</a>.</p>
|
||
|
||
<dt>An end tag whose tag name is "br"<dd>
|
||
<p>Act as described in the "anything else" entry below.</p>
|
||
<dt>A start tag whose tag name is one of: "head", "noscript"<dt>Any other end tag<dd>
|
||
<p><a href=#parse-errors id=parsing-main-inheadnoscript:parse-errors-2>Parse error</a>. Ignore the token.</p>
|
||
<dt>Anything else<dd>
|
||
|
||
|
||
|
||
<p><a href=#parse-errors id=parsing-main-inheadnoscript:parse-errors-3>Parse error</a>.</p>
|
||
|
||
|
||
<p>Pop the <a href=#current-node id=parsing-main-inheadnoscript:current-node-3>current node</a> (which will be a <code id=parsing-main-inheadnoscript:the-noscript-element-2><a href=scripting.html#the-noscript-element>noscript</a></code> element) from the
|
||
<a href=#stack-of-open-elements id=parsing-main-inheadnoscript:stack-of-open-elements-2>stack of open elements</a>; the new <a href=#current-node id=parsing-main-inheadnoscript:current-node-4>current node</a> will be a
|
||
<code id=parsing-main-inheadnoscript:the-head-element-2><a href=semantics.html#the-head-element>head</a></code> element.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-inheadnoscript:insertion-mode-5>insertion mode</a> to "<a href=#parsing-main-inhead id=parsing-main-inheadnoscript:parsing-main-inhead-3>in
|
||
head</a>".</p>
|
||
|
||
|
||
<p>Reprocess the token.</p>
|
||
|
||
</dl>
|
||
|
||
|
||
<h6 id=the-after-head-insertion-mode><span class=secno>12.2.6.4.6</span> The "<dfn>after head</dfn>" insertion mode<a href=#the-after-head-insertion-mode class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#the-after-head-insertion-mode id=the-after-head-insertion-mode:the-after-head-insertion-mode>after head</a>" <a href=#insertion-mode id=the-after-head-insertion-mode: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
|
||
TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
|
||
U+000D CARRIAGE RETURN (CR), or U+0020 SPACE<dd>
|
||
<p><a href=#insert-a-character id=the-after-head-insertion-mode:insert-a-character>Insert the character</a>.</p>
|
||
<dt>A comment token<dd>
|
||
<p><a href=#insert-a-comment id=the-after-head-insertion-mode:insert-a-comment>Insert a comment</a>.</p>
|
||
<dt>A DOCTYPE token<dd>
|
||
<p><a href=#parse-errors id=the-after-head-insertion-mode:parse-errors>Parse error</a>. Ignore the token.</p>
|
||
<dt>A start tag whose tag name is "html"<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=the-after-head-insertion-mode:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody id=the-after-head-insertion-mode:parsing-main-inbody>in body</a>" <a href=#insertion-mode id=the-after-head-insertion-mode:insertion-mode-2>insertion mode</a>.</p>
|
||
|
||
<dt>A start tag whose tag name is "body"<dd>
|
||
|
||
<p><a href=#insert-an-html-element id=the-after-head-insertion-mode:insert-an-html-element>Insert an HTML element</a> for the token.</p>
|
||
|
||
<p>Set the <a href=#frameset-ok-flag id=the-after-head-insertion-mode:frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=the-after-head-insertion-mode:insertion-mode-3>insertion mode</a> to "<a href=#parsing-main-inbody id=the-after-head-insertion-mode:parsing-main-inbody-2>in
|
||
body</a>".</p>
|
||
|
||
<dt>A start tag whose tag name is "frameset"<dd>
|
||
|
||
<p><a href=#insert-an-html-element id=the-after-head-insertion-mode:insert-an-html-element-2>Insert an HTML element</a> for the token.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=the-after-head-insertion-mode:insertion-mode-4>insertion mode</a> to "<a href=#parsing-main-inframeset id=the-after-head-insertion-mode:parsing-main-inframeset>in
|
||
frameset</a>".</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "base", "basefont", "bgsound", "link", "meta",
|
||
"noframes", "script", "style", "template", "title"<dd>
|
||
|
||
<p><a href=#parse-errors id=the-after-head-insertion-mode:parse-errors-2>Parse error</a>.</p>
|
||
|
||
<p>Push the node pointed to by the <a href=#head-element-pointer id=the-after-head-insertion-mode:head-element-pointer><code>head</code> element pointer</a> onto
|
||
the <a href=#stack-of-open-elements id=the-after-head-insertion-mode:stack-of-open-elements>stack of open elements</a>.</p>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=the-after-head-insertion-mode:using-the-rules-for-2>using the rules for</a> the "<a href=#parsing-main-inhead id=the-after-head-insertion-mode:parsing-main-inhead>in head</a>" <a href=#insertion-mode id=the-after-head-insertion-mode:insertion-mode-5>insertion mode</a>.</p>
|
||
|
||
<p>Remove the node pointed to by the <a href=#head-element-pointer id=the-after-head-insertion-mode:head-element-pointer-2><code>head</code> element pointer</a>
|
||
from the <a href=#stack-of-open-elements id=the-after-head-insertion-mode:stack-of-open-elements-2>stack of open elements</a>. (It might not be the <a href=#current-node id=the-after-head-insertion-mode:current-node>current node</a> at
|
||
this point.)</p>
|
||
|
||
<p class=note>The <a href=#head-element-pointer id=the-after-head-insertion-mode:head-element-pointer-3><code>head</code> element pointer</a> cannot be null at
|
||
this point.</p>
|
||
|
||
<dt>An end tag whose tag name is "template"<dd>
|
||
<p>Process the token <a href=#using-the-rules-for id=the-after-head-insertion-mode:using-the-rules-for-3>using the rules for</a> the "<a href=#parsing-main-inhead id=the-after-head-insertion-mode:parsing-main-inhead-2>in head</a>" <a href=#insertion-mode id=the-after-head-insertion-mode:insertion-mode-6>insertion mode</a>.</p>
|
||
<dt>An end tag whose tag name is one of: "body", "html", "br"<dd>
|
||
<p>Act as described in the "anything else" entry below.</p>
|
||
<dt>A start tag whose tag name is "head"<dt>Any other end tag<dd>
|
||
<p><a href=#parse-errors id=the-after-head-insertion-mode:parse-errors-3>Parse error</a>. Ignore the token.</p>
|
||
<dt>Anything else<dd>
|
||
|
||
|
||
<p><a href=#insert-an-html-element id=the-after-head-insertion-mode:insert-an-html-element-3>Insert an HTML element</a> for a "body" start tag token with no attributes.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=the-after-head-insertion-mode:insertion-mode-7>insertion mode</a> to "<a href=#parsing-main-inbody id=the-after-head-insertion-mode:parsing-main-inbody-3>in
|
||
body</a>".</p>
|
||
|
||
|
||
<p>Reprocess the current token.</p>
|
||
|
||
</dl>
|
||
|
||
|
||
<h6 id=parsing-main-inbody><span class=secno>12.2.6.4.7</span> The "<dfn>in body</dfn>" insertion mode<a href=#parsing-main-inbody class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-inbody id=parsing-main-inbody:parsing-main-inbody>in
|
||
body</a>" <a href=#insertion-mode id=parsing-main-inbody:insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
|
||
|
||
<dl class=switch><dt>A character token that is U+0000 NULL<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-inbody:parse-errors>Parse error</a>. Ignore the token.</p>
|
||
|
||
|
||
|
||
<dt>A character token that is one of U+0009 CHARACTER TABULATION,
|
||
U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE
|
||
RETURN (CR), or U+0020 SPACE<dd>
|
||
|
||
<p><a href=#reconstruct-the-active-formatting-elements id=parsing-main-inbody:reconstruct-the-active-formatting-elements>Reconstruct the active formatting elements</a>, if any.</p>
|
||
|
||
<p><a href=#insert-a-character id=parsing-main-inbody:insert-a-character>Insert the token's character</a>.</p>
|
||
|
||
<dt>Any other character token<dd>
|
||
|
||
<p><a href=#reconstruct-the-active-formatting-elements id=parsing-main-inbody:reconstruct-the-active-formatting-elements-2>Reconstruct the active formatting elements</a>, if any.</p>
|
||
|
||
<p><a href=#insert-a-character id=parsing-main-inbody:insert-a-character-2>Insert the token's character</a>.</p>
|
||
|
||
<p>Set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
|
||
|
||
<dt>A comment token<dd>
|
||
<p><a href=#insert-a-comment id=parsing-main-inbody:insert-a-comment>Insert a comment</a>.</p>
|
||
<dt>A DOCTYPE token<dd>
|
||
<p><a href=#parse-errors id=parsing-main-inbody:parse-errors-2>Parse error</a>. Ignore the token.</p>
|
||
<dt>A start tag whose tag name is "html"<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-inbody:parse-errors-3>Parse error</a>.</p>
|
||
|
||
<p>If there is a <code id=parsing-main-inbody:the-template-element><a href=scripting.html#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements id=parsing-main-inbody: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 id=parsing-main-inbody:stack-of-open-elements-2>stack of open elements</a>. If it is not, add the attribute
|
||
and its corresponding value to that element.</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "base", "basefont", "bgsound", "link", "meta",
|
||
"noframes", "script", "style", "template", "title"<dt>An end tag whose tag name is "template"<dd>
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-inbody:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead id=parsing-main-inbody:parsing-main-inhead>in head</a>" <a href=#insertion-mode id=parsing-main-inbody:insertion-mode-2>insertion mode</a>.</p>
|
||
<dt>A start tag whose tag name is "body"<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-inbody:parse-errors-4>Parse error</a>.</p>
|
||
|
||
<p>If the second element on the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-3>stack of open elements</a> is not a <code id=parsing-main-inbody:the-body-element><a href=sections.html#the-body-element>body</a></code>
|
||
element, if the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-4>stack of open elements</a> has only one node on it, or if there is a
|
||
<code id=parsing-main-inbody:the-template-element-2><a href=scripting.html#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-5>stack of open elements</a>, then ignore the token.
|
||
(<a href=#fragment-case id=parsing-main-inbody:fragment-case>fragment case</a>)</p>
|
||
|
||
<p>Otherwise, set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-2>frameset-ok flag</a> to "not ok"; then, for each attribute on the
|
||
token, check to see if the attribute is already present on the <code id=parsing-main-inbody:the-body-element-2><a href=sections.html#the-body-element>body</a></code> element (the
|
||
second element) on the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-6>stack of open elements</a>, and if it is not, add the attribute
|
||
and its corresponding value to that element.</p>
|
||
|
||
<dt>A start tag whose tag name is "frameset"<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-inbody:parse-errors-5>Parse error</a>.</p>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-7>stack of open elements</a> has only one node on it, or if the second element
|
||
on the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-8>stack of open elements</a> is not a <code id=parsing-main-inbody:the-body-element-3><a href=sections.html#the-body-element>body</a></code> element, then ignore the
|
||
token. (<a href=#fragment-case id=parsing-main-inbody:fragment-case-2>fragment case</a>)</p>
|
||
|
||
<p>If the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-3>frameset-ok flag</a> is set to "not ok", ignore the token.</p>
|
||
|
||
<p>Otherwise, run the following steps:</p>
|
||
|
||
<ol><li><p>Remove the second element on the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-9>stack of open elements</a> from its parent
|
||
node, if it has one.<li><p>Pop all the nodes from the bottom of the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-10>stack of open elements</a>, from the
|
||
<a href=#current-node id=parsing-main-inbody:current-node>current node</a> up to, but not including, the root <code id=parsing-main-inbody:the-html-element><a href=semantics.html#the-html-element>html</a></code> element.</p>
|
||
|
||
<li><p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element>Insert an HTML element</a> for the token.<li><p>Switch the <a href=#insertion-mode id=parsing-main-inbody:insertion-mode-3>insertion mode</a> to "<a href=#parsing-main-inframeset id=parsing-main-inbody:parsing-main-inframeset>in
|
||
frameset</a>".</p>
|
||
|
||
</ol>
|
||
|
||
<dt>An end-of-file token<dd>
|
||
|
||
<p>If the <a href=#stack-of-template-insertion-modes id=parsing-main-inbody:stack-of-template-insertion-modes>stack of template insertion modes</a> is not empty, then process the token
|
||
<a href=#using-the-rules-for id=parsing-main-inbody:using-the-rules-for-2>using the rules for</a> the "<a href=#parsing-main-intemplate id=parsing-main-inbody:parsing-main-intemplate>in
|
||
template</a>" <a href=#insertion-mode id=parsing-main-inbody:insertion-mode-4>insertion mode</a>.</p>
|
||
|
||
|
||
<p>Otherwise, follow these steps:</p>
|
||
|
||
<ol><li><p>If there is a node in the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-11>stack of open elements</a> that is not either a
|
||
<code id=parsing-main-inbody:the-dd-element><a href=grouping-content.html#the-dd-element>dd</a></code> element, a <code id=parsing-main-inbody:the-dt-element><a href=grouping-content.html#the-dt-element>dt</a></code> element, an <code id=parsing-main-inbody:the-li-element><a href=grouping-content.html#the-li-element>li</a></code> element, an
|
||
<code id=parsing-main-inbody:the-optgroup-element><a href=form-elements.html#the-optgroup-element>optgroup</a></code> element, an <code id=parsing-main-inbody:the-option-element><a href=form-elements.html#the-option-element>option</a></code> element, a <code id=parsing-main-inbody:the-p-element><a href=grouping-content.html#the-p-element>p</a></code> element, an
|
||
<code id=parsing-main-inbody:rb><a href=obsolete.html#rb>rb</a></code> element, an <code id=parsing-main-inbody:the-rp-element><a href=text-level-semantics.html#the-rp-element>rp</a></code> element, an <code id=parsing-main-inbody:the-rt-element><a href=text-level-semantics.html#the-rt-element>rt</a></code> element, an
|
||
<code id=parsing-main-inbody:rtc><a href=obsolete.html#rtc>rtc</a></code> element, a <code id=parsing-main-inbody:the-tbody-element><a href=tables.html#the-tbody-element>tbody</a></code> element, a <code id=parsing-main-inbody:the-td-element><a href=tables.html#the-td-element>td</a></code> element, a
|
||
<code id=parsing-main-inbody:the-tfoot-element><a href=tables.html#the-tfoot-element>tfoot</a></code> element, a <code id=parsing-main-inbody:the-th-element><a href=tables.html#the-th-element>th</a></code> element, a <code id=parsing-main-inbody:the-thead-element><a href=tables.html#the-thead-element>thead</a></code> element, a
|
||
<code id=parsing-main-inbody:the-tr-element><a href=tables.html#the-tr-element>tr</a></code> element, the <code id=parsing-main-inbody:the-body-element-4><a href=sections.html#the-body-element>body</a></code> element, or the <code id=parsing-main-inbody:the-html-element-2><a href=semantics.html#the-html-element>html</a></code> element, then
|
||
this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-6>parse error</a>.<li><p><a href=#stop-parsing id=parsing-main-inbody:stop-parsing>Stop parsing</a>.</ol>
|
||
|
||
<dt>An end tag whose tag name is "body"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-12>stack of open elements</a> does not <a href=#has-an-element-in-scope id=parsing-main-inbody:has-an-element-in-scope>have a <code>body</code> element in scope</a>, this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-7>parse error</a>;
|
||
ignore the token.</p>
|
||
|
||
|
||
|
||
<p>Otherwise, if there is a node in the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-13>stack of open elements</a> that is not either a
|
||
<code id=parsing-main-inbody:the-dd-element-2><a href=grouping-content.html#the-dd-element>dd</a></code> element, a <code id=parsing-main-inbody:the-dt-element-2><a href=grouping-content.html#the-dt-element>dt</a></code> element, an <code id=parsing-main-inbody:the-li-element-2><a href=grouping-content.html#the-li-element>li</a></code> element, an
|
||
<code id=parsing-main-inbody:the-optgroup-element-2><a href=form-elements.html#the-optgroup-element>optgroup</a></code> element, an <code id=parsing-main-inbody:the-option-element-2><a href=form-elements.html#the-option-element>option</a></code> element, a <code id=parsing-main-inbody:the-p-element-2><a href=grouping-content.html#the-p-element>p</a></code> element, an
|
||
<code id=parsing-main-inbody:rb-2><a href=obsolete.html#rb>rb</a></code> element, an <code id=parsing-main-inbody:the-rp-element-2><a href=text-level-semantics.html#the-rp-element>rp</a></code> element, an <code id=parsing-main-inbody:the-rt-element-2><a href=text-level-semantics.html#the-rt-element>rt</a></code> element, an
|
||
<code id=parsing-main-inbody:rtc-2><a href=obsolete.html#rtc>rtc</a></code> element, a <code id=parsing-main-inbody:the-tbody-element-2><a href=tables.html#the-tbody-element>tbody</a></code> element, a <code id=parsing-main-inbody:the-td-element-2><a href=tables.html#the-td-element>td</a></code> element, a
|
||
<code id=parsing-main-inbody:the-tfoot-element-2><a href=tables.html#the-tfoot-element>tfoot</a></code> element, a <code id=parsing-main-inbody:the-th-element-2><a href=tables.html#the-th-element>th</a></code> element, a <code id=parsing-main-inbody:the-thead-element-2><a href=tables.html#the-thead-element>thead</a></code> element, a
|
||
<code id=parsing-main-inbody:the-tr-element-2><a href=tables.html#the-tr-element>tr</a></code> element, the <code id=parsing-main-inbody:the-body-element-5><a href=sections.html#the-body-element>body</a></code> element, or the <code id=parsing-main-inbody:the-html-element-3><a href=semantics.html#the-html-element>html</a></code> element, then
|
||
this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-8>parse error</a>.</p>
|
||
|
||
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-inbody:insertion-mode-5>insertion mode</a> to "<a href=#parsing-main-afterbody id=parsing-main-inbody:parsing-main-afterbody>after
|
||
body</a>".</p>
|
||
|
||
<dt>An end tag whose tag name is "html"<dd>
|
||
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-14>stack of open elements</a> does not <a href=#has-an-element-in-scope id=parsing-main-inbody:has-an-element-in-scope-2>have a <code>body</code> element in scope</a>, this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-9>parse error</a>;
|
||
ignore the token.</p>
|
||
|
||
|
||
|
||
<p>Otherwise, if there is a node in the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-15>stack of open elements</a> that is not either a
|
||
<code id=parsing-main-inbody:the-dd-element-3><a href=grouping-content.html#the-dd-element>dd</a></code> element, a <code id=parsing-main-inbody:the-dt-element-3><a href=grouping-content.html#the-dt-element>dt</a></code> element, an <code id=parsing-main-inbody:the-li-element-3><a href=grouping-content.html#the-li-element>li</a></code> element, an
|
||
<code id=parsing-main-inbody:the-optgroup-element-3><a href=form-elements.html#the-optgroup-element>optgroup</a></code> element, an <code id=parsing-main-inbody:the-option-element-3><a href=form-elements.html#the-option-element>option</a></code> element, a <code id=parsing-main-inbody:the-p-element-3><a href=grouping-content.html#the-p-element>p</a></code> element, an
|
||
<code id=parsing-main-inbody:rb-3><a href=obsolete.html#rb>rb</a></code> element, an <code id=parsing-main-inbody:the-rp-element-3><a href=text-level-semantics.html#the-rp-element>rp</a></code> element, an <code id=parsing-main-inbody:the-rt-element-3><a href=text-level-semantics.html#the-rt-element>rt</a></code> element, an
|
||
<code id=parsing-main-inbody:rtc-3><a href=obsolete.html#rtc>rtc</a></code> element, a <code id=parsing-main-inbody:the-tbody-element-3><a href=tables.html#the-tbody-element>tbody</a></code> element, a <code id=parsing-main-inbody:the-td-element-3><a href=tables.html#the-td-element>td</a></code> element, a
|
||
<code id=parsing-main-inbody:the-tfoot-element-3><a href=tables.html#the-tfoot-element>tfoot</a></code> element, a <code id=parsing-main-inbody:the-th-element-3><a href=tables.html#the-th-element>th</a></code> element, a <code id=parsing-main-inbody:the-thead-element-3><a href=tables.html#the-thead-element>thead</a></code> element, a
|
||
<code id=parsing-main-inbody:the-tr-element-3><a href=tables.html#the-tr-element>tr</a></code> element, the <code id=parsing-main-inbody:the-body-element-6><a href=sections.html#the-body-element>body</a></code> element, or the <code id=parsing-main-inbody:the-html-element-4><a href=semantics.html#the-html-element>html</a></code> element, then
|
||
this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-10>parse error</a>.</p>
|
||
|
||
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-inbody:insertion-mode-6>insertion mode</a> to "<a href=#parsing-main-afterbody id=parsing-main-inbody:parsing-main-afterbody-2>after
|
||
body</a>".</p>
|
||
|
||
|
||
<p>Reprocess the token.</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "address", "article", "aside", "blockquote", "center",
|
||
"details", "dialog", "dir", "div", "dl", "fieldset", "figcaption", "figure", "footer", "header",
|
||
"hgroup", "main", "menu", "nav", "ol", "p", "section", "summary", "ul"<dd>
|
||
|
||
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-16>stack of open elements</a> <a href=#has-an-element-in-button-scope id=parsing-main-inbody:has-an-element-in-button-scope>has a
|
||
<code>p</code> element in button scope</a>, then <a href=#close-a-p-element id=parsing-main-inbody:close-a-p-element>close a <code>p</code>
|
||
element</a>.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-2>Insert an HTML element</a> for the token.</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "h1", "h2", "h3", "h4",
|
||
"h5", "h6"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-17>stack of open elements</a> <a href=#has-an-element-in-button-scope id=parsing-main-inbody:has-an-element-in-button-scope-2>has a
|
||
<code>p</code> element in button scope</a>, then <a href=#close-a-p-element id=parsing-main-inbody:close-a-p-element-2>close a <code>p</code>
|
||
element</a>.</p>
|
||
|
||
<p>If the <a href=#current-node id=parsing-main-inbody:current-node-2>current node</a> is an <a href=infrastructure.html#html-elements id=parsing-main-inbody:html-elements>HTML element</a> whose
|
||
tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-11>parse
|
||
error</a>; pop the <a href=#current-node id=parsing-main-inbody:current-node-3>current node</a> off the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-18>stack of open elements</a>.</p>
|
||
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-3>Insert an HTML element</a> for the token.</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "pre", "listing"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-19>stack of open elements</a> <a href=#has-an-element-in-button-scope id=parsing-main-inbody:has-an-element-in-button-scope-3>has
|
||
a <code>p</code> element in button scope</a>, then <a href=#close-a-p-element id=parsing-main-inbody:close-a-p-element-3>close a <code>p</code>
|
||
element</a>.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-4>Insert an HTML element</a> for the token.</p>
|
||
|
||
<p>If the <a href=#next-token id=parsing-main-inbody:next-token>next token</a> is a U+000A LINE FEED (LF) character token, then ignore that
|
||
token and move on to the next one. (Newlines at the start of <code id=parsing-main-inbody:the-pre-element><a href=grouping-content.html#the-pre-element>pre</a></code> blocks are ignored
|
||
as an authoring convenience.)</p>
|
||
|
||
|
||
|
||
<p>Set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-4>frameset-ok flag</a> to "not ok".</p>
|
||
|
||
<dt>A start tag whose tag name is "form"<dd>
|
||
|
||
<p>If the <a href=#form-element-pointer id=parsing-main-inbody:form-element-pointer><code>form</code> element pointer</a> is not null, and there is
|
||
no <code id=parsing-main-inbody:the-template-element-3><a href=scripting.html#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-20>stack of open elements</a>, then this is a
|
||
<a href=#parse-errors id=parsing-main-inbody:parse-errors-12>parse error</a>; ignore the token.</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-21>stack of open elements</a> <a href=#has-an-element-in-button-scope id=parsing-main-inbody:has-an-element-in-button-scope-4>has
|
||
a <code>p</code> element in button scope</a>, then <a href=#close-a-p-element id=parsing-main-inbody:close-a-p-element-4>close a <code>p</code>
|
||
element</a>.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-5>Insert an HTML element</a> for the token, and, if there is no <code id=parsing-main-inbody:the-template-element-4><a href=scripting.html#the-template-element>template</a></code>
|
||
element on the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-22>stack of open elements</a>, set the <a href=#form-element-pointer id=parsing-main-inbody:form-element-pointer-2><code>form</code> element pointer</a> to point to the element created.</p>
|
||
|
||
<dt>A start tag whose tag name is "li"<dd>
|
||
|
||
<p>Run these steps:</p>
|
||
|
||
<ol><li><p>Set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-5>frameset-ok flag</a> to "not ok".<li><p>Initialize <var>node</var> to be the <a href=#current-node id=parsing-main-inbody:current-node-4>current
|
||
node</a> (the bottommost node of the stack).<li>
|
||
|
||
<p><i>Loop</i>: If <var>node</var> is an <code id=parsing-main-inbody:the-li-element-4><a href=grouping-content.html#the-li-element>li</a></code> element, then run these
|
||
substeps:</p>
|
||
|
||
<ol><li><p><a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags>Generate implied end tags</a>, except for <code id=parsing-main-inbody:the-li-element-5><a href=grouping-content.html#the-li-element>li</a></code> elements.<li><p>If the <a href=#current-node id=parsing-main-inbody:current-node-5>current node</a> is not an <code id=parsing-main-inbody:the-li-element-6><a href=grouping-content.html#the-li-element>li</a></code> element, then this is a
|
||
<a href=#parse-errors id=parsing-main-inbody:parse-errors-13>parse error</a>.<li><p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-23>stack of open elements</a> until an <code id=parsing-main-inbody:the-li-element-7><a href=grouping-content.html#the-li-element>li</a></code>
|
||
element has been popped from the stack.<li><p>Jump to the step labeled <i>done</i> below.</ol>
|
||
|
||
<li><p>If <var>node</var> is in the <a href=#special id=parsing-main-inbody:special>special</a> category, but is not an
|
||
<code id=parsing-main-inbody:the-address-element><a href=sections.html#the-address-element>address</a></code>, <code id=parsing-main-inbody:the-div-element><a href=grouping-content.html#the-div-element>div</a></code>, or <code id=parsing-main-inbody:the-p-element-4><a href=grouping-content.html#the-p-element>p</a></code> element, then jump to the step
|
||
labeled <i>done</i> below.<li><p>Otherwise, set <var>node</var> to the previous entry in the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-24>stack of open
|
||
elements</a> and return to the step labeled <i>loop</i>.<li><p><i>Done</i>: If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-25>stack of open elements</a> <a href=#has-an-element-in-button-scope id=parsing-main-inbody:has-an-element-in-button-scope-5>has a <code>p</code> element in button scope</a>, then <a href=#close-a-p-element id=parsing-main-inbody:close-a-p-element-5>close a
|
||
<code>p</code> element</a>.<li><p>Finally, <a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-6>insert an HTML element</a> for the token.</ol>
|
||
|
||
<dt>A start tag whose tag name is one of: "dd", "dt"<dd>
|
||
|
||
<p>Run these steps:</p>
|
||
|
||
<ol><li><p>Set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-6>frameset-ok flag</a> to "not ok".<li><p>Initialize <var>node</var> to be the <a href=#current-node id=parsing-main-inbody:current-node-6>current
|
||
node</a> (the bottommost node of the stack).<li>
|
||
|
||
<p><i>Loop</i>: If <var>node</var> is a <code id=parsing-main-inbody:the-dd-element-4><a href=grouping-content.html#the-dd-element>dd</a></code> element, then run these
|
||
substeps:</p>
|
||
|
||
<ol><li><p><a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-2>Generate implied end tags</a>, except for <code id=parsing-main-inbody:the-dd-element-5><a href=grouping-content.html#the-dd-element>dd</a></code> elements.<li><p>If the <a href=#current-node id=parsing-main-inbody:current-node-7>current node</a> is not a <code id=parsing-main-inbody:the-dd-element-6><a href=grouping-content.html#the-dd-element>dd</a></code> element, then this is a
|
||
<a href=#parse-errors id=parsing-main-inbody:parse-errors-14>parse error</a>.<li><p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-26>stack of open elements</a> until a <code id=parsing-main-inbody:the-dd-element-7><a href=grouping-content.html#the-dd-element>dd</a></code>
|
||
element has been popped from the stack.<li><p>Jump to the step labeled <i>done</i> below.</ol>
|
||
|
||
<li>
|
||
|
||
<p>If <var>node</var> is a <code id=parsing-main-inbody:the-dt-element-4><a href=grouping-content.html#the-dt-element>dt</a></code> element, then run these substeps:</p>
|
||
|
||
<ol><li><p><a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-3>Generate implied end tags</a>, except for <code id=parsing-main-inbody:the-dt-element-5><a href=grouping-content.html#the-dt-element>dt</a></code> elements.<li><p>If the <a href=#current-node id=parsing-main-inbody:current-node-8>current node</a> is not a <code id=parsing-main-inbody:the-dt-element-6><a href=grouping-content.html#the-dt-element>dt</a></code> element, then this is a
|
||
<a href=#parse-errors id=parsing-main-inbody:parse-errors-15>parse error</a>.<li><p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-27>stack of open elements</a> until a <code id=parsing-main-inbody:the-dt-element-7><a href=grouping-content.html#the-dt-element>dt</a></code>
|
||
element has been popped from the stack.<li><p>Jump to the step labeled <i>done</i> below.</ol>
|
||
|
||
<li><p>If <var>node</var> is in the <a href=#special id=parsing-main-inbody:special-2>special</a> category, but is not an
|
||
<code id=parsing-main-inbody:the-address-element-2><a href=sections.html#the-address-element>address</a></code>, <code id=parsing-main-inbody:the-div-element-2><a href=grouping-content.html#the-div-element>div</a></code>, or <code id=parsing-main-inbody:the-p-element-5><a href=grouping-content.html#the-p-element>p</a></code> element, then jump to the step
|
||
labeled <i>done</i> below.<li><p>Otherwise, set <var>node</var> to the previous entry in the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-28>stack of open
|
||
elements</a> and return to the step labeled <i>loop</i>.<li><p><i>Done</i>: If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-29>stack of open elements</a> <a href=#has-an-element-in-button-scope id=parsing-main-inbody:has-an-element-in-button-scope-6>has a <code>p</code> element in button scope</a>, then <a href=#close-a-p-element id=parsing-main-inbody:close-a-p-element-6>close a
|
||
<code>p</code> element</a>.<li><p>Finally, <a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-7>insert an HTML element</a> for the token.</ol>
|
||
|
||
<dt>A start tag whose tag name is "plaintext"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-30>stack of open elements</a> <a href=#has-an-element-in-button-scope id=parsing-main-inbody:has-an-element-in-button-scope-7>has a
|
||
<code>p</code> element in button scope</a>, then <a href=#close-a-p-element id=parsing-main-inbody:close-a-p-element-7>close a <code>p</code>
|
||
element</a>.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-8>Insert an HTML element</a> for the token.</p>
|
||
|
||
<p>Switch the tokenizer to the <a href=#plaintext-state id=parsing-main-inbody:plaintext-state>PLAINTEXT state</a>.</p>
|
||
|
||
<p class=note>Once a start tag with the tag name "plaintext" has been seen, that will be the
|
||
last token ever seen other than character tokens (and the end-of-file token), because there is
|
||
no way to switch out of the <a href=#plaintext-state id=parsing-main-inbody:plaintext-state-2>PLAINTEXT state</a>.</p>
|
||
|
||
<dt>A start tag whose tag name is "button"<dd>
|
||
|
||
<ol><li>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-31>stack of open elements</a> <a href=#has-an-element-in-scope id=parsing-main-inbody:has-an-element-in-scope-3>has a
|
||
<code>button</code> element in scope</a>, then run these substeps:</p>
|
||
|
||
<ol><li><p><a href=#parse-errors id=parsing-main-inbody:parse-errors-16>Parse error</a>.<li><p><a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-4>Generate implied end tags</a>.<li><p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-32>stack of open elements</a> until a <code id=parsing-main-inbody:the-button-element><a href=form-elements.html#the-button-element>button</a></code>
|
||
element has been popped from the stack.</ol>
|
||
|
||
<li><p><a href=#reconstruct-the-active-formatting-elements id=parsing-main-inbody:reconstruct-the-active-formatting-elements-3>Reconstruct the active formatting elements</a>, if any.<li><p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-9>Insert an HTML element</a> for the token.<li><p>Set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-7>frameset-ok flag</a> to "not ok".</ol>
|
||
|
||
<dt>An end tag whose tag name is one of: "address", "article", "aside", "blockquote", "button",
|
||
"center", "details", "dialog", "dir", "div", "dl", "fieldset", "figcaption", "figure", "footer",
|
||
"header", "hgroup", "listing", "main", "menu", "nav", "ol", "pre", "section", "summary",
|
||
"ul"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-33>stack of open elements</a> does not <a href=#has-an-element-in-scope id=parsing-main-inbody:has-an-element-in-scope-4>have an element in scope</a> that is an <a href=infrastructure.html#html-elements id=parsing-main-inbody:html-elements-2>HTML
|
||
element</a> with the same tag name as that of the token, then this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-17>parse
|
||
error</a>; ignore the token.</p>
|
||
|
||
<p>Otherwise, run these steps:</p>
|
||
|
||
<ol><li><p><a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-5>Generate implied end tags</a>.<li><p>If the <a href=#current-node id=parsing-main-inbody:current-node-9>current node</a> is not an <a href=infrastructure.html#html-elements id=parsing-main-inbody:html-elements-3>HTML element</a> with
|
||
the same tag name as that of the token, then this is a
|
||
<a href=#parse-errors id=parsing-main-inbody:parse-errors-18>parse error</a>.<li><p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-34>stack of open elements</a> until an <a href=infrastructure.html#html-elements id=parsing-main-inbody:html-elements-4>HTML element</a> with the same tag name as the token has been popped from the
|
||
stack.</ol>
|
||
|
||
<dt>An end tag whose tag name is "form"<dd>
|
||
|
||
<p>If there is no <code id=parsing-main-inbody:the-template-element-5><a href=scripting.html#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-35>stack of open elements</a>, then
|
||
run these substeps:</p>
|
||
|
||
<ol><li><p>Let <var>node</var> be the element that the <a href=#form-element-pointer id=parsing-main-inbody:form-element-pointer-3><code>form</code>
|
||
element pointer</a> is set to, or null if it is not set to an element.<li><p>Set the <a href=#form-element-pointer id=parsing-main-inbody:form-element-pointer-4><code>form</code> element pointer</a> to null.<li><p>If <var>node</var> is null or if the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-36>stack of open elements</a> does
|
||
not <a href=#has-an-element-in-scope id=parsing-main-inbody:has-an-element-in-scope-5>have <var>node</var> in scope</a>, then
|
||
this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-19>parse error</a>; abort these steps and ignore the token.<li><p><a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-6>Generate implied end tags</a>.<li><p>If the <a href=#current-node id=parsing-main-inbody:current-node-10>current node</a> is not <var>node</var>, then this is a
|
||
<a href=#parse-errors id=parsing-main-inbody:parse-errors-20>parse error</a>.<li><p>Remove <var>node</var> from the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-37>stack of open elements</a>.</ol>
|
||
|
||
<p>If there <em>is</em> a <code id=parsing-main-inbody:the-template-element-6><a href=scripting.html#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-38>stack of open
|
||
elements</a>, then run these substeps instead:</p>
|
||
|
||
<ol><li><p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-39>stack of open elements</a> does not <a href=#has-an-element-in-scope id=parsing-main-inbody:has-an-element-in-scope-6>have a <code>form</code> element in scope</a>, then this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-21>parse
|
||
error</a>; abort these steps and ignore the token.<li><p><a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-7>Generate implied end tags</a>.<li><p>If the <a href=#current-node id=parsing-main-inbody:current-node-11>current node</a> is not a <code id=parsing-main-inbody:the-form-element><a href=forms.html#the-form-element>form</a></code> element, then this is a
|
||
<a href=#parse-errors id=parsing-main-inbody:parse-errors-22>parse error</a>.<li><p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-40>stack of open elements</a> until a <code id=parsing-main-inbody:the-form-element-2><a href=forms.html#the-form-element>form</a></code>
|
||
element has been popped from the stack.</ol>
|
||
|
||
<dt>An end tag whose tag name is "p"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-41>stack of open elements</a> does not <a href=#has-an-element-in-button-scope id=parsing-main-inbody:has-an-element-in-button-scope-8>have a <code>p</code> element in button scope</a>, then this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-23>parse
|
||
error</a>; <a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-10>insert an HTML element</a> for a "p" start tag token with no
|
||
attributes.</p>
|
||
|
||
<p><a href=#close-a-p-element id=parsing-main-inbody:close-a-p-element-8>Close a <code>p</code> element</a>.</p>
|
||
|
||
<dt>An end tag whose tag name is "li"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-42>stack of open elements</a> does not <a href=#has-an-element-in-list-item-scope id=parsing-main-inbody:has-an-element-in-list-item-scope>have an <code>li</code> element in list item scope</a>, then this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-24>parse
|
||
error</a>; ignore the token.</p>
|
||
|
||
<p>Otherwise, run these steps:</p>
|
||
|
||
<ol><li><p><a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-8>Generate implied end tags</a>, except for <code id=parsing-main-inbody:the-li-element-8><a href=grouping-content.html#the-li-element>li</a></code> elements.<li><p>If the <a href=#current-node id=parsing-main-inbody:current-node-12>current node</a> is not an <code id=parsing-main-inbody:the-li-element-9><a href=grouping-content.html#the-li-element>li</a></code> element, then this is a
|
||
<a href=#parse-errors id=parsing-main-inbody:parse-errors-25>parse error</a>.<li><p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-43>stack of open elements</a> until an <code id=parsing-main-inbody:the-li-element-10><a href=grouping-content.html#the-li-element>li</a></code>
|
||
element has been popped from the stack.</ol>
|
||
|
||
<dt>An end tag whose tag name is one of: "dd", "dt"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-44>stack of open elements</a> does not <a href=#has-an-element-in-scope id=parsing-main-inbody:has-an-element-in-scope-7>have an element in scope</a> that is an <a href=infrastructure.html#html-elements id=parsing-main-inbody:html-elements-5>HTML
|
||
element</a> with the same tag name as that of the token, then this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-26>parse
|
||
error</a>; ignore the token.</p>
|
||
|
||
<p>Otherwise, run these steps:</p>
|
||
|
||
<ol><li><p><a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-9>Generate implied end tags</a>, except for <a id=parsing-main-inbody:html-elements-6 href=infrastructure.html#html-elements>HTML elements</a> with the
|
||
same tag name as the token.<li><p>If the <a href=#current-node id=parsing-main-inbody:current-node-13>current node</a> is not an <a href=infrastructure.html#html-elements id=parsing-main-inbody:html-elements-7>HTML
|
||
element</a> with the same tag name as that of the token, then this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-27>parse
|
||
error</a>.<li><p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-45>stack of open elements</a> until an <a href=infrastructure.html#html-elements id=parsing-main-inbody:html-elements-8>HTML element</a> with the same tag name as the token has been popped from the
|
||
stack.</ol>
|
||
|
||
<dt>An end tag whose tag name is one of: "h1", "h2", "h3", "h4", "h5", "h6"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-46>stack of open elements</a> does not <a href=#has-an-element-in-scope id=parsing-main-inbody:has-an-element-in-scope-8>have an element in scope</a> that is an <a href=infrastructure.html#html-elements id=parsing-main-inbody:html-elements-9>HTML
|
||
element</a> and whose tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is
|
||
a <a href=#parse-errors id=parsing-main-inbody:parse-errors-28>parse error</a>; ignore the token.</p>
|
||
|
||
<p>Otherwise, run these steps:</p>
|
||
|
||
<ol><li><p><a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-10>Generate implied end tags</a>.<li><p>If the <a href=#current-node id=parsing-main-inbody:current-node-14>current node</a> is not an <a href=infrastructure.html#html-elements id=parsing-main-inbody:html-elements-10>HTML
|
||
element</a> with the same tag name as that of the token, then this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-29>parse
|
||
error</a>.<li><p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-47>stack of open elements</a> until an <a href=infrastructure.html#html-elements id=parsing-main-inbody:html-elements-11>HTML element</a> whose tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6"
|
||
has been popped from the stack.</ol>
|
||
|
||
<dt>An end tag whose tag name is "sarcasm"<dd>
|
||
<p>Take a deep breath, then act as described in the "any other end
|
||
tag" entry below.</p>
|
||
<dt>A start tag whose tag name is "a"<dd>
|
||
|
||
<p>If the <a href=#list-of-active-formatting-elements id=parsing-main-inbody:list-of-active-formatting-elements>list of active formatting elements</a> contains an <code id=parsing-main-inbody:the-a-element><a href=text-level-semantics.html#the-a-element>a</a></code> element
|
||
between the end of the list and the last <a href=#concept-parser-marker id=parsing-main-inbody:concept-parser-marker>marker</a> on
|
||
the list (or the start of the list if there is no <a href=#concept-parser-marker id=parsing-main-inbody:concept-parser-marker-2>marker</a> on the list), then this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-30>parse
|
||
error</a>; run the <a href=#adoption-agency-algorithm id=parsing-main-inbody:adoption-agency-algorithm>adoption agency algorithm</a> for the token, then remove that
|
||
element from the <a href=#list-of-active-formatting-elements id=parsing-main-inbody:list-of-active-formatting-elements-2>list of active formatting elements</a> and the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-48>stack of open
|
||
elements</a> if the <a href=#adoption-agency-algorithm id=parsing-main-inbody:adoption-agency-algorithm-2>adoption agency algorithm</a> didn't already remove it (it might
|
||
not have if the element is not <a href=#has-an-element-in-table-scope id=parsing-main-inbody:has-an-element-in-table-scope>in table
|
||
scope</a>).</p>
|
||
|
||
<p class=example>In the non-conforming stream
|
||
<code><a href="a">a<table><a href="b">b</table>x</code>, the first
|
||
<code id=parsing-main-inbody:the-a-element-2><a href=text-level-semantics.html#the-a-element>a</a></code> element would be closed upon seeing the second one, and the "x" character would
|
||
be inside a link to "b", not to "a". This is despite the fact that the outer <code id=parsing-main-inbody:the-a-element-3><a href=text-level-semantics.html#the-a-element>a</a></code>
|
||
element is not in table scope (meaning that a regular <code></a></code> end tag at the start
|
||
of the table wouldn't close the outer <code id=parsing-main-inbody:the-a-element-4><a href=text-level-semantics.html#the-a-element>a</a></code> element). The result is that the two
|
||
<code id=parsing-main-inbody:the-a-element-5><a href=text-level-semantics.html#the-a-element>a</a></code> elements are indirectly nested inside each other — non-conforming markup
|
||
will often result in non-conforming DOMs when parsed.</p>
|
||
|
||
<p><a href=#reconstruct-the-active-formatting-elements id=parsing-main-inbody:reconstruct-the-active-formatting-elements-4>Reconstruct the active formatting elements</a>, if any.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-11>Insert an HTML element</a> for the token. <a href=#push-onto-the-list-of-active-formatting-elements id=parsing-main-inbody:push-onto-the-list-of-active-formatting-elements>Push onto the list of active
|
||
formatting elements</a> that element.</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "b", "big", "code", "em",
|
||
"font", "i", "s", "small", "strike", "strong", "tt", "u"<dd>
|
||
|
||
<p><a href=#reconstruct-the-active-formatting-elements id=parsing-main-inbody:reconstruct-the-active-formatting-elements-5>Reconstruct the active formatting elements</a>, if any.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-12>Insert an HTML element</a> for the token. <a href=#push-onto-the-list-of-active-formatting-elements id=parsing-main-inbody:push-onto-the-list-of-active-formatting-elements-2>Push onto the list of active
|
||
formatting elements</a> that element.</p>
|
||
|
||
<dt>A start tag whose tag name is "nobr"<dd>
|
||
|
||
<p><a href=#reconstruct-the-active-formatting-elements id=parsing-main-inbody:reconstruct-the-active-formatting-elements-6>Reconstruct the active formatting elements</a>, if any.</p>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-49>stack of open elements</a> <a href=#has-an-element-in-scope id=parsing-main-inbody:has-an-element-in-scope-9>has a
|
||
<code>nobr</code> element in scope</a>, then this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-31>parse error</a>; run the
|
||
<a href=#adoption-agency-algorithm id=parsing-main-inbody:adoption-agency-algorithm-3>adoption agency algorithm</a> for the token, then once again <a href=#reconstruct-the-active-formatting-elements id=parsing-main-inbody:reconstruct-the-active-formatting-elements-7>reconstruct the
|
||
active formatting elements</a>, if any.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-13>Insert an HTML element</a> for the token. <a href=#push-onto-the-list-of-active-formatting-elements id=parsing-main-inbody:push-onto-the-list-of-active-formatting-elements-3>Push onto the list of active
|
||
formatting elements</a> that element.</p>
|
||
|
||
<dt>An end tag whose tag name is one of: "a",
|
||
"b", "big", "code", "em", "font", "i", "nobr", "s", "small",
|
||
"strike", "strong", "tt", "u"<dd>
|
||
|
||
<p>Run the <a href=#adoption-agency-algorithm id=parsing-main-inbody:adoption-agency-algorithm-4>adoption agency algorithm</a> for the token.</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "applet", "marquee", "object"<dd>
|
||
|
||
<p><a href=#reconstruct-the-active-formatting-elements id=parsing-main-inbody:reconstruct-the-active-formatting-elements-8>Reconstruct the active formatting elements</a>, if any.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-14>Insert an HTML element</a> for the token.</p>
|
||
|
||
<p>Insert a <a href=#concept-parser-marker id=parsing-main-inbody:concept-parser-marker-3>marker</a> at the end of the <a href=#list-of-active-formatting-elements id=parsing-main-inbody:list-of-active-formatting-elements-3>list of
|
||
active formatting elements</a>.</p>
|
||
|
||
<p>Set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-8>frameset-ok flag</a> to "not ok".</p>
|
||
|
||
<dt>An end tag token whose tag name is one of: "applet", "marquee", "object"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-50>stack of open elements</a> does not <a href=#has-an-element-in-scope id=parsing-main-inbody:has-an-element-in-scope-10>have an element in scope</a> that is an <a href=infrastructure.html#html-elements id=parsing-main-inbody:html-elements-12>HTML
|
||
element</a> with the same tag name as that of the token, then this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-32>parse
|
||
error</a>; ignore the token.</p>
|
||
|
||
<p>Otherwise, run these steps:</p>
|
||
|
||
<ol><li><p><a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-11>Generate implied end tags</a>.<li><p>If the <a href=#current-node id=parsing-main-inbody:current-node-15>current node</a> is not an <a href=infrastructure.html#html-elements id=parsing-main-inbody:html-elements-13>HTML
|
||
element</a> with the same tag name as that of the token, then this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-33>parse
|
||
error</a>.<li><p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-51>stack of open elements</a> until an <a href=infrastructure.html#html-elements id=parsing-main-inbody:html-elements-14>HTML element</a> with the same tag name as the token has been popped from the
|
||
stack.<li><a href=#clear-the-list-of-active-formatting-elements-up-to-the-last-marker id=parsing-main-inbody: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>.</ol>
|
||
|
||
<dt>A start tag whose tag name is "table"<dd>
|
||
|
||
<p>If the <code id=parsing-main-inbody:document><a href=dom.html#document>Document</a></code> is <em>not</em> set to <a id=parsing-main-inbody:quirks-mode href=https://dom.spec.whatwg.org/#concept-document-quirks data-x-internal=quirks-mode>quirks mode</a>, and the
|
||
<a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-52>stack of open elements</a> <a href=#has-an-element-in-button-scope id=parsing-main-inbody:has-an-element-in-button-scope-9>has a
|
||
<code>p</code> element in button scope</a>, then <a href=#close-a-p-element id=parsing-main-inbody:close-a-p-element-9>close a <code>p</code>
|
||
element</a>.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-15>Insert an HTML element</a> for the token.</p>
|
||
|
||
<p>Set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-9>frameset-ok flag</a> to "not ok".</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-inbody:insertion-mode-7>insertion mode</a> to "<a href=#parsing-main-intable id=parsing-main-inbody:parsing-main-intable>in
|
||
table</a>".</p>
|
||
|
||
<dt>An end tag whose tag name is "br"<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-inbody:parse-errors-34>Parse error</a>. Drop the attributes from the token, and act as described in the
|
||
next entry; i.e. act as if this was a "br" start tag token with no attributes, rather than the
|
||
end tag token that it actually is.</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "area", "br", "embed",
|
||
"img", "keygen", "wbr"<dd>
|
||
|
||
<p><a href=#reconstruct-the-active-formatting-elements id=parsing-main-inbody:reconstruct-the-active-formatting-elements-9>Reconstruct the active formatting elements</a>, if any.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-16>Insert an HTML element</a> for the token. Immediately pop the <a href=#current-node id=parsing-main-inbody:current-node-16>current
|
||
node</a> off the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-53>stack of open elements</a>.</p>
|
||
|
||
<p><a href=#acknowledge-self-closing-flag id=parsing-main-inbody:acknowledge-self-closing-flag>Acknowledge the token's <i>self-closing
|
||
flag</i></a>, if it is set.</p>
|
||
|
||
<p>Set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-10>frameset-ok flag</a> to "not ok".</p>
|
||
|
||
|
||
<dt>A start tag whose tag name is "input"<dd>
|
||
|
||
<p><a href=#reconstruct-the-active-formatting-elements id=parsing-main-inbody:reconstruct-the-active-formatting-elements-10>Reconstruct the active formatting elements</a>, if any.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-17>Insert an HTML element</a> for the token. Immediately pop the <a href=#current-node id=parsing-main-inbody:current-node-17>current
|
||
node</a> off the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-54>stack of open elements</a>.</p>
|
||
|
||
<p><a href=#acknowledge-self-closing-flag id=parsing-main-inbody:acknowledge-self-closing-flag-2>Acknowledge the token's <i>self-closing
|
||
flag</i></a>, if it is set.</p>
|
||
|
||
<p>If the token does not have an attribute with the name "type", or if it does, but that
|
||
attribute's value is not an <a id=parsing-main-inbody:ascii-case-insensitive href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code>hidden</code>", then: set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-11>frameset-ok flag</a> to "not ok".</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "param", "source", "track"<dd>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-18>Insert an HTML element</a> for the token. Immediately pop the <a href=#current-node id=parsing-main-inbody:current-node-18>current
|
||
node</a> off the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-55>stack of open elements</a>.</p>
|
||
|
||
<p><a href=#acknowledge-self-closing-flag id=parsing-main-inbody:acknowledge-self-closing-flag-3>Acknowledge the token's <i>self-closing
|
||
flag</i></a>, if it is set.</p>
|
||
|
||
<dt>A start tag whose tag name is "hr"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-56>stack of open elements</a> <a href=#has-an-element-in-button-scope id=parsing-main-inbody:has-an-element-in-button-scope-10>has a
|
||
<code>p</code> element in button scope</a>, then <a href=#close-a-p-element id=parsing-main-inbody:close-a-p-element-10>close a <code>p</code>
|
||
element</a>.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-19>Insert an HTML element</a> for the token. Immediately pop the <a href=#current-node id=parsing-main-inbody:current-node-19>current
|
||
node</a> off the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-57>stack of open elements</a>.</p>
|
||
|
||
<p><a href=#acknowledge-self-closing-flag id=parsing-main-inbody:acknowledge-self-closing-flag-4>Acknowledge the token's <i>self-closing
|
||
flag</i></a>, if it is set.</p>
|
||
|
||
<p>Set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-12>frameset-ok flag</a> to "not ok".</p>
|
||
|
||
<dt>A start tag whose tag name is "image"<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-inbody:parse-errors-35>Parse error</a>. Change the token's tag name to "img" and reprocess it. (Don't
|
||
ask.)</p>
|
||
<dt>A start tag whose tag name is "textarea"<dd>
|
||
|
||
<p>Run these steps:</p>
|
||
|
||
<ol><li><p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-20>Insert an HTML element</a> for the token.<li><p>If the <a href=#next-token id=parsing-main-inbody:next-token-2>next token</a> is a U+000A LINE FEED (LF) character token, then ignore
|
||
that token and move on to the next one. (Newlines at the start of <code id=parsing-main-inbody:the-textarea-element><a href=form-elements.html#the-textarea-element>textarea</a></code>
|
||
elements are ignored as an authoring convenience.)<li><p>Switch the tokenizer to the <a href=#rcdata-state id=parsing-main-inbody:rcdata-state>RCDATA state</a>.<li><p>Let the <a href=#original-insertion-mode id=parsing-main-inbody:original-insertion-mode>original insertion mode</a> be the current <a href=#insertion-mode id=parsing-main-inbody:insertion-mode-8>insertion
|
||
mode</a>.</p>
|
||
|
||
<li><p>Set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-13>frameset-ok flag</a> to "not ok".<li><p>Switch the <a href=#insertion-mode id=parsing-main-inbody:insertion-mode-9>insertion mode</a> to "<a href=#parsing-main-incdata id=parsing-main-inbody:parsing-main-incdata>text</a>".</ol>
|
||
|
||
<dt>A start tag whose tag name is "xmp"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-58>stack of open elements</a> <a href=#has-an-element-in-button-scope id=parsing-main-inbody:has-an-element-in-button-scope-11>has a
|
||
<code>p</code> element in button scope</a>, then <a href=#close-a-p-element id=parsing-main-inbody:close-a-p-element-11>close a <code>p</code>
|
||
element</a>.</p>
|
||
|
||
<p><a href=#reconstruct-the-active-formatting-elements id=parsing-main-inbody:reconstruct-the-active-formatting-elements-11>Reconstruct the active formatting elements</a>, if any.</p>
|
||
|
||
<p>Set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-14>frameset-ok flag</a> to "not ok".</p>
|
||
|
||
<p>Follow the <a href=#generic-raw-text-element-parsing-algorithm id=parsing-main-inbody:generic-raw-text-element-parsing-algorithm>generic raw text element parsing algorithm</a>.</p>
|
||
|
||
<dt>A start tag whose tag name is "iframe"<dd>
|
||
|
||
<p>Set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-15>frameset-ok flag</a> to "not ok".</p>
|
||
|
||
<p>Follow the <a href=#generic-raw-text-element-parsing-algorithm id=parsing-main-inbody:generic-raw-text-element-parsing-algorithm-2>generic raw text element parsing algorithm</a>.</p>
|
||
|
||
<dt>A start tag whose tag name is "noembed"<dt>A start tag whose tag name is "noscript", if the <a href=#scripting-flag id=parsing-main-inbody:scripting-flag>scripting flag</a> is enabled<dd>
|
||
|
||
<p>Follow the <a href=#generic-raw-text-element-parsing-algorithm id=parsing-main-inbody:generic-raw-text-element-parsing-algorithm-3>generic raw text element parsing algorithm</a>.</p>
|
||
|
||
<dt>A start tag whose tag name is "select"<dd>
|
||
|
||
<p><a href=#reconstruct-the-active-formatting-elements id=parsing-main-inbody:reconstruct-the-active-formatting-elements-12>Reconstruct the active formatting elements</a>, if any.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-21>Insert an HTML element</a> for the token.</p>
|
||
|
||
<p>Set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-16>frameset-ok flag</a> to "not ok".</p>
|
||
|
||
<p>If the <a href=#insertion-mode id=parsing-main-inbody:insertion-mode-10>insertion mode</a> is one of "<a href=#parsing-main-intable id=parsing-main-inbody:parsing-main-intable-2>in
|
||
table</a>", "<a href=#parsing-main-incaption id=parsing-main-inbody:parsing-main-incaption>in caption</a>", "<a href=#parsing-main-intbody id=parsing-main-inbody:parsing-main-intbody>in table body</a>", "<a href=#parsing-main-intr id=parsing-main-inbody:parsing-main-intr>in row</a>", or "<a href=#parsing-main-intd id=parsing-main-inbody:parsing-main-intd>in cell</a>", then switch the
|
||
<a href=#insertion-mode id=parsing-main-inbody:insertion-mode-11>insertion mode</a> to "<a href=#parsing-main-inselectintable id=parsing-main-inbody:parsing-main-inselectintable>in select in
|
||
table</a>". Otherwise, switch the <a href=#insertion-mode id=parsing-main-inbody:insertion-mode-12>insertion mode</a> to "<a href=#parsing-main-inselect id=parsing-main-inbody:parsing-main-inselect>in select</a>".</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "optgroup", "option"<dd>
|
||
|
||
<p>If the <a href=#current-node id=parsing-main-inbody:current-node-20>current node</a> is an <code id=parsing-main-inbody:the-option-element-4><a href=form-elements.html#the-option-element>option</a></code> element, then pop the
|
||
<a href=#current-node id=parsing-main-inbody:current-node-21>current node</a> off the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-59>stack of open elements</a>.</p>
|
||
|
||
<p><a href=#reconstruct-the-active-formatting-elements id=parsing-main-inbody:reconstruct-the-active-formatting-elements-13>Reconstruct the active formatting elements</a>, if any.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-22>Insert an HTML element</a> for the token.</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "rb", "rtc"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-60>stack of open elements</a> <a href=#has-an-element-in-scope id=parsing-main-inbody:has-an-element-in-scope-11>has a
|
||
<code>ruby</code> element in scope</a>, then <a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-12>generate implied end tags</a>. If the
|
||
<a href=#current-node id=parsing-main-inbody:current-node-22>current node</a> is not now a <code id=parsing-main-inbody:the-ruby-element><a href=text-level-semantics.html#the-ruby-element>ruby</a></code> element, this is a
|
||
<a href=#parse-errors id=parsing-main-inbody:parse-errors-36>parse error</a>.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-23>Insert an HTML element</a> for the token.</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "rp", "rt"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-61>stack of open elements</a> <a href=#has-an-element-in-scope id=parsing-main-inbody:has-an-element-in-scope-12>has a
|
||
<code>ruby</code> element in scope</a>, then <a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-13>generate implied end tags</a>, except
|
||
for <code id=parsing-main-inbody:rtc-4><a href=obsolete.html#rtc>rtc</a></code> elements. If the <a href=#current-node id=parsing-main-inbody:current-node-23>current node</a> is not now a <code id=parsing-main-inbody:rtc-5><a href=obsolete.html#rtc>rtc</a></code>
|
||
element or a <code id=parsing-main-inbody:the-ruby-element-2><a href=text-level-semantics.html#the-ruby-element>ruby</a></code> element, this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-37>parse error</a>.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-24>Insert an HTML element</a> for the token.</p>
|
||
|
||
<dt>A start tag whose tag name is "math"<dd>
|
||
|
||
<p><a href=#reconstruct-the-active-formatting-elements id=parsing-main-inbody:reconstruct-the-active-formatting-elements-14>Reconstruct the active formatting elements</a>, if any.</p>
|
||
|
||
<p><a href=#adjust-mathml-attributes id=parsing-main-inbody:adjust-mathml-attributes>Adjust MathML attributes</a> for the token. (This fixes the case of MathML
|
||
attributes that are not all lowercase.)</p>
|
||
|
||
<p><a href=#adjust-foreign-attributes id=parsing-main-inbody:adjust-foreign-attributes>Adjust foreign attributes</a> for the token. (This fixes the use of namespaced
|
||
attributes, in particular XLink.)</p>
|
||
|
||
<p><a href=#insert-a-foreign-element id=parsing-main-inbody:insert-a-foreign-element>Insert a foreign element</a> for the token, in the <a id=parsing-main-inbody:mathml-namespace href=https://infra.spec.whatwg.org/#mathml-namespace data-x-internal=mathml-namespace>MathML
|
||
namespace</a>.</p>
|
||
|
||
|
||
|
||
<p>If the token has its <i id=parsing-main-inbody:self-closing-flag><a href=#self-closing-flag>self-closing flag</a></i> set, pop the <a href=#current-node id=parsing-main-inbody:current-node-24>current node</a> off the
|
||
<a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-62>stack of open elements</a> and <a href=#acknowledge-self-closing-flag id=parsing-main-inbody:acknowledge-self-closing-flag-5>acknowledge
|
||
the token's <i>self-closing flag</i></a>.</p>
|
||
|
||
<dt>A start tag whose tag name is "svg"<dd>
|
||
|
||
<p><a href=#reconstruct-the-active-formatting-elements id=parsing-main-inbody:reconstruct-the-active-formatting-elements-15>Reconstruct the active formatting elements</a>, if any.</p>
|
||
|
||
<p><a href=#adjust-svg-attributes id=parsing-main-inbody:adjust-svg-attributes>Adjust SVG attributes</a> for the token. (This fixes the case of SVG attributes that
|
||
are not all lowercase.)</p>
|
||
|
||
<p><a href=#adjust-foreign-attributes id=parsing-main-inbody:adjust-foreign-attributes-2>Adjust foreign attributes</a> for the token. (This fixes the use of namespaced
|
||
attributes, in particular XLink in SVG.)</p>
|
||
|
||
<p><a href=#insert-a-foreign-element id=parsing-main-inbody:insert-a-foreign-element-2>Insert a foreign element</a> for the token, in the <a id=parsing-main-inbody:svg-namespace href=https://infra.spec.whatwg.org/#svg-namespace data-x-internal=svg-namespace>SVG namespace</a>.</p>
|
||
|
||
|
||
|
||
<p>If the token has its <i id=parsing-main-inbody:self-closing-flag-2><a href=#self-closing-flag>self-closing flag</a></i> set, pop the <a href=#current-node id=parsing-main-inbody:current-node-25>current node</a> off the
|
||
<a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-63>stack of open elements</a> and <a href=#acknowledge-self-closing-flag id=parsing-main-inbody:acknowledge-self-closing-flag-6>acknowledge
|
||
the token's <i>self-closing flag</i></a>.</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "caption", "col", "colgroup", "frame",
|
||
"head", "tbody", "td", "tfoot", "th", "thead", "tr"<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-inbody:parse-errors-38>Parse error</a>. Ignore the token.</p>
|
||
|
||
|
||
|
||
<dt>Any other start tag<dd>
|
||
|
||
<p><a href=#reconstruct-the-active-formatting-elements id=parsing-main-inbody:reconstruct-the-active-formatting-elements-16>Reconstruct the active formatting elements</a>, if any.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-25>Insert an HTML element</a> for the token.</p>
|
||
|
||
<p class=note>This element will be an <a href=#ordinary id=parsing-main-inbody:ordinary>ordinary</a>
|
||
element.</p>
|
||
|
||
<dt>Any other end tag<dd>
|
||
|
||
<p>Run these steps:</p>
|
||
|
||
<ol><li><p>Initialize <var>node</var> to be the <a href=#current-node id=parsing-main-inbody:current-node-26>current node</a> (the bottommost
|
||
node of the stack).<li><p><i>Loop</i>: If <var>node</var> is an <a href=infrastructure.html#html-elements id=parsing-main-inbody:html-elements-15>HTML
|
||
element</a> with the same tag name as the token, then:</p>
|
||
|
||
<ol><li><p><a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-14>Generate implied end tags</a>, except for <a id=parsing-main-inbody:html-elements-16 href=infrastructure.html#html-elements>HTML elements</a> with the
|
||
same tag name as the token.<li><p>If <var>node</var> is not the <a href=#current-node id=parsing-main-inbody:current-node-27>current node</a>, then this is a
|
||
<a href=#parse-errors id=parsing-main-inbody:parse-errors-39>parse error</a>.<li><p>Pop all the nodes from the <a href=#current-node id=parsing-main-inbody:current-node-28>current node</a> up to <var>node</var>,
|
||
including <var>node</var>, then stop these steps.</ol>
|
||
|
||
<li><p>Otherwise, if <var>node</var> is in the <a href=#special id=parsing-main-inbody:special-3>special</a> category, then
|
||
this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-40>parse error</a>; ignore the token, and abort these steps.<li><p>Set <var>node</var> to the previous entry in the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-64>stack of open
|
||
elements</a>.<li><p>Return to the step labeled <i>loop</i>.</ol>
|
||
|
||
</dl>
|
||
|
||
<p>When the steps above say the user agent is to <dfn id=close-a-p-element>close a <code>p</code> element</dfn>, it
|
||
means that the user agent must run the following steps:</p>
|
||
|
||
<ol><li><p><a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-15>Generate implied end tags</a>, except for <code id=parsing-main-inbody:the-p-element-6><a href=grouping-content.html#the-p-element>p</a></code> elements.<li><p>If the <a href=#current-node id=parsing-main-inbody:current-node-29>current node</a> is not a <code id=parsing-main-inbody:the-p-element-7><a href=grouping-content.html#the-p-element>p</a></code> element, then this is a
|
||
<a href=#parse-errors id=parsing-main-inbody:parse-errors-41>parse error</a>.<li><p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-65>stack of open elements</a> until a <code id=parsing-main-inbody:the-p-element-8><a href=grouping-content.html#the-p-element>p</a></code> element
|
||
has been popped from the stack.</ol>
|
||
|
||
|
||
<p id=adoptionAgency>The <dfn id=adoption-agency-algorithm>adoption agency algorithm</dfn>, which takes as its only argument
|
||
a token <var>token</var> for which the algorithm is being run, consists of the following
|
||
steps:</p>
|
||
|
||
<ol><li><p>Let <var>subject</var> be <var>token</var>'s tag name.<li><p>If the <a href=#current-node id=parsing-main-inbody:current-node-30>current node</a> is an <a href=infrastructure.html#html-elements id=parsing-main-inbody:html-elements-17>HTML element</a>
|
||
whose tag name is <var>subject</var>, and the <a href=#current-node id=parsing-main-inbody:current-node-31>current node</a> is not in the
|
||
<a href=#list-of-active-formatting-elements id=parsing-main-inbody:list-of-active-formatting-elements-4>list of active formatting elements</a>, then pop the <a href=#current-node id=parsing-main-inbody:current-node-32>current node</a> off the
|
||
<a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-66>stack of open elements</a>, and abort these steps.<li><p>Let <var>outer loop counter</var> be zero.<li><p><i>Outer loop</i>: If <var>outer loop counter</var> is greater than or equal to
|
||
eight, then abort these steps.<li><p>Increment <var>outer loop counter</var> by one.<li>
|
||
|
||
<p>Let <var>formatting element</var> be the last element in the <a href=#list-of-active-formatting-elements id=parsing-main-inbody:list-of-active-formatting-elements-5>list of active
|
||
formatting elements</a> that:</p>
|
||
|
||
<ul><li>is between the end of the list and the last <a href=#concept-parser-marker id=parsing-main-inbody:concept-parser-marker-4>marker</a> in the list, if any, or the start of the list
|
||
otherwise, and<li>has the tag name <var>subject</var>.</ul>
|
||
|
||
<p>If there is no such element, then abort these steps and instead act as described in the "any
|
||
other end tag" entry above.</p>
|
||
|
||
<li><p>If <var>formatting element</var> is not in the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-67>stack of open
|
||
elements</a>, then this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-42>parse error</a>; remove the element from the list, and
|
||
abort these steps.<li><p>If <var>formatting element</var> is in the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-68>stack of open elements</a>,
|
||
but the element is not <a href=#has-an-element-in-scope id=parsing-main-inbody:has-an-element-in-scope-13>in scope</a>, then this is a
|
||
<a href=#parse-errors id=parsing-main-inbody:parse-errors-43>parse error</a>; abort these steps.<li><p>If <var>formatting element</var> is not the <a href=#current-node id=parsing-main-inbody:current-node-33>current node</a>, this is a
|
||
<a href=#parse-errors id=parsing-main-inbody:parse-errors-44>parse error</a>. (But do not abort these steps.)<li><p>Let <var>furthest block</var> be the topmost node in the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-69>stack of open
|
||
elements</a> that is lower in the stack than <var>formatting element</var>, and is an
|
||
element in the <a href=#special id=parsing-main-inbody:special-4>special</a> category. There might not be one.<li><p>If there is no <var>furthest block</var>, then the UA must first pop all the
|
||
nodes from the bottom of the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-70>stack of open elements</a>, from the <a href=#current-node id=parsing-main-inbody:current-node-34>current
|
||
node</a> up to and including <var>formatting element</var>, then remove <var>formatting element</var> from the <a href=#list-of-active-formatting-elements id=parsing-main-inbody:list-of-active-formatting-elements-6>list of active formatting elements</a>, and
|
||
finally abort these steps.<li><p>Let <var>common ancestor</var> be the element immediately above <var>formatting element</var> in the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-71>stack of open elements</a>.<li><p>Let a bookmark note the position of <var>formatting element</var> in the
|
||
<a href=#list-of-active-formatting-elements id=parsing-main-inbody:list-of-active-formatting-elements-7>list of active formatting elements</a> relative to the elements on either side of it in
|
||
the list.<li>
|
||
|
||
<p>Let <var>node</var> and <var>last node</var> be <var>furthest
|
||
block</var>. Follow these steps:</p>
|
||
|
||
<ol><li><p>Let <var>inner loop counter</var> be zero.<li><p><i>Inner loop</i>: Increment <var>inner loop counter</var> by one.<li><p>Let <var>node</var> be the element immediately above <var>node</var>
|
||
in the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-72>stack of open elements</a>, or if <var>node</var> is no longer in the
|
||
<a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-73>stack of open elements</a> (e.g. because it got removed by this algorithm), the element that was immediately above <var>node</var> in the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-74>stack of open elements</a> before <var>node</var>
|
||
was removed.<li><p>If <var>node</var> is <var>formatting element</var>, then go to the
|
||
next step in the overall algorithm.<li><p>If <var>inner loop counter</var> is greater than three and <var>node</var> is in the <a href=#list-of-active-formatting-elements id=parsing-main-inbody:list-of-active-formatting-elements-8>list of active formatting elements</a>, then remove <var>node</var> from the <a href=#list-of-active-formatting-elements id=parsing-main-inbody:list-of-active-formatting-elements-9>list of active formatting elements</a>.<li><p>If <var>node</var> is not in the <a href=#list-of-active-formatting-elements id=parsing-main-inbody:list-of-active-formatting-elements-10>list of active
|
||
formatting elements</a>, then remove <var>node</var> from the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-75>stack of open
|
||
elements</a> and then go back to the step labeled <i>inner loop</i>.<li><p><a href=#create-an-element-for-the-token id=parsing-main-inbody:create-an-element-for-the-token>Create an element for the token</a> for which the element <var>node</var> was created, in the <a id=parsing-main-inbody:html-namespace-2 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a>, with <var>common
|
||
ancestor</var> as the intended parent; replace the entry for <var>node</var> in the
|
||
<a href=#list-of-active-formatting-elements id=parsing-main-inbody:list-of-active-formatting-elements-11>list of active formatting elements</a> with an entry for the new element, replace the
|
||
entry for <var>node</var> in the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-76>stack of open elements</a> with an entry for
|
||
the new element, and let <var>node</var> be the new element.<li><p>If <var>last node</var> is <var>furthest block</var>, then move the
|
||
aforementioned bookmark to be immediately after the new <var>node</var> in the
|
||
<a href=#list-of-active-formatting-elements id=parsing-main-inbody:list-of-active-formatting-elements-12>list of active formatting elements</a>.<li><p>Insert <var>last node</var> into <var>node</var>, first removing it
|
||
from its previous parent node if any.<li><p>Let <var>last node</var> be <var>node</var>.<li><p>Return to the step labeled <i>inner loop</i>.</ol>
|
||
|
||
<li><p>Insert whatever <var>last node</var> ended up being in the previous step at the
|
||
<a href=#appropriate-place-for-inserting-a-node id=parsing-main-inbody:appropriate-place-for-inserting-a-node>appropriate place for inserting a node</a>, but using <var>common
|
||
ancestor</var> as the <i>override target</i>.<li><p><a href=#create-an-element-for-the-token id=parsing-main-inbody:create-an-element-for-the-token-2>Create an element for the token</a> for which <var>formatting
|
||
element</var> was created, in the <a id=parsing-main-inbody:html-namespace-2-2 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a>, with <var>furthest
|
||
block</var> as the intended parent.<li><p>Take all of the child nodes of <var>furthest block</var> and append them to the
|
||
element created in the last step.<li><p>Append that new element to <var>furthest block</var>.<li><p>Remove <var>formatting element</var> from the <a href=#list-of-active-formatting-elements id=parsing-main-inbody:list-of-active-formatting-elements-13>list of active formatting
|
||
elements</a>, and insert the new element into the <a href=#list-of-active-formatting-elements id=parsing-main-inbody:list-of-active-formatting-elements-14>list of active formatting
|
||
elements</a> at the position of the aforementioned bookmark.<li><p>Remove <var>formatting element</var> from the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-77>stack of open
|
||
elements</a>, and insert the new element into the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-78>stack of open elements</a>
|
||
immediately below the position of <var>furthest block</var> in that stack.<li><p>Jump back to the step labeled <i>outer loop</i>.</ol>
|
||
|
||
<p class=note>This algorithm's name, the "adoption agency algorithm", comes from the way it
|
||
causes elements to change parents, and is in contrast with other possible algorithms for dealing
|
||
with misnested content, which included the "incest algorithm", the "secret affair algorithm", and
|
||
the "Heisenberg algorithm".</p>
|
||
|
||
|
||
|
||
|
||
|
||
<h6 id=parsing-main-incdata><span class=secno>12.2.6.4.8</span> The "<dfn>text</dfn>" insertion mode<a href=#parsing-main-incdata class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-incdata id=parsing-main-incdata:parsing-main-incdata>text</a>" <a href=#insertion-mode id=parsing-main-incdata:insertion-mode>insertion mode</a>, the user agent must handle the token as
|
||
follows:</p>
|
||
|
||
<dl class=switch><dt>A character token<dd>
|
||
|
||
<p><a href=#insert-a-character id=parsing-main-incdata:insert-a-character>Insert the token's character</a>.</p>
|
||
|
||
<p class=note>This can never be a U+0000 NULL character; the tokenizer converts those to
|
||
U+FFFD REPLACEMENT CHARACTER characters.</p>
|
||
|
||
<dt>An end-of-file token<dd>
|
||
|
||
|
||
<p><a href=#parse-errors id=parsing-main-incdata:parse-errors>Parse error</a>.</p>
|
||
|
||
<p>If the <a href=#current-node id=parsing-main-incdata:current-node>current node</a> is a <code id=parsing-main-incdata:the-script-element><a href=scripting.html#the-script-element>script</a></code> element, mark the
|
||
<code id=parsing-main-incdata:the-script-element-2><a href=scripting.html#the-script-element>script</a></code> element as <a id=parsing-main-incdata:already-started href=scripting.html#already-started>"already started"</a>.</p>
|
||
|
||
<p>Pop the <a href=#current-node id=parsing-main-incdata:current-node-2>current node</a> off the <a href=#stack-of-open-elements id=parsing-main-incdata:stack-of-open-elements>stack of open elements</a>.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-incdata:insertion-mode-2>insertion mode</a> to the <a href=#original-insertion-mode id=parsing-main-incdata:original-insertion-mode>original insertion mode</a> and
|
||
reprocess the token.</p>
|
||
|
||
<dt id=scriptEndTag>An end tag whose tag name is "script"<dd>
|
||
|
||
<p>If the <a id=parsing-main-incdata:javascript-execution-context-stack href=https://tc39.github.io/ecma262/#execution-context-stack data-x-internal=javascript-execution-context-stack>JavaScript execution context stack</a> is empty, <a id=parsing-main-incdata:perform-a-microtask-checkpoint href=webappapis.html#perform-a-microtask-checkpoint>perform a microtask
|
||
checkpoint</a>.</p>
|
||
|
||
<p>Let <var>script</var> be the <a href=#current-node id=parsing-main-incdata:current-node-3>current node</a> (which will be a
|
||
<code id=parsing-main-incdata:the-script-element-3><a href=scripting.html#the-script-element>script</a></code> element).</p>
|
||
|
||
<p>Pop the <a href=#current-node id=parsing-main-incdata:current-node-4>current node</a> off the <a href=#stack-of-open-elements id=parsing-main-incdata:stack-of-open-elements-2>stack of open elements</a>.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-incdata:insertion-mode-3>insertion mode</a> to the <a href=#original-insertion-mode id=parsing-main-incdata:original-insertion-mode-2>original insertion mode</a>.</p>
|
||
|
||
<p>Let the <var>old insertion point</var> have the same value as the current
|
||
<a href=#insertion-point id=parsing-main-incdata:insertion-point>insertion point</a>. Let the <a href=#insertion-point id=parsing-main-incdata:insertion-point-2>insertion point</a> be just before the <a href=#next-input-character id=parsing-main-incdata:next-input-character>next
|
||
input character</a>.</p>
|
||
|
||
<p>Increment the parser's <a href=#script-nesting-level id=parsing-main-incdata:script-nesting-level>script nesting level</a> by one.</p>
|
||
|
||
<p><a href=scripting.html#prepare-a-script id=parsing-main-incdata:prepare-a-script>Prepare</a> the <var>script</var>. This might
|
||
cause some script to execute, which might cause <a href=dynamic-markup-insertion.html#dom-document-write-2 id=parsing-main-incdata:dom-document-write-2>new characters
|
||
to be inserted into the tokenizer</a>, and might cause the tokenizer to output more tokens,
|
||
resulting in a <a href=#nestedParsing>reentrant invocation of the parser</a>.</p>
|
||
|
||
<p>Decrement the parser's <a href=#script-nesting-level id=parsing-main-incdata:script-nesting-level-2>script nesting level</a> by one. If the parser's <a href=#script-nesting-level id=parsing-main-incdata:script-nesting-level-3>script
|
||
nesting level</a> is zero, then set the <a href=#parser-pause-flag id=parsing-main-incdata:parser-pause-flag>parser pause flag</a> to false.</p>
|
||
|
||
<p>Let the <a href=#insertion-point id=parsing-main-incdata:insertion-point-3>insertion point</a> have the value of the <var>old insertion
|
||
point</var>. (In other words, restore the <a href=#insertion-point id=parsing-main-incdata:insertion-point-4>insertion point</a> to its previous value.
|
||
This value might be the "undefined" value.)</p>
|
||
|
||
<p id=scriptTagParserResumes>At this stage, if there is a <a id=parsing-main-incdata:pending-parsing-blocking-script href=scripting.html#pending-parsing-blocking-script>pending parsing-blocking
|
||
script</a>, then:</p>
|
||
|
||
<dl class=switch><dt>If the <a href=#script-nesting-level id=parsing-main-incdata:script-nesting-level-4>script nesting level</a> is not zero:<dd>
|
||
|
||
<p>Set the <a href=#parser-pause-flag id=parsing-main-incdata:parser-pause-flag-2>parser pause flag</a> to true, and abort the processing of any nested
|
||
invocations of the tokenizer, yielding control back to the caller. (Tokenization will resume
|
||
when the caller returns to the "outer" tree construction stage.)</p>
|
||
|
||
<p class=note>The tree construction stage of this particular parser is <a href=#nestedParsing>being called reentrantly</a>, say from a call to <code id=parsing-main-incdata:dom-document-write-2-2><a href=dynamic-markup-insertion.html#dom-document-write-2>document.write()</a></code>.</p>
|
||
|
||
<dt>Otherwise:<dd>
|
||
|
||
<p>Run these steps:</p>
|
||
|
||
<ol><li><p>Let <var>the script</var> be the <a id=parsing-main-incdata:pending-parsing-blocking-script-2 href=scripting.html#pending-parsing-blocking-script>pending parsing-blocking
|
||
script</a>. There is no longer a <a id=parsing-main-incdata:pending-parsing-blocking-script-3 href=scripting.html#pending-parsing-blocking-script>pending parsing-blocking script</a>.<li><p>Block the <a href=#tokenization id=parsing-main-incdata:tokenization>tokenizer</a> for this instance of the
|
||
<a href=#html-parser id=parsing-main-incdata:html-parser>HTML parser</a>, such that the <a id=parsing-main-incdata:event-loop href=webappapis.html#event-loop>event loop</a> will not run <a href=webappapis.html#concept-task id=parsing-main-incdata:concept-task>tasks</a> that invoke the <a href=#tokenization id=parsing-main-incdata:tokenization-2>tokenizer</a>.<li><p>If the parser's <code id=parsing-main-incdata:document><a href=dom.html#document>Document</a></code> <a id=parsing-main-incdata:has-a-style-sheet-that-is-blocking-scripts href=semantics.html#has-a-style-sheet-that-is-blocking-scripts>has a style sheet that is blocking
|
||
scripts</a> or <var>the script</var>'s <a id=parsing-main-incdata:ready-to-be-parser-executed href=scripting.html#ready-to-be-parser-executed>"ready to be parser-executed"</a>
|
||
flag is not set: <a id=parsing-main-incdata:spin-the-event-loop href=webappapis.html#spin-the-event-loop>spin the event loop</a> until the parser's <code id=parsing-main-incdata:document-2><a href=dom.html#document>Document</a></code>
|
||
<a id=parsing-main-incdata:has-no-style-sheet-that-is-blocking-scripts href=semantics.html#has-no-style-sheet-that-is-blocking-scripts>has no style sheet that is blocking scripts</a> and <var>the script</var>'s
|
||
<a id=parsing-main-incdata:ready-to-be-parser-executed-2 href=scripting.html#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag is set.<li>
|
||
|
||
<p>If this <a href=#abort-a-parser id=parsing-main-incdata:abort-a-parser>parser has been aborted</a> in the meantime,
|
||
abort these steps.</p>
|
||
|
||
<p class=note>This could happen if, e.g., while the <a id=parsing-main-incdata:spin-the-event-loop-2 href=webappapis.html#spin-the-event-loop>spin the event loop</a>
|
||
algorithm is running, the <a id=parsing-main-incdata:browsing-context href=browsers.html#browsing-context>browsing context</a> gets closed, or the <code id=parsing-main-incdata:dom-document-open><a href=dynamic-markup-insertion.html#dom-document-open>document.open()</a></code> method gets invoked on the
|
||
<code id=parsing-main-incdata:document-3><a href=dom.html#document>Document</a></code>.</p>
|
||
|
||
<li><p>Unblock the <a href=#tokenization id=parsing-main-incdata:tokenization-3>tokenizer</a> for this instance of the
|
||
<a href=#html-parser id=parsing-main-incdata:html-parser-2>HTML parser</a>, such that <a href=webappapis.html#concept-task id=parsing-main-incdata:concept-task-2>tasks</a> that invoke the
|
||
<a href=#tokenization id=parsing-main-incdata:tokenization-4>tokenizer</a> can again be run.<li><p>Let the <a href=#insertion-point id=parsing-main-incdata:insertion-point-5>insertion point</a> be just before the <a href=#next-input-character id=parsing-main-incdata:next-input-character-2>next input
|
||
character</a>.<li><p>Increment the parser's <a href=#script-nesting-level id=parsing-main-incdata:script-nesting-level-5>script nesting level</a> by one (it should be zero
|
||
before this step, so this sets it to one).<li><p><a href=scripting.html#execute-the-script-block id=parsing-main-incdata:execute-the-script-block>Execute</a> <var>the
|
||
script</var>.<li><p>Decrement the parser's <a href=#script-nesting-level id=parsing-main-incdata:script-nesting-level-6>script nesting level</a> by one. If the parser's
|
||
<a href=#script-nesting-level id=parsing-main-incdata:script-nesting-level-7>script nesting level</a> is zero (which it always should be at this point), then set
|
||
the <a href=#parser-pause-flag id=parsing-main-incdata:parser-pause-flag-3>parser pause flag</a> to false.</p>
|
||
|
||
<li><p>Let the <a href=#insertion-point id=parsing-main-incdata:insertion-point-6>insertion point</a> be undefined again.<li><p>If there is once again a <a id=parsing-main-incdata:pending-parsing-blocking-script-4 href=scripting.html#pending-parsing-blocking-script>pending parsing-blocking script</a>, then repeat
|
||
these steps from step 1.</ol>
|
||
|
||
</dl>
|
||
|
||
<dt>Any other end tag<dd>
|
||
|
||
<p>Pop the <a href=#current-node id=parsing-main-incdata:current-node-5>current node</a> off the <a href=#stack-of-open-elements id=parsing-main-incdata:stack-of-open-elements-3>stack of open elements</a>.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-incdata:insertion-mode-4>insertion mode</a> to the <a href=#original-insertion-mode id=parsing-main-incdata:original-insertion-mode-3>original insertion mode</a>.</p>
|
||
|
||
</dl>
|
||
|
||
|
||
<h6 id=parsing-main-intable><span class=secno>12.2.6.4.9</span> The "<dfn>in table</dfn>" insertion mode<a href=#parsing-main-intable class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-intable id=parsing-main-intable:parsing-main-intable>in
|
||
table</a>" <a href=#insertion-mode id=parsing-main-intable:insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
|
||
|
||
<dl class=switch><dt>A character token, if the <a href=#current-node id=parsing-main-intable:current-node>current node</a> is <code id=parsing-main-intable:the-table-element><a href=tables.html#the-table-element>table</a></code>, <code id=parsing-main-intable:the-tbody-element><a href=tables.html#the-tbody-element>tbody</a></code>, <code id=parsing-main-intable:the-tfoot-element><a href=tables.html#the-tfoot-element>tfoot</a></code>, <code id=parsing-main-intable:the-thead-element><a href=tables.html#the-thead-element>thead</a></code>, or <code id=parsing-main-intable:the-tr-element><a href=tables.html#the-tr-element>tr</a></code> element<dd>
|
||
|
||
<p>Let the <dfn id=concept-pending-table-char-tokens><var>pending table character
|
||
tokens</var></dfn> be an empty list of tokens.</p>
|
||
|
||
<p>Let the <a href=#original-insertion-mode id=parsing-main-intable:original-insertion-mode>original insertion mode</a> be the current <a href=#insertion-mode id=parsing-main-intable:insertion-mode-2>insertion mode</a>.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-intable:insertion-mode-3>insertion mode</a> to "<a href=#parsing-main-intabletext id=parsing-main-intable:parsing-main-intabletext>in
|
||
table text</a>" and reprocess the token.</p>
|
||
|
||
<dt>A comment token<dd>
|
||
<p><a href=#insert-a-comment id=parsing-main-intable:insert-a-comment>Insert a comment</a>.</p>
|
||
<dt>A DOCTYPE token<dd>
|
||
<p><a href=#parse-errors id=parsing-main-intable:parse-errors>Parse error</a>. Ignore the token.</p>
|
||
<dt>A start tag whose tag name is "caption"<dd>
|
||
|
||
<p><a href=#clear-the-stack-back-to-a-table-context id=parsing-main-intable:clear-the-stack-back-to-a-table-context>Clear the stack back to a table context</a>. (See below.)</p>
|
||
|
||
<p>Insert a <a href=#concept-parser-marker id=parsing-main-intable:concept-parser-marker>marker</a> at the end of the <a href=#list-of-active-formatting-elements id=parsing-main-intable:list-of-active-formatting-elements>list of
|
||
active formatting elements</a>.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-intable:insert-an-html-element>Insert an HTML element</a> for the token, then switch the <a href=#insertion-mode id=parsing-main-intable:insertion-mode-4>insertion
|
||
mode</a> to "<a href=#parsing-main-incaption id=parsing-main-intable:parsing-main-incaption>in caption</a>".</p>
|
||
|
||
<dt>A start tag whose tag name is "colgroup"<dd>
|
||
|
||
<p><a href=#clear-the-stack-back-to-a-table-context id=parsing-main-intable:clear-the-stack-back-to-a-table-context-2>Clear the stack back to a table context</a>. (See below.)</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-intable:insert-an-html-element-2>Insert an HTML element</a> for the token, then switch the <a href=#insertion-mode id=parsing-main-intable:insertion-mode-5>insertion
|
||
mode</a> to "<a href=#parsing-main-incolgroup id=parsing-main-intable:parsing-main-incolgroup>in column group</a>".</p>
|
||
|
||
<dt>A start tag whose tag name is "col"<dd>
|
||
|
||
|
||
<p><a href=#clear-the-stack-back-to-a-table-context id=parsing-main-intable:clear-the-stack-back-to-a-table-context-3>Clear the stack back to a table context</a>. (See below.)</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-intable:insert-an-html-element-3>Insert an HTML element</a> for a "colgroup" start tag token with no attributes, then
|
||
switch the <a href=#insertion-mode id=parsing-main-intable:insertion-mode-6>insertion mode</a> to "<a href=#parsing-main-incolgroup id=parsing-main-intable:parsing-main-incolgroup-2>in
|
||
column group</a>".</p>
|
||
|
||
|
||
<p>Reprocess the current token.</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "tbody", "tfoot", "thead"<dd>
|
||
|
||
<p><a href=#clear-the-stack-back-to-a-table-context id=parsing-main-intable:clear-the-stack-back-to-a-table-context-4>Clear the stack back to a table context</a>. (See below.)</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-intable:insert-an-html-element-4>Insert an HTML element</a> for the token, then switch the <a href=#insertion-mode id=parsing-main-intable:insertion-mode-7>insertion
|
||
mode</a> to "<a href=#parsing-main-intbody id=parsing-main-intable:parsing-main-intbody>in table body</a>".</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "td", "th", "tr"<dd>
|
||
|
||
|
||
<p><a href=#clear-the-stack-back-to-a-table-context id=parsing-main-intable:clear-the-stack-back-to-a-table-context-5>Clear the stack back to a table context</a>. (See below.)</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-intable:insert-an-html-element-5>Insert an HTML element</a> for a "tbody" start tag token with no attributes, then
|
||
switch the <a href=#insertion-mode id=parsing-main-intable:insertion-mode-8>insertion mode</a> to "<a href=#parsing-main-intbody id=parsing-main-intable:parsing-main-intbody-2>in table
|
||
body</a>".</p>
|
||
|
||
|
||
<p>Reprocess the current token.</p>
|
||
|
||
<dt>A start tag whose tag name is "table"<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-intable:parse-errors-2>Parse error</a>.</p>
|
||
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-intable:stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope id=parsing-main-intable:has-an-element-in-table-scope>have a <code>table</code> element in table scope</a>, ignore the token.</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
<p>Pop elements from this stack until a <code id=parsing-main-intable:the-table-element-2><a href=tables.html#the-table-element>table</a></code> element has been popped from the
|
||
stack.</p>
|
||
|
||
<p><a href=#reset-the-insertion-mode-appropriately id=parsing-main-intable:reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
|
||
|
||
|
||
<p>Reprocess the token.</p>
|
||
|
||
<dt>An end tag whose tag name is "table"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-intable:stack-of-open-elements-2>stack of open elements</a> does not <a href=#has-an-element-in-table-scope id=parsing-main-intable:has-an-element-in-table-scope-2>have a <code>table</code> element in table scope</a>, this is a <a href=#parse-errors id=parsing-main-intable:parse-errors-3>parse
|
||
error</a>; ignore the token.</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
<p>Pop elements from this stack until a <code id=parsing-main-intable:the-table-element-3><a href=tables.html#the-table-element>table</a></code> element has been popped from the
|
||
stack.</p>
|
||
|
||
<p><a href=#reset-the-insertion-mode-appropriately id=parsing-main-intable:reset-the-insertion-mode-appropriately-2>Reset the insertion mode appropriately</a>.</p>
|
||
|
||
<dt>An end tag whose tag name is one of: "body", "caption", "col", "colgroup", "html", "tbody",
|
||
"td", "tfoot", "th", "thead", "tr"<dd>
|
||
<p><a href=#parse-errors id=parsing-main-intable:parse-errors-4>Parse error</a>. Ignore the token.</p>
|
||
<dt>A start tag whose tag name is one of: "style", "script", "template"<dt>An end tag whose tag name is "template"<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-intable:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inhead id=parsing-main-intable:parsing-main-inhead>in head</a>" <a href=#insertion-mode id=parsing-main-intable:insertion-mode-9>insertion
|
||
mode</a>.</p>
|
||
|
||
<dt>A start tag whose tag name is "input"<dd>
|
||
|
||
<p>If the token does not have an attribute with the name "type", or if it does, but that
|
||
attribute's value is not an <a id=parsing-main-intable:ascii-case-insensitive href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> match for the string "<code>hidden</code>", then: act as described in the "anything else" entry below.</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-intable:parse-errors-5>Parse error</a>.</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-intable:insert-an-html-element-6>Insert an HTML element</a> for the token.</p>
|
||
|
||
<p>Pop that <code id=parsing-main-intable:the-input-element><a href=input.html#the-input-element>input</a></code> element off the <a href=#stack-of-open-elements id=parsing-main-intable:stack-of-open-elements-3>stack of open elements</a>.</p>
|
||
|
||
<p><a href=#acknowledge-self-closing-flag id=parsing-main-intable:acknowledge-self-closing-flag>Acknowledge the token's <i>self-closing
|
||
flag</i></a>, if it is set.</p>
|
||
|
||
<dt>A start tag whose tag name is "form"<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-intable:parse-errors-6>Parse error</a>.</p>
|
||
|
||
<p>If there is a <code id=parsing-main-intable:the-template-element><a href=scripting.html#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements id=parsing-main-intable:stack-of-open-elements-4>stack of open elements</a>, or if
|
||
the <a href=#form-element-pointer id=parsing-main-intable:form-element-pointer><code>form</code> element pointer</a> is not null, ignore the
|
||
token.</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-intable:insert-an-html-element-7>Insert an HTML element</a> for the token, and set the <a href=#form-element-pointer id=parsing-main-intable:form-element-pointer-2><code>form</code> element pointer</a> to point to the element created.</p>
|
||
|
||
<p>Pop that <code id=parsing-main-intable:the-form-element><a href=forms.html#the-form-element>form</a></code> element off the <a href=#stack-of-open-elements id=parsing-main-intable:stack-of-open-elements-5>stack of open elements</a>.</p>
|
||
|
||
<dt>An end-of-file token<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-intable:using-the-rules-for-2>using the rules for</a> the "<a href=#parsing-main-inbody id=parsing-main-intable:parsing-main-inbody>in body</a>" <a href=#insertion-mode id=parsing-main-intable:insertion-mode-10>insertion mode</a>.</p>
|
||
|
||
<dt>Anything else<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-intable:parse-errors-7>Parse error</a>. Enable <a href=#foster-parent id=parsing-main-intable:foster-parent>foster parenting</a>, process
|
||
the token <a href=#using-the-rules-for id=parsing-main-intable:using-the-rules-for-3>using the rules for</a> the "<a href=#parsing-main-inbody id=parsing-main-intable:parsing-main-inbody-2>in
|
||
body</a>" <a href=#insertion-mode id=parsing-main-intable:insertion-mode-11>insertion mode</a>, and then disable <a href=#foster-parent id=parsing-main-intable:foster-parent-2>foster
|
||
parenting</a>.</p>
|
||
|
||
</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 id=parsing-main-intable:current-node-2>current node</a> is not a <code id=parsing-main-intable:the-table-element-4><a href=tables.html#the-table-element>table</a></code>,
|
||
<code id=parsing-main-intable:the-template-element-2><a href=scripting.html#the-template-element>template</a></code>, or <code id=parsing-main-intable:the-html-element><a href=semantics.html#the-html-element>html</a></code> element, pop elements from the <a href=#stack-of-open-elements id=parsing-main-intable:stack-of-open-elements-6>stack of open
|
||
elements</a>.</p>
|
||
|
||
<p class=note>This is the same list of elements as used in the <i id=parsing-main-intable:has-an-element-in-table-scope-3><a href=#has-an-element-in-table-scope>has an element in table scope</a></i> steps.</p>
|
||
|
||
<p class=note>The <a href=#current-node id=parsing-main-intable:current-node-3>current node</a> being an <code id=parsing-main-intable:the-html-element-2><a href=semantics.html#the-html-element>html</a></code> element after this
|
||
process is a <a href=#fragment-case id=parsing-main-intable:fragment-case>fragment case</a>.</p>
|
||
|
||
|
||
|
||
<h6 id=parsing-main-intabletext><span class=secno>12.2.6.4.10</span> The "<dfn>in table text</dfn>" insertion mode<a href=#parsing-main-intabletext class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-intabletext id=parsing-main-intabletext:parsing-main-intabletext>in table text</a>" <a href=#insertion-mode id=parsing-main-intabletext:insertion-mode>insertion mode</a>, the user agent must handle the token as
|
||
follows:</p>
|
||
|
||
<dl class=switch><dt>A character token that is U+0000 NULL<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-intabletext:parse-errors>Parse error</a>. Ignore the token.</p>
|
||
|
||
<dt>Any other character token<dd>
|
||
|
||
<p>Append the character token to the <var id=parsing-main-intabletext:concept-pending-table-char-tokens><a href=#concept-pending-table-char-tokens>pending
|
||
table character tokens</a></var> list.</p>
|
||
|
||
<dt>Anything else<dd>
|
||
|
||
|
||
|
||
<p>If any of the tokens in the <var id=parsing-main-intabletext:concept-pending-table-char-tokens-2><a href=#concept-pending-table-char-tokens>pending table
|
||
character tokens</a></var> list are character tokens that are not <a id=parsing-main-intabletext:space-characters href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a>,
|
||
then this is a <a href=#parse-errors id=parsing-main-intabletext:parse-errors-2>parse error</a>: reprocess the character tokens in the <var id=parsing-main-intabletext:concept-pending-table-char-tokens-3><a href=#concept-pending-table-char-tokens>pending table character tokens</a></var> list using the
|
||
rules given in the "anything else" entry in the "<a href=#parsing-main-intable id=parsing-main-intabletext:parsing-main-intable>in
|
||
table</a>" insertion mode.</p>
|
||
|
||
|
||
|
||
<p>Otherwise, <a href=#insert-a-character id=parsing-main-intabletext:insert-a-character>insert the characters</a> given by the <var id=parsing-main-intabletext:concept-pending-table-char-tokens-4><a href=#concept-pending-table-char-tokens>pending table character tokens</a></var> list.</p>
|
||
|
||
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-intabletext:insertion-mode-2>insertion mode</a> to the <a href=#original-insertion-mode id=parsing-main-intabletext:original-insertion-mode>original insertion mode</a> and
|
||
reprocess the token.</p>
|
||
|
||
</dl>
|
||
|
||
|
||
<h6 id=parsing-main-incaption><span class=secno>12.2.6.4.11</span> The "<dfn>in caption</dfn>" insertion mode<a href=#parsing-main-incaption class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-incaption id=parsing-main-incaption:parsing-main-incaption>in
|
||
caption</a>" <a href=#insertion-mode id=parsing-main-incaption:insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
|
||
|
||
<dl class=switch><dt>An end tag whose tag name is "caption"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-incaption:stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope id=parsing-main-incaption:has-an-element-in-table-scope>have a <code>caption</code> element in table scope</a>, this is a <a href=#parse-errors id=parsing-main-incaption:parse-errors>parse
|
||
error</a>; ignore the token. (<a href=#fragment-case id=parsing-main-incaption:fragment-case>fragment case</a>)</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
<p><a href=#generate-implied-end-tags id=parsing-main-incaption:generate-implied-end-tags>Generate implied end tags</a>.</p>
|
||
|
||
<p>Now, if the <a href=#current-node id=parsing-main-incaption:current-node>current node</a> is not a <code id=parsing-main-incaption:the-caption-element><a href=tables.html#the-caption-element>caption</a></code> element, then this is a
|
||
<a href=#parse-errors id=parsing-main-incaption:parse-errors-2>parse error</a>.</p>
|
||
|
||
<p>Pop elements from this stack until a <code id=parsing-main-incaption:the-caption-element-2><a href=tables.html#the-caption-element>caption</a></code> element has been popped from the
|
||
stack.</p>
|
||
|
||
<p><a href=#clear-the-list-of-active-formatting-elements-up-to-the-last-marker id=parsing-main-incaption: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>.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-incaption:insertion-mode-2>insertion mode</a> to "<a href=#parsing-main-intable id=parsing-main-incaption:parsing-main-intable>in
|
||
table</a>".</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "caption", "col", "colgroup", "tbody", "td", "tfoot",
|
||
"th", "thead", "tr"<dt>An end tag whose tag name is "table"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-incaption:stack-of-open-elements-2>stack of open elements</a> does not <a href=#has-an-element-in-table-scope id=parsing-main-incaption:has-an-element-in-table-scope-2>have a <code>caption</code> element in table scope</a>, this is a <a href=#parse-errors id=parsing-main-incaption:parse-errors-3>parse
|
||
error</a>; ignore the token. (<a href=#fragment-case id=parsing-main-incaption:fragment-case-2>fragment case</a>)</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
|
||
<p><a href=#generate-implied-end-tags id=parsing-main-incaption:generate-implied-end-tags-2>Generate implied end tags</a>.</p>
|
||
|
||
<p>Now, if the <a href=#current-node id=parsing-main-incaption:current-node-2>current node</a> is not a <code id=parsing-main-incaption:the-caption-element-3><a href=tables.html#the-caption-element>caption</a></code> element, then this is a
|
||
<a href=#parse-errors id=parsing-main-incaption:parse-errors-4>parse error</a>.</p>
|
||
|
||
<p>Pop elements from this stack until a <code id=parsing-main-incaption:the-caption-element-4><a href=tables.html#the-caption-element>caption</a></code> element has been popped from the
|
||
stack.</p>
|
||
|
||
<p><a href=#clear-the-list-of-active-formatting-elements-up-to-the-last-marker id=parsing-main-incaption:clear-the-list-of-active-formatting-elements-up-to-the-last-marker-2>Clear the list of active formatting elements up to the last marker</a>.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-incaption:insertion-mode-3>insertion mode</a> to "<a href=#parsing-main-intable id=parsing-main-incaption:parsing-main-intable-2>in
|
||
table</a>".</p>
|
||
|
||
|
||
<p>Reprocess the token.</p>
|
||
|
||
<dt>An end tag whose tag name is one of: "body", "col", "colgroup", "html", "tbody", "td",
|
||
"tfoot", "th", "thead", "tr"<dd>
|
||
<p><a href=#parse-errors id=parsing-main-incaption:parse-errors-5>Parse error</a>. Ignore the token.</p>
|
||
<dt>Anything else<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-incaption:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody id=parsing-main-incaption:parsing-main-inbody>in body</a>" <a href=#insertion-mode id=parsing-main-incaption:insertion-mode-4>insertion mode</a>.</p>
|
||
|
||
</dl>
|
||
|
||
|
||
<h6 id=parsing-main-incolgroup><span class=secno>12.2.6.4.12</span> The "<dfn>in column group</dfn>" insertion mode<a href=#parsing-main-incolgroup class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-incolgroup id=parsing-main-incolgroup:parsing-main-incolgroup>in column group</a>" <a href=#insertion-mode id=parsing-main-incolgroup: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 TABULATION, U+000A LINE FEED (LF), U+000C
|
||
FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE<dd>
|
||
<p><a href=#insert-a-character id=parsing-main-incolgroup:insert-a-character>Insert the character</a>.</p>
|
||
<dt>A comment token<dd>
|
||
<p><a href=#insert-a-comment id=parsing-main-incolgroup:insert-a-comment>Insert a comment</a>.</p>
|
||
<dt>A DOCTYPE token<dd>
|
||
<p><a href=#parse-errors id=parsing-main-incolgroup:parse-errors>Parse error</a>. Ignore the token.</p>
|
||
<dt>A start tag whose tag name is "html"<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-incolgroup:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody id=parsing-main-incolgroup:parsing-main-inbody>in body</a>" <a href=#insertion-mode id=parsing-main-incolgroup:insertion-mode-2>insertion mode</a>.</p>
|
||
|
||
<dt>A start tag whose tag name is "col"<dd>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-incolgroup:insert-an-html-element>Insert an HTML element</a> for the token. Immediately pop the <a href=#current-node id=parsing-main-incolgroup:current-node>current
|
||
node</a> off the <a href=#stack-of-open-elements id=parsing-main-incolgroup:stack-of-open-elements>stack of open elements</a>.</p>
|
||
|
||
<p><a href=#acknowledge-self-closing-flag id=parsing-main-incolgroup:acknowledge-self-closing-flag>Acknowledge the token's <i>self-closing
|
||
flag</i></a>, if it is set.</p>
|
||
|
||
<dt>An end tag whose tag name is "colgroup"<dd>
|
||
|
||
<p>If the <a href=#current-node id=parsing-main-incolgroup:current-node-2>current node</a> is not a <code id=parsing-main-incolgroup:the-colgroup-element><a href=tables.html#the-colgroup-element>colgroup</a></code> element, then this is a
|
||
<a href=#parse-errors id=parsing-main-incolgroup:parse-errors-2>parse error</a>; ignore the token.</p>
|
||
|
||
<p>Otherwise, pop the <a href=#current-node id=parsing-main-incolgroup:current-node-3>current node</a> from the <a href=#stack-of-open-elements id=parsing-main-incolgroup:stack-of-open-elements-2>stack of open elements</a>.
|
||
Switch the <a href=#insertion-mode id=parsing-main-incolgroup:insertion-mode-3>insertion mode</a> to "<a href=#parsing-main-intable id=parsing-main-incolgroup:parsing-main-intable>in
|
||
table</a>".</p>
|
||
|
||
<dt>An end tag whose tag name is "col"<dd>
|
||
<p><a href=#parse-errors id=parsing-main-incolgroup:parse-errors-3>Parse error</a>. Ignore the token.</p>
|
||
<dt>A start tag whose tag name is "template"<dt>An end tag whose tag name is "template"<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-incolgroup:using-the-rules-for-2>using the rules for</a> the "<a href=#parsing-main-inhead id=parsing-main-incolgroup:parsing-main-inhead>in head</a>" <a href=#insertion-mode id=parsing-main-incolgroup:insertion-mode-4>insertion mode</a>.</p>
|
||
|
||
<dt>An end-of-file token<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-incolgroup:using-the-rules-for-3>using the rules for</a> the "<a href=#parsing-main-inbody id=parsing-main-incolgroup:parsing-main-inbody-2>in body</a>" <a href=#insertion-mode id=parsing-main-incolgroup:insertion-mode-5>insertion mode</a>.</p>
|
||
|
||
<dt>Anything else<dd>
|
||
|
||
|
||
<p>If the <a href=#current-node id=parsing-main-incolgroup:current-node-4>current node</a> is not a <code id=parsing-main-incolgroup:the-colgroup-element-2><a href=tables.html#the-colgroup-element>colgroup</a></code> element, then this is a
|
||
<a href=#parse-errors id=parsing-main-incolgroup:parse-errors-4>parse error</a>; ignore the token.</p>
|
||
|
||
<p>Otherwise, pop the <a href=#current-node id=parsing-main-incolgroup:current-node-5>current node</a> from the <a href=#stack-of-open-elements id=parsing-main-incolgroup:stack-of-open-elements-3>stack of open
|
||
elements</a>.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-incolgroup:insertion-mode-6>insertion mode</a> to "<a href=#parsing-main-intable id=parsing-main-incolgroup:parsing-main-intable-2>in
|
||
table</a>".</p>
|
||
|
||
|
||
<p>Reprocess the token.</p>
|
||
|
||
</dl>
|
||
|
||
|
||
<h6 id=parsing-main-intbody><span class=secno>12.2.6.4.13</span> The "<dfn>in table body</dfn>" insertion mode<a href=#parsing-main-intbody class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-intbody id=parsing-main-intbody:parsing-main-intbody>in table body</a>" <a href=#insertion-mode id=parsing-main-intbody:insertion-mode>insertion mode</a>, the user agent must handle the token as
|
||
follows:</p>
|
||
|
||
<dl class=switch><dt>A start tag whose tag name is "tr"<dd>
|
||
|
||
<p><a href=#clear-the-stack-back-to-a-table-body-context id=parsing-main-intbody:clear-the-stack-back-to-a-table-body-context>Clear the stack back to a table body context</a>. (See below.)</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-intbody:insert-an-html-element>Insert an HTML element</a> for the token, then switch the <a href=#insertion-mode id=parsing-main-intbody:insertion-mode-2>insertion
|
||
mode</a> to "<a href=#parsing-main-intr id=parsing-main-intbody:parsing-main-intr>in row</a>".</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "th", "td"<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-intbody:parse-errors>Parse error</a>.</p>
|
||
|
||
|
||
<p><a href=#clear-the-stack-back-to-a-table-body-context id=parsing-main-intbody:clear-the-stack-back-to-a-table-body-context-2>Clear the stack back to a table body context</a>. (See below.)</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-intbody:insert-an-html-element-2>Insert an HTML element</a> for a "tr" start tag token with no attributes, then
|
||
switch the <a href=#insertion-mode id=parsing-main-intbody:insertion-mode-3>insertion mode</a> to "<a href=#parsing-main-intr id=parsing-main-intbody:parsing-main-intr-2>in
|
||
row</a>".</p>
|
||
|
||
|
||
<p>Reprocess the current token.</p>
|
||
|
||
<dt>An end tag whose tag name is one of: "tbody", "tfoot",
|
||
"thead"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-intbody:stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope id=parsing-main-intbody:has-an-element-in-table-scope>have an element in table scope</a> that is an <a href=infrastructure.html#html-elements id=parsing-main-intbody:html-elements>HTML
|
||
element</a> with the same tag name as the token, this is a <a href=#parse-errors id=parsing-main-intbody:parse-errors-2>parse error</a>;
|
||
ignore the token.</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
<p><a href=#clear-the-stack-back-to-a-table-body-context id=parsing-main-intbody:clear-the-stack-back-to-a-table-body-context-3>Clear the stack back to a table body context</a>. (See below.)</p>
|
||
|
||
<p>Pop the <a href=#current-node id=parsing-main-intbody:current-node>current node</a> from the <a href=#stack-of-open-elements id=parsing-main-intbody:stack-of-open-elements-2>stack of open elements</a>. Switch the
|
||
<a href=#insertion-mode id=parsing-main-intbody:insertion-mode-4>insertion mode</a> to "<a href=#parsing-main-intable id=parsing-main-intbody:parsing-main-intable>in table</a>".</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "caption", "col",
|
||
"colgroup", "tbody", "tfoot", "thead"<dt>An end tag whose tag name is "table"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-intbody:stack-of-open-elements-3>stack of open elements</a> does not <a href=#has-an-element-in-table-scope id=parsing-main-intbody:has-an-element-in-table-scope-2>have a <code>tbody</code>, <code>thead</code>, or <code>tfoot</code> element in table
|
||
scope</a>, this is a <a href=#parse-errors id=parsing-main-intbody:parse-errors-3>parse error</a>; ignore the token.</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
<p><a href=#clear-the-stack-back-to-a-table-body-context id=parsing-main-intbody:clear-the-stack-back-to-a-table-body-context-4>Clear the stack back to a table body context</a>. (See below.)</p>
|
||
|
||
|
||
|
||
<p>Pop the <a href=#current-node id=parsing-main-intbody:current-node-2>current node</a> from the <a href=#stack-of-open-elements id=parsing-main-intbody:stack-of-open-elements-4>stack of open elements</a>. Switch the
|
||
<a href=#insertion-mode id=parsing-main-intbody:insertion-mode-5>insertion mode</a> to "<a href=#parsing-main-intable id=parsing-main-intbody:parsing-main-intable-2>in table</a>".</p>
|
||
|
||
|
||
|
||
<p>Reprocess the token.</p>
|
||
|
||
<dt>An end tag whose tag name is one of: "body", "caption", "col", "colgroup", "html", "td",
|
||
"th", "tr"<dd>
|
||
<p><a href=#parse-errors id=parsing-main-intbody:parse-errors-4>Parse error</a>. Ignore the token.</p>
|
||
<dt>Anything else<dd>
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-intbody:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-intable id=parsing-main-intbody:parsing-main-intable-3>in table</a>" <a href=#insertion-mode id=parsing-main-intbody:insertion-mode-6>insertion mode</a>.</p>
|
||
</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 id=parsing-main-intbody:current-node-3>current node</a> is not a <code id=parsing-main-intbody:the-tbody-element><a href=tables.html#the-tbody-element>tbody</a></code>,
|
||
<code id=parsing-main-intbody:the-tfoot-element><a href=tables.html#the-tfoot-element>tfoot</a></code>, <code id=parsing-main-intbody:the-thead-element><a href=tables.html#the-thead-element>thead</a></code>, <code id=parsing-main-intbody:the-template-element><a href=scripting.html#the-template-element>template</a></code>, or <code id=parsing-main-intbody:the-html-element><a href=semantics.html#the-html-element>html</a></code> element, pop
|
||
elements from the <a href=#stack-of-open-elements id=parsing-main-intbody:stack-of-open-elements-5>stack of open elements</a>.</p>
|
||
|
||
<p class=note>The <a href=#current-node id=parsing-main-intbody:current-node-4>current node</a> being an <code id=parsing-main-intbody:the-html-element-2><a href=semantics.html#the-html-element>html</a></code> element after this
|
||
process is a <a href=#fragment-case id=parsing-main-intbody:fragment-case>fragment case</a>.</p>
|
||
|
||
|
||
<h6 id=parsing-main-intr><span class=secno>12.2.6.4.14</span> The "<dfn>in row</dfn>" insertion mode<a href=#parsing-main-intr class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-intr id=parsing-main-intr:parsing-main-intr>in
|
||
row</a>" <a href=#insertion-mode id=parsing-main-intr:insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
|
||
|
||
<dl class=switch><dt>A start tag whose tag name is one of: "th", "td"<dd>
|
||
|
||
<p><a href=#clear-the-stack-back-to-a-table-row-context id=parsing-main-intr:clear-the-stack-back-to-a-table-row-context>Clear the stack back to a table row context</a>. (See below.)</p>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-intr:insert-an-html-element>Insert an HTML element</a> for the token, then switch the <a href=#insertion-mode id=parsing-main-intr:insertion-mode-2>insertion
|
||
mode</a> to "<a href=#parsing-main-intd id=parsing-main-intr:parsing-main-intd>in cell</a>".</p>
|
||
|
||
<p>Insert a <a href=#concept-parser-marker id=parsing-main-intr:concept-parser-marker>marker</a> at the end of the <a href=#list-of-active-formatting-elements id=parsing-main-intr:list-of-active-formatting-elements>list of
|
||
active formatting elements</a>.</p>
|
||
|
||
<dt>An end tag whose tag name is "tr"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-intr:stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope id=parsing-main-intr:has-an-element-in-table-scope>have a <code>tr</code> element in table scope</a>, this is a <a href=#parse-errors id=parsing-main-intr:parse-errors>parse error</a>;
|
||
ignore the token.</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
<p><a href=#clear-the-stack-back-to-a-table-row-context id=parsing-main-intr:clear-the-stack-back-to-a-table-row-context-2>Clear the stack back to a table row context</a>. (See below.)</p>
|
||
|
||
<p>Pop the <a href=#current-node id=parsing-main-intr:current-node>current node</a> (which will be a <code id=parsing-main-intr:the-tr-element><a href=tables.html#the-tr-element>tr</a></code> element) from the
|
||
<a href=#stack-of-open-elements id=parsing-main-intr:stack-of-open-elements-2>stack of open elements</a>. Switch the <a href=#insertion-mode id=parsing-main-intr:insertion-mode-3>insertion mode</a> to "<a href=#parsing-main-intbody id=parsing-main-intr:parsing-main-intbody>in table body</a>".</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "caption", "col", "colgroup", "tbody", "tfoot",
|
||
"thead", "tr"<dt>An end tag whose tag name is "table"<dd>
|
||
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-intr:stack-of-open-elements-3>stack of open elements</a> does not <a href=#has-an-element-in-table-scope id=parsing-main-intr:has-an-element-in-table-scope-2>have a <code>tr</code> element in table scope</a>, this is a <a href=#parse-errors id=parsing-main-intr:parse-errors-2>parse error</a>;
|
||
ignore the token.</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
<p><a href=#clear-the-stack-back-to-a-table-row-context id=parsing-main-intr:clear-the-stack-back-to-a-table-row-context-3>Clear the stack back to a table row context</a>. (See below.)</p>
|
||
|
||
<p>Pop the <a href=#current-node id=parsing-main-intr:current-node-2>current node</a> (which will be a <code id=parsing-main-intr:the-tr-element-2><a href=tables.html#the-tr-element>tr</a></code> element) from the
|
||
<a href=#stack-of-open-elements id=parsing-main-intr:stack-of-open-elements-4>stack of open elements</a>. Switch the <a href=#insertion-mode id=parsing-main-intr:insertion-mode-4>insertion mode</a> to "<a href=#parsing-main-intbody id=parsing-main-intr:parsing-main-intbody-2>in table body</a>".</p>
|
||
|
||
|
||
<p>Reprocess the token.</p>
|
||
|
||
<dt>An end tag whose tag name is one of: "tbody", "tfoot", "thead"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-intr:stack-of-open-elements-5>stack of open elements</a> does not <a href=#has-an-element-in-table-scope id=parsing-main-intr:has-an-element-in-table-scope-3>have an element in table scope</a> that is an <a href=infrastructure.html#html-elements id=parsing-main-intr:html-elements>HTML
|
||
element</a> with the same tag name as the token, this is a <a href=#parse-errors id=parsing-main-intr:parse-errors-3>parse error</a>;
|
||
ignore the token.</p>
|
||
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-intr:stack-of-open-elements-6>stack of open elements</a> does not <a href=#has-an-element-in-table-scope id=parsing-main-intr:has-an-element-in-table-scope-4>have a <code>tr</code> element in table scope</a>, ignore the token.</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
<p><a href=#clear-the-stack-back-to-a-table-row-context id=parsing-main-intr:clear-the-stack-back-to-a-table-row-context-4>Clear the stack back to a table row context</a>. (See below.)</p>
|
||
|
||
<p>Pop the <a href=#current-node id=parsing-main-intr:current-node-3>current node</a> (which will be a <code id=parsing-main-intr:the-tr-element-3><a href=tables.html#the-tr-element>tr</a></code> element) from the
|
||
<a href=#stack-of-open-elements id=parsing-main-intr:stack-of-open-elements-7>stack of open elements</a>. Switch the <a href=#insertion-mode id=parsing-main-intr:insertion-mode-5>insertion mode</a> to "<a href=#parsing-main-intbody id=parsing-main-intr:parsing-main-intbody-3>in table body</a>".</p>
|
||
|
||
|
||
<p>Reprocess the token.</p>
|
||
|
||
<dt>An end tag whose tag name is one of: "body", "caption", "col", "colgroup", "html", "td",
|
||
"th"<dd>
|
||
<p><a href=#parse-errors id=parsing-main-intr:parse-errors-4>Parse error</a>. Ignore the token.</p>
|
||
<dt>Anything else<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-intr:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-intable id=parsing-main-intr:parsing-main-intable>in table</a>" <a href=#insertion-mode id=parsing-main-intr:insertion-mode-6>insertion mode</a>.</p>
|
||
|
||
</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 id=parsing-main-intr:current-node-4>current node</a> is not a <code id=parsing-main-intr:the-tr-element-4><a href=tables.html#the-tr-element>tr</a></code>,
|
||
<code id=parsing-main-intr:the-template-element><a href=scripting.html#the-template-element>template</a></code>, or <code id=parsing-main-intr:the-html-element><a href=semantics.html#the-html-element>html</a></code> element, pop elements from the <a href=#stack-of-open-elements id=parsing-main-intr:stack-of-open-elements-8>stack of open
|
||
elements</a>.</p>
|
||
|
||
<p class=note>The <a href=#current-node id=parsing-main-intr:current-node-5>current node</a> being an <code id=parsing-main-intr:the-html-element-2><a href=semantics.html#the-html-element>html</a></code> element after this
|
||
process is a <a href=#fragment-case id=parsing-main-intr:fragment-case>fragment case</a>.</p>
|
||
|
||
|
||
<h6 id=parsing-main-intd><span class=secno>12.2.6.4.15</span> The "<dfn>in cell</dfn>" insertion mode<a href=#parsing-main-intd class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-intd id=parsing-main-intd:parsing-main-intd>in cell</a>" <a href=#insertion-mode id=parsing-main-intd:insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
|
||
|
||
<dl class=switch><dt>An end tag whose tag name is one of: "td", "th"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-intd:stack-of-open-elements>stack of open elements</a> does not <a href=#has-an-element-in-table-scope id=parsing-main-intd:has-an-element-in-table-scope>have an element in table scope</a> that is an <a href=infrastructure.html#html-elements id=parsing-main-intd:html-elements>HTML
|
||
element</a> with the same tag name as that of the token, then this is a <a href=#parse-errors id=parsing-main-intd:parse-errors>parse
|
||
error</a>; ignore the token.</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
<p><a href=#generate-implied-end-tags id=parsing-main-intd:generate-implied-end-tags>Generate implied end tags</a>.</p>
|
||
|
||
<p>Now, if the <a href=#current-node id=parsing-main-intd:current-node>current node</a> is not an <a href=infrastructure.html#html-elements id=parsing-main-intd:html-elements-2>HTML
|
||
element</a> with the same tag name as the token, then this is a <a href=#parse-errors id=parsing-main-intd:parse-errors-2>parse error</a>.</p>
|
||
|
||
<p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-intd:stack-of-open-elements-2>stack of open elements</a> stack until an <a href=infrastructure.html#html-elements id=parsing-main-intd:html-elements-3>HTML element</a> with the same tag name as the token has been popped from the
|
||
stack.</p>
|
||
|
||
<p><a href=#clear-the-list-of-active-formatting-elements-up-to-the-last-marker id=parsing-main-intd: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>.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-intd:insertion-mode-2>insertion mode</a> to "<a href=#parsing-main-intr id=parsing-main-intd:parsing-main-intr>in
|
||
row</a>".</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "caption", "col",
|
||
"colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-intd:stack-of-open-elements-3>stack of open elements</a> does <em>not</em> <a href=#has-an-element-in-table-scope id=parsing-main-intd:has-an-element-in-table-scope-2>have a <code>td</code> or <code>th</code> element in table scope</a>, then this
|
||
is a <a href=#parse-errors id=parsing-main-intd:parse-errors-3>parse error</a>; ignore the token. (<a href=#fragment-case id=parsing-main-intd:fragment-case>fragment case</a>)</p>
|
||
|
||
<p>Otherwise, <a href=#close-the-cell id=parsing-main-intd:close-the-cell>close the cell</a> (see below) and reprocess the token.</p>
|
||
|
||
<dt>An end tag whose tag name is one of: "body", "caption",
|
||
"col", "colgroup", "html"<dd>
|
||
<p><a href=#parse-errors id=parsing-main-intd:parse-errors-4>Parse error</a>. Ignore the token.</p>
|
||
<dt>An end tag whose tag name is one of: "table", "tbody",
|
||
"tfoot", "thead", "tr"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-intd:stack-of-open-elements-4>stack of open elements</a> does not <a href=#has-an-element-in-table-scope id=parsing-main-intd:has-an-element-in-table-scope-3>have an element in table scope</a> that is an <a href=infrastructure.html#html-elements id=parsing-main-intd:html-elements-4>HTML
|
||
element</a> with the same tag name as that of the token, then this is a <a href=#parse-errors id=parsing-main-intd:parse-errors-5>parse
|
||
error</a>; ignore the token.</p>
|
||
|
||
<p>Otherwise, <a href=#close-the-cell id=parsing-main-intd:close-the-cell-2>close the cell</a> (see below) and reprocess the token.</p>
|
||
|
||
<dt>Anything else<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-intd:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody id=parsing-main-intd:parsing-main-inbody>in body</a>" <a href=#insertion-mode id=parsing-main-intd:insertion-mode-3>insertion mode</a>.</p>
|
||
|
||
</dl>
|
||
|
||
<p>Where the steps above say to <dfn id=close-the-cell>close the cell</dfn>, they mean to run the following
|
||
algorithm:</p>
|
||
|
||
<ol><li><p><a href=#generate-implied-end-tags id=parsing-main-intd:generate-implied-end-tags-2>Generate implied end tags</a>.<li><p>If the <a href=#current-node id=parsing-main-intd:current-node-2>current node</a> is not now a <code id=parsing-main-intd:the-td-element><a href=tables.html#the-td-element>td</a></code> element or a <code id=parsing-main-intd:the-th-element><a href=tables.html#the-th-element>th</a></code>
|
||
element, then this is a <a href=#parse-errors id=parsing-main-intd:parse-errors-6>parse error</a>.<li><p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-intd:stack-of-open-elements-5>stack of open elements</a> stack until a <code id=parsing-main-intd:the-td-element-2><a href=tables.html#the-td-element>td</a></code>
|
||
element or a <code id=parsing-main-intd:the-th-element-2><a href=tables.html#the-th-element>th</a></code> element has been popped from the stack.<li><p><a href=#clear-the-list-of-active-formatting-elements-up-to-the-last-marker id=parsing-main-intd:clear-the-list-of-active-formatting-elements-up-to-the-last-marker-2>Clear the list of active formatting elements up to the last marker</a>.<li><p>Switch the <a href=#insertion-mode id=parsing-main-intd:insertion-mode-4>insertion mode</a> to "<a href=#parsing-main-intr id=parsing-main-intd:parsing-main-intr-2>in
|
||
row</a>".</ol>
|
||
|
||
<p class=note>The <a href=#stack-of-open-elements id=parsing-main-intd:stack-of-open-elements-6>stack of open elements</a> cannot have both a <code id=parsing-main-intd:the-td-element-3><a href=tables.html#the-td-element>td</a></code> and a
|
||
<code id=parsing-main-intd:the-th-element-3><a href=tables.html#the-th-element>th</a></code> element <a href=#has-an-element-in-table-scope id=parsing-main-intd:has-an-element-in-table-scope-4>in table scope</a> at the
|
||
same time, nor can it have neither when the <a href=#close-the-cell id=parsing-main-intd:close-the-cell-3>close the cell</a> algorithm is invoked.</p>
|
||
|
||
|
||
<h6 id=parsing-main-inselect><span class=secno>12.2.6.4.16</span> The "<dfn>in select</dfn>" insertion mode<a href=#parsing-main-inselect class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-inselect id=parsing-main-inselect:parsing-main-inselect>in
|
||
select</a>" <a href=#insertion-mode id=parsing-main-inselect:insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
|
||
|
||
<dl class=switch><dt>A character token that is U+0000 NULL<dd>
|
||
<p><a href=#parse-errors id=parsing-main-inselect:parse-errors>Parse error</a>. Ignore the token.</p>
|
||
<dt>Any other character token<dd>
|
||
|
||
<p><a href=#insert-a-character id=parsing-main-inselect:insert-a-character>Insert the token's character</a>.</p>
|
||
|
||
<dt>A comment token<dd>
|
||
<p><a href=#insert-a-comment id=parsing-main-inselect:insert-a-comment>Insert a comment</a>.</p>
|
||
<dt>A DOCTYPE token<dd>
|
||
<p><a href=#parse-errors id=parsing-main-inselect:parse-errors-2>Parse error</a>. Ignore the token.</p>
|
||
<dt>A start tag whose tag name is "html"<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-inselect:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody id=parsing-main-inselect:parsing-main-inbody>in body</a>" <a href=#insertion-mode id=parsing-main-inselect:insertion-mode-2>insertion mode</a>.</p>
|
||
|
||
<dt>A start tag whose tag name is "option"<dd>
|
||
|
||
|
||
<p>If the <a href=#current-node id=parsing-main-inselect:current-node>current node</a> is an <code id=parsing-main-inselect:the-option-element><a href=form-elements.html#the-option-element>option</a></code> element, pop that node from the
|
||
<a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements>stack of open elements</a>.</p>
|
||
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inselect:insert-an-html-element>Insert an HTML element</a> for the token.</p>
|
||
|
||
<dt>A start tag whose tag name is "optgroup"<dd>
|
||
|
||
|
||
<p>If the <a href=#current-node id=parsing-main-inselect:current-node-2>current node</a> is an <code id=parsing-main-inselect:the-option-element-2><a href=form-elements.html#the-option-element>option</a></code> element, pop that node from the
|
||
<a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-2>stack of open elements</a>.</p>
|
||
|
||
|
||
|
||
<p>If the <a href=#current-node id=parsing-main-inselect:current-node-3>current node</a> is an <code id=parsing-main-inselect:the-optgroup-element><a href=form-elements.html#the-optgroup-element>optgroup</a></code> element, pop that node from the
|
||
<a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-3>stack of open elements</a>.</p>
|
||
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inselect:insert-an-html-element-2>Insert an HTML element</a> for the token.</p>
|
||
|
||
<dt>An end tag whose tag name is "optgroup"<dd>
|
||
|
||
|
||
<p>First, if the <a href=#current-node id=parsing-main-inselect:current-node-4>current node</a> is an <code id=parsing-main-inselect:the-option-element-3><a href=form-elements.html#the-option-element>option</a></code> element, and the node
|
||
immediately before it in the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-4>stack of open elements</a> is an <code id=parsing-main-inselect:the-optgroup-element-2><a href=form-elements.html#the-optgroup-element>optgroup</a></code>
|
||
element, then pop the <a href=#current-node id=parsing-main-inselect:current-node-5>current node</a> from the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-5>stack of open
|
||
elements</a>.</p>
|
||
|
||
|
||
<p>If the <a href=#current-node id=parsing-main-inselect:current-node-6>current node</a> is an <code id=parsing-main-inselect:the-optgroup-element-3><a href=form-elements.html#the-optgroup-element>optgroup</a></code> element, then pop that node from
|
||
the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-6>stack of open elements</a>. Otherwise, this is a <a href=#parse-errors id=parsing-main-inselect:parse-errors-3>parse error</a>; ignore
|
||
the token.</p>
|
||
|
||
<dt>An end tag whose tag name is "option"<dd>
|
||
|
||
<p>If the <a href=#current-node id=parsing-main-inselect:current-node-7>current node</a> is an <code id=parsing-main-inselect:the-option-element-4><a href=form-elements.html#the-option-element>option</a></code> element, then pop that node from
|
||
the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-7>stack of open elements</a>. Otherwise, this is a <a href=#parse-errors id=parsing-main-inselect:parse-errors-4>parse error</a>; ignore
|
||
the token.</p>
|
||
|
||
<dt>An end tag whose tag name is "select"<dd>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-8>stack of open elements</a> does not <a href=#has-an-element-in-select-scope id=parsing-main-inselect:has-an-element-in-select-scope>have a <code>select</code> element in select scope</a>, this is a <a href=#parse-errors id=parsing-main-inselect:parse-errors-5>parse
|
||
error</a>; ignore the token. (<a href=#fragment-case id=parsing-main-inselect:fragment-case>fragment case</a>)</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
<p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-9>stack of open elements</a> until a <code id=parsing-main-inselect:the-select-element><a href=form-elements.html#the-select-element>select</a></code> element
|
||
has been popped from the stack.</p>
|
||
|
||
<p><a href=#reset-the-insertion-mode-appropriately id=parsing-main-inselect:reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
|
||
|
||
<dt>A start tag whose tag name is "select"<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-inselect:parse-errors-6>Parse error</a>.</p>
|
||
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-10>stack of open elements</a> does not <a href=#has-an-element-in-select-scope id=parsing-main-inselect:has-an-element-in-select-scope-2>have a <code>select</code> element in select scope</a>, ignore the token.
|
||
(<a href=#fragment-case id=parsing-main-inselect:fragment-case-2>fragment case</a>)</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
<p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-11>stack of open elements</a> until a <code id=parsing-main-inselect:the-select-element-2><a href=form-elements.html#the-select-element>select</a></code> element
|
||
has been popped from the stack.</p>
|
||
|
||
<p><a href=#reset-the-insertion-mode-appropriately id=parsing-main-inselect:reset-the-insertion-mode-appropriately-2>Reset the insertion mode appropriately</a>.</p>
|
||
|
||
|
||
<p class=note>It just gets treated like an end tag.</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "input", "keygen", "textarea"<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-inselect:parse-errors-7>Parse error</a>.</p>
|
||
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-12>stack of open elements</a> does not <a href=#has-an-element-in-select-scope id=parsing-main-inselect:has-an-element-in-select-scope-3>have a <code>select</code> element in select scope</a>, ignore the token.
|
||
(<a href=#fragment-case id=parsing-main-inselect:fragment-case-3>fragment case</a>)</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
<p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-13>stack of open elements</a> until a <code id=parsing-main-inselect:the-select-element-3><a href=form-elements.html#the-select-element>select</a></code> element
|
||
has been popped from the stack.</p>
|
||
|
||
<p><a href=#reset-the-insertion-mode-appropriately id=parsing-main-inselect:reset-the-insertion-mode-appropriately-3>Reset the insertion mode appropriately</a>.</p>
|
||
|
||
|
||
<p>Reprocess the token.</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "script", "template"<dt>An end tag whose tag name is "template"<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-inselect:using-the-rules-for-2>using the rules for</a> the "<a href=#parsing-main-inhead id=parsing-main-inselect:parsing-main-inhead>in head</a>" <a href=#insertion-mode id=parsing-main-inselect:insertion-mode-3>insertion mode</a>.</p>
|
||
|
||
<dt>An end-of-file token<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-inselect:using-the-rules-for-3>using the rules for</a> the "<a href=#parsing-main-inbody id=parsing-main-inselect:parsing-main-inbody-2>in body</a>" <a href=#insertion-mode id=parsing-main-inselect:insertion-mode-4>insertion mode</a>.</p>
|
||
|
||
<dt>Anything else<dd>
|
||
<p><a href=#parse-errors id=parsing-main-inselect:parse-errors-8>Parse error</a>. Ignore the token.</p>
|
||
</dl>
|
||
|
||
|
||
<h6 id=parsing-main-inselectintable><span class=secno>12.2.6.4.17</span> The "<dfn>in select in table</dfn>" insertion mode<a href=#parsing-main-inselectintable class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-inselectintable id=parsing-main-inselectintable:parsing-main-inselectintable>in select in table</a>" <a href=#insertion-mode id=parsing-main-inselectintable:insertion-mode>insertion mode</a>, the user agent must handle the
|
||
token as follows:</p>
|
||
|
||
<dl class=switch><dt>A start tag whose tag name is one of: "caption", "table", "tbody", "tfoot", "thead", "tr",
|
||
"td", "th"<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-inselectintable:parse-errors>Parse error</a>.</p>
|
||
|
||
|
||
<p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inselectintable:stack-of-open-elements>stack of open elements</a> until a <code id=parsing-main-inselectintable:the-select-element><a href=form-elements.html#the-select-element>select</a></code> element
|
||
has been popped from the stack.</p>
|
||
|
||
<p><a href=#reset-the-insertion-mode-appropriately id=parsing-main-inselectintable:reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
|
||
|
||
|
||
<p>Reprocess the token.</p>
|
||
|
||
<dt>An end tag whose tag name is one of: "caption", "table", "tbody", "tfoot", "thead", "tr",
|
||
"td", "th"<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-inselectintable:parse-errors-2>Parse error</a>.</p>
|
||
|
||
<p>If the <a href=#stack-of-open-elements id=parsing-main-inselectintable:stack-of-open-elements-2>stack of open elements</a> does not <a href=#has-an-element-in-table-scope id=parsing-main-inselectintable:has-an-element-in-table-scope>have an element in table scope</a> that is an <a href=infrastructure.html#html-elements id=parsing-main-inselectintable:html-elements>HTML
|
||
element</a> with the same tag name as that of the token, then ignore the token.</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
|
||
<p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inselectintable:stack-of-open-elements-3>stack of open elements</a> until a <code id=parsing-main-inselectintable:the-select-element-2><a href=form-elements.html#the-select-element>select</a></code> element
|
||
has been popped from the stack.</p>
|
||
|
||
<p><a href=#reset-the-insertion-mode-appropriately id=parsing-main-inselectintable:reset-the-insertion-mode-appropriately-2>Reset the insertion mode appropriately</a>.</p>
|
||
|
||
|
||
<p>Reprocess the token.</p>
|
||
|
||
<dt>Anything else<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-inselectintable:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inselect id=parsing-main-inselectintable:parsing-main-inselect>in select</a>" <a href=#insertion-mode id=parsing-main-inselectintable:insertion-mode-2>insertion mode</a>.</p>
|
||
|
||
</dl>
|
||
|
||
|
||
|
||
<h6 id=parsing-main-intemplate><span class=secno>12.2.6.4.18</span> The "<dfn>in template</dfn>" insertion mode<a href=#parsing-main-intemplate class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-intemplate id=parsing-main-intemplate:parsing-main-intemplate>in
|
||
template</a>" <a href=#insertion-mode id=parsing-main-intemplate:insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
|
||
|
||
<dl class=switch><dt>A character token<dt>A comment token<dt>A DOCTYPE token<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-intemplate:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody id=parsing-main-intemplate:parsing-main-inbody>in body</a>" <a href=#insertion-mode id=parsing-main-intemplate:insertion-mode-2>insertion mode</a>.</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "base", "basefont", "bgsound", "link", "meta", "noframes", "script", "style", "template", "title"<dt>An end tag whose tag name is "template"<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-intemplate:using-the-rules-for-2>using the rules for</a> the "<a href=#parsing-main-inhead id=parsing-main-intemplate:parsing-main-inhead>in head</a>" <a href=#insertion-mode id=parsing-main-intemplate:insertion-mode-3>insertion mode</a>.</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "caption", "colgroup", "tbody", "tfoot", "thead"<dd>
|
||
|
||
<p>Pop the <a href=#current-template-insertion-mode id=parsing-main-intemplate:current-template-insertion-mode>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes id=parsing-main-intemplate:stack-of-template-insertion-modes>stack of template
|
||
insertion modes</a>.</p>
|
||
|
||
<p>Push "<a href=#parsing-main-intable id=parsing-main-intemplate:parsing-main-intable>in table</a>" onto the <a href=#stack-of-template-insertion-modes id=parsing-main-intemplate:stack-of-template-insertion-modes-2>stack of
|
||
template insertion modes</a> so that it is the new <a href=#current-template-insertion-mode id=parsing-main-intemplate:current-template-insertion-mode-2>current template insertion
|
||
mode</a>.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-intemplate:insertion-mode-4>insertion mode</a> to "<a href=#parsing-main-intable id=parsing-main-intemplate:parsing-main-intable-2>in
|
||
table</a>", and reprocess the token.</p>
|
||
|
||
<dt>A start tag whose tag name is "col"<dd>
|
||
|
||
<p>Pop the <a href=#current-template-insertion-mode id=parsing-main-intemplate:current-template-insertion-mode-3>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes id=parsing-main-intemplate:stack-of-template-insertion-modes-3>stack of template
|
||
insertion modes</a>.</p>
|
||
|
||
<p>Push "<a href=#parsing-main-incolgroup id=parsing-main-intemplate:parsing-main-incolgroup>in column group</a>" onto the
|
||
<a href=#stack-of-template-insertion-modes id=parsing-main-intemplate:stack-of-template-insertion-modes-4>stack of template insertion modes</a> so that it is the new <a href=#current-template-insertion-mode id=parsing-main-intemplate:current-template-insertion-mode-4>current template
|
||
insertion mode</a>.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-intemplate:insertion-mode-5>insertion mode</a> to "<a href=#parsing-main-incolgroup id=parsing-main-intemplate:parsing-main-incolgroup-2>in
|
||
column group</a>", and reprocess the token.</p>
|
||
|
||
<dt>A start tag whose tag name is "tr"<dd>
|
||
|
||
<p>Pop the <a href=#current-template-insertion-mode id=parsing-main-intemplate:current-template-insertion-mode-5>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes id=parsing-main-intemplate:stack-of-template-insertion-modes-5>stack of template
|
||
insertion modes</a>.</p>
|
||
|
||
<p>Push "<a href=#parsing-main-intbody id=parsing-main-intemplate:parsing-main-intbody>in table body</a>" onto the <a href=#stack-of-template-insertion-modes id=parsing-main-intemplate:stack-of-template-insertion-modes-6>stack
|
||
of template insertion modes</a> so that it is the new <a href=#current-template-insertion-mode id=parsing-main-intemplate:current-template-insertion-mode-6>current template insertion
|
||
mode</a>.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-intemplate:insertion-mode-6>insertion mode</a> to "<a href=#parsing-main-intbody id=parsing-main-intemplate:parsing-main-intbody-2>in
|
||
table body</a>", and reprocess the token.</p>
|
||
|
||
<dt>A start tag whose tag name is one of: "td", "th"<dd>
|
||
|
||
<p>Pop the <a href=#current-template-insertion-mode id=parsing-main-intemplate:current-template-insertion-mode-7>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes id=parsing-main-intemplate:stack-of-template-insertion-modes-7>stack of template
|
||
insertion modes</a>.</p>
|
||
|
||
<p>Push "<a href=#parsing-main-intr id=parsing-main-intemplate:parsing-main-intr>in row</a>" onto the <a href=#stack-of-template-insertion-modes id=parsing-main-intemplate:stack-of-template-insertion-modes-8>stack of template
|
||
insertion modes</a> so that it is the new <a href=#current-template-insertion-mode id=parsing-main-intemplate:current-template-insertion-mode-8>current template insertion mode</a>.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-intemplate:insertion-mode-7>insertion mode</a> to "<a href=#parsing-main-intr id=parsing-main-intemplate:parsing-main-intr-2>in
|
||
row</a>", and reprocess the token.</p>
|
||
|
||
<dt>Any other start tag<dd>
|
||
|
||
<p>Pop the <a href=#current-template-insertion-mode id=parsing-main-intemplate:current-template-insertion-mode-9>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes id=parsing-main-intemplate:stack-of-template-insertion-modes-9>stack of template
|
||
insertion modes</a>.</p>
|
||
|
||
<p>Push "<a href=#parsing-main-inbody id=parsing-main-intemplate:parsing-main-inbody-2>in body</a>" onto the <a href=#stack-of-template-insertion-modes id=parsing-main-intemplate:stack-of-template-insertion-modes-10>stack of template
|
||
insertion modes</a> so that it is the new <a href=#current-template-insertion-mode id=parsing-main-intemplate:current-template-insertion-mode-10>current template insertion mode</a>.</p>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-intemplate:insertion-mode-8>insertion mode</a> to "<a href=#parsing-main-inbody id=parsing-main-intemplate:parsing-main-inbody-3>in
|
||
body</a>", and reprocess the token.</p>
|
||
|
||
<dt>Any other end tag<dd>
|
||
<p><a href=#parse-errors id=parsing-main-intemplate:parse-errors>Parse error</a>. Ignore the token.</p>
|
||
<dt>An end-of-file token<dd>
|
||
|
||
<p>If there is no <code id=parsing-main-intemplate:the-template-element><a href=scripting.html#the-template-element>template</a></code> element on the <a href=#stack-of-open-elements id=parsing-main-intemplate:stack-of-open-elements>stack of open elements</a>, then
|
||
<a href=#stop-parsing id=parsing-main-intemplate:stop-parsing>stop parsing</a>. (<a href=#fragment-case id=parsing-main-intemplate:fragment-case>fragment case</a>)</p>
|
||
|
||
<p>Otherwise, this is a <a href=#parse-errors id=parsing-main-intemplate:parse-errors-2>parse error</a>.</p>
|
||
|
||
|
||
<p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-intemplate:stack-of-open-elements-2>stack of open elements</a> until a <code id=parsing-main-intemplate:the-template-element-2><a href=scripting.html#the-template-element>template</a></code>
|
||
element has been popped from the stack.</p>
|
||
|
||
<p><a href=#clear-the-list-of-active-formatting-elements-up-to-the-last-marker id=parsing-main-intemplate: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>.</p>
|
||
|
||
<p>Pop the <a href=#current-template-insertion-mode id=parsing-main-intemplate:current-template-insertion-mode-11>current template insertion mode</a> off the <a href=#stack-of-template-insertion-modes id=parsing-main-intemplate:stack-of-template-insertion-modes-11>stack of template
|
||
insertion modes</a>.</p>
|
||
|
||
<p><a href=#reset-the-insertion-mode-appropriately id=parsing-main-intemplate:reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
|
||
|
||
|
||
<p>Reprocess the token.</p>
|
||
|
||
</dl>
|
||
|
||
|
||
<h6 id=parsing-main-afterbody><span class=secno>12.2.6.4.19</span> The "<dfn>after body</dfn>" insertion mode<a href=#parsing-main-afterbody class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-afterbody id=parsing-main-afterbody:parsing-main-afterbody>after body</a>" <a href=#insertion-mode id=parsing-main-afterbody: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 TABULATION, U+000A LINE FEED (LF), U+000C
|
||
FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-afterbody:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody id=parsing-main-afterbody:parsing-main-inbody>in body</a>" <a href=#insertion-mode id=parsing-main-afterbody:insertion-mode-2>insertion mode</a>.</p>
|
||
|
||
<dt>A comment token<dd>
|
||
|
||
<p><a href=#insert-a-comment id=parsing-main-afterbody:insert-a-comment>Insert a comment</a> as the last child of the first element in the <a href=#stack-of-open-elements id=parsing-main-afterbody:stack-of-open-elements>stack of
|
||
open elements</a> (the <code id=parsing-main-afterbody:the-html-element><a href=semantics.html#the-html-element>html</a></code> element).</p>
|
||
|
||
<dt>A DOCTYPE token<dd>
|
||
<p><a href=#parse-errors id=parsing-main-afterbody:parse-errors>Parse error</a>. Ignore the token.</p>
|
||
<dt>A start tag whose tag name is "html"<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-afterbody:using-the-rules-for-2>using the rules for</a> the "<a href=#parsing-main-inbody id=parsing-main-afterbody:parsing-main-inbody-2>in body</a>" <a href=#insertion-mode id=parsing-main-afterbody:insertion-mode-3>insertion mode</a>.</p>
|
||
|
||
<dt>An end tag whose tag name is "html"<dd>
|
||
|
||
<p>If the parser was originally created as part of the <a href=#html-fragment-parsing-algorithm id=parsing-main-afterbody:html-fragment-parsing-algorithm>HTML fragment parsing
|
||
algorithm</a>, this is a <a href=#parse-errors id=parsing-main-afterbody:parse-errors-2>parse error</a>; ignore the token. (<a href=#fragment-case id=parsing-main-afterbody:fragment-case>fragment
|
||
case</a>)</p>
|
||
|
||
<p>Otherwise, switch the <a href=#insertion-mode id=parsing-main-afterbody:insertion-mode-4>insertion mode</a> to "<a href=#the-after-after-body-insertion-mode id=parsing-main-afterbody:the-after-after-body-insertion-mode>after after body</a>".</p>
|
||
|
||
<dt>An end-of-file token<dd>
|
||
<p><a href=#stop-parsing id=parsing-main-afterbody:stop-parsing>Stop parsing</a>.</p>
|
||
<dt>Anything else<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-afterbody:parse-errors-3>Parse error</a>. Switch the <a href=#insertion-mode id=parsing-main-afterbody:insertion-mode-5>insertion mode</a> to "<a href=#parsing-main-inbody id=parsing-main-afterbody:parsing-main-inbody-3>in body</a>" and reprocess the token.</p>
|
||
|
||
</dl>
|
||
|
||
|
||
<h6 id=parsing-main-inframeset><span class=secno>12.2.6.4.20</span> The "<dfn>in frameset</dfn>" insertion mode<a href=#parsing-main-inframeset class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-inframeset id=parsing-main-inframeset:parsing-main-inframeset>in
|
||
frameset</a>" <a href=#insertion-mode id=parsing-main-inframeset: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 TABULATION, U+000A LINE FEED (LF), U+000C
|
||
FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE<dd>
|
||
<p><a href=#insert-a-character id=parsing-main-inframeset:insert-a-character>Insert the character</a>.</p>
|
||
<dt>A comment token<dd>
|
||
<p><a href=#insert-a-comment id=parsing-main-inframeset:insert-a-comment>Insert a comment</a>.</p>
|
||
<dt>A DOCTYPE token<dd>
|
||
<p><a href=#parse-errors id=parsing-main-inframeset:parse-errors>Parse error</a>. Ignore the token.</p>
|
||
<dt>A start tag whose tag name is "html"<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-inframeset:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody id=parsing-main-inframeset:parsing-main-inbody>in body</a>" <a href=#insertion-mode id=parsing-main-inframeset:insertion-mode-2>insertion mode</a>.</p>
|
||
|
||
<dt>A start tag whose tag name is "frameset"<dd>
|
||
<p><a href=#insert-an-html-element id=parsing-main-inframeset:insert-an-html-element>Insert an HTML element</a> for the token.</p>
|
||
<dt>An end tag whose tag name is "frameset"<dd>
|
||
|
||
<p>If the <a href=#current-node id=parsing-main-inframeset:current-node>current node</a> is the root <code id=parsing-main-inframeset:the-html-element><a href=semantics.html#the-html-element>html</a></code> element, then this is a
|
||
<a href=#parse-errors id=parsing-main-inframeset:parse-errors-2>parse error</a>; ignore the token. (<a href=#fragment-case id=parsing-main-inframeset:fragment-case>fragment case</a>)</p>
|
||
|
||
<p>Otherwise, pop the <a href=#current-node id=parsing-main-inframeset:current-node-2>current node</a> from the <a href=#stack-of-open-elements id=parsing-main-inframeset:stack-of-open-elements>stack of open
|
||
elements</a>.</p>
|
||
|
||
<p>If the parser was <em>not</em> originally created as part of the <a href=#html-fragment-parsing-algorithm id=parsing-main-inframeset:html-fragment-parsing-algorithm>HTML fragment parsing
|
||
algorithm</a> (<a href=#fragment-case id=parsing-main-inframeset:fragment-case-2>fragment case</a>), and the <a href=#current-node id=parsing-main-inframeset:current-node-3>current node</a> is no longer a
|
||
<code id=parsing-main-inframeset:frameset><a href=obsolete.html#frameset>frameset</a></code> element, then switch the <a href=#insertion-mode id=parsing-main-inframeset:insertion-mode-3>insertion mode</a> to "<a href=#parsing-main-afterframeset id=parsing-main-inframeset:parsing-main-afterframeset>after frameset</a>".</p>
|
||
|
||
<dt>A start tag whose tag name is "frame"<dd>
|
||
|
||
<p><a href=#insert-an-html-element id=parsing-main-inframeset:insert-an-html-element-2>Insert an HTML element</a> for the token. Immediately pop the <a href=#current-node id=parsing-main-inframeset:current-node-4>current
|
||
node</a> off the <a href=#stack-of-open-elements id=parsing-main-inframeset:stack-of-open-elements-2>stack of open elements</a>.</p>
|
||
|
||
<p><a href=#acknowledge-self-closing-flag id=parsing-main-inframeset:acknowledge-self-closing-flag>Acknowledge the token's <i>self-closing
|
||
flag</i></a>, if it is set.</p>
|
||
|
||
<dt>A start tag whose tag name is "noframes"<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-inframeset:using-the-rules-for-2>using the rules for</a> the "<a href=#parsing-main-inhead id=parsing-main-inframeset:parsing-main-inhead>in head</a>" <a href=#insertion-mode id=parsing-main-inframeset:insertion-mode-4>insertion mode</a>.</p>
|
||
|
||
<dt>An end-of-file token<dd>
|
||
|
||
<p>If the <a href=#current-node id=parsing-main-inframeset:current-node-5>current node</a> is not the root <code id=parsing-main-inframeset:the-html-element-2><a href=semantics.html#the-html-element>html</a></code> element, then this is a
|
||
<a href=#parse-errors id=parsing-main-inframeset:parse-errors-3>parse error</a>.</p>
|
||
|
||
<p class=note>The <a href=#current-node id=parsing-main-inframeset:current-node-6>current node</a> can only be the root
|
||
<code id=parsing-main-inframeset:the-html-element-3><a href=semantics.html#the-html-element>html</a></code> element in the <a href=#fragment-case id=parsing-main-inframeset:fragment-case-3>fragment case</a>.</p>
|
||
|
||
<p><a href=#stop-parsing id=parsing-main-inframeset:stop-parsing>Stop parsing</a>.</p>
|
||
|
||
<dt>Anything else<dd>
|
||
<p><a href=#parse-errors id=parsing-main-inframeset:parse-errors-4>Parse error</a>. Ignore the token.</p>
|
||
</dl>
|
||
|
||
|
||
<h6 id=parsing-main-afterframeset><span class=secno>12.2.6.4.21</span> The "<dfn>after frameset</dfn>" insertion mode<a href=#parsing-main-afterframeset class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-afterframeset id=parsing-main-afterframeset:parsing-main-afterframeset>after frameset</a>" <a href=#insertion-mode id=parsing-main-afterframeset: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 TABULATION, U+000A LINE FEED (LF), U+000C
|
||
FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE<dd>
|
||
<p><a href=#insert-a-character id=parsing-main-afterframeset:insert-a-character>Insert the character</a>.</p>
|
||
<dt>A comment token<dd>
|
||
<p><a href=#insert-a-comment id=parsing-main-afterframeset:insert-a-comment>Insert a comment</a>.</p>
|
||
<dt>A DOCTYPE token<dd>
|
||
<p><a href=#parse-errors id=parsing-main-afterframeset:parse-errors>Parse error</a>. Ignore the token.</p>
|
||
<dt>A start tag whose tag name is "html"<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-afterframeset:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody id=parsing-main-afterframeset:parsing-main-inbody>in body</a>" <a href=#insertion-mode id=parsing-main-afterframeset:insertion-mode-2>insertion mode</a>.</p>
|
||
|
||
<dt>An end tag whose tag name is "html"<dd>
|
||
|
||
<p>Switch the <a href=#insertion-mode id=parsing-main-afterframeset:insertion-mode-3>insertion mode</a> to "<a href=#the-after-after-frameset-insertion-mode id=parsing-main-afterframeset:the-after-after-frameset-insertion-mode>after after frameset</a>".</p>
|
||
|
||
<dt>A start tag whose tag name is "noframes"<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=parsing-main-afterframeset:using-the-rules-for-2>using the rules for</a> the "<a href=#parsing-main-inhead id=parsing-main-afterframeset:parsing-main-inhead>in head</a>" <a href=#insertion-mode id=parsing-main-afterframeset:insertion-mode-4>insertion mode</a>.</p>
|
||
|
||
<dt>An end-of-file token<dd>
|
||
<p><a href=#stop-parsing id=parsing-main-afterframeset:stop-parsing>Stop parsing</a>.</p>
|
||
<dt>Anything else<dd>
|
||
<p><a href=#parse-errors id=parsing-main-afterframeset:parse-errors-2>Parse error</a>. Ignore the token.</p>
|
||
</dl>
|
||
|
||
|
||
<h6 id=the-after-after-body-insertion-mode><span class=secno>12.2.6.4.22</span> The "<dfn>after after body</dfn>" insertion mode<a href=#the-after-after-body-insertion-mode class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#the-after-after-body-insertion-mode id=the-after-after-body-insertion-mode:the-after-after-body-insertion-mode>after after body</a>" <a href=#insertion-mode id=the-after-after-body-insertion-mode:insertion-mode>insertion mode</a>, the user agent must handle the token
|
||
as follows:</p>
|
||
|
||
<dl class=switch><dt>A comment token<dd>
|
||
<p><a href=#insert-a-comment id=the-after-after-body-insertion-mode:insert-a-comment>Insert a comment</a> as the last child of the <code id=the-after-after-body-insertion-mode:document><a href=dom.html#document>Document</a></code> object.</p>
|
||
<dt>A DOCTYPE token<dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C
|
||
FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE<dt>A start tag whose tag name is "html"<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=the-after-after-body-insertion-mode:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody id=the-after-after-body-insertion-mode:parsing-main-inbody>in body</a>" <a href=#insertion-mode id=the-after-after-body-insertion-mode:insertion-mode-2>insertion mode</a>.</p>
|
||
|
||
<dt>An end-of-file token<dd>
|
||
<p><a href=#stop-parsing id=the-after-after-body-insertion-mode:stop-parsing>Stop parsing</a>.</p>
|
||
<dt>Anything else<dd>
|
||
|
||
<p><a href=#parse-errors id=the-after-after-body-insertion-mode:parse-errors>Parse error</a>. Switch the <a href=#insertion-mode id=the-after-after-body-insertion-mode:insertion-mode-3>insertion mode</a> to "<a href=#parsing-main-inbody id=the-after-after-body-insertion-mode:parsing-main-inbody-2>in body</a>" and reprocess the token.</p>
|
||
|
||
</dl>
|
||
|
||
|
||
<h6 id=the-after-after-frameset-insertion-mode><span class=secno>12.2.6.4.23</span> The "<dfn>after after frameset</dfn>" insertion mode<a href=#the-after-after-frameset-insertion-mode class=self-link></a></h6>
|
||
|
||
<p>When the user agent is to apply the rules for the "<a href=#the-after-after-frameset-insertion-mode id=the-after-after-frameset-insertion-mode:the-after-after-frameset-insertion-mode>after after frameset</a>" <a href=#insertion-mode id=the-after-after-frameset-insertion-mode:insertion-mode>insertion mode</a>, the user agent must handle the
|
||
token as follows:</p>
|
||
|
||
<dl class=switch><dt>A comment token<dd>
|
||
<p><a href=#insert-a-comment id=the-after-after-frameset-insertion-mode:insert-a-comment>Insert a comment</a> as the last child of the <code id=the-after-after-frameset-insertion-mode:document><a href=dom.html#document>Document</a></code> object.</p>
|
||
<dt>A DOCTYPE token<dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C
|
||
FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE<dt>A start tag whose tag name is "html"<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=the-after-after-frameset-insertion-mode:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody id=the-after-after-frameset-insertion-mode:parsing-main-inbody>in body</a>" <a href=#insertion-mode id=the-after-after-frameset-insertion-mode:insertion-mode-2>insertion mode</a>.</p>
|
||
|
||
<dt>An end-of-file token<dd>
|
||
<p><a href=#stop-parsing id=the-after-after-frameset-insertion-mode:stop-parsing>Stop parsing</a>.</p>
|
||
<dt>A start tag whose tag name is "noframes"<dd>
|
||
|
||
<p>Process the token <a href=#using-the-rules-for id=the-after-after-frameset-insertion-mode:using-the-rules-for-2>using the rules for</a> the "<a href=#parsing-main-inhead id=the-after-after-frameset-insertion-mode:parsing-main-inhead>in head</a>" <a href=#insertion-mode id=the-after-after-frameset-insertion-mode:insertion-mode-3>insertion mode</a>.</p>
|
||
|
||
<dt>Anything else<dd>
|
||
<p><a href=#parse-errors id=the-after-after-frameset-insertion-mode:parse-errors>Parse error</a>. Ignore the token.</p>
|
||
</dl>
|
||
|
||
|
||
|
||
<h5 id=parsing-main-inforeign><span class=secno>12.2.6.5</span> The rules for parsing tokens <dfn>in foreign content</dfn><a href=#parsing-main-inforeign class=self-link></a></h5>
|
||
|
||
<p>When the user agent is to apply the rules for parsing tokens in foreign content, the user agent
|
||
must handle the token as follows:</p>
|
||
|
||
<dl class=switch><dt>A character token that is U+0000 NULL<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-inforeign:parse-errors>Parse error</a>. <a href=#insert-a-character id=parsing-main-inforeign:insert-a-character>Insert a U+FFFD REPLACEMENT
|
||
CHARACTER character</a>.</p>
|
||
|
||
<dt>A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C
|
||
FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE<dd>
|
||
|
||
<p><a href=#insert-a-character id=parsing-main-inforeign:insert-a-character-2>Insert the token's character</a>.</p>
|
||
|
||
<dt>Any other character token<dd>
|
||
|
||
<p><a href=#insert-a-character id=parsing-main-inforeign:insert-a-character-3>Insert the token's character</a>.</p>
|
||
|
||
<p>Set the <a href=#frameset-ok-flag id=parsing-main-inforeign:frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>
|
||
|
||
<dt>A comment token<dd>
|
||
|
||
<p><a href=#insert-a-comment id=parsing-main-inforeign:insert-a-comment>Insert a comment</a>.</p>
|
||
|
||
<dt>A DOCTYPE token<dd>
|
||
<p><a href=#parse-errors id=parsing-main-inforeign:parse-errors-2>Parse error</a>. Ignore the token.</p>
|
||
<dt>A start tag whose tag name is one of: "b", "big", "blockquote", "body", "br", "center", "code", "dd", "div", "dl", "dt", "em", "embed", "h1", "h2", "h3", "h4", "h5", "h6", "head", "hr", "i", "img",
|
||
"li", "listing",
|
||
"menu", "meta", "nobr", "ol", "p", "pre", "ruby", "s", "small", "span", "strong", "strike", "sub",
|
||
"sup", "table", "tt", "u", "ul", "var"<dt>A start tag whose tag name is "font", if the token has any attributes named "color", "face",
|
||
or "size"<dd>
|
||
|
||
<p><a href=#parse-errors id=parsing-main-inforeign:parse-errors-3>Parse error</a>.</p>
|
||
|
||
|
||
|
||
<p>If the parser was originally created for the <a href=#html-fragment-parsing-algorithm id=parsing-main-inforeign:html-fragment-parsing-algorithm>HTML fragment parsing algorithm</a>,
|
||
then act as described in the "any other start tag" entry below. (<a href=#fragment-case id=parsing-main-inforeign:fragment-case>fragment case</a>)</p>
|
||
|
||
<p>Otherwise:</p>
|
||
|
||
<p>Pop an element from the <a href=#stack-of-open-elements id=parsing-main-inforeign:stack-of-open-elements>stack of open elements</a>, and then keep popping more
|
||
elements from the <a href=#stack-of-open-elements id=parsing-main-inforeign:stack-of-open-elements-2>stack of open elements</a> until the <a href=#current-node id=parsing-main-inforeign:current-node>current node</a> is a
|
||
<a href=#mathml-text-integration-point id=parsing-main-inforeign:mathml-text-integration-point>MathML text integration point</a>, an <a href=#html-integration-point id=parsing-main-inforeign:html-integration-point>HTML integration point</a>, or an
|
||
element in the <a id=parsing-main-inforeign:html-namespace-2 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a>.</p>
|
||
|
||
<p>Then, reprocess the token.</p>
|
||
|
||
<dt>Any other start tag<dd>
|
||
|
||
<p>If the <a href=#adjusted-current-node id=parsing-main-inforeign:adjusted-current-node>adjusted current node</a> is an element in the <a id=parsing-main-inforeign:mathml-namespace href=https://infra.spec.whatwg.org/#mathml-namespace data-x-internal=mathml-namespace>MathML namespace</a>,
|
||
<a href=#adjust-mathml-attributes id=parsing-main-inforeign:adjust-mathml-attributes>adjust MathML attributes</a> for the token. (This fixes the case of MathML attributes
|
||
that are not all lowercase.)</p>
|
||
|
||
<p>If the <a href=#adjusted-current-node id=parsing-main-inforeign:adjusted-current-node-2>adjusted current node</a> is an element in the <a id=parsing-main-inforeign:svg-namespace href=https://infra.spec.whatwg.org/#svg-namespace data-x-internal=svg-namespace>SVG namespace</a>, and the
|
||
token's tag name is one of the ones in the first column of the following table, change the tag
|
||
name to the name given in the corresponding cell in the second column. (This fixes the case of
|
||
SVG elements that are not all lowercase.)</p>
|
||
|
||
<table><thead><tr><th> Tag name <th> Element name
|
||
<tbody><tr><td> <code>altglyph</code> <td> <code>altGlyph</code>
|
||
<tr><td> <code>altglyphdef</code> <td> <code>altGlyphDef</code>
|
||
<tr><td> <code>altglyphitem</code> <td> <code>altGlyphItem</code>
|
||
<tr><td> <code>animatecolor</code> <td> <code>animateColor</code>
|
||
<tr><td> <code>animatemotion</code> <td> <code>animateMotion</code>
|
||
<tr><td> <code>animatetransform</code> <td> <code>animateTransform</code>
|
||
<tr><td> <code>clippath</code> <td> <code>clipPath</code>
|
||
<tr><td> <code>feblend</code> <td> <code>feBlend</code>
|
||
<tr><td> <code>fecolormatrix</code> <td> <code>feColorMatrix</code>
|
||
<tr><td> <code>fecomponenttransfer</code> <td> <code>feComponentTransfer</code>
|
||
<tr><td> <code>fecomposite</code> <td> <code>feComposite</code>
|
||
<tr><td> <code>feconvolvematrix</code> <td> <code>feConvolveMatrix</code>
|
||
<tr><td> <code>fediffuselighting</code> <td> <code>feDiffuseLighting</code>
|
||
<tr><td> <code>fedisplacementmap</code> <td> <code>feDisplacementMap</code>
|
||
<tr><td> <code>fedistantlight</code> <td> <code>feDistantLight</code>
|
||
<tr><td> <code>fedropshadow</code> <td> <code>feDropShadow</code>
|
||
<tr><td> <code>feflood</code> <td> <code>feFlood</code>
|
||
<tr><td> <code>fefunca</code> <td> <code>feFuncA</code>
|
||
<tr><td> <code>fefuncb</code> <td> <code>feFuncB</code>
|
||
<tr><td> <code>fefuncg</code> <td> <code>feFuncG</code>
|
||
<tr><td> <code>fefuncr</code> <td> <code>feFuncR</code>
|
||
<tr><td> <code>fegaussianblur</code> <td> <code>feGaussianBlur</code>
|
||
<tr><td> <code>feimage</code> <td> <code>feImage</code>
|
||
<tr><td> <code>femerge</code> <td> <code>feMerge</code>
|
||
<tr><td> <code>femergenode</code> <td> <code>feMergeNode</code>
|
||
<tr><td> <code>femorphology</code> <td> <code>feMorphology</code>
|
||
<tr><td> <code>feoffset</code> <td> <code>feOffset</code>
|
||
<tr><td> <code>fepointlight</code> <td> <code>fePointLight</code>
|
||
<tr><td> <code>fespecularlighting</code> <td> <code>feSpecularLighting</code>
|
||
<tr><td> <code>fespotlight</code> <td> <code>feSpotLight</code>
|
||
<tr><td> <code>fetile</code> <td> <code>feTile</code>
|
||
<tr><td> <code>feturbulence</code> <td> <code>feTurbulence</code>
|
||
<tr><td> <code>foreignobject</code> <td> <code>foreignObject</code>
|
||
<tr><td> <code>glyphref</code> <td> <code>glyphRef</code>
|
||
<tr><td> <code>lineargradient</code> <td> <code>linearGradient</code>
|
||
<tr><td> <code>radialgradient</code> <td> <code>radialGradient</code>
|
||
|
||
<tr><td> <code>textpath</code> <td> <code>textPath</code>
|
||
</table>
|
||
|
||
<p>If the <a href=#adjusted-current-node id=parsing-main-inforeign:adjusted-current-node-3>adjusted current node</a> is an element in the <a id=parsing-main-inforeign:svg-namespace-2 href=https://infra.spec.whatwg.org/#svg-namespace data-x-internal=svg-namespace>SVG namespace</a>,
|
||
<a href=#adjust-svg-attributes id=parsing-main-inforeign:adjust-svg-attributes>adjust SVG attributes</a> for the token. (This fixes the case of SVG attributes that
|
||
are not all lowercase.)</p>
|
||
|
||
<p><a href=#adjust-foreign-attributes id=parsing-main-inforeign:adjust-foreign-attributes>Adjust foreign attributes</a> for the token. (This fixes the use of namespaced
|
||
attributes, in particular XLink in SVG.)</p>
|
||
|
||
<p><a href=#insert-a-foreign-element id=parsing-main-inforeign:insert-a-foreign-element>Insert a foreign element</a> for the token, in the same namespace as the
|
||
<a href=#adjusted-current-node id=parsing-main-inforeign:adjusted-current-node-4>adjusted current node</a>.</p>
|
||
|
||
<p>If the token has its <i id=parsing-main-inforeign:self-closing-flag><a href=#self-closing-flag>self-closing flag</a></i> set, then run the appropriate steps from the
|
||
following list:</p>
|
||
|
||
<dl class=switch><dt>If the token's tag name is "script", and the new <a href=#current-node id=parsing-main-inforeign:current-node-2>current node</a> is in the <a id=parsing-main-inforeign:svg-namespace-3 href=https://infra.spec.whatwg.org/#svg-namespace data-x-internal=svg-namespace>SVG namespace</a><dd>
|
||
|
||
<p><a href=#acknowledge-self-closing-flag id=parsing-main-inforeign:acknowledge-self-closing-flag>Acknowledge the token's <i>self-closing
|
||
flag</i></a>, and then act as described in the steps for a "script" end tag below.</p>
|
||
|
||
<dt>Otherwise<dd>
|
||
|
||
<p>Pop the <a href=#current-node id=parsing-main-inforeign:current-node-3>current node</a> off the <a href=#stack-of-open-elements id=parsing-main-inforeign:stack-of-open-elements-3>stack of open elements</a> and <a href=#acknowledge-self-closing-flag id=parsing-main-inforeign:acknowledge-self-closing-flag-2>acknowledge the token's <i>self-closing
|
||
flag</i></a>.</p>
|
||
|
||
</dl>
|
||
|
||
<dt id=scriptForeignEndTag>An end tag whose tag name is "script", if the <a href=#current-node id=parsing-main-inforeign:current-node-4>current
|
||
node</a> is an <a id=parsing-main-inforeign:svg-script href=https://www.w3.org/TR/SVG11/script.html#ScriptElement data-x-internal=svg-script>SVG <code>script</code></a> element<dd>
|
||
|
||
<p>Pop the <a href=#current-node id=parsing-main-inforeign:current-node-5>current node</a> off the <a href=#stack-of-open-elements id=parsing-main-inforeign:stack-of-open-elements-4>stack of open elements</a>.</p>
|
||
|
||
<p>Let the <var>old insertion point</var> have the same value as the current
|
||
<a href=#insertion-point id=parsing-main-inforeign:insertion-point>insertion point</a>. Let the <a href=#insertion-point id=parsing-main-inforeign:insertion-point-2>insertion point</a> be just before the <a href=#next-input-character id=parsing-main-inforeign:next-input-character>next
|
||
input character</a>.</p>
|
||
|
||
<p>Increment the parser's <a href=#script-nesting-level id=parsing-main-inforeign:script-nesting-level>script nesting level</a> by one. Set the <a href=#parser-pause-flag id=parsing-main-inforeign:parser-pause-flag>parser pause
|
||
flag</a> to true.</p>
|
||
|
||
<p><a href=https://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing>Process the
|
||
SVG <code>script</code> element</a> according to the SVG rules, if the user agent
|
||
supports SVG. <a href=references.html#refsSVG>[SVG]</a></p>
|
||
|
||
<p class=note>Even if this causes <a href=dynamic-markup-insertion.html#dom-document-write-2 id=parsing-main-inforeign:dom-document-write-2>new characters to be
|
||
inserted into the tokenizer</a>, the parser will not be executed reentrantly, since the
|
||
<a href=#parser-pause-flag id=parsing-main-inforeign:parser-pause-flag-2>parser pause flag</a> is true.</p>
|
||
|
||
<p>Decrement the parser's <a href=#script-nesting-level id=parsing-main-inforeign:script-nesting-level-2>script nesting level</a> by one. If the parser's <a href=#script-nesting-level id=parsing-main-inforeign:script-nesting-level-3>script
|
||
nesting level</a> is zero, then set the <a href=#parser-pause-flag id=parsing-main-inforeign:parser-pause-flag-3>parser pause flag</a> to false.</p>
|
||
|
||
<p>Let the <a href=#insertion-point id=parsing-main-inforeign:insertion-point-3>insertion point</a> have the value of the <var>old insertion
|
||
point</var>. (In other words, restore the <a href=#insertion-point id=parsing-main-inforeign:insertion-point-4>insertion point</a> to its previous value.
|
||
This value might be the "undefined" value.)</p>
|
||
|
||
<dt>Any other end tag<dd>
|
||
|
||
<p>Run these steps:</p>
|
||
|
||
<ol><li><p>Initialize <var>node</var> to be the <a href=#current-node id=parsing-main-inforeign:current-node-6>current node</a> (the bottommost
|
||
node of the stack).<li><p>If <var>node</var>'s tag name, <a id=parsing-main-inforeign:converted-to-ascii-lowercase href=https://infra.spec.whatwg.org/#ascii-lowercase data-x-internal=converted-to-ascii-lowercase>converted to ASCII lowercase</a>, is
|
||
not the same as the tag name of the token, then this is a <a href=#parse-errors id=parsing-main-inforeign:parse-errors-4>parse error</a>.<li><p><i>Loop</i>: If <var>node</var> is the topmost element in the <a href=#stack-of-open-elements id=parsing-main-inforeign:stack-of-open-elements-5>stack of
|
||
open elements</a>, abort these steps. (<a href=#fragment-case id=parsing-main-inforeign:fragment-case-2>fragment case</a>)<li><p>If <var>node</var>'s tag name, <a id=parsing-main-inforeign:converted-to-ascii-lowercase-2 href=https://infra.spec.whatwg.org/#ascii-lowercase data-x-internal=converted-to-ascii-lowercase>converted to ASCII lowercase</a>, is
|
||
the same as the tag name of the token, pop elements from the <a href=#stack-of-open-elements id=parsing-main-inforeign:stack-of-open-elements-6>stack of open
|
||
elements</a> until <var>node</var> has been popped from the stack, and then abort
|
||
these steps.<li><p>Set <var>node</var> to the previous entry in the <a href=#stack-of-open-elements id=parsing-main-inforeign:stack-of-open-elements-7>stack of open
|
||
elements</a>.<li><p>If <var>node</var> is not an element in the <a id=parsing-main-inforeign:html-namespace-2-2 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a>, return
|
||
to the step labeled <i>loop</i>.<li><p>Otherwise, process the token according to the rules given in the section corresponding
|
||
to the current <a href=#insertion-mode id=parsing-main-inforeign:insertion-mode>insertion mode</a> in HTML content.</ol>
|
||
|
||
</dl>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h4 id=the-end><span class=secno>12.2.7</span> The end<a href=#the-end class=self-link></a></h4>
|
||
|
||
<p>Once the user agent <dfn id=stop-parsing>stops parsing</dfn> the document, the user agent
|
||
must run the following steps:<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> domcontentloaded<span class="and_chr yes"><span>Chrome for Android</span> <span>59+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>3.2+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.4+</span></span><span class="firefox yes"><span>Firefox</span> <span>2+</span></span><span class="ie yes"><span>IE</span> <span>9+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>3.1+</span></span><span class="android yes"><span>Android Browser</span> <span>2.1+</span></span><span class="opera yes"><span>Opera</span> <span>9+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=domcontentloaded">caniuse.com</a></div>
|
||
|
||
<ol><li><p>Set the <a id=the-end:current-document-readiness href=dom.html#current-document-readiness>current document readiness</a> to "<code>interactive</code>"
|
||
and the <a href=#insertion-point id=the-end:insertion-point>insertion point</a> to
|
||
undefined.<li><p>Pop <em>all</em> the nodes off the <a href=#stack-of-open-elements id=the-end:stack-of-open-elements>stack of open elements</a>.<li><p>If the <a id=the-end:list-of-scripts-that-will-execute-when-the-document-has-finished-parsing href=scripting.html#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when the document has finished
|
||
parsing</a> is not empty, run these substeps:</p>
|
||
|
||
<ol><li><p><a id=the-end:spin-the-event-loop href=webappapis.html#spin-the-event-loop>Spin the event loop</a> until the first <code id=the-end:the-script-element><a href=scripting.html#the-script-element>script</a></code> in the <a id=the-end:list-of-scripts-that-will-execute-when-the-document-has-finished-parsing-2 href=scripting.html#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list
|
||
of scripts that will execute when the document has finished parsing</a> has its <a id=the-end:ready-to-be-parser-executed href=scripting.html#ready-to-be-parser-executed>"ready
|
||
to be parser-executed"</a> flag set <em>and</em> the parser's <code id=the-end:document><a href=dom.html#document>Document</a></code>
|
||
<a id=the-end:has-no-style-sheet-that-is-blocking-scripts href=semantics.html#has-no-style-sheet-that-is-blocking-scripts>has no style sheet that is blocking scripts</a>.<li><p><a href=scripting.html#execute-the-script-block id=the-end:execute-the-script-block>Execute</a> the first <code id=the-end:the-script-element-2><a href=scripting.html#the-script-element>script</a></code> in
|
||
the <a id=the-end:list-of-scripts-that-will-execute-when-the-document-has-finished-parsing-3 href=scripting.html#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when the document has finished
|
||
parsing</a>.<li><p>Remove the first <code id=the-end:the-script-element-3><a href=scripting.html#the-script-element>script</a></code> element from the <a id=the-end:list-of-scripts-that-will-execute-when-the-document-has-finished-parsing-4 href=scripting.html#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will
|
||
execute when the document has finished parsing</a> (i.e. shift out the first entry in the
|
||
list).<li><p>If the <a id=the-end:list-of-scripts-that-will-execute-when-the-document-has-finished-parsing-5 href=scripting.html#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when the document has finished
|
||
parsing</a> is still not empty, repeat these substeps again from substep 1.</p>
|
||
|
||
</ol>
|
||
|
||
<li>
|
||
<p><a id=the-end:queue-a-task href=webappapis.html#queue-a-task>Queue a task</a> to run the following substeps:</p>
|
||
|
||
<ol><li><p><a href=https://dom.spec.whatwg.org/#concept-event-fire id=the-end:concept-event-fire data-x-internal=concept-event-fire>Fire an event</a> named <code id=the-end:event-domcontentloaded><a href=indices.html#event-domcontentloaded>DOMContentLoaded</a></code> at the <code id=the-end:document-2><a href=dom.html#document>Document</a></code>
|
||
object, with its <code id=the-end:dom-event-bubbles><a data-x-internal=dom-event-bubbles href=https://dom.spec.whatwg.org/#dom-event-bubbles>bubbles</a></code> attribute initialized to
|
||
true.<li><p>Enable the <a href=https://w3c.github.io/ServiceWorker/#dfn-client-message-queue id=the-end:dfn-client-message-queue data-x-internal=dfn-client-message-queue>client message queue</a> of the
|
||
<code id=the-end:serviceworkercontainer><a data-x-internal=serviceworkercontainer href=https://w3c.github.io/ServiceWorker/#serviceworkercontainer>ServiceWorkerContainer</a></code> object whose associated <a href=https://w3c.github.io/ServiceWorker/#serviceworkercontainer-service-worker-client id=the-end:serviceworkercontainer-service-worker-client data-x-internal=serviceworkercontainer-service-worker-client>service worker client</a> is the
|
||
<code id=the-end:document-3><a href=dom.html#document>Document</a></code> object's <a id=the-end:relevant-settings-object href=webappapis.html#relevant-settings-object>relevant settings object</a>.</ol>
|
||
<li><p><a id=the-end:spin-the-event-loop-2 href=webappapis.html#spin-the-event-loop>Spin the event loop</a> until the <a id=the-end:set-of-scripts-that-will-execute-as-soon-as-possible href=scripting.html#set-of-scripts-that-will-execute-as-soon-as-possible>set of scripts that will execute as soon
|
||
as possible</a> and the <a id=the-end:list-of-scripts-that-will-execute-in-order-as-soon-as-possible href=scripting.html#list-of-scripts-that-will-execute-in-order-as-soon-as-possible>list of scripts that will execute in order as soon as
|
||
possible</a> are empty.<li><p><a id=the-end:spin-the-event-loop-3 href=webappapis.html#spin-the-event-loop>Spin the event loop</a> until there is nothing that <dfn id=delay-the-load-event>delays the load event</dfn> in the <code id=the-end:document-4><a href=dom.html#document>Document</a></code>.<li>
|
||
|
||
<p><a id=the-end:queue-a-task-2 href=webappapis.html#queue-a-task>Queue a task</a> to run the following substeps:</p>
|
||
|
||
<ol><li><p>Set the <a id=the-end:current-document-readiness-2 href=dom.html#current-document-readiness>current document readiness</a> to "<code>complete</code>".<li><p><i>Load event</i>: If the <code id=the-end:document-5><a href=dom.html#document>Document</a></code> has a <a href=browsers.html#concept-document-bc id=the-end:concept-document-bc>browsing context</a>, then <a href=https://dom.spec.whatwg.org/#concept-event-fire id=the-end:concept-event-fire-2 data-x-internal=concept-event-fire>fire an event</a> named <code id=the-end:event-load><a href=indices.html#event-load>load</a></code> at
|
||
the <code id=the-end:document-6><a href=dom.html#document>Document</a></code> object's <code id=the-end:window><a href=window-object.html#window>Window</a></code> object, with <var>legacy target override
|
||
flag</var> set.</ol>
|
||
|
||
<li>
|
||
|
||
<p>If the <code id=the-end:document-7><a href=dom.html#document>Document</a></code> has a <a href=browsers.html#concept-document-bc id=the-end:concept-document-bc-2>browsing
|
||
context</a>, then <a id=the-end:queue-a-task-3 href=webappapis.html#queue-a-task>queue a task</a> to run the following substeps:</p>
|
||
|
||
<ol><li><p>If the <code id=the-end:document-8><a href=dom.html#document>Document</a></code>'s <a id=the-end:page-showing href=browsing-the-web.html#page-showing>page showing</a> flag is true, then abort this
|
||
task (i.e. don't fire the event below).<li><p>Set the <code id=the-end:document-9><a href=dom.html#document>Document</a></code>'s <a id=the-end:page-showing-2 href=browsing-the-web.html#page-showing>page showing</a> flag to true.<li><p><a href=https://dom.spec.whatwg.org/#concept-event-fire id=the-end:concept-event-fire-3 data-x-internal=concept-event-fire>Fire an event</a> named <code id=the-end:event-pageshow><a href=indices.html#event-pageshow>pageshow</a></code> at the <code id=the-end:document-10><a href=dom.html#document>Document</a></code> object's
|
||
<code id=the-end:window-2><a href=window-object.html#window>Window</a></code> object, using <code id=the-end:pagetransitionevent><a href=browsing-the-web.html#pagetransitionevent>PageTransitionEvent</a></code>, with the <code id=the-end:dom-pagetransitionevent-persisted-2><a href=browsing-the-web.html#dom-pagetransitionevent-persisted-2>persisted</a></code> attribute initialized to false, and
|
||
<var>legacy target override flag</var> set.</ol>
|
||
|
||
<li><p>If the <code id=the-end:document-11><a href=dom.html#document>Document</a></code> has any <a id=the-end:pending-application-cache-download-process-tasks href=offline.html#pending-application-cache-download-process-tasks>pending application cache download process
|
||
tasks</a>, then <a href=webappapis.html#queue-a-task id=the-end:queue-a-task-4>queue</a> each such <a href=webappapis.html#concept-task id=the-end:concept-task>task</a> in the order they were added to the list of <a id=the-end:pending-application-cache-download-process-tasks-2 href=offline.html#pending-application-cache-download-process-tasks>pending
|
||
application cache download process tasks</a>, and then empty the list of <a id=the-end:pending-application-cache-download-process-tasks-3 href=offline.html#pending-application-cache-download-process-tasks>pending
|
||
application cache download process tasks</a>. The <a id=the-end:task-source href=webappapis.html#task-source>task source</a> for these <a href=webappapis.html#concept-task id=the-end:concept-task-2>tasks</a> is the <a id=the-end:networking-task-source href=webappapis.html#networking-task-source>networking task source</a>.<li><p>If the <code id=the-end:document-12><a href=dom.html#document>Document</a></code>'s <a id=the-end:print-when-loaded href=timers-and-user-prompts.html#print-when-loaded>print when loaded</a> flag is set, then run the
|
||
<a id=the-end:printing-steps href=timers-and-user-prompts.html#printing-steps>printing steps</a>.<li><p>The <code id=the-end:document-13><a href=dom.html#document>Document</a></code> is now <dfn id=ready-for-post-load-tasks>ready for post-load tasks</dfn>.<li><p><a id=the-end:queue-a-task-5 href=webappapis.html#queue-a-task>Queue a task</a> to mark the <code id=the-end:document-14><a href=dom.html#document>Document</a></code> as <dfn id=completely-loaded>completely
|
||
loaded</dfn>.</ol>
|
||
|
||
<p>When the user agent is to <dfn id=abort-a-parser>abort a parser</dfn>, it must run the following steps:</p>
|
||
|
||
<ol><li><p>Throw away any pending content in the <a href=#input-stream id=the-end:input-stream>input stream</a>, and discard any future
|
||
content that would have been added to it.<li><p>Set the <a id=the-end:current-document-readiness-3 href=dom.html#current-document-readiness>current document readiness</a> to "<code>interactive</code>".<li><p>Pop <em>all</em> the nodes off the <a href=#stack-of-open-elements id=the-end:stack-of-open-elements-2>stack of open elements</a>.<li><p>Set the <a id=the-end:current-document-readiness-4 href=dom.html#current-document-readiness>current document readiness</a> to "<code>complete</code>".</ol>
|
||
|
||
<p>Except where otherwise specified, the <a id=the-end:task-source-2 href=webappapis.html#task-source>task source</a> for the <a href=webappapis.html#concept-task id=the-end:concept-task-3>tasks</a> mentioned in this section is the <a id=the-end:dom-manipulation-task-source href=webappapis.html#dom-manipulation-task-source>DOM manipulation task
|
||
source</a>.</p>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h4 id=coercing-an-html-dom-into-an-infoset><span class=secno>12.2.8</span> Coercing an HTML DOM into an infoset<a href=#coercing-an-html-dom-into-an-infoset class=self-link></a></h4>
|
||
|
||
<p>When an application uses an <a href=#html-parser id=coercing-an-html-dom-into-an-infoset:html-parser>HTML parser</a> in conjunction with an XML pipeline, it is
|
||
possible that the constructed DOM is not compatible with the XML tool chain in certain subtle
|
||
ways. For example, an XML toolchain might not be able to represent attributes with the name <code>xmlns</code>, since they conflict with the Namespaces in XML syntax. There is also some
|
||
data that the <a href=#html-parser id=coercing-an-html-dom-into-an-infoset:html-parser-2>HTML parser</a> generates that isn't included in the DOM itself. This
|
||
section specifies some rules for handling these issues.</p>
|
||
|
||
<p>If the XML API being used doesn't support DOCTYPEs, the tool may drop DOCTYPEs altogether.</p>
|
||
|
||
<p>If the XML API doesn't support attributes in no namespace that are named "<code>xmlns</code>", attributes whose names start with "<code>xmlns:</code>", or
|
||
attributes in the <a id=coercing-an-html-dom-into-an-infoset:xmlns-namespace href=https://infra.spec.whatwg.org/#xmlns-namespace data-x-internal=xmlns-namespace>XMLNS namespace</a>, then the tool may drop such attributes.</p>
|
||
|
||
<p>The tool may annotate the output with any namespace declarations required for proper
|
||
operation.</p>
|
||
|
||
<p>If the XML API being used restricts the allowable characters in the local names of elements and
|
||
attributes, then the tool may map all element and attribute local names that the API wouldn't
|
||
support to a set of names that <em>are</em> allowed, by replacing any character that isn't
|
||
supported with the uppercase letter U and the six digits of the character's code point when
|
||
expressed in hexadecimal, using digits 0-9 and capital letters A-F as the symbols, in increasing
|
||
numeric order.</p>
|
||
|
||
<p class=example>For example, the element name <code>foo<bar</code>, which can be
|
||
output by the <a href=#html-parser id=coercing-an-html-dom-into-an-infoset:html-parser-3>HTML parser</a>, though it is neither a legal HTML element name nor a
|
||
well-formed XML element name, would be converted into <code>fooU00003Cbar</code>, which
|
||
<em>is</em> a well-formed XML element name (though it's still not legal in HTML by any means).</p>
|
||
|
||
<p class=example>As another example, consider the attribute <code>xlink:href</code>.
|
||
Used on a MathML element, it becomes, after being <a href=#adjust-foreign-attributes id=coercing-an-html-dom-into-an-infoset:adjust-foreign-attributes>adjusted</a>, an attribute with a prefix "<code>xlink</code>" and a local
|
||
name "<code>href</code>". However, used on an HTML element, it becomes an attribute with
|
||
no prefix and the local name "<code>xlink:href</code>", which is not a valid NCName, and
|
||
thus might not be accepted by an XML API. It could thus get converted, becoming "<code>xlinkU00003Ahref</code>".</p>
|
||
|
||
<p class=note>The resulting names from this conversion conveniently can't clash with any
|
||
attribute generated by the <a href=#html-parser id=coercing-an-html-dom-into-an-infoset:html-parser-4>HTML parser</a>, since those are all either lowercase or those
|
||
listed in the <a href=#adjust-foreign-attributes id=coercing-an-html-dom-into-an-infoset:adjust-foreign-attributes-2>adjust foreign attributes</a> algorithm's table.</p>
|
||
|
||
<p>If the XML API restricts comments from having two consecutive U+002D HYPHEN-MINUS characters
|
||
(--), the tool may insert a single U+0020 SPACE character between any such offending
|
||
characters.</p>
|
||
|
||
<p>If the XML API restricts comments from ending in a U+002D HYPHEN-MINUS character (-), the tool
|
||
may insert a single U+0020 SPACE character at the end of such comments.</p>
|
||
|
||
<p>If the XML API restricts allowed characters in character data, attribute values, or comments,
|
||
the tool may replace any U+000C FORM FEED (FF) character with a U+0020 SPACE character, and any
|
||
other literal non-XML character with a U+FFFD REPLACEMENT CHARACTER.</p>
|
||
|
||
<p>If the tool has no way to convey out-of-band information, then the tool may drop the following
|
||
information:</p>
|
||
|
||
<ul><li>Whether the document is set to <i id=coercing-an-html-dom-into-an-infoset:no-quirks-mode><a data-x-internal=no-quirks-mode href=https://dom.spec.whatwg.org/#concept-document-no-quirks>no-quirks mode</a></i>, <i id=coercing-an-html-dom-into-an-infoset:limited-quirks-mode><a data-x-internal=limited-quirks-mode href=https://dom.spec.whatwg.org/#concept-document-limited-quirks>limited-quirks mode</a></i>, or
|
||
<i id=coercing-an-html-dom-into-an-infoset:quirks-mode><a data-x-internal=quirks-mode href=https://dom.spec.whatwg.org/#concept-document-quirks>quirks mode</a></i><li>The association between form controls and forms that aren't their nearest <code id=coercing-an-html-dom-into-an-infoset:the-form-element><a href=forms.html#the-form-element>form</a></code>
|
||
element ancestor (use of the <a href=#form-element-pointer id=coercing-an-html-dom-into-an-infoset:form-element-pointer><code>form</code> element pointer</a> in the parser)<li>The <a id=coercing-an-html-dom-into-an-infoset:template-contents href=scripting.html#template-contents>template contents</a> of any <code id=coercing-an-html-dom-into-an-infoset:the-template-element><a href=scripting.html#the-template-element>template</a></code> elements.</ul>
|
||
|
||
<p class=note>The mutations allowed by this section apply <em>after</em> the <a href=#html-parser id=coercing-an-html-dom-into-an-infoset:html-parser-5>HTML
|
||
parser</a>'s rules have been applied. For example, a <code><a::></code> start tag
|
||
will be closed by a <code></a::></code> end tag, and never by a <code></aU00003AU00003A></code> end tag, even if the user agent is using the rules above to
|
||
then generate an actual element in the DOM with the name <code>aU00003AU00003A</code> for
|
||
that start tag.</p>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h4 id=an-introduction-to-error-handling-and-strange-cases-in-the-parser><span class=secno>12.2.9</span> An introduction to error handling and strange cases in the parser<a href=#an-introduction-to-error-handling-and-strange-cases-in-the-parser class=self-link></a></h4>
|
||
|
||
<p><i>This section is non-normative.</i></p>
|
||
|
||
<p>This section examines some erroneous markup and discusses how the <a href=#html-parser id=an-introduction-to-error-handling-and-strange-cases-in-the-parser:html-parser>HTML parser</a>
|
||
handles these cases.</p>
|
||
|
||
|
||
<h5 id=misnested-tags:-b-i-/b-/i><span class=secno>12.2.9.1</span> Misnested tags: <b><i></b></i><a href=#misnested-tags:-b-i-/b-/i class=self-link></a></h5>
|
||
|
||
<p><i>This section is non-normative.</i></p>
|
||
|
||
<p>The most-often discussed example of erroneous markup is as follows:</p>
|
||
|
||
<pre><p>1<b>2<i>3</b>4</i>5</p></pre>
|
||
|
||
<p>The parsing of this markup is straightforward up to the "3". At this point, the DOM looks like
|
||
this:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=misnested-tags:-b-i-/b-/i:the-html-element><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=misnested-tags:-b-i-/b-/i:the-head-element><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=misnested-tags:-b-i-/b-/i:the-body-element><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=misnested-tags:-b-i-/b-/i:the-p-element><a href=grouping-content.html#the-p-element>p</a></code><ul><li class=t3><code id=misnested-tags:-b-i-/b-/i:text><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>1</span><li class=t1><code id=misnested-tags:-b-i-/b-/i:the-b-element><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t3><code id=misnested-tags:-b-i-/b-/i:text-2><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>2</span><li class=t1><code id=misnested-tags:-b-i-/b-/i:the-i-element><a href=text-level-semantics.html#the-i-element>i</a></code><ul><li class=t3><code id=misnested-tags:-b-i-/b-/i:text-3><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>3</span></ul></ul></ul></ul></ul></ul>
|
||
|
||
<p>Here, the <a href=#stack-of-open-elements id=misnested-tags:-b-i-/b-/i:stack-of-open-elements>stack of open elements</a> has five elements on it: <code id=misnested-tags:-b-i-/b-/i:the-html-element-2><a href=semantics.html#the-html-element>html</a></code>,
|
||
<code id=misnested-tags:-b-i-/b-/i:the-body-element-2><a href=sections.html#the-body-element>body</a></code>, <code id=misnested-tags:-b-i-/b-/i:the-p-element-2><a href=grouping-content.html#the-p-element>p</a></code>, <code id=misnested-tags:-b-i-/b-/i:the-b-element-2><a href=text-level-semantics.html#the-b-element>b</a></code>, and <code id=misnested-tags:-b-i-/b-/i:the-i-element-2><a href=text-level-semantics.html#the-i-element>i</a></code>. The <a href=#list-of-active-formatting-elements id=misnested-tags:-b-i-/b-/i:list-of-active-formatting-elements>list of active
|
||
formatting elements</a> just has two: <code id=misnested-tags:-b-i-/b-/i:the-b-element-3><a href=text-level-semantics.html#the-b-element>b</a></code> and <code id=misnested-tags:-b-i-/b-/i:the-i-element-3><a href=text-level-semantics.html#the-i-element>i</a></code>. The <a href=#insertion-mode id=misnested-tags:-b-i-/b-/i:insertion-mode>insertion
|
||
mode</a> is "<a href=#parsing-main-inbody id=misnested-tags:-b-i-/b-/i:parsing-main-inbody>in body</a>".</p>
|
||
|
||
<p>Upon receiving the end tag token with the tag name "b", the "<a href=#adoptionAgency>adoption
|
||
agency algorithm</a>" is invoked. This is a simple case, in that the <var>formatting
|
||
element</var> is the <code id=misnested-tags:-b-i-/b-/i:the-b-element-4><a href=text-level-semantics.html#the-b-element>b</a></code> element, and there is no <var>furthest block</var>.
|
||
Thus, the <a href=#stack-of-open-elements id=misnested-tags:-b-i-/b-/i:stack-of-open-elements-2>stack of open elements</a> ends up with just three elements: <code id=misnested-tags:-b-i-/b-/i:the-html-element-3><a href=semantics.html#the-html-element>html</a></code>,
|
||
<code id=misnested-tags:-b-i-/b-/i:the-body-element-3><a href=sections.html#the-body-element>body</a></code>, and <code id=misnested-tags:-b-i-/b-/i:the-p-element-3><a href=grouping-content.html#the-p-element>p</a></code>, while the <a href=#list-of-active-formatting-elements id=misnested-tags:-b-i-/b-/i:list-of-active-formatting-elements-2>list of active formatting elements</a>
|
||
has just one: <code id=misnested-tags:-b-i-/b-/i:the-i-element-4><a href=text-level-semantics.html#the-i-element>i</a></code>. The DOM tree is unmodified at this point.</p>
|
||
|
||
<p>The next token is a character ("4"), triggers the <a href=#reconstruct-the-active-formatting-elements id=misnested-tags:-b-i-/b-/i:reconstruct-the-active-formatting-elements>reconstruction of the active formatting elements</a>, in this case just
|
||
the <code id=misnested-tags:-b-i-/b-/i:the-i-element-5><a href=text-level-semantics.html#the-i-element>i</a></code> element. A new <code id=misnested-tags:-b-i-/b-/i:the-i-element-6><a href=text-level-semantics.html#the-i-element>i</a></code> element is thus created for the "4"
|
||
<code id=misnested-tags:-b-i-/b-/i:text-4><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node. After the end tag token for the "i" is also received, and the "5"
|
||
<code id=misnested-tags:-b-i-/b-/i:text-5><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node is inserted, the DOM looks as follows:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=misnested-tags:-b-i-/b-/i:the-html-element-4><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=misnested-tags:-b-i-/b-/i:the-head-element-2><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=misnested-tags:-b-i-/b-/i:the-body-element-4><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=misnested-tags:-b-i-/b-/i:the-p-element-4><a href=grouping-content.html#the-p-element>p</a></code><ul><li class=t3><code id=misnested-tags:-b-i-/b-/i:text-6><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>1</span><li class=t1><code id=misnested-tags:-b-i-/b-/i:the-b-element-5><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t3><code id=misnested-tags:-b-i-/b-/i:text-7><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>2</span><li class=t1><code id=misnested-tags:-b-i-/b-/i:the-i-element-7><a href=text-level-semantics.html#the-i-element>i</a></code><ul><li class=t3><code id=misnested-tags:-b-i-/b-/i:text-8><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>3</span></ul></ul><li class=t1><code id=misnested-tags:-b-i-/b-/i:the-i-element-8><a href=text-level-semantics.html#the-i-element>i</a></code><ul><li class=t3><code id=misnested-tags:-b-i-/b-/i:text-9><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>4</span></ul><li class=t3><code id=misnested-tags:-b-i-/b-/i:text-10><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>5</span></ul></ul></ul></ul>
|
||
|
||
|
||
<h5 id=misnested-tags:-b-p-/b-/p><span class=secno>12.2.9.2</span> Misnested tags: <b><p></b></p><a href=#misnested-tags:-b-p-/b-/p class=self-link></a></h5>
|
||
|
||
<p><i>This section is non-normative.</i></p>
|
||
|
||
<p>A case similar to the previous one is the following:</p>
|
||
|
||
<pre><b>1<p>2</b>3</p></pre>
|
||
|
||
<p>Up to the "2" the parsing here is straightforward:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-html-element><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-head-element><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-body-element><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-b-element><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t3><code id=misnested-tags:-b-p-/b-/p:text><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>1</span><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-p-element><a href=grouping-content.html#the-p-element>p</a></code><ul><li class=t3><code id=misnested-tags:-b-p-/b-/p:text-2><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>2</span></ul></ul></ul></ul></ul>
|
||
|
||
<p>The interesting part is when the end tag token with the tag name "b" is parsed.</p>
|
||
|
||
<p>Before that token is seen, the <a href=#stack-of-open-elements id=misnested-tags:-b-p-/b-/p:stack-of-open-elements>stack of open elements</a> has four elements on it:
|
||
<code id=misnested-tags:-b-p-/b-/p:the-html-element-2><a href=semantics.html#the-html-element>html</a></code>, <code id=misnested-tags:-b-p-/b-/p:the-body-element-2><a href=sections.html#the-body-element>body</a></code>, <code id=misnested-tags:-b-p-/b-/p:the-b-element-2><a href=text-level-semantics.html#the-b-element>b</a></code>, and <code id=misnested-tags:-b-p-/b-/p:the-p-element-2><a href=grouping-content.html#the-p-element>p</a></code>. The <a href=#list-of-active-formatting-elements id=misnested-tags:-b-p-/b-/p:list-of-active-formatting-elements>list of active
|
||
formatting elements</a> just has the one: <code id=misnested-tags:-b-p-/b-/p:the-b-element-3><a href=text-level-semantics.html#the-b-element>b</a></code>. The <a href=#insertion-mode id=misnested-tags:-b-p-/b-/p:insertion-mode>insertion mode</a> is
|
||
"<a href=#parsing-main-inbody id=misnested-tags:-b-p-/b-/p:parsing-main-inbody>in body</a>".</p>
|
||
|
||
<p>Upon receiving the end tag token with the tag name "b", the "<a href=#adoptionAgency>adoption
|
||
agency algorithm</a>" is invoked, as in the previous example. However, in this case, there
|
||
<em>is</em> a <var>furthest block</var>, namely the <code id=misnested-tags:-b-p-/b-/p:the-p-element-3><a href=grouping-content.html#the-p-element>p</a></code> element. Thus, this
|
||
time the adoption agency algorithm isn't skipped over.</p>
|
||
|
||
<p>The <var>common ancestor</var> is the <code id=misnested-tags:-b-p-/b-/p:the-body-element-3><a href=sections.html#the-body-element>body</a></code> element. A conceptual
|
||
"bookmark" marks the position of the <code id=misnested-tags:-b-p-/b-/p:the-b-element-4><a href=text-level-semantics.html#the-b-element>b</a></code> in the <a href=#list-of-active-formatting-elements id=misnested-tags:-b-p-/b-/p:list-of-active-formatting-elements-2>list of active formatting
|
||
elements</a>, but since that list has only one element in it, the bookmark won't have much
|
||
effect.</p>
|
||
|
||
<p>As the algorithm progresses, <var>node</var> ends up set to the formatting element
|
||
(<code id=misnested-tags:-b-p-/b-/p:the-b-element-5><a href=text-level-semantics.html#the-b-element>b</a></code>), and <var>last node</var> ends up set to the <var>furthest
|
||
block</var> (<code id=misnested-tags:-b-p-/b-/p:the-p-element-4><a href=grouping-content.html#the-p-element>p</a></code>).</p>
|
||
|
||
<p>The <var>last node</var> gets appended (moved) to the <var>common
|
||
ancestor</var>, so that the DOM looks like:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-html-element-3><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-head-element-2><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-body-element-4><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-b-element-6><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t3><code id=misnested-tags:-b-p-/b-/p:text-3><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>1</span></ul><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-p-element-5><a href=grouping-content.html#the-p-element>p</a></code><ul><li class=t3><code id=misnested-tags:-b-p-/b-/p:text-4><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>2</span></ul></ul></ul></ul>
|
||
|
||
<p>A new <code id=misnested-tags:-b-p-/b-/p:the-b-element-7><a href=text-level-semantics.html#the-b-element>b</a></code> element is created, and the children of the <code id=misnested-tags:-b-p-/b-/p:the-p-element-6><a href=grouping-content.html#the-p-element>p</a></code> element are
|
||
moved to it:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-html-element-4><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-head-element-3><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-body-element-5><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-b-element-8><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t3><code id=misnested-tags:-b-p-/b-/p:text-5><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>1</span></ul><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-p-element-7><a href=grouping-content.html#the-p-element>p</a></code></ul></ul></ul>
|
||
<ul class=domTree><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-b-element-9><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t3><code id=misnested-tags:-b-p-/b-/p:text-6><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>2</span></ul></ul>
|
||
|
||
<p>Finally, the new <code id=misnested-tags:-b-p-/b-/p:the-b-element-10><a href=text-level-semantics.html#the-b-element>b</a></code> element is appended to the <code id=misnested-tags:-b-p-/b-/p:the-p-element-8><a href=grouping-content.html#the-p-element>p</a></code> element, so that the
|
||
DOM looks like:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-html-element-5><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-head-element-4><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-body-element-6><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-b-element-11><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t3><code id=misnested-tags:-b-p-/b-/p:text-7><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>1</span></ul><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-p-element-9><a href=grouping-content.html#the-p-element>p</a></code><ul><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-b-element-12><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t3><code id=misnested-tags:-b-p-/b-/p:text-8><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>2</span></ul></ul></ul></ul></ul>
|
||
|
||
<p>The <code id=misnested-tags:-b-p-/b-/p:the-b-element-13><a href=text-level-semantics.html#the-b-element>b</a></code> element is removed from the <a href=#list-of-active-formatting-elements id=misnested-tags:-b-p-/b-/p:list-of-active-formatting-elements-3>list of active formatting elements</a>
|
||
and the <a href=#stack-of-open-elements id=misnested-tags:-b-p-/b-/p:stack-of-open-elements-2>stack of open elements</a>, so that when the "3" is parsed, it is appended to the
|
||
<code id=misnested-tags:-b-p-/b-/p:the-p-element-10><a href=grouping-content.html#the-p-element>p</a></code> element:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-html-element-6><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-head-element-5><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-body-element-7><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-b-element-14><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t3><code id=misnested-tags:-b-p-/b-/p:text-9><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>1</span></ul><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-p-element-11><a href=grouping-content.html#the-p-element>p</a></code><ul><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-b-element-15><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t3><code id=misnested-tags:-b-p-/b-/p:text-10><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>2</span></ul><li class=t3><code id=misnested-tags:-b-p-/b-/p:text-11><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>3</span></ul></ul></ul></ul>
|
||
|
||
|
||
<h5 id=unexpected-markup-in-tables><span class=secno>12.2.9.3</span> Unexpected markup in tables<a href=#unexpected-markup-in-tables class=self-link></a></h5>
|
||
|
||
<p><i>This section is non-normative.</i></p>
|
||
|
||
<p>Error handling in tables is, for historical reasons, especially strange. For example, consider
|
||
the following markup:</p>
|
||
|
||
<pre><table><strong><b></strong><tr><td>aaa</td></tr><strong>bbb</strong></table>ccc</pre>
|
||
|
||
<p>The highlighted <code id=unexpected-markup-in-tables:the-b-element><a href=text-level-semantics.html#the-b-element>b</a></code> element start tag is not allowed directly inside a table like
|
||
that, and the parser handles this case by placing the element <em>before</em> the table. (This is
|
||
called <i id=unexpected-markup-in-tables:foster-parent><a href=#foster-parent>foster parenting</a></i>.) This can be seen by examining the DOM tree
|
||
as it stands just after the <code id=unexpected-markup-in-tables:the-table-element><a href=tables.html#the-table-element>table</a></code> element's start tag has been seen:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=unexpected-markup-in-tables:the-html-element><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-head-element><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=unexpected-markup-in-tables:the-body-element><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-table-element-2><a href=tables.html#the-table-element>table</a></code></ul></ul></ul>
|
||
|
||
<p>...and then immediately after the <code id=unexpected-markup-in-tables:the-b-element-2><a href=text-level-semantics.html#the-b-element>b</a></code> element start tag has been seen:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=unexpected-markup-in-tables:the-html-element-2><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-head-element-2><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=unexpected-markup-in-tables:the-body-element-2><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-b-element-3><a href=text-level-semantics.html#the-b-element>b</a></code><li class=t1><code id=unexpected-markup-in-tables:the-table-element-3><a href=tables.html#the-table-element>table</a></code></ul></ul></ul>
|
||
|
||
<p>At this point, the <a href=#stack-of-open-elements id=unexpected-markup-in-tables:stack-of-open-elements>stack of open elements</a> has on it the elements
|
||
<code id=unexpected-markup-in-tables:the-html-element-3><a href=semantics.html#the-html-element>html</a></code>, <code id=unexpected-markup-in-tables:the-body-element-3><a href=sections.html#the-body-element>body</a></code>, <code id=unexpected-markup-in-tables:the-table-element-4><a href=tables.html#the-table-element>table</a></code>, and <code id=unexpected-markup-in-tables:the-b-element-4><a href=text-level-semantics.html#the-b-element>b</a></code> (in that order,
|
||
despite the resulting DOM tree); the <a href=#list-of-active-formatting-elements id=unexpected-markup-in-tables:list-of-active-formatting-elements>list of active formatting elements</a> just has the
|
||
<code id=unexpected-markup-in-tables:the-b-element-5><a href=text-level-semantics.html#the-b-element>b</a></code> element in it; and the <a href=#insertion-mode id=unexpected-markup-in-tables:insertion-mode>insertion mode</a> is "<a href=#parsing-main-intable id=unexpected-markup-in-tables:parsing-main-intable>in table</a>".</p>
|
||
|
||
<p>The <code id=unexpected-markup-in-tables:the-tr-element><a href=tables.html#the-tr-element>tr</a></code> start tag causes the <code id=unexpected-markup-in-tables:the-b-element-6><a href=text-level-semantics.html#the-b-element>b</a></code> element to be popped off the stack and
|
||
a <code id=unexpected-markup-in-tables:the-tbody-element><a href=tables.html#the-tbody-element>tbody</a></code> start tag to be implied; the <code id=unexpected-markup-in-tables:the-tbody-element-2><a href=tables.html#the-tbody-element>tbody</a></code> and <code id=unexpected-markup-in-tables:the-tr-element-2><a href=tables.html#the-tr-element>tr</a></code> elements
|
||
are then handled in a rather straight-forward manner, taking the parser through the "<a href=#parsing-main-intbody id=unexpected-markup-in-tables:parsing-main-intbody>in table body</a>" and "<a href=#parsing-main-intr id=unexpected-markup-in-tables:parsing-main-intr>in row</a>" insertion modes, after which the DOM looks as follows:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=unexpected-markup-in-tables:the-html-element-4><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-head-element-3><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=unexpected-markup-in-tables:the-body-element-4><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-b-element-7><a href=text-level-semantics.html#the-b-element>b</a></code><li class=t1><code id=unexpected-markup-in-tables:the-table-element-5><a href=tables.html#the-table-element>table</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-tbody-element-3><a href=tables.html#the-tbody-element>tbody</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-tr-element-3><a href=tables.html#the-tr-element>tr</a></code></ul></ul></ul></ul></ul>
|
||
|
||
<p>Here, the <a href=#stack-of-open-elements id=unexpected-markup-in-tables:stack-of-open-elements-2>stack of open elements</a> has on it the elements <code id=unexpected-markup-in-tables:the-html-element-5><a href=semantics.html#the-html-element>html</a></code>,
|
||
<code id=unexpected-markup-in-tables:the-body-element-5><a href=sections.html#the-body-element>body</a></code>, <code id=unexpected-markup-in-tables:the-table-element-6><a href=tables.html#the-table-element>table</a></code>, <code id=unexpected-markup-in-tables:the-tbody-element-4><a href=tables.html#the-tbody-element>tbody</a></code>, and <code id=unexpected-markup-in-tables:the-tr-element-4><a href=tables.html#the-tr-element>tr</a></code>; the <a href=#list-of-active-formatting-elements id=unexpected-markup-in-tables:list-of-active-formatting-elements-2>list of
|
||
active formatting elements</a> still has the <code id=unexpected-markup-in-tables:the-b-element-8><a href=text-level-semantics.html#the-b-element>b</a></code> element in it; and the
|
||
<a href=#insertion-mode id=unexpected-markup-in-tables:insertion-mode-2>insertion mode</a> is "<a href=#parsing-main-intr id=unexpected-markup-in-tables:parsing-main-intr-2>in row</a>".</p>
|
||
|
||
<p>The <code id=unexpected-markup-in-tables:the-td-element><a href=tables.html#the-td-element>td</a></code> element start tag token, after putting a <code id=unexpected-markup-in-tables:the-td-element-2><a href=tables.html#the-td-element>td</a></code> element on the
|
||
tree, puts a <a href=#concept-parser-marker id=unexpected-markup-in-tables:concept-parser-marker>marker</a> on the <a href=#list-of-active-formatting-elements id=unexpected-markup-in-tables:list-of-active-formatting-elements-3>list of active
|
||
formatting elements</a> (it also switches to the "<a href=#parsing-main-intd id=unexpected-markup-in-tables:parsing-main-intd>in
|
||
cell</a>" <a href=#insertion-mode id=unexpected-markup-in-tables:insertion-mode-3>insertion mode</a>).</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=unexpected-markup-in-tables:the-html-element-6><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-head-element-4><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=unexpected-markup-in-tables:the-body-element-6><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-b-element-9><a href=text-level-semantics.html#the-b-element>b</a></code><li class=t1><code id=unexpected-markup-in-tables:the-table-element-7><a href=tables.html#the-table-element>table</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-tbody-element-5><a href=tables.html#the-tbody-element>tbody</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-tr-element-5><a href=tables.html#the-tr-element>tr</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-td-element-3><a href=tables.html#the-td-element>td</a></code></ul></ul></ul></ul></ul></ul>
|
||
|
||
<p>The <a href=#concept-parser-marker id=unexpected-markup-in-tables:concept-parser-marker-2>marker</a> means that when the "aaa" character
|
||
tokens are seen, no <code id=unexpected-markup-in-tables:the-b-element-10><a href=text-level-semantics.html#the-b-element>b</a></code> element is created to hold the resulting <code id=unexpected-markup-in-tables:text><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code>
|
||
node:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=unexpected-markup-in-tables:the-html-element-7><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-head-element-5><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=unexpected-markup-in-tables:the-body-element-7><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-b-element-11><a href=text-level-semantics.html#the-b-element>b</a></code><li class=t1><code id=unexpected-markup-in-tables:the-table-element-8><a href=tables.html#the-table-element>table</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-tbody-element-6><a href=tables.html#the-tbody-element>tbody</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-tr-element-6><a href=tables.html#the-tr-element>tr</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-td-element-4><a href=tables.html#the-td-element>td</a></code><ul><li class=t3><code id=unexpected-markup-in-tables:text-2><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>aaa</span></ul></ul></ul></ul></ul></ul></ul>
|
||
|
||
<p>The end tags are handled in a straight-forward manner; after handling them, the <a href=#stack-of-open-elements id=unexpected-markup-in-tables:stack-of-open-elements-3>stack of
|
||
open elements</a> has on it the elements <code id=unexpected-markup-in-tables:the-html-element-8><a href=semantics.html#the-html-element>html</a></code>, <code id=unexpected-markup-in-tables:the-body-element-8><a href=sections.html#the-body-element>body</a></code>,
|
||
<code id=unexpected-markup-in-tables:the-table-element-9><a href=tables.html#the-table-element>table</a></code>, and <code id=unexpected-markup-in-tables:the-tbody-element-7><a href=tables.html#the-tbody-element>tbody</a></code>; the <a href=#list-of-active-formatting-elements id=unexpected-markup-in-tables:list-of-active-formatting-elements-4>list of active formatting elements</a>
|
||
still has the <code id=unexpected-markup-in-tables:the-b-element-12><a href=text-level-semantics.html#the-b-element>b</a></code> element in it (the <a href=#concept-parser-marker id=unexpected-markup-in-tables:concept-parser-marker-3>marker</a>
|
||
having been removed by the "td" end tag token); and the <a href=#insertion-mode id=unexpected-markup-in-tables:insertion-mode-4>insertion mode</a> is "<a href=#parsing-main-intbody id=unexpected-markup-in-tables:parsing-main-intbody-2>in table body</a>".</p>
|
||
|
||
<p>Thus it is that the "bbb" character tokens are found. These trigger the "<a href=#parsing-main-intabletext id=unexpected-markup-in-tables:parsing-main-intabletext>in table text</a>" insertion mode to be used (with the <a href=#original-insertion-mode id=unexpected-markup-in-tables:original-insertion-mode>original
|
||
insertion mode</a> set to "<a href=#parsing-main-intbody id=unexpected-markup-in-tables:parsing-main-intbody-3>in table body</a>").
|
||
The character tokens are collected, and when the next token (the <code id=unexpected-markup-in-tables:the-table-element-10><a href=tables.html#the-table-element>table</a></code> element end
|
||
tag) is seen, they are processed as a group. Since they are not all spaces, they are handled as
|
||
per the "anything else" rules in the "<a href=#parsing-main-intable id=unexpected-markup-in-tables:parsing-main-intable-2>in table</a>"
|
||
insertion mode, which defer to the "<a href=#parsing-main-inbody id=unexpected-markup-in-tables:parsing-main-inbody>in body</a>"
|
||
insertion mode but with <a href=#foster-parent id=unexpected-markup-in-tables:foster-parent-2>foster parenting</a>.</p>
|
||
|
||
<p>When <a href=#reconstruct-the-active-formatting-elements id=unexpected-markup-in-tables:reconstruct-the-active-formatting-elements>the active formatting elements
|
||
are reconstructed</a>, a <code id=unexpected-markup-in-tables:the-b-element-13><a href=text-level-semantics.html#the-b-element>b</a></code> element is created and <a href=#foster-parent id=unexpected-markup-in-tables:foster-parent-3>foster parented</a>, and then the "bbb" <code id=unexpected-markup-in-tables:text-3><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node is appended to it:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=unexpected-markup-in-tables:the-html-element-9><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-head-element-6><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=unexpected-markup-in-tables:the-body-element-9><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-b-element-14><a href=text-level-semantics.html#the-b-element>b</a></code><li class=t1><code id=unexpected-markup-in-tables:the-b-element-15><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t3><code id=unexpected-markup-in-tables:text-4><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>bbb</span></ul><li class=t1><code id=unexpected-markup-in-tables:the-table-element-11><a href=tables.html#the-table-element>table</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-tbody-element-8><a href=tables.html#the-tbody-element>tbody</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-tr-element-7><a href=tables.html#the-tr-element>tr</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-td-element-5><a href=tables.html#the-td-element>td</a></code><ul><li class=t3><code id=unexpected-markup-in-tables:text-5><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>aaa</span></ul></ul></ul></ul></ul></ul></ul>
|
||
|
||
<p>The <a href=#stack-of-open-elements id=unexpected-markup-in-tables:stack-of-open-elements-4>stack of open elements</a> has on it the elements <code id=unexpected-markup-in-tables:the-html-element-10><a href=semantics.html#the-html-element>html</a></code>,
|
||
<code id=unexpected-markup-in-tables:the-body-element-10><a href=sections.html#the-body-element>body</a></code>, <code id=unexpected-markup-in-tables:the-table-element-12><a href=tables.html#the-table-element>table</a></code>, <code id=unexpected-markup-in-tables:the-tbody-element-9><a href=tables.html#the-tbody-element>tbody</a></code>, and the new <code id=unexpected-markup-in-tables:the-b-element-16><a href=text-level-semantics.html#the-b-element>b</a></code> (again, note
|
||
that this doesn't match the resulting tree!); the <a href=#list-of-active-formatting-elements id=unexpected-markup-in-tables:list-of-active-formatting-elements-5>list of active formatting elements</a>
|
||
has the new <code id=unexpected-markup-in-tables:the-b-element-17><a href=text-level-semantics.html#the-b-element>b</a></code> element in it; and the <a href=#insertion-mode id=unexpected-markup-in-tables:insertion-mode-5>insertion mode</a> is still "<a href=#parsing-main-intbody id=unexpected-markup-in-tables:parsing-main-intbody-4>in table body</a>".</p>
|
||
|
||
<p>Had the character tokens been only <a id=unexpected-markup-in-tables:space-characters href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a> instead of "bbb", then that
|
||
<a id=unexpected-markup-in-tables:space-characters-2 href=https://infra.spec.whatwg.org/#ascii-whitespace data-x-internal=space-characters>ASCII whitespace</a> would just be appended to the <code id=unexpected-markup-in-tables:the-tbody-element-10><a href=tables.html#the-tbody-element>tbody</a></code> element.</p>
|
||
|
||
<p>Finally, the <code id=unexpected-markup-in-tables:the-table-element-13><a href=tables.html#the-table-element>table</a></code> is closed by a "table" end tag. This pops all the nodes from
|
||
the <a href=#stack-of-open-elements id=unexpected-markup-in-tables:stack-of-open-elements-5>stack of open elements</a> up to and including the <code id=unexpected-markup-in-tables:the-table-element-14><a href=tables.html#the-table-element>table</a></code> element, but it
|
||
doesn't affect the <a href=#list-of-active-formatting-elements id=unexpected-markup-in-tables:list-of-active-formatting-elements-6>list of active formatting elements</a>, so the "ccc" character tokens
|
||
after the table result in yet another <code id=unexpected-markup-in-tables:the-b-element-18><a href=text-level-semantics.html#the-b-element>b</a></code> element being created, this time after the
|
||
table:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=unexpected-markup-in-tables:the-html-element-11><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-head-element-7><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=unexpected-markup-in-tables:the-body-element-11><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-b-element-19><a href=text-level-semantics.html#the-b-element>b</a></code><li class=t1><code id=unexpected-markup-in-tables:the-b-element-20><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t3><code id=unexpected-markup-in-tables:text-6><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>bbb</span></ul><li class=t1><code id=unexpected-markup-in-tables:the-table-element-15><a href=tables.html#the-table-element>table</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-tbody-element-11><a href=tables.html#the-tbody-element>tbody</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-tr-element-8><a href=tables.html#the-tr-element>tr</a></code><ul><li class=t1><code id=unexpected-markup-in-tables:the-td-element-6><a href=tables.html#the-td-element>td</a></code><ul><li class=t3><code id=unexpected-markup-in-tables:text-7><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>aaa</span></ul></ul></ul></ul><li class=t1><code id=unexpected-markup-in-tables:the-b-element-21><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t3><code id=unexpected-markup-in-tables:text-8><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>ccc</span></ul></ul></ul></ul>
|
||
|
||
|
||
<h5 id=scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>12.2.9.4</span> Scripts that modify the page as it is being parsed<a href=#scripts-that-modify-the-page-as-it-is-being-parsed class=self-link></a></h5>
|
||
|
||
<p><i>This section is non-normative.</i></p>
|
||
|
||
<p>Consider the following markup, which for this example we will assume is the document with
|
||
<a id=scripts-that-modify-the-page-as-it-is-being-parsed:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> <code>https://example.com/inner</code>, being rendered as the content of
|
||
an <code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-iframe-element><a href=iframe-embed-object.html#the-iframe-element>iframe</a></code> in another document with the <a id=scripts-that-modify-the-page-as-it-is-being-parsed:url-2 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> <code>https://example.com/outer</code>:</p>
|
||
|
||
<pre><div id=a>
|
||
<script>
|
||
var div = document.getElementById('a');
|
||
parent.document.body.appendChild(div);
|
||
</script>
|
||
<script>
|
||
alert(document.URL);
|
||
</script>
|
||
</div>
|
||
<script>
|
||
alert(document.URL);
|
||
</script></pre>
|
||
|
||
<p>Up to the first "script" end tag, before the script is parsed, the result is relatively
|
||
straightforward:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-html-element><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-head-element><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-body-element><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-div-element><a href=grouping-content.html#the-div-element>div</a></code> <span class=t2><code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-id-attribute class="attribute name"><a href=dom.html#the-id-attribute>id</a></code>="<code class="attribute value">a</code>"</span><ul><li class=t3><code id=scripts-that-modify-the-page-as-it-is-being-parsed:text><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>
|
||
</span><li class=t1><code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-script-element><a href=scripting.html#the-script-element>script</a></code><ul><li class=t3><code id=scripts-that-modify-the-page-as-it-is-being-parsed:text-2><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>var div = document.getElementById('a'); ⏎ parent.document.body.appendChild(div);</span></ul></ul></ul></ul></ul>
|
||
|
||
<p>After the script is parsed, though, the <code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-div-element-2><a href=grouping-content.html#the-div-element>div</a></code> element and its child
|
||
<code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-script-element-2><a href=scripting.html#the-script-element>script</a></code> element are gone:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-html-element-2><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-head-element-2><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-body-element-2><a href=sections.html#the-body-element>body</a></code></ul></ul>
|
||
|
||
<p>They are, at this point, in the <code id=scripts-that-modify-the-page-as-it-is-being-parsed:document><a href=dom.html#document>Document</a></code> of the aforementioned outer
|
||
<a id=scripts-that-modify-the-page-as-it-is-being-parsed:browsing-context href=browsers.html#browsing-context>browsing context</a>. However, the <a href=#stack-of-open-elements id=scripts-that-modify-the-page-as-it-is-being-parsed:stack-of-open-elements>stack of open elements</a> <em>still contains
|
||
the <code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-div-element-3><a href=grouping-content.html#the-div-element>div</a></code> element</em>.</p>
|
||
|
||
<p>Thus, when the second <code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-script-element-3><a href=scripting.html#the-script-element>script</a></code> element is parsed, it is inserted <em>into the outer
|
||
<code id=scripts-that-modify-the-page-as-it-is-being-parsed:document-2><a href=dom.html#document>Document</a></code> object</em>.</p>
|
||
|
||
<p>Those parsed into different <code id=scripts-that-modify-the-page-as-it-is-being-parsed:document-3><a href=dom.html#document>Document</a></code>s than the one the parser was created for do
|
||
not execute, so the first alert does not show.</p>
|
||
|
||
<p>Once the <code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-div-element-4><a href=grouping-content.html#the-div-element>div</a></code> element's end tag is parsed, the <code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-div-element-5><a href=grouping-content.html#the-div-element>div</a></code> element is popped
|
||
off the stack, and so the next <code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-script-element-4><a href=scripting.html#the-script-element>script</a></code> element is in the inner
|
||
<code id=scripts-that-modify-the-page-as-it-is-being-parsed:document-4><a href=dom.html#document>Document</a></code>:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-html-element-3><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-head-element-3><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-body-element-3><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=scripts-that-modify-the-page-as-it-is-being-parsed:the-script-element-5><a href=scripting.html#the-script-element>script</a></code><ul><li class=t3><code id=scripts-that-modify-the-page-as-it-is-being-parsed:text-3><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>alert(document.URL);</span></ul></ul></ul></ul>
|
||
|
||
<p>This script does execute, resulting in an alert that says "https://example.com/inner".</p>
|
||
|
||
|
||
<h5 id=the-execution-of-scripts-that-are-moving-across-multiple-documents><span class=secno>12.2.9.5</span> The execution of scripts that are moving across multiple documents<a href=#the-execution-of-scripts-that-are-moving-across-multiple-documents class=self-link></a></h5>
|
||
|
||
<p><i>This section is non-normative.</i></p>
|
||
|
||
<p>Elaborating on the example in the previous section, consider the case where the second
|
||
<code id=the-execution-of-scripts-that-are-moving-across-multiple-documents:the-script-element><a href=scripting.html#the-script-element>script</a></code> element is an external script (i.e. one with a <code id=the-execution-of-scripts-that-are-moving-across-multiple-documents:attr-script-src><a href=scripting.html#attr-script-src>src</a></code> attribute). Since the element was not in the parser's
|
||
<code id=the-execution-of-scripts-that-are-moving-across-multiple-documents:document><a href=dom.html#document>Document</a></code> when it was created, that external script is not even downloaded.</p>
|
||
|
||
<p>In a case where a <code id=the-execution-of-scripts-that-are-moving-across-multiple-documents:the-script-element-2><a href=scripting.html#the-script-element>script</a></code> element with a <code id=the-execution-of-scripts-that-are-moving-across-multiple-documents:attr-script-src-2><a href=scripting.html#attr-script-src>src</a></code>
|
||
attribute is parsed normally into its parser's <code id=the-execution-of-scripts-that-are-moving-across-multiple-documents:document-2><a href=dom.html#document>Document</a></code>, but while the external
|
||
script is being downloaded, the element is moved to another document, the script continues to
|
||
download, but does not execute.</p>
|
||
|
||
<p class=note>In general, moving <code id=the-execution-of-scripts-that-are-moving-across-multiple-documents:the-script-element-3><a href=scripting.html#the-script-element>script</a></code> elements between <code id=the-execution-of-scripts-that-are-moving-across-multiple-documents:document-3><a href=dom.html#document>Document</a></code>s is
|
||
considered a bad practice.</p>
|
||
|
||
|
||
|
||
<h5 id=unclosed-formatting-elements><span class=secno>12.2.9.6</span> Unclosed formatting elements<a href=#unclosed-formatting-elements class=self-link></a></h5>
|
||
|
||
<p><i>This section is non-normative.</i></p>
|
||
|
||
<p>The following markup shows how nested formatting elements (such as <code id=unclosed-formatting-elements:the-b-element><a href=text-level-semantics.html#the-b-element>b</a></code>) get
|
||
collected and continue to be applied even as the elements they are contained in are closed, but
|
||
that excessive duplicates are thrown away.</p>
|
||
|
||
<pre><!DOCTYPE html>
|
||
<p><b class=x><b class=x><b><b class=x><b class=x><b>X
|
||
<p>X
|
||
<p><b><b class=x><b>X
|
||
<p></b></b></b></b></b></b>X</pre>
|
||
|
||
<p>The resulting DOM tree is as follows:</p>
|
||
|
||
<ul class=domTree><li class=t10>DOCTYPE: <code>html</code><li class=t1><code id=unclosed-formatting-elements:the-html-element><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=unclosed-formatting-elements:the-head-element><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=unclosed-formatting-elements:the-body-element><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=unclosed-formatting-elements:the-p-element><a href=grouping-content.html#the-p-element>p</a></code><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-2><a href=text-level-semantics.html#the-b-element>b</a></code> <span class=t2><code id=unclosed-formatting-elements:classes class="attribute name"><a href=dom.html#classes>class</a></code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-3><a href=text-level-semantics.html#the-b-element>b</a></code> <span class=t2><code id=unclosed-formatting-elements:classes-2 class="attribute name"><a href=dom.html#classes>class</a></code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-4><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-5><a href=text-level-semantics.html#the-b-element>b</a></code> <span class=t2><code id=unclosed-formatting-elements:classes-3 class="attribute name"><a href=dom.html#classes>class</a></code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-6><a href=text-level-semantics.html#the-b-element>b</a></code> <span class=t2><code id=unclosed-formatting-elements:classes-4 class="attribute name"><a href=dom.html#classes>class</a></code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-7><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t3><code id=unclosed-formatting-elements:text><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>X⏎</span></ul></ul></ul></ul></ul></ul></ul><li class=t1><code id=unclosed-formatting-elements:the-p-element-2><a href=grouping-content.html#the-p-element>p</a></code><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-8><a href=text-level-semantics.html#the-b-element>b</a></code> <span class=t2><code id=unclosed-formatting-elements:classes-5 class="attribute name"><a href=dom.html#classes>class</a></code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-9><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-10><a href=text-level-semantics.html#the-b-element>b</a></code> <span class=t2><code id=unclosed-formatting-elements:classes-6 class="attribute name"><a href=dom.html#classes>class</a></code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-11><a href=text-level-semantics.html#the-b-element>b</a></code> <span class=t2><code id=unclosed-formatting-elements:classes-7 class="attribute name"><a href=dom.html#classes>class</a></code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-12><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t3><code id=unclosed-formatting-elements:text-2><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>X⏎</span></ul></ul></ul></ul></ul></ul><li class=t1><code id=unclosed-formatting-elements:the-p-element-3><a href=grouping-content.html#the-p-element>p</a></code><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-13><a href=text-level-semantics.html#the-b-element>b</a></code> <span class=t2><code id=unclosed-formatting-elements:classes-8 class="attribute name"><a href=dom.html#classes>class</a></code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-14><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-15><a href=text-level-semantics.html#the-b-element>b</a></code> <span class=t2><code id=unclosed-formatting-elements:classes-9 class="attribute name"><a href=dom.html#classes>class</a></code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-16><a href=text-level-semantics.html#the-b-element>b</a></code> <span class=t2><code id=unclosed-formatting-elements:classes-10 class="attribute name"><a href=dom.html#classes>class</a></code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-17><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-18><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-19><a href=text-level-semantics.html#the-b-element>b</a></code> <span class=t2><code id=unclosed-formatting-elements:classes-11 class="attribute name"><a href=dom.html#classes>class</a></code>="<code class="attribute value">x</code>"</span><ul><li class=t1><code id=unclosed-formatting-elements:the-b-element-20><a href=text-level-semantics.html#the-b-element>b</a></code><ul><li class=t3><code id=unclosed-formatting-elements:text-3><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>X⏎</span></ul></ul></ul></ul></ul></ul></ul></ul></ul><li class=t1><code id=unclosed-formatting-elements:the-p-element-4><a href=grouping-content.html#the-p-element>p</a></code><ul><li class=t3><code id=unclosed-formatting-elements:text-4><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>#text</a></code>: <span>X⏎</span></ul></ul></ul></ul>
|
||
|
||
<p>Note how the second <code id=unclosed-formatting-elements:the-p-element-5><a href=grouping-content.html#the-p-element>p</a></code> element in the markup has no explicit <code id=unclosed-formatting-elements:the-b-element-21><a href=text-level-semantics.html#the-b-element>b</a></code>
|
||
elements, but in the resulting DOM, up to three of each kind of formatting element (in this case
|
||
three <code id=unclosed-formatting-elements:the-b-element-22><a href=text-level-semantics.html#the-b-element>b</a></code> elements with the class attribute, and two unadorned <code id=unclosed-formatting-elements:the-b-element-23><a href=text-level-semantics.html#the-b-element>b</a></code> elements)
|
||
get reconstructed before the element's "X".</p>
|
||
|
||
<p>Also note how this means that in the final paragraph only six <code id=unclosed-formatting-elements:the-b-element-24><a href=text-level-semantics.html#the-b-element>b</a></code> end tags are
|
||
needed to completely clear the <a href=#list-of-active-formatting-elements id=unclosed-formatting-elements:list-of-active-formatting-elements>list of active formatting elements</a>, even though nine
|
||
<code id=unclosed-formatting-elements:the-b-element-25><a href=text-level-semantics.html#the-b-element>b</a></code> start tags have been seen up to this point.</p>
|
||
|
||
|
||
|
||
|
||
|
||
<h3 id=serialising-html-fragments><span class=secno>12.3</span> Serializing HTML fragments<a href=#serialising-html-fragments class=self-link></a></h3>
|
||
|
||
<p>The following steps form the <dfn data-export="" id=html-fragment-serialisation-algorithm>HTML fragment serialization algorithm</dfn>. The algorithm takes as input a DOM
|
||
<code id=serialising-html-fragments:element><a data-x-internal=element href=https://dom.spec.whatwg.org/#interface-element>Element</a></code>, <code id=serialising-html-fragments:document><a href=dom.html#document>Document</a></code>, or <code id=serialising-html-fragments:documentfragment><a data-x-internal=documentfragment href=https://dom.spec.whatwg.org/#interface-documentfragment>DocumentFragment</a></code> referred to as
|
||
<var>the node</var>, and returns a string.</p>
|
||
|
||
<p class=note>This algorithm serializes the <em>children</em> of the node being serialized, not
|
||
the node itself.</p>
|
||
|
||
<ol><li><p>Let <var>s</var> be a string, and initialize it to the empty string.<li><p>If <var>the node</var> is a <code id=serialising-html-fragments:the-template-element><a href=scripting.html#the-template-element>template</a></code> element, then let <var>the node</var> instead be the <code id=serialising-html-fragments:the-template-element-2><a href=scripting.html#the-template-element>template</a></code> element's <a id=serialising-html-fragments:template-contents href=scripting.html#template-contents>template
|
||
contents</a> (a <code id=serialising-html-fragments:documentfragment-2><a data-x-internal=documentfragment href=https://dom.spec.whatwg.org/#interface-documentfragment>DocumentFragment</a></code> node).<li>
|
||
|
||
<p>For each child node of <var>the node</var>, in <a id=serialising-html-fragments:tree-order href=https://dom.spec.whatwg.org/#concept-tree-order data-x-internal=tree-order>tree order</a>, run the
|
||
following steps:
|
||
|
||
<ol><li><p>Let <var>current node</var> be the child node being processed.<li>
|
||
|
||
<p>Append the appropriate string from the following list to <var>s</var>:</p>
|
||
|
||
<dl class=switch><dt>If <var>current node</var> is an <code>Element</code><dd>
|
||
|
||
<p>If <var>current node</var> is an element in the <a id=serialising-html-fragments:html-namespace-2 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a>, the
|
||
<a id=serialising-html-fragments:mathml-namespace href=https://infra.spec.whatwg.org/#mathml-namespace data-x-internal=mathml-namespace>MathML namespace</a>, or the <a id=serialising-html-fragments:svg-namespace href=https://infra.spec.whatwg.org/#svg-namespace data-x-internal=svg-namespace>SVG namespace</a>, then let <var>tagname</var> be <var>current node</var>'s local name. Otherwise, let <var>tagname</var> be <var>current node</var>'s qualified name.</p>
|
||
|
||
<p>Append a U+003C LESS-THAN SIGN character (<), followed by <var>tagname</var>.</p>
|
||
|
||
<p class=note>For <a id=serialising-html-fragments:html-elements href=infrastructure.html#html-elements>HTML elements</a> created by the <a href=#html-parser id=serialising-html-fragments:html-parser>HTML parser</a> or
|
||
<code id=serialising-html-fragments:dom-document-createelement><a data-x-internal=dom-document-createelement href=https://dom.spec.whatwg.org/#dom-document-createelement>createElement()</a></code>, <var>tagname</var> will be
|
||
lowercase.</p>
|
||
|
||
<p>For each attribute that the element has, append a U+0020 SPACE character, the <a href="#attribute's-serialised-name" id="serialising-html-fragments:attribute's-serialised-name">attribute's serialized name as described below</a>, a
|
||
U+003D EQUALS SIGN character (=), a U+0022 QUOTATION MARK character ("), the
|
||
attribute's value, <a href=#escapingString id=serialising-html-fragments:escapingString>escaped as described below</a> in
|
||
<i>attribute mode</i>, and a second U+0022 QUOTATION MARK character (").</p>
|
||
|
||
<p>An <dfn id="attribute's-serialised-name">attribute's serialized name</dfn>
|
||
for the purposes of the previous paragraph must be determined as follows:</p>
|
||
|
||
<dl class=switch><dt>If the attribute has no namespace<dd>
|
||
|
||
<p>The attribute's serialized name is the attribute's local name.</p>
|
||
|
||
<p class=note>For attributes on <a id=serialising-html-fragments:html-elements-2 href=infrastructure.html#html-elements>HTML elements</a> set by the <a href=#html-parser id=serialising-html-fragments:html-parser-2>HTML
|
||
parser</a> or by <code>Element.setAttribute()</code>, the local name will be
|
||
lowercase.</p>
|
||
|
||
<dt>If the attribute is in the <a id=serialising-html-fragments:xml-namespace href=https://infra.spec.whatwg.org/#xml-namespace data-x-internal=xml-namespace>XML namespace</a><dd><p>The attribute's serialized name is the string "<code>xml:</code>" followed
|
||
by the attribute's local name.<dt>If the attribute is in the <a id=serialising-html-fragments:xmlns-namespace href=https://infra.spec.whatwg.org/#xmlns-namespace data-x-internal=xmlns-namespace>XMLNS namespace</a> and the attribute's local name
|
||
is <code>xmlns</code><dd><p>The attribute's serialized name is the string "<code>xmlns</code>".<dt>If the attribute is in the <a id=serialising-html-fragments:xmlns-namespace-2 href=https://infra.spec.whatwg.org/#xmlns-namespace data-x-internal=xmlns-namespace>XMLNS namespace</a> and the attribute's local name
|
||
is not <code>xmlns</code><dd><p>The attribute's serialized name is the string "<code>xmlns:</code>"
|
||
followed by the attribute's local name.<dt>If the attribute is in the <a id=serialising-html-fragments:xlink-namespace href=https://infra.spec.whatwg.org/#xlink-namespace data-x-internal=xlink-namespace>XLink namespace</a><dd><p>The attribute's serialized name is the string "<code>xlink:</code>"
|
||
followed by the attribute's local name.<dt>If the attribute is in some other namespace<dd><p>The attribute's serialized name is the attribute's qualified name.</dl>
|
||
|
||
<p>While the exact order of attributes is UA-defined, and may depend on factors such as the
|
||
order that the attributes were given in the original markup, the sort order must be stable,
|
||
such that consecutive invocations of this algorithm serialize an element's attributes in the
|
||
same order.</p>
|
||
|
||
<p>Append a U+003E GREATER-THAN SIGN character (>).</p>
|
||
|
||
<p>If <var>current node</var> is an <code id=serialising-html-fragments:the-area-element><a href=image-maps.html#the-area-element>area</a></code>, <code id=serialising-html-fragments:the-base-element><a href=semantics.html#the-base-element>base</a></code>,
|
||
<code id=serialising-html-fragments:basefont><a href=obsolete.html#basefont>basefont</a></code>, <code id=serialising-html-fragments:bgsound><a href=obsolete.html#bgsound>bgsound</a></code>, <code id=serialising-html-fragments:the-br-element><a href=text-level-semantics.html#the-br-element>br</a></code>, <code id=serialising-html-fragments:the-col-element><a href=tables.html#the-col-element>col</a></code>,
|
||
<code id=serialising-html-fragments:the-embed-element><a href=iframe-embed-object.html#the-embed-element>embed</a></code>, <code id=serialising-html-fragments:frame><a href=obsolete.html#frame>frame</a></code>, <code id=serialising-html-fragments:the-hr-element><a href=grouping-content.html#the-hr-element>hr</a></code>, <code id=serialising-html-fragments:the-img-element><a href=embedded-content.html#the-img-element>img</a></code>,
|
||
<code id=serialising-html-fragments:the-input-element><a href=input.html#the-input-element>input</a></code>, <code id=serialising-html-fragments:keygen><a href=obsolete.html#keygen>keygen</a></code>, <code id=serialising-html-fragments:the-link-element><a href=semantics.html#the-link-element>link</a></code>, <code id=serialising-html-fragments:the-meta-element><a href=semantics.html#the-meta-element>meta</a></code>,
|
||
<code id=serialising-html-fragments:the-param-element><a href=iframe-embed-object.html#the-param-element>param</a></code>, <code id=serialising-html-fragments:the-source-element><a href=embedded-content.html#the-source-element>source</a></code>, <code id=serialising-html-fragments:the-track-element><a href=media.html#the-track-element>track</a></code> or <code id=serialising-html-fragments:the-wbr-element><a href=text-level-semantics.html#the-wbr-element>wbr</a></code> element,
|
||
then continue on to the next child node at this point.</p>
|
||
|
||
|
||
|
||
<p>Append the value of running the <a href=#html-fragment-serialisation-algorithm id=serialising-html-fragments:html-fragment-serialisation-algorithm>HTML fragment serialization algorithm</a> on the
|
||
<var>current node</var> element (thus recursing into this algorithm for that
|
||
element), followed by a U+003C LESS-THAN SIGN character (<), a U+002F SOLIDUS character
|
||
(/), <var>tagname</var> again, and finally a U+003E GREATER-THAN SIGN character
|
||
(>).</p>
|
||
|
||
<dt>If <var>current node</var> is a <code>Text</code> node<dd>
|
||
|
||
<p>If the parent of <var>current node</var> is a <code id=serialising-html-fragments:the-style-element><a href=semantics.html#the-style-element>style</a></code>,
|
||
<code id=serialising-html-fragments:the-script-element><a href=scripting.html#the-script-element>script</a></code>, <code id=serialising-html-fragments:xmp><a href=obsolete.html#xmp>xmp</a></code>, <code id=serialising-html-fragments:the-iframe-element><a href=iframe-embed-object.html#the-iframe-element>iframe</a></code>, <code id=serialising-html-fragments:noembed><a href=obsolete.html#noembed>noembed</a></code>,
|
||
<code id=serialising-html-fragments:noframes><a href=obsolete.html#noframes>noframes</a></code>, or <code id=serialising-html-fragments:plaintext><a href=obsolete.html#plaintext>plaintext</a></code> element, or if the parent of <var>current node</var> is a <code id=serialising-html-fragments:the-noscript-element><a href=scripting.html#the-noscript-element>noscript</a></code> element and <a href=webappapis.html#concept-n-script id=serialising-html-fragments:concept-n-script>scripting is enabled</a> for the node, then append the value of
|
||
<var>current node</var>'s <code>data</code> IDL attribute literally.</p>
|
||
|
||
<p>Otherwise, append the value of <var>current node</var>'s <code>data</code> IDL attribute, <a href=#escapingString id=serialising-html-fragments:escapingString-2>escaped as described
|
||
below</a>.</p>
|
||
|
||
<dt>If <var>current node</var> is a <code>Comment</code><dd>
|
||
|
||
<p>Append the literal string "<code><!--</code>" (U+003C LESS-THAN SIGN, U+0021
|
||
EXCLAMATION MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS), followed by the value of <var>current node</var>'s <code>data</code> IDL attribute, followed by the
|
||
literal string "<code>--></code>" (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS,
|
||
U+003E GREATER-THAN SIGN).</p>
|
||
|
||
<dt>If <var>current node</var> is a <code>ProcessingInstruction</code><dd>
|
||
|
||
<p>Append the literal string "<code><?</code>" (U+003C LESS-THAN SIGN, U+003F
|
||
QUESTION MARK), followed by the value of <var>current node</var>'s <code>target</code> IDL attribute, followed by a single U+0020 SPACE character, followed
|
||
by the value of <var>current node</var>'s <code>data</code> IDL
|
||
attribute, followed by a single U+003E GREATER-THAN SIGN character (>).</p>
|
||
|
||
<dt>If <var>current node</var> is a <code>DocumentType</code><dd>
|
||
|
||
<p>Append the literal string "<code><!DOCTYPE</code>" (U+003C LESS-THAN SIGN, U+0021
|
||
EXCLAMATION MARK, U+0044 LATIN CAPITAL LETTER D, U+004F LATIN CAPITAL LETTER O, U+0043 LATIN
|
||
CAPITAL LETTER C, U+0054 LATIN CAPITAL LETTER T, U+0059 LATIN CAPITAL LETTER Y, U+0050 LATIN
|
||
CAPITAL LETTER P, U+0045 LATIN CAPITAL LETTER E), followed by a space (U+0020 SPACE),
|
||
followed by the value of <var>current node</var>'s <code>name</code> IDL
|
||
attribute, followed by the literal string "<code>></code>" (U+003E GREATER-THAN SIGN).</p>
|
||
|
||
</dl>
|
||
|
||
</ol>
|
||
|
||
<li><p>The result of the algorithm is the string <var>s</var>.</ol>
|
||
|
||
<p class=warning>It is possible that the output of this algorithm, if parsed with an <a href=#html-parser id=serialising-html-fragments:html-parser-3>HTML
|
||
parser</a>, will not return the original tree structure. Tree structures that do not roundtrip
|
||
a serialize and reparse step can also be produced by the <a href=#html-parser id=serialising-html-fragments:html-parser-4>HTML parser</a> itself, although
|
||
such cases are typically non-conforming.</p>
|
||
|
||
<div class=example>
|
||
|
||
<p>For instance, if a <code id=serialising-html-fragments:the-textarea-element><a href=form-elements.html#the-textarea-element>textarea</a></code> element to which a <code>Comment</code>
|
||
node has been appended is serialized and the output is then reparsed, the comment will end up
|
||
being displayed in the text control. Similarly, if, as a result of DOM manipulation, an element
|
||
contains a comment that contains the literal string "<code>--></code>", then when
|
||
the result of serializing the element is parsed, the comment will be truncated at that point and
|
||
the rest of the comment will be interpreted as markup. More examples would be making a
|
||
<code id=serialising-html-fragments:the-script-element-2><a href=scripting.html#the-script-element>script</a></code> element contain a <code id=serialising-html-fragments:text><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node with the text string "<code></script></code>", or having a <code id=serialising-html-fragments:the-p-element><a href=grouping-content.html#the-p-element>p</a></code> element that contains a
|
||
<code id=serialising-html-fragments:the-ul-element><a href=grouping-content.html#the-ul-element>ul</a></code> element (as the <code id=serialising-html-fragments:the-ul-element-2><a href=grouping-content.html#the-ul-element>ul</a></code> element's <a href=syntax.html#syntax-start-tag id=serialising-html-fragments:syntax-start-tag>start
|
||
tag</a> would imply the end tag for the <code id=serialising-html-fragments:the-p-element-2><a href=grouping-content.html#the-p-element>p</a></code>).</p>
|
||
|
||
<p>This can enable cross-site scripting attacks. An example of this would be a page that lets the
|
||
user enter some font family names that are then inserted into a CSS <code id=serialising-html-fragments:the-style-element-2><a href=semantics.html#the-style-element>style</a></code> block via
|
||
the DOM and which then uses the <code id=serialising-html-fragments:dom-innerhtml><a data-x-internal=dom-innerhtml href=https://w3c.github.io/DOM-Parsing/#widl-Element-innerHTML>innerHTML</a></code> IDL attribute to get
|
||
the HTML serialization of that <code id=serialising-html-fragments:the-style-element-3><a href=semantics.html#the-style-element>style</a></code> element: if the user enters
|
||
"<code></style><script>attack</script></code>" as a font family name, <code id=serialising-html-fragments:dom-innerhtml-2><a data-x-internal=dom-innerhtml href=https://w3c.github.io/DOM-Parsing/#widl-Element-innerHTML>innerHTML</a></code> will return markup that, if parsed in a different context,
|
||
would contain a <code id=serialising-html-fragments:the-script-element-3><a href=scripting.html#the-script-element>script</a></code> node, even though no <code id=serialising-html-fragments:the-script-element-4><a href=scripting.html#the-script-element>script</a></code> node existed in the
|
||
original DOM.</p>
|
||
|
||
</div>
|
||
|
||
<div class=example>
|
||
|
||
<p>For example, consider the following markup:</p>
|
||
|
||
<pre><form id="outer"><div></form><form id="inner"><input></pre>
|
||
|
||
<p>This will be parsed into:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=serialising-html-fragments:the-html-element><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=serialising-html-fragments:the-head-element><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=serialising-html-fragments:the-body-element><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=serialising-html-fragments:the-form-element><a href=forms.html#the-form-element>form</a></code> <span class=t2><code id=serialising-html-fragments:the-id-attribute class="attribute name"><a href=dom.html#the-id-attribute>id</a></code>="<code class="attribute value">outer</code>"</span><ul><li class=t1><code id=serialising-html-fragments:the-div-element><a href=grouping-content.html#the-div-element>div</a></code><ul><li class=t1><code id=serialising-html-fragments:the-form-element-2><a href=forms.html#the-form-element>form</a></code> <span class=t2><code id=serialising-html-fragments:the-id-attribute-2 class="attribute name"><a href=dom.html#the-id-attribute>id</a></code>="<code class="attribute value">inner</code>"</span><ul><li class=t1><code id=serialising-html-fragments:the-input-element-2><a href=input.html#the-input-element>input</a></code></ul></ul></ul></ul></ul></ul>
|
||
|
||
<p>The <code id=serialising-html-fragments:the-input-element-3><a href=input.html#the-input-element>input</a></code> element will be associated with the inner <code id=serialising-html-fragments:the-form-element-3><a href=forms.html#the-form-element>form</a></code> element.
|
||
Now, if this tree structure is serialized and reparsed, the <code><form
|
||
id="inner"></code> start tag will be ignored, and so the <code id=serialising-html-fragments:the-input-element-4><a href=input.html#the-input-element>input</a></code> element will be
|
||
associated with the outer <code id=serialising-html-fragments:the-form-element-4><a href=forms.html#the-form-element>form</a></code> element instead.</p>
|
||
|
||
<pre><html><head></head><body><form id="outer"><div><mark><form id="inner"></mark><input></form></div></form></body></html></pre>
|
||
|
||
<ul class=domTree><li class=t1><code id=serialising-html-fragments:the-html-element-2><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=serialising-html-fragments:the-head-element-2><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=serialising-html-fragments:the-body-element-2><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=serialising-html-fragments:the-form-element-5><a href=forms.html#the-form-element>form</a></code> <span class=t2><code id=serialising-html-fragments:the-id-attribute-3 class="attribute name"><a href=dom.html#the-id-attribute>id</a></code>="<code class="attribute value">outer</code>"</span><ul><li class=t1><code id=serialising-html-fragments:the-div-element-2><a href=grouping-content.html#the-div-element>div</a></code><ul><li class=t1><code id=serialising-html-fragments:the-input-element-5><a href=input.html#the-input-element>input</a></code></ul></ul></ul></ul></ul>
|
||
|
||
</div>
|
||
|
||
<div class=example>
|
||
|
||
<p>As another example, consider the following markup:</p>
|
||
|
||
<pre><a><table><a></pre>
|
||
|
||
<p>This will be parsed into:</p>
|
||
|
||
<ul class=domTree><li class=t1><code id=serialising-html-fragments:the-html-element-3><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=serialising-html-fragments:the-head-element-3><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=serialising-html-fragments:the-body-element-3><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=serialising-html-fragments:the-a-element><a href=text-level-semantics.html#the-a-element>a</a></code><ul><li class=t1><code id=serialising-html-fragments:the-a-element-2><a href=text-level-semantics.html#the-a-element>a</a></code><li class=t1><code id=serialising-html-fragments:the-table-element><a href=tables.html#the-table-element>table</a></code></ul></ul></ul></ul>
|
||
|
||
<p>That is, the <code id=serialising-html-fragments:the-a-element-3><a href=text-level-semantics.html#the-a-element>a</a></code> elements are nested, because the second <code id=serialising-html-fragments:the-a-element-4><a href=text-level-semantics.html#the-a-element>a</a></code> element is
|
||
<a href=#foster-parent id=serialising-html-fragments:foster-parent>foster parented</a>. After a serialize-reparse roundtrip, the
|
||
<code id=serialising-html-fragments:the-a-element-5><a href=text-level-semantics.html#the-a-element>a</a></code> elements and the <code id=serialising-html-fragments:the-table-element-2><a href=tables.html#the-table-element>table</a></code> element would all be siblings, because the
|
||
second <code><a></code> start tag implicitly closes the first <code id=serialising-html-fragments:the-a-element-6><a href=text-level-semantics.html#the-a-element>a</a></code>
|
||
element.</p>
|
||
|
||
<pre><html><head></head><body><a><mark><a></mark></a><table></table></a></body></html></pre>
|
||
|
||
<ul class=domTree><li class=t1><code id=serialising-html-fragments:the-html-element-4><a href=semantics.html#the-html-element>html</a></code><ul><li class=t1><code id=serialising-html-fragments:the-head-element-4><a href=semantics.html#the-head-element>head</a></code><li class=t1><code id=serialising-html-fragments:the-body-element-4><a href=sections.html#the-body-element>body</a></code><ul><li class=t1><code id=serialising-html-fragments:the-a-element-7><a href=text-level-semantics.html#the-a-element>a</a></code><li class=t1><code id=serialising-html-fragments:the-a-element-8><a href=text-level-semantics.html#the-a-element>a</a></code><li class=t1><code id=serialising-html-fragments:the-table-element-3><a href=tables.html#the-table-element>table</a></code></ul></ul></ul>
|
||
|
||
</div>
|
||
|
||
<p>For historical reasons, this algorithm does not round-trip an initial U+000A LINE FEED (LF)
|
||
character in <code id=serialising-html-fragments:the-pre-element><a href=grouping-content.html#the-pre-element>pre</a></code>, <code id=serialising-html-fragments:the-textarea-element-2><a href=form-elements.html#the-textarea-element>textarea</a></code>, or <code id=serialising-html-fragments:listing><a href=obsolete.html#listing>listing</a></code> elements, even
|
||
though (in the first two cases) the markup being round-tripped can be conforming. The <a href=#html-parser id=serialising-html-fragments:html-parser-5>HTML
|
||
parser</a> will drop such a character during parsing, but this algorithm does <em>not</em>
|
||
serialize an extra U+000A LINE FEED (LF) character.</p>
|
||
|
||
|
||
<div class=example>
|
||
<p>For example, consider the following markup:</p>
|
||
|
||
<pre><pre>
|
||
|
||
Hello.</pre></pre>
|
||
|
||
<p>When this document is first parsed, the <code id=serialising-html-fragments:the-pre-element-2><a href=grouping-content.html#the-pre-element>pre</a></code> element's <a id=serialising-html-fragments:child-text-content href=https://dom.spec.whatwg.org/#concept-child-text-content data-x-internal=child-text-content>child text
|
||
content</a> starts with a single newline character. After a serialize-reparse roundtrip, the
|
||
<code id=serialising-html-fragments:the-pre-element-3><a href=grouping-content.html#the-pre-element>pre</a></code> element's <a id=serialising-html-fragments:child-text-content-2 href=https://dom.spec.whatwg.org/#concept-child-text-content data-x-internal=child-text-content>child text content</a> is simply "<code>Hello.</code>".</p>
|
||
</div>
|
||
|
||
<p><dfn id=escapingString>Escaping a string</dfn> (for the purposes of the algorithm above)
|
||
consists of running the following steps:</p>
|
||
|
||
<ol><li><p>Replace any occurrence of the "<code>&</code>" character by the string "<code>&amp;</code>".<li><p>Replace any occurrences of the U+00A0 NO-BREAK SPACE character by the string "<code>&nbsp;</code>".<li><p>If the algorithm was invoked in the <i>attribute mode</i>, replace any occurrences of the
|
||
"<code>"</code>" character by the string "<code>&quot;</code>".<li><p>If the algorithm was <em>not</em> invoked in the <i>attribute mode</i>, replace any
|
||
occurrences of the "<code><</code>" character by the string "<code>&lt;</code>", and any occurrences of the "<code>></code>" character by
|
||
the string "<code>&gt;</code>".</ol>
|
||
|
||
|
||
<h3 id=parsing-html-fragments><span class=secno>12.4</span> Parsing HTML fragments<a href=#parsing-html-fragments class=self-link></a></h3>
|
||
|
||
<p>The following steps form the <dfn id=html-fragment-parsing-algorithm>HTML fragment parsing algorithm</dfn>. The algorithm
|
||
takes as input an <code id=parsing-html-fragments:element><a data-x-internal=element href=https://dom.spec.whatwg.org/#interface-element>Element</a></code> node, referred to as the <dfn id=concept-frag-parse-context><var>context</var></dfn> element, which gives the context for
|
||
the parser, as well as <var>input</var>, a string to parse, and returns a list of zero or
|
||
more nodes.</p>
|
||
|
||
<p class=note>Parts marked <dfn id=fragment-case>fragment case</dfn> in algorithms in the parser section are
|
||
parts that only occur if the parser was created for the purposes of this algorithm. The algorithms have been annotated
|
||
with such markings for informational purposes only; such markings have no normative weight. If it
|
||
is possible for a condition described as a <a href=#fragment-case id=parsing-html-fragments:fragment-case>fragment case</a> to occur even when the
|
||
parser wasn't created for the purposes of handling this algorithm, then that is an error in the
|
||
specification.</p>
|
||
|
||
<ol><li>
|
||
|
||
<p>Create a new <code id=parsing-html-fragments:document><a href=dom.html#document>Document</a></code> node, and mark it as being an <a href=https://dom.spec.whatwg.org/#html-document id=parsing-html-fragments:html-documents data-x-internal=html-documents>HTML document</a>.</p>
|
||
|
||
<li>
|
||
|
||
<p>If the
|
||
<a id=parsing-html-fragments:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> of the <var id=parsing-html-fragments:concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element is in
|
||
<a id=parsing-html-fragments:quirks-mode href=https://dom.spec.whatwg.org/#concept-document-quirks data-x-internal=quirks-mode>quirks mode</a>, then let the <code id=parsing-html-fragments:document-2><a href=dom.html#document>Document</a></code> be in <a id=parsing-html-fragments:quirks-mode-2 href=https://dom.spec.whatwg.org/#concept-document-quirks data-x-internal=quirks-mode>quirks mode</a>.
|
||
Otherwise, the
|
||
<a id=parsing-html-fragments:node-document-2 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> of the <var id=parsing-html-fragments:concept-frag-parse-context-2><a href=#concept-frag-parse-context>context</a></var> element is in
|
||
<a id=parsing-html-fragments:limited-quirks-mode href=https://dom.spec.whatwg.org/#concept-document-limited-quirks data-x-internal=limited-quirks-mode>limited-quirks mode</a>, then let the <code id=parsing-html-fragments:document-3><a href=dom.html#document>Document</a></code> be in <a id=parsing-html-fragments:limited-quirks-mode-2 href=https://dom.spec.whatwg.org/#concept-document-limited-quirks data-x-internal=limited-quirks-mode>limited-quirks
|
||
mode</a>. Otherwise, leave the <code id=parsing-html-fragments:document-4><a href=dom.html#document>Document</a></code> in <a id=parsing-html-fragments:no-quirks-mode href=https://dom.spec.whatwg.org/#concept-document-no-quirks data-x-internal=no-quirks-mode>no-quirks mode</a>.</p>
|
||
|
||
<li>
|
||
|
||
<p>Create a new <a href=#html-parser id=parsing-html-fragments:html-parser>HTML parser</a>, and associate it with the just created
|
||
<code id=parsing-html-fragments:document-5><a href=dom.html#document>Document</a></code> node.</p>
|
||
|
||
<li>
|
||
|
||
<p>Set the state of the <a href=#html-parser id=parsing-html-fragments:html-parser-2>HTML parser</a>'s <a href=#tokenization id=parsing-html-fragments:tokenization>tokenization</a> stage as
|
||
follows, switching on the <var id=parsing-html-fragments:concept-frag-parse-context-3><a href=#concept-frag-parse-context>context</a></var> element:</p>
|
||
|
||
<dl class=switch><dt><code id=parsing-html-fragments:the-title-element><a href=semantics.html#the-title-element>title</a></code><dt><code id=parsing-html-fragments:the-textarea-element><a href=form-elements.html#the-textarea-element>textarea</a></code><dd>Switch the tokenizer to the <a href=#rcdata-state id=parsing-html-fragments:rcdata-state>RCDATA state</a>.<dt><code id=parsing-html-fragments:the-style-element><a href=semantics.html#the-style-element>style</a></code><dt><code id=parsing-html-fragments:xmp><a href=obsolete.html#xmp>xmp</a></code><dt><code id=parsing-html-fragments:the-iframe-element><a href=iframe-embed-object.html#the-iframe-element>iframe</a></code><dt><code id=parsing-html-fragments:noembed><a href=obsolete.html#noembed>noembed</a></code><dt><code id=parsing-html-fragments:noframes><a href=obsolete.html#noframes>noframes</a></code><dd>Switch the tokenizer to the <a href=#rawtext-state id=parsing-html-fragments:rawtext-state>RAWTEXT state</a>.<dt><code id=parsing-html-fragments:the-script-element><a href=scripting.html#the-script-element>script</a></code><dd>Switch the tokenizer to the <a href=#script-data-state id=parsing-html-fragments:script-data-state>script data state</a>.<dt><code id=parsing-html-fragments:the-noscript-element><a href=scripting.html#the-noscript-element>noscript</a></code><dd>If the <a href=#scripting-flag id=parsing-html-fragments:scripting-flag>scripting flag</a> is enabled, switch the tokenizer to the <a href=#rawtext-state id=parsing-html-fragments:rawtext-state-2>RAWTEXT
|
||
state</a>. Otherwise, leave the tokenizer in the <a href=#data-state id=parsing-html-fragments:data-state>data state</a>.<dt><code id=parsing-html-fragments:plaintext><a href=obsolete.html#plaintext>plaintext</a></code><dd>Switch the tokenizer to the <a href=#plaintext-state id=parsing-html-fragments:plaintext-state>PLAINTEXT state</a>.<dt>Any other element<dd>Leave the tokenizer in the <a href=#data-state id=parsing-html-fragments:data-state-2>data state</a>.</dl>
|
||
|
||
<p class=note>For performance reasons, an implementation that does not report errors and
|
||
that uses the actual state machine described in this specification directly could use the
|
||
PLAINTEXT state instead of the RAWTEXT and script data states where those are mentioned in the
|
||
list above. Except for rules regarding parse errors, they are equivalent, since there is no
|
||
<a href=#appropriate-end-tag-token id=parsing-html-fragments:appropriate-end-tag-token>appropriate end tag token</a> in the fragment case, yet they involve far fewer state
|
||
transitions.</p>
|
||
|
||
<li>
|
||
|
||
<p>Let <var>root</var> be a new <code id=parsing-html-fragments:the-html-element><a href=semantics.html#the-html-element>html</a></code> element with no attributes.</p>
|
||
|
||
<li>
|
||
|
||
<p>Append the element <var>root</var> to the <code id=parsing-html-fragments:document-6><a href=dom.html#document>Document</a></code> node created
|
||
above.</p>
|
||
|
||
<li>
|
||
|
||
<p>Set up the parser's <a href=#stack-of-open-elements id=parsing-html-fragments:stack-of-open-elements>stack of open elements</a> so that it contains just the single
|
||
element <var>root</var>.</p>
|
||
|
||
<li>
|
||
|
||
<p>If the <var id=parsing-html-fragments:concept-frag-parse-context-4><a href=#concept-frag-parse-context>context</a></var> element is a
|
||
<code id=parsing-html-fragments:the-template-element><a href=scripting.html#the-template-element>template</a></code> element, push "<a href=#parsing-main-intemplate id=parsing-html-fragments:parsing-main-intemplate>in
|
||
template</a>" onto the <a href=#stack-of-template-insertion-modes id=parsing-html-fragments:stack-of-template-insertion-modes>stack of template insertion modes</a> so that it is the new
|
||
<a href=#current-template-insertion-mode id=parsing-html-fragments:current-template-insertion-mode>current template insertion mode</a>.</p>
|
||
|
||
<li>
|
||
|
||
<p>Create a start tag token whose name is the local name of <var id=parsing-html-fragments:concept-frag-parse-context-5><a href=#concept-frag-parse-context>context</a></var> and whose attributes are the attributes of
|
||
<var id=parsing-html-fragments:concept-frag-parse-context-6><a href=#concept-frag-parse-context>context</a></var>.</p>
|
||
|
||
<p>Let this start tag token be the start tag token of the <var id=parsing-html-fragments:concept-frag-parse-context-7><a href=#concept-frag-parse-context>context</a></var> node, e.g. for the purposes of determining
|
||
if it is an <a href=#html-integration-point id=parsing-html-fragments:html-integration-point>HTML integration point</a>.</p>
|
||
|
||
<li>
|
||
|
||
<p><a href=#reset-the-insertion-mode-appropriately id=parsing-html-fragments:reset-the-insertion-mode-appropriately>Reset the parser's insertion mode
|
||
appropriately</a>.</p>
|
||
|
||
<p class=note>The parser will reference the <var id=parsing-html-fragments:concept-frag-parse-context-8><a href=#concept-frag-parse-context>context</a></var> element as part of that algorithm.</p>
|
||
|
||
<li>
|
||
|
||
<p>Set the parser's <a href=#form-element-pointer id=parsing-html-fragments:form-element-pointer><code>form</code> element pointer</a> to the nearest node to the
|
||
<var id=parsing-html-fragments:concept-frag-parse-context-9><a href=#concept-frag-parse-context>context</a></var> element that is a <code id=parsing-html-fragments:the-form-element><a href=forms.html#the-form-element>form</a></code>
|
||
element (going straight up the ancestor chain, and including the element itself, if it is a
|
||
<code id=parsing-html-fragments:the-form-element-2><a href=forms.html#the-form-element>form</a></code> element), if any. (If there is no such <code id=parsing-html-fragments:the-form-element-3><a href=forms.html#the-form-element>form</a></code> element, the
|
||
<a href=#form-element-pointer id=parsing-html-fragments:form-element-pointer-2><code>form</code> element pointer</a> keeps its initial value, null.)</p>
|
||
|
||
<li>
|
||
|
||
<p>Place the <var>input</var> into the <a href=#input-stream id=parsing-html-fragments:input-stream>input stream</a> for the <a href=#html-parser id=parsing-html-fragments:html-parser-3>HTML
|
||
parser</a> just created. The encoding <a href=#concept-encoding-confidence id=parsing-html-fragments:concept-encoding-confidence>confidence</a> is <i>irrelevant</i>.</p>
|
||
|
||
<li>
|
||
|
||
<p>Start the parser and let it run until it has consumed all the characters just inserted into
|
||
the input stream.</p>
|
||
|
||
<li>
|
||
|
||
<p>Return the child
|
||
nodes of <var>root</var>, in <a id=parsing-html-fragments:tree-order href=https://dom.spec.whatwg.org/#concept-tree-order data-x-internal=tree-order>tree order</a>.</p>
|
||
|
||
</ol>
|
||
|
||
|
||
|
||
|
||
|
||
<nav><a href=syntax.html>← 12 The HTML syntax</a> — <a href=./>Table of Contents</a> — <a href=named-characters.html>12.5 Named character references →</a></nav>
|