Annotation of html5/spec/syntax.html, revision 1.565

1.2       mike        1: <!DOCTYPE HTML>
1.258     mike        2: <!-- when publishing, change bits marked ZZZ --><html lang="en-US-x-Hixie"><head><title>9 The HTML syntax &#8212; HTML 5</title><style type="text/css">
1.1       mike        3:    pre { margin-left: 2em; white-space: pre-wrap; }
                      4:    h2 { margin: 3em 0 1em 0; }
                      5:    h3 { margin: 2.5em 0 1em 0; }
                      6:    h4 { margin: 2.5em 0 0.75em 0; }
                      7:    h5, h6 { margin: 2.5em 0 1em; }
                      8:    h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
                      9:    h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
                     10:    p { margin: 1em 0; }
                     11:    hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
                     12:    dl, dd { margin-top: 0; margin-bottom: 0; }
                     13:    dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
                     14:    dt + dt { margin-top: 0; }
                     15:    dd dt { margin-top: 0.25em; margin-bottom: 0; }
                     16:    dd p { margin-top: 0; }
                     17:    dd dl + p { margin-top: 1em; }
                     18:    dd table + p { margin-top: 1em; }
                     19:    p + * > li, dd li { margin: 1em 0; }
                     20:    dt, dfn { font-weight: bold; font-style: normal; }
                     21:    dt dfn { font-style: italic; }
                     22:    pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
                     23:    pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
                     24:    pre em { font-weight: bolder; font-style: normal; }
                     25:    @media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
                     26:    var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
                     27:    table { border-collapse: collapse; border-style: hidden hidden none hidden; }
                     28:    table thead { border-bottom: solid; }
                     29:    table tbody th:first-child { border-left: solid; }
1.475     mike       30:    table tbody th { text-align: left; }
1.1       mike       31:    table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
                     32:    blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
                     33: 
                     34:    .bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
                     35:    .matrix, .matrix td { border: none; text-align: right; }
                     36:    .matrix { margin-left: 2em; }
                     37:    .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
                     38:    .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
                     39:    .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
                     40: 
                     41:    .toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
                     42:    img.extra { float: right; }
                     43:    pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; }
                     44:    pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
                     45:    pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
                     46:    pre.css:first-line { color: #AAAA50; }
                     47:    dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #EEFFEE; }
                     48:    hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
                     49:    dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
                     50:    dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
                     51:    dl.domintro dd p { margin: 0.5em 0; }
                     52:    dl.switch { padding-left: 2em; }
                     53:    dl.switch > dt { text-indent: -1.5em; }
                     54:    dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
                     55:    dl.triple { padding: 0 0 0 1em; }
                     56:    dl.triple dt, dl.triple dd { margin: 0; display: inline }
                     57:    dl.triple dt:after { content: ':'; }
                     58:    dl.triple dd:after { content: '\A'; white-space: pre; }
                     59:    .diff-old { text-decoration: line-through; color: silver; background: transparent; }
                     60:    .diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
                     61:    a .diff-new { border-bottom: 1px blue solid; }
                     62: 
                     63:    h2 { page-break-before: always; }
                     64:    h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
                     65:    h1 + h2, hr + h2.no-toc { page-break-before: auto; }
                     66: 
                     67:    p > span:not([title=""]):not([class="XXX"]):not([class="impl"]), li > span:not([title=""]):not([class="XXX"]):not([class="impl"]) { border-bottom: solid #9999CC; }
                     68: 
                     69:    div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
                     70:    div.head p { margin: 0; }
                     71:    div.head h1 { margin: 0; }
                     72:    div.head .logo { float: right; margin: 0 1em; }
                     73:    div.head .logo img { border: none } /* remove border from top image */
                     74:    div.head dl { margin: 1em 0; }
                     75:    p.copyright { font-size: x-small; font-style: oblique; margin: 0; }
                     76: 
                     77:    body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
                     78:    body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
                     79:    body > .toc > li > * { margin-bottom: 0.5em; }
                     80:    body > .toc > li > * > li > * { margin-bottom: 0.25em; }
                     81:    .toc, .toc li { list-style: none; }
                     82: 
                     83:    .brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
                     84:    .brief li { margin: 0; padding: 0; }
                     85:    .brief li p { margin: 0; padding: 0; }
                     86: 
                     87:    .category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
                     88:    .category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
                     89:    .category-list li { display: inline; }
                     90:    .category-list li:not(:last-child)::after { content: ', '; }
                     91:    .category-list li > span, .category-list li > a { text-transform: lowercase; }
                     92:    .category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
                     93: 
                     94:    .XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
                     95:    .XXX > :first-child { margin-top: 0; }
                     96:    p .XXX { line-height: 3em; }
1.159     mike       97:    .annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
                     98:    .annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
                     99:    .annotation :link, .annotation :visited { color: inherit; }
                    100:    .annotation :link:hover, .annotation :visited:hover { background: transparent; }
                    101:    .annotation span { border: none ! important; }
1.1       mike      102:    .note { color: green; background: transparent; font-family: sans-serif; }
                    103:    .warning { color: red; background: transparent; }
                    104:    .note, .warning { font-weight: bolder; font-style: italic; }
                    105:    p.note, div.note { padding: 0.5em 2em; }
                    106:    span.note { padding: 0 2em; }
                    107:    .note p:first-child, .warning p:first-child { margin-top: 0; }
                    108:    .note p:last-child, .warning p:last-child { margin-bottom: 0; }
                    109:    .warning:before { font-style: normal; }
                    110:    p.note:before { content: 'Note: '; }
                    111:    p.warning:before { content: '\26A0 Warning! '; }
                    112: 
                    113:    .bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
                    114:    .bookkeeping { font-size: 0.8em; margin: 2em 0; }
                    115:    .bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
                    116: 
                    117:    h4 { position: relative; z-index: 3; }
                    118:    h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
                    119:    .element {
                    120:      background: #EEEEFF;
                    121:      color: black;
                    122:      margin: 0 0 1em 0.15em;
                    123:      padding: 0 1em 0.25em 0.75em;
                    124:      border-left: solid #9999FF 0.25em;
                    125:      position: relative;
                    126:      z-index: 1;
                    127:    }
                    128:    .element:before {
                    129:      position: absolute;
                    130:      z-index: 2;
                    131:      top: 0;
                    132:      left: -1.15em;
                    133:      height: 2em;
                    134:      width: 0.9em;
                    135:      background: #EEEEFF;
                    136:      content: ' ';
                    137:      border-style: none none solid solid;
                    138:      border-color: #9999FF;
                    139:      border-width: 0.25em;
                    140:    }
                    141: 
1.149     mike      142:    .example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
                    143:    td > .example:only-child { margin: 0 0 0 0.1em; }
1.1       mike      144: 
                    145:    .tall-and-narrow {
                    146:      font-size: 0.6em;
                    147:      column-width: 25em;
                    148:      column-gap: 1em;
                    149:      -moz-column-width: 25em;
                    150:      -moz-column-gap: 1em;
                    151:      -webkit-column-width: 25em;
                    152:      -webkit-column-gap: 1em;
                    153:    }
                    154: 
                    155:    ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
                    156:    ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
                    157:    ul.domTree li li { list-style: none; }
                    158:    ul.domTree li:first-child::before { position: absolute; top: 0; height: 0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
                    159:    ul.domTree li:not(:last-child)::after { position: absolute; top: 0; bottom: -0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
                    160:    ul.domTree span { font-style: italic; font-family: serif; }
                    161:    ul.domTree .t1 code { color: purple; font-weight: bold; }
                    162:    ul.domTree .t2 { font-style: normal; font-family: monospace; }
                    163:    ul.domTree .t2 .name { color: black; font-weight: bold; }
                    164:    ul.domTree .t2 .value { color: blue; font-weight: normal; }
                    165:    ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
                    166:    ul.domTree .t7 code, .domTree .t8 code { color: green; }
                    167:    ul.domTree .t10 code { color: teal; }
                    168: 
1.267     mike      169:   </style><style type="text/css">
                    170: 
1.292     mike      171:    .applies thead th > * { display: block; }
                    172:    .applies thead code { display: block; }
                    173:    .applies tbody th { whitespace: nowrap; }
                    174:    .applies td { text-align: center; }
                    175:    .applies .yes { background: yellow; }
                    176: 
1.267     mike      177:    .matrix, .matrix td { border: none; text-align: right; }
                    178:    .matrix { margin-left: 2em; }
                    179: 
                    180:    .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
                    181:    .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
                    182:    .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
                    183: 
                    184:    #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
                    185:    #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
                    186:    #table-example-1 caption { padding-bottom: 0.5em; }
                    187:    #table-example-1 thead, #table-example-1 tbody { border: none; }
                    188:    #table-example-1 th, #table-example-1 td { border: solid thin; }
                    189:    #table-example-1 th { font-weight: normal; }
                    190:    #table-example-1 td { border-style: none solid; vertical-align: top; }
                    191:    #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
                    192:    #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
                    193:    #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
                    194:    #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
                    195:    #table-example-1 tbody td:first-child::after { content: leader(". "); }
                    196:    #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
                    197:    #table-example-1 tbody td:first-child + td { width: 10em; }
                    198:    #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
                    199:    #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
                    200: 
                    201:    .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
                    202:    .apple-table-examples * { font-family: "Times", serif; }
                    203:    .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
                    204:    .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
                    205:    .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
                    206:    .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
                    207:    .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
                    208:    .apple-table-examples td { text-align: right; vertical-align: top; }
                    209:    .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
                    210:    .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
                    211:    .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
                    212:    .apple-table-examples sup { line-height: 0; }
                    213: 
1.235     mike      214:   </style><link href="data:text/css," rel="stylesheet" title="Complete specification"><link href="data:text/css,.impl%20%7B%20display:%20none;%20%7D" rel="alternate stylesheet" title="Author documentation only"><link href="data:text/css,.impl%20%7B%20background:%20%23FFEEEE;%20%7D" rel="alternate stylesheet" title="Highlight implementation requirements"><link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel="stylesheet" type="text/css"><!-- ZZZ ED vs WD -->
1.2       mike      215:   <script src="link-fixup.js"></script>
                    216:   <link href="comms.html" title="8 Communication" rel="prev">
                    217:   <link href="spec.html#contents" title="Table of contents" rel="index">
1.1       mike      218:   <link href="named-character-references.html" title="9.6 Named character references" rel="next">
1.16      mike      219:   </head><body onload="fixBrokenLink(); fixBrokenLink()"><div class="head">
1.1       mike      220:    <p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p>
1.183     mike      221:    <h1>HTML5</h1>
1.1       mike      222:    <h2 class="no-num no-toc" id="a-vocabulary-and-associated-apis-for-html-and-xhtml">A vocabulary and associated APIs for HTML and XHTML</h2>
1.123     mike      223:    </div><nav>
1.1       mike      224:    <a href="comms.html">&#8592; 8 Communication</a> &#8211;
1.2       mike      225:    <a href="spec.html#contents">Table of contents</a> &#8211;
1.1       mike      226:    <a href="named-character-references.html">9.6 Named character references &#8594;</a>
1.565   ! mike      227:   </nav><p>This is revision 1.3366.</p>
1.11      mike      228: 
1.1       mike      229: 
1.123     mike      230:   <h2 id="syntax"><span class="secno">9 </span><dfn>The HTML syntax</dfn></h2><p class="note">This section only describes the rules for
1.83      mike      231:   <code><a href="iana-considerations.html#text-html">text/html</a></code> resources. Rules for XML resources are
1.1       mike      232:   discussed in the section below entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
1.159     mike      233:   syntax</a>".</p><h3 id="writing"><span class="secno">9.1 </span>Writing HTML documents</h3><p class="XXX annotation"><b>Status: </b><i>Working draft</i></p><div class="impl">
1.1       mike      234: 
                    235:   <p><i>This section only applies to documents, authoring tools, and
                    236:   markup generators. In particular, it does not apply to conformance
                    237:   checkers; conformance checkers must use the requirements given in
                    238:   the next section ("parsing HTML documents").</i></p>
                    239: 
1.123     mike      240:   </div><p>Documents must consist of the following parts, in the given
                    241:   order:</p><ol><li>Optionally, a single U+FEFF BYTE ORDER MARK (BOM) character.</li>
1.1       mike      242: 
                    243:    <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
                    244:    <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    245: 
                    246:    <li>A <a href="#syntax-doctype" title="syntax-doctype">DOCTYPE</a>.
                    247: 
                    248:    </li><li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
                    249:    <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    250: 
1.159     mike      251:    <li>The root element, in the form of an <code><a href="semantics.html#the-html-element-0">html</a></code> <a href="#syntax-elements" title="syntax-elements">element</a>.</li>
1.1       mike      252: 
                    253:    <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
                    254:    <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    255: 
                    256:   </ol><p>The various types of content mentioned above are described in the
1.123     mike      257:   next few sections.</p><p>In addition, there are some restrictions on how <a href="semantics.html#character-encoding-declaration" title="character encoding declaration">character encoding
1.1       mike      258:   declarations</a> are to be serialized, as discussed in the
1.123     mike      259:   section on that topic.</p><div class="note">
1.1       mike      260: 
1.159     mike      261:    <p>Space characters before the root <code><a href="semantics.html#the-html-element-0">html</a></code> element, and
                    262:    space characters at the start of the <code><a href="semantics.html#the-html-element-0">html</a></code> element and
                    263:    before the <code><a href="semantics.html#the-head-element-0">head</a></code> element, will be dropped when the
1.1       mike      264:    document is parsed; space characters <em>after</em> the root
1.159     mike      265:    <code><a href="semantics.html#the-html-element-0">html</a></code> element will be parsed as if they were at the end
                    266:    of the <code><a href="semantics.html#the-body-element-0">body</a></code> element. Thus, space characters around the
1.1       mike      267:    root element do not round-trip.</p>
                    268: 
                    269:    <p>It is suggested that newlines be inserted after the DOCTYPE,
                    270:    after any comments that are before the root element, after the
1.159     mike      271:    <code><a href="semantics.html#the-html-element-0">html</a></code> element's start tag (if it is not <a href="#syntax-tag-omission" title="syntax-tag-omission">omitted</a>), and after any comments
                    272:    that are inside the <code><a href="semantics.html#the-html-element-0">html</a></code> element but before the
                    273:    <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1       mike      274: 
1.123     mike      275:   </div><p>Many strings in the HTML syntax (e.g. the names of elements and
1.1       mike      276:   their attributes) are case-insensitive, but only for characters in
1.547     mike      277:   the ranges U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL
                    278:   LETTER Z) and U+0061 to U+007A (LATIN SMALL LETTER A to LATIN SMALL
1.1       mike      279:   LETTER Z). For convenience, in this section this is just referred to
1.168     mike      280:   as "case-insensitive".</p><h4 id="the-doctype"><span class="secno">9.1.1 </span>The DOCTYPE</h4><p class="XXX annotation"><span><a href="http://www.w3.org/html/wg/tracker/issues/4">ISSUE-4</a> (html-versioning) blocks progress to Last Call</span></p><p>A <dfn id="syntax-doctype" title="syntax-doctype">DOCTYPE</dfn> is a mostly useless,
1.123     mike      281:   but required, header.</p><p class="note">DOCTYPEs are required for legacy reasons. When
1.1       mike      282:   omitted, browsers tend to use a different rendering mode that is
                    283:   incompatible with some specifications. Including the DOCTYPE in a
                    284:   document ensures that the browser makes a best-effort attempt at
1.123     mike      285:   following the relevant specifications.</p><p>A DOCTYPE must consist of the following characters, in this
                    286:   order:</p><ol class="brief"><li>A U+003C LESS-THAN SIGN (<code>&lt;</code>) character.</li>
1.1       mike      287:    <li>A U+0021 EXCLAMATION MARK (<code>!</code>) character.</li>
                    288:    <li>A string that is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code title="">DOCTYPE</code>".</li>
                    289:    <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    290:    <li>A string that is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code title="">HTML</code>".</li>
                    291:    <li>Optionally, a <a href="#doctype-legacy-string">DOCTYPE legacy string</a> (defined below).</li>
                    292:    <li>Zero or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    293:    <li>A U+003E GREATER-THAN SIGN (<code>&gt;</code>) character.</li>
                    294:   </ol><p class="note">In other words, <code>&lt;!DOCTYPE HTML&gt;</code>,
1.123     mike      295:   case-insensitively.</p><p>For the purposes of HTML generators that cannot output HTML
1.1       mike      296:   markup with the short DOCTYPE "<code title="">&lt;!DOCTYPE
                    297:   HTML&gt;</code>", a <dfn id="doctype-legacy-string">DOCTYPE legacy string</dfn> may be inserted
                    298:   into the DOCTYPE (in the position defined above). This string must
1.123     mike      299:   consist of:</p><ol class="brief"><li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
1.1       mike      300:    <li>A string that is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code title="">SYSTEM</code>".</li>
1.444     mike      301:    <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
1.1       mike      302:    <li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>quote mark</i>).</li>
1.465     mike      303:    <li>The literal string "<code><a href="infrastructure.html#about:legacy-compat">about:legacy-compat</a></code>".</li>
1.1       mike      304:    <li>A matching U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (i.e. the same character as in the earlier step marked <i>quote mark</i>).</li>
                    305:   </ol><p class="note">In other words, <code>&lt;!DOCTYPE HTML SYSTEM
                    306:   "about:legacy-compat"&gt;</code> or <code>&lt;!DOCTYPE HTML SYSTEM
                    307:   'about:legacy-compat'&gt;</code>, case-insensitively except for the bit
1.123     mike      308:   in quotes.</p><p>The <a href="#doctype-legacy-string">DOCTYPE legacy string</a> should not be used unless
1.1       mike      309:   the document is generated from a system that cannot output the
1.373     mike      310:   shorter string.</p><h4 id="elements-0"><span class="secno">9.1.2 </span>Elements</h4><p>There are five different kinds of <dfn id="syntax-elements" title="syntax-elements">elements</dfn>: <a href="#void-elements">void elements</a>,
                    311:   <a href="#raw-text-elements">raw text elements</a>, <a href="#rcdata-elements">RCDATA elements</a>,
                    312:   <a href="#foreign-elements">foreign elements</a>, and <a href="#normal-elements">normal elements</a>.</p><dl><dt><dfn id="void-elements">Void elements</dfn></dt>
1.1       mike      313: 
                    314:    <dd><code><a href="the-canvas-element.html#the-area-element">area</a></code>, <code><a href="semantics.html#the-base-element">base</a></code>, <code><a href="semantics.html#the-br-element">br</a></code>,
1.159     mike      315:    <code><a href="tabular-data.html#the-col-element">col</a></code>, <code><a href="interactive-elements.html#the-command">command</a></code>, <code><a href="text-level-semantics.html#the-embed-element">embed</a></code>,
                    316:    <code><a href="semantics.html#the-hr-element">hr</a></code>, <code><a href="text-level-semantics.html#the-img-element">img</a></code>, <code><a href="forms.html#the-input-element">input</a></code>,
1.1       mike      317:    <code><a href="forms.html#the-keygen-element">keygen</a></code>, <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="semantics.html#meta">meta</a></code>,
1.159     mike      318:    <code><a href="text-level-semantics.html#the-param-element">param</a></code>, <code><a href="video.html#the-source-element">source</a></code></dd>
1.1       mike      319: 
1.373     mike      320:    <dt><dfn id="raw-text-elements">Raw text elements</dfn></dt>
1.1       mike      321: 
                    322:    <dd><code><a href="semantics.html#script">script</a></code>, <code><a href="semantics.html#the-style-element">style</a></code></dd> <!-- iframe and
1.91      mike      323:    noscript don't count as raw text for syntax purposes -->
1.1       mike      324: 
1.373     mike      325:    <dt><dfn id="rcdata-elements">RCDATA elements</dfn></dt>
1.1       mike      326: 
1.159     mike      327:    <dd><code><a href="forms.html#the-textarea-element">textarea</a></code>, <code><a href="semantics.html#the-title-element-0">title</a></code></dd>
1.1       mike      328: 
1.373     mike      329:    <dt><dfn id="foreign-elements">Foreign elements</dfn></dt>
1.1       mike      330: 
                    331:    <dd>Elements from the <a href="#mathml-namespace">MathML namespace</a>
                    332:    and the <a href="#svg-namespace">SVG namespace</a>.</dd>
                    333: 
1.373     mike      334:    <dt><dfn id="normal-elements">Normal elements</dfn></dt>
1.1       mike      335: 
                    336:    <dd>All other allowed <a href="infrastructure.html#html-elements">HTML elements</a> are normal
                    337:    elements.</dd>
                    338: 
                    339:   </dl><p><dfn id="syntax-tags" title="syntax-tags">Tags</dfn> are used to delimit the start
1.373     mike      340:   and end of elements in the markup. <a href="#raw-text-elements" title="raw text
                    341:   elements">Raw text</a>, <a href="#rcdata-elements" title="RCDATA
                    342:   elements">RCDATA</a>, and <a href="#normal-elements" title="normal
                    343:   elements">normal</a> elements have a <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> to indicate where they
                    344:   begin, and an <a href="#syntax-end-tag" title="syntax-end-tag">end tag</a> to
                    345:   indicate where they end. The start and end tags of certain
                    346:   <a href="#normal-elements">normal elements</a> can be <a href="#syntax-tag-omission" title="syntax-tag-omission">omitted</a>, as described
1.1       mike      347:   later. Those that cannot be omitted must not be omitted. <a href="#void-elements">Void
                    348:   elements</a> only have a start tag; end tags must not be
1.373     mike      349:   specified for <a href="#void-elements">void elements</a>. <a href="#foreign-elements">Foreign
                    350:   elements</a> must either have a start tag and an end tag, or a
                    351:   start tag that is marked as self-closing, in which case they must
                    352:   not have an end tag.</p><p>The contents of the element must be placed between just after the
1.1       mike      353:   start tag (which <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied,
                    354:   in certain cases</a>) and just before the end tag (which again,
                    355:   <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied in certain
                    356:   cases</a>). The exact allowed contents of each individual element
                    357:   depends on the content model of that element, as described earlier
                    358:   in this specification. Elements must not contain content that their
                    359:   content model disallows. In addition to the restrictions placed on
                    360:   the contents by those content models, however, the five types of
1.123     mike      361:   elements have additional <em>syntactic</em> requirements.</p><p><a href="#void-elements">Void elements</a> can't have any contents (since there's
1.1       mike      362:   no end tag, no content can be put between the start tag and the end
1.373     mike      363:   tag).</p><p><a href="#raw-text-elements">Raw text elements</a> can have <a href="#syntax-text" title="syntax-text">text</a>, though it has <a href="#cdata-rcdata-restrictions">restrictions</a> described
                    364:   below.</p><p><a href="#rcdata-elements">RCDATA elements</a> can have <a href="#syntax-text" title="syntax-text">text</a> and <a href="#syntax-charref" title="syntax-charref">character references</a>, but the text
                    365:   must not contain an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.
1.1       mike      366:   There are also <a href="#cdata-rcdata-restrictions">further
1.373     mike      367:   restrictions</a> described below.</p><p><a href="#foreign-elements">Foreign elements</a> whose start tag is marked as
                    368:   self-closing can't have any contents (since, again, as there's no
                    369:   end tag, no content can be put between the start tag and the end
                    370:   tag). <a href="#foreign-elements">Foreign elements</a> whose start tag is <em>not</em>
                    371:   marked as self-closing can have <a href="#syntax-text" title="syntax-text">text</a>, <a href="#syntax-charref" title="syntax-charref">character references</a>, <a href="#syntax-cdata" title="syntax-cdata">CDATA sections</a>, other <a href="#syntax-elements" title="syntax-elements">elements</a>, and <a href="#syntax-comments" title="syntax-comments">comments</a>, but the text must not
1.1       mike      372:   contain the character U+003C LESS-THAN SIGN (<code>&lt;</code>) or
                    373:   an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous
1.374     mike      374:   ampersand</a>.</p><div class="note">
                    375: 
                    376:    <p>The HTML syntax does not support namespace
                    377:    declarations, even in <a href="#foreign-elements">foreign elements</a>.</p>
                    378: 
                    379:    <p>For instance, consider the following HTML fragment:</p>
                    380: 
                    381:    <pre>&lt;p&gt;
                    382:  &lt;svg&gt;
                    383:   &lt;metadata&gt;
                    384:    &lt;!-- this is invalid --&gt;
                    385:    &lt;cdr:license xmlns:cdr="http://www.example.com/cdr/metadata" name="MIT"/&gt;
                    386:   &lt;/metadata&gt;
                    387:  &lt;/svg&gt;
                    388: &lt;/p&gt;</pre>
                    389: 
                    390:    <p>The innermost element, <code title="">cdr:license</code>, is
                    391:    actually in the SVG namespace, as the "<code title="">xmlns:cdr</code>" attribute has no effect (unlike in
                    392:    XML). In fact, as the comment in the fragment above says, the
                    393:    fragment is actually non-conforming. This is because the SVG
                    394:    specification does not define any elements called "<code title="">cdr:license</code>" in the SVG namespace.</p>
                    395: 
                    396:   </div><p><a href="#normal-elements">Normal elements</a> can have <a href="#syntax-text" title="syntax-text">text</a>, <a href="#syntax-charref" title="syntax-charref">character references</a>, other <a href="#syntax-elements" title="syntax-elements">elements</a>, and <a href="#syntax-comments" title="syntax-comments">comments</a>, but the text must not
1.1       mike      397:   contain the character U+003C LESS-THAN SIGN (<code>&lt;</code>) or
                    398:   an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous
1.373     mike      399:   ampersand</a>. Some <a href="#normal-elements">normal elements</a> also have <a href="#element-restrictions">yet more restrictions</a> on what
1.1       mike      400:   content they are allowed to hold, beyond the restrictions imposed by
                    401:   the content model and those described in this paragraph. Those
1.123     mike      402:   restrictions are described below.</p><p>Tags contain a <dfn id="syntax-tag-name" title="syntax-tag-name">tag name</dfn>,
1.1       mike      403:   giving the element's name. HTML elements all have names that only
1.464     mike      404:   use characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
                    405:   NINE (9), U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER
                    406:   Z, and U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER
                    407:   Z. In the HTML syntax, tag names, even those for <a href="#foreign-elements">foreign
1.462     mike      408:   elements</a>, may be written with any mix of lower- and uppercase
                    409:   letters that, when converted to all-lowercase, matches the element's
                    410:   tag name; tag names are case-insensitive.</p><h5 id="start-tags"><span class="secno">9.1.2.1 </span>Start tags</h5><p><dfn id="syntax-start-tag" title="syntax-start-tag">Start tags</dfn> must have the
1.123     mike      411:   following format:</p><ol><li>The first character of a start tag must be a U+003C LESS-THAN
1.1       mike      412:    SIGN (<code>&lt;</code>).</li>
                    413: 
                    414:    <li>The next few characters of a start tag must be the element's
                    415:    <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
                    416: 
                    417:    <li>If there are to be any attributes in the next step, there must
                    418:    first be one or more <a href="infrastructure.html#space-character" title="space character">space
                    419:    characters</a>.</li>
                    420: 
                    421:    <li>Then, the start tag may have a number of attributes, the <a href="#syntax-attributes" title="syntax-attributes">syntax for which</a> is described
                    422:    below. Attributes may be separated from each other by one or more
                    423:    <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    424: 
                    425:    <li>After the attributes, there may be one or more <a href="infrastructure.html#space-character" title="space character">space characters</a>. (Some attributes
                    426:    are required to be followed by a space. See the <a href="#syntax-attributes" title="syntax-attributes">attributes section</a> below.)</li>
                    427: 
                    428:    <li>Then, if the element is one of the <a href="#void-elements">void elements</a>,
1.373     mike      429:    or if the element is a <a href="#foreign-elements" title="foreign elements">foreign
                    430:    element</a>, then there may be a single U+002F SOLIDUS
                    431:    (<code>/</code>) character. This character has no effect on
                    432:    <a href="#void-elements">void elements</a>, but on <a href="#foreign-elements">foreign elements</a> it
                    433:    marks the start tag as self-closing.</li>
1.1       mike      434: 
                    435:    <li>Finally, start tags must be closed by a U+003E GREATER-THAN
                    436:    SIGN (<code>&gt;</code>) character.</li>
                    437: 
1.123     mike      438:   </ol><h5 id="end-tags"><span class="secno">9.1.2.2 </span>End tags</h5><p><dfn id="syntax-end-tag" title="syntax-end-tag">End tags</dfn> must have the
                    439:   following format:</p><ol><li>The first character of an end tag must be a U+003C LESS-THAN
1.1       mike      440:    SIGN (<code>&lt;</code>).</li>
                    441: 
                    442:    <li>The second character of an end tag must be a U+002F SOLIDUS
                    443:    (<code>/</code>).</li>
                    444: 
                    445:    <li>The next few characters of an end tag must be the element's
                    446:    <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
                    447: 
                    448:    <li>After the tag name, there may be one or more <a href="infrastructure.html#space-character" title="space
                    449:    character">space characters</a>.</li>
                    450: 
                    451:    <li>Finally, end tags must be closed by a U+003E GREATER-THAN
                    452:    SIGN (<code>&gt;</code>) character.</li>
                    453: 
1.123     mike      454:   </ol><h5 id="attributes"><span class="secno">9.1.2.3 </span>Attributes</h5><p><dfn id="syntax-attributes" title="syntax-attributes">Attributes</dfn> for an element
                    455:   are expressed inside the element's start tag.</p><p>Attributes have a name and a value. <dfn id="syntax-attribute-name" title="syntax-attribute-name">Attribute names</dfn> must consist of
1.1       mike      456:   one or more characters other than the <a href="infrastructure.html#space-character" title="space
                    457:   character">space characters</a>, U+0000 NULL, U+0022 QUOTATION
                    458:   MARK ("), U+0027 APOSTROPHE ('), U+003E GREATER-THAN SIGN
                    459:   (&gt;), U+002F SOLIDUS (/), and U+003D EQUALS SIGN (=) characters,
                    460:   the control characters, and any characters that are not defined by
1.462     mike      461:   Unicode. In the HTML syntax, attribute names, even those for
                    462:   <a href="#foreign-elements">foreign elements</a>, may be written with any mix of lower-
                    463:   and uppercase letters that are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.123     mike      464:   case-insensitive</a> match for the attribute's name.</p><p><dfn id="syntax-attribute-value" title="syntax-attribute-value">Attribute values</dfn> are a
1.1       mike      465:   mixture of <a href="#syntax-text" title="syntax-text">text</a> and <a href="#syntax-charref" title="syntax-charref">character references</a>, except with the
1.123     mike      466:   additional restriction that the text cannot contain an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.</p><p>Attributes can be specified in four different ways:</p><dl><dt>Empty attribute syntax</dt>
1.1       mike      467: 
                    468:    <dd>
                    469: 
                    470:     <p>Just the <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute
                    471:     name</a>.</p>
                    472: 
                    473:     <div class="example">
                    474: 
                    475:      <p>In the following example, the <code title="attr-fe-disabled"><a href="forms.html#attr-fe-disabled">disabled</a></code> attribute is given with
                    476:      the empty attribute syntax:</p>
                    477: 
                    478:      <pre>&lt;input <em>disabled</em>&gt;</pre>
                    479: 
                    480:     </div>
                    481: 
                    482:     <p>If an attribute using the empty attribute syntax is to be
                    483:     followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
                    484:     character</a> separating the two.</p>
                    485: 
                    486:    </dd>
                    487: 
1.2       mike      488:    <dt id="unquoted">Unquoted attribute value syntax</dt>
1.1       mike      489: 
                    490:    <dd>
                    491: 
                    492:     <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
                    493:     followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
                    494:     characters</a>, followed by a single U+003D EQUALS SIGN
                    495:     character, followed by zero or more <a href="infrastructure.html#space-character" title="space
                    496:     character">space characters</a>, followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
                    497:     addition to the requirements given above for attribute values,
                    498:     must not contain any literal <a href="infrastructure.html#space-character" title="space character">space
                    499:     characters</a>, any U+0022 QUOTATION MARK (<code>"</code>)
                    500:     characters, U+0027 APOSTROPHE (<code>'</code>) characters,
                    501:     U+003D EQUALS SIGN (<code>=</code>) characters, U+003C LESS-THAN
1.463     mike      502:     SIGN (<code>&lt;</code>) characters, U+003E GREATER-THAN SIGN
                    503:     (<code>&gt;</code>) characters, or U+0060 GRAVE ACCENT (`)
                    504:     characters, and must not be the empty string.</p>
                    505: 
                    506:     <!-- The ` character is in this list on a temporary basis, waiting
                    507:          for IE to fix it's parsing bug whereby it treats ` as an
                    508:          attribute value delimiter. Otherwise, escaping software that
                    509:          tries to be clever and not use quotes when it doesn't need to
                    510:          could be tricked by an attacker.
                    511: 
                    512:          Posit a site that allows the user to input text that is used
                    513:          verbatim in two attributes, such that the user can set the
                    514:          first attribute's value to:
                    515: 
                    516:             `
                    517: 
                    518:          ...and the second to:
                    519: 
                    520:             ` onload='...payload...' end=x
                    521: 
                    522:          ...with the assumption that the site is going to not quote
                    523:          the first one, and quote the second one with double quotes:
                    524: 
                    525:             <body title=` class="` onload='...payload...' end=x">
                    526: 
                    527:          In IE, this is treated as:
                    528: 
                    529:             <body title=' class="'
                    530:                   onload='...payload...'
                    531:                   end='x"'>
                    532: 
                    533:     -->
                    534: 
1.1       mike      535: 
                    536:     <div class="example">
                    537: 
                    538:      <p>In the following example, the <code title="attr-input-value"><a href="forms.html#attr-input-value">value</a></code> attribute is given
                    539:      with the unquoted attribute value syntax:</p>
                    540: 
                    541:      <pre>&lt;input <em>value=yes</em>&gt;</pre>
                    542: 
                    543:     </div>
                    544: 
                    545:     <p>If an attribute using the unquoted attribute syntax is to be
1.101     mike      546:     followed by another attribute or by the optional U+002F SOLIDUS
1.464     mike      547:     character (/) allowed in step 6 of the <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> syntax above, then there
1.1       mike      548:     must be a <a href="infrastructure.html#space-character">space character</a> separating the two.</p>
                    549: 
                    550:    </dd>
                    551: 
                    552:    <dt>Single-quoted attribute value syntax</dt>
                    553: 
                    554:    <dd>
                    555: 
                    556:     <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
                    557:     followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
                    558:     characters</a>, followed by a single U+003D EQUALS SIGN
                    559:     character, followed by zero or more <a href="infrastructure.html#space-character" title="space
                    560:     character">space characters</a>, followed by a single U+0027
                    561:     APOSTROPHE (<code>'</code>) character, followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
                    562:     addition to the requirements given above for attribute values,
                    563:     must not contain any literal U+0027 APOSTROPHE (<code>'</code>)
                    564:     characters, and finally followed by a second single U+0027
                    565:     APOSTROPHE (<code>'</code>) character.</p>
                    566: 
                    567:     <div class="example">
                    568: 
                    569:      <p>In the following example, the <code title="attr-input-type"><a href="forms.html#attr-input-type">type</a></code> attribute is given with the
                    570:      single-quoted attribute value syntax:</p>
                    571: 
                    572:      <pre>&lt;input <em>type='checkbox'</em>&gt;</pre>
                    573: 
                    574:     </div>
                    575: 
                    576:     <p>If an attribute using the single-quoted attribute syntax is to
                    577:     be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
                    578:     character</a> separating the two.</p>
                    579: 
                    580:    </dd>
                    581: 
                    582:    <dt>Double-quoted attribute value syntax</dt>
                    583: 
                    584:    <dd>
                    585: 
                    586:     <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
                    587:     followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
                    588:     characters</a>, followed by a single U+003D EQUALS SIGN
                    589:     character, followed by zero or more <a href="infrastructure.html#space-character" title="space
                    590:     character">space characters</a>, followed by a single U+0022
                    591:     QUOTATION MARK (<code>"</code>) character, followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
                    592:     addition to the requirements given above for attribute values,
                    593:     must not contain any literal U+0022 QUOTATION MARK
                    594:     (<code>"</code>) characters, and finally followed by a second
                    595:     single U+0022 QUOTATION MARK (<code>"</code>) character.</p>
                    596: 
                    597:     <div class="example">
                    598: 
                    599:      <p>In the following example, the <code title="attr-fe-name"><a href="forms.html#attr-fe-name">name</a></code> attribute is given with the
                    600:      double-quoted attribute value syntax:</p>
                    601: 
                    602:      <pre>&lt;input <em>name="be evil"</em>&gt;</pre>
                    603: 
                    604:     </div>
                    605: 
                    606:     <p>If an attribute using the double-quoted attribute syntax is to
                    607:     be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
                    608:     character</a> separating the two.</p>
                    609: 
                    610:    </dd>
                    611: 
                    612:   </dl><p>There must never be two or more attributes on the same start tag
                    613:   whose names are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for
1.462     mike      614:   each other.</p><hr><p>When a <a href="#foreign-elements" title="foreign elements">foreign element</a> has
                    615:   one of the namespaced attributes given by the local name and
                    616:   namespace of the first and second cells of a row from the following
                    617:   table, it must be written using the name given by the third cell
                    618:   from the same row.</p><table><thead><tr><th> Local name </th><th> Namespace </th><th> Attribute name
                    619:    </th></tr></thead><tbody><tr><td> <code title="">actuate</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:actuate</code>
                    620:     </td></tr><tr><td> <code title="">arcrole</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:arcrole</code>
                    621:     </td></tr><tr><td> <code title="">href</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:href</code>
                    622:     </td></tr><tr><td> <code title="">role</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:role</code>
                    623:     </td></tr><tr><td> <code title="">show</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:show</code>
                    624:     </td></tr><tr><td> <code title="">title</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:title</code>
                    625:     </td></tr><tr><td> <code title="">type</code> </td><td> <a href="#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:type</code>
                    626:     </td></tr><tr><td> <code title="">base</code> </td><td> <a href="#xml-namespace">XML namespace</a> <!-- attr-xml-base --> </td><td> <code title="">xml:base</code>
                    627:     </td></tr><tr><td> <code title="">lang</code> </td><td> <a href="#xml-namespace">XML namespace</a> </td><td> <code title="">xml:lang</code>
                    628:     </td></tr><tr><td> <code title="">space</code> </td><td> <a href="#xml-namespace">XML namespace</a> </td><td> <code title="">xml:space</code>
                    629:     </td></tr><tr><td> <code title="">xmlns</code> </td><td> <a href="#xmlns-namespace">XMLNS namespace</a> </td><td> <code title="">xmlns</code>
                    630:     </td></tr><tr><td> <code title="">xlink</code> </td><td> <a href="#xmlns-namespace">XMLNS namespace</a> </td><td> <code title="">xmlns:xlink</code>
                    631:   </td></tr></tbody></table><p>No other namespaced attribute can be expressed in the <a href="#syntax">the
                    632:   HTML syntax</a>.</p><h5 id="optional-tags"><span class="secno">9.1.2.4 </span>Optional tags</h5><p>Certain tags can be <dfn id="syntax-tag-omission" title="syntax-tag-omission">omitted</dfn>.</p><p class="note">Omitting an element's <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> does not mean the element
1.1       mike      633:   is not present; it is implied, but it is still there. An HTML
1.159     mike      634:   document always has a root <code><a href="semantics.html#the-html-element-0">html</a></code> element, even if the
1.1       mike      635:   string <code title="">&lt;html&gt;</code> doesn't appear anywhere in
1.159     mike      636:   the markup.</p><!-- <html> --><p>An <code><a href="semantics.html#the-html-element-0">html</a></code> element's <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> may be omitted if the
                    637:   first thing inside the <code><a href="semantics.html#the-html-element-0">html</a></code> element is not a <a href="#syntax-comments" title="syntax-comments">comment</a>.</p><!-- </html> --><p>An <code><a href="semantics.html#the-html-element-0">html</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
                    638:   tag</a> may be omitted if the <code><a href="semantics.html#the-html-element-0">html</a></code> element is not
                    639:   immediately followed by a <a href="#syntax-comments" title="syntax-comments">comment</a>.</p><!-- <head> --><p>A <code><a href="semantics.html#the-head-element-0">head</a></code> element's <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> may be omitted <!--if the
1.1       mike      640:   element is empty, or--> if the first thing inside the
1.159     mike      641:   <code><a href="semantics.html#the-head-element-0">head</a></code> element is an element.</p><!-- </head> --><p>A <code><a href="semantics.html#the-head-element-0">head</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
                    642:   tag</a> may be omitted if the <code><a href="semantics.html#the-head-element-0">head</a></code> element is not
                    643:   immediately followed by a <a href="infrastructure.html#space-character">space character</a> or a <a href="#syntax-comments" title="syntax-comments">comment</a>.</p><!-- <body> --><p>A <code><a href="semantics.html#the-body-element-0">body</a></code> element's <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> may be omitted if the
                    644:   element is empty, or if the first thing inside the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1       mike      645:   element is not a <a href="infrastructure.html#space-character">space character</a> or a <a href="#syntax-comments" title="syntax-comments">comment</a>, except if the first thing
1.159     mike      646:   inside the <code><a href="semantics.html#the-body-element-0">body</a></code> element is a <code><a href="semantics.html#script">script</a></code> or
1.1       mike      647:   <code><a href="semantics.html#the-style-element">style</a></code> element. <!-- Note that even if the </head> end
                    648:   tag is present, the parser makes <style> and <script> elements
                    649:   between </head> and <body> end up in the <head> instead of implying
1.159     mike      650:   the <body> --></p><!-- </body> --><p>A <code><a href="semantics.html#the-body-element-0">body</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
                    651:   tag</a> may be omitted if the <code><a href="semantics.html#the-body-element-0">body</a></code> element is not
1.123     mike      652:   immediately followed by a <a href="#syntax-comments" title="syntax-comments">comment</a>.</p><!-- </li> --><p>A <code><a href="semantics.html#the-li-element">li</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      653:   tag</a> may be omitted if the <code><a href="semantics.html#the-li-element">li</a></code> element is
                    654:   immediately followed by another <code><a href="semantics.html#the-li-element">li</a></code> element or if there
1.422     mike      655:   is no more content in the parent element.</p><!-- </dt> --><p>A <code><a href="semantics.html#the-dt-element">dt</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      656:   tag</a> may be omitted if the <code><a href="semantics.html#the-dt-element">dt</a></code> element is
                    657:   immediately followed by another <code><a href="semantics.html#the-dt-element">dt</a></code> element or a
1.123     mike      658:   <code><a href="semantics.html#the-dd-element">dd</a></code> element.</p><!-- </dd> --><p>A <code><a href="semantics.html#the-dd-element">dd</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      659:   tag</a> may be omitted if the <code><a href="semantics.html#the-dd-element">dd</a></code> element is
                    660:   immediately followed by another <code><a href="semantics.html#the-dd-element">dd</a></code> element or a
                    661:   <code><a href="semantics.html#the-dt-element">dt</a></code> element, or if there is no more content in the
1.123     mike      662:   parent element.</p><!-- </p> --><p>A <code><a href="semantics.html#the-p-element">p</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      663:   tag</a> may be omitted if the <code><a href="semantics.html#the-p-element">p</a></code> element is
                    664:   immediately followed by an <code><a href="semantics.html#the-address-element">address</a></code>,
                    665:   <code><a href="semantics.html#the-article-element">article</a></code>, <code><a href="semantics.html#the-aside-element">aside</a></code>, <code><a href="semantics.html#the-blockquote-element">blockquote</a></code>,
1.305     mike      666:   <!--v2DATAGRID <code>datagrid</code>,--> <code><a href="obsolete.html#dir">dir</a></code>,
1.306     mike      667:   <code><a href="semantics.html#the-div-element">div</a></code>, <code><a href="semantics.html#the-dl-element">dl</a></code>, <code><a href="forms.html#the-fieldset-element">fieldset</a></code>,
1.305     mike      668:   <code><a href="semantics.html#the-footer-element">footer</a></code>, <code><a href="forms.html#the-form-element">form</a></code>, <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h1</a></code>,
                    669:   <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h2</a></code>, <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h3</a></code>, <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h4</a></code>, <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h5</a></code>,
                    670:   <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h6</a></code>, <code><a href="semantics.html#the-header-element">header</a></code>, <code><a href="semantics.html#the-hgroup-element">hgroup</a></code>,
                    671:   <code><a href="semantics.html#the-hr-element">hr</a></code>, <code><a href="interactive-elements.html#menus">menu</a></code>, <code><a href="semantics.html#the-nav-element">nav</a></code>,
                    672:   <code><a href="semantics.html#the-ol-element">ol</a></code>, <code><a href="semantics.html#the-p-element">p</a></code>, <code><a href="semantics.html#the-pre-element">pre</a></code>,
1.1       mike      673:   <code><a href="semantics.html#the-section-element">section</a></code>, <code><a href="tabular-data.html#the-table-element">table</a></code>, or <code><a href="semantics.html#the-ul-element">ul</a></code>,
                    674:   element, or if there is no more content in the parent element and
1.123     mike      675:   the parent element is not an <code><a href="text-level-semantics.html#the-a-element">a</a></code> element.</p><!-- </rt> --><p>An <code><a href="text-level-semantics.html#the-rt-element">rt</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      676:   tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rt-element">rt</a></code> element is
                    677:   immediately followed by an <code><a href="text-level-semantics.html#the-rt-element">rt</a></code> or <code><a href="text-level-semantics.html#the-rp-element">rp</a></code>
1.123     mike      678:   element, or if there is no more content in the parent element.</p><!-- </rp> --><p>An <code><a href="text-level-semantics.html#the-rp-element">rp</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      679:   tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rp-element">rp</a></code> element is
                    680:   immediately followed by an <code><a href="text-level-semantics.html#the-rt-element">rt</a></code> or <code><a href="text-level-semantics.html#the-rp-element">rp</a></code>
1.123     mike      681:   element, or if there is no more content in the parent element.</p><!-- </optgroup> (the text assumes <optgroup> can only be inside a
1.1       mike      682:   <select>; commented out text below can handle the non-<select> case
1.123     mike      683:   if we ever allow it) --><p>An <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end tag</a> may be omitted if the
1.1       mike      684:   <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element <!--has an ancestor
                    685:   <code>select</code> element and--> is immediately followed by
                    686:   another <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or if <!--all of the elements
                    687:   that are ancestors of the <code>optgroup</code> element, up to and
                    688:   including the first ancestor element that is not an
                    689:   <code>optgroup</code> element, have no more content--> there is no
1.123     mike      690:   more content in the parent element.</p><!-- so e.g. the max number of </optgroup>s are omitted here:
1.1       mike      691:    <select><optgroup></select>
                    692:    <p id=x><optgroup></optgroup>x</p>
                    693:    <p id=x><optgroup><optgroup></optgroup></optgroup>x</p>
                    694:    <p><optgroup id=x><optgroup></optgroup>x</p>
                    695:    <p><optgroup><optgroup id=x>x</p>
1.123     mike      696:   --><!-- </option> --><p>An <code><a href="forms.html#the-option-element">option</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      697:   tag</a> may be omitted if the <code><a href="forms.html#the-option-element">option</a></code> element is
                    698:   immediately followed by another <code><a href="forms.html#the-option-element">option</a></code> element, or if
                    699:   it is immediately followed by an <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or
1.123     mike      700:   if there is no more content in the parent element.</p><!-- <colgroup> --><p>A <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element's <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> may be omitted if the
1.1       mike      701:   first thing inside the <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is a
                    702:   <code><a href="tabular-data.html#the-col-element">col</a></code> element, and if the element is not immediately
                    703:   preceded by another <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element whose <a href="#syntax-end-tag" title="syntax-end-tag">end tag</a> has been omitted. (It can't be
1.123     mike      704:   omitted if the element is empty.)</p><!-- </colgroup> --><p>A <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end tag</a> may be omitted if the
1.1       mike      705:   <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is not immediately followed by a
1.123     mike      706:   <a href="infrastructure.html#space-character">space character</a> or a <a href="#syntax-comments" title="syntax-comments">comment</a>.</p><!-- </thead> --><p>A <code><a href="tabular-data.html#the-thead-element">thead</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      707:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-thead-element">thead</a></code> element is
                    708:   immediately followed by a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> or <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code>
1.123     mike      709:   element.</p><!-- <tbody> --><p>A <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element's <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> may be omitted if the
1.1       mike      710:   first thing inside the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is a
                    711:   <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, and if the element is not immediately
                    712:   preceded by a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>, <code><a href="tabular-data.html#the-thead-element">thead</a></code>, or
                    713:   <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element whose <a href="#syntax-end-tag" title="syntax-end-tag">end
                    714:   tag</a> has been omitted. (It can't be omitted if the element is
1.123     mike      715:   empty.)</p><!-- </tbody> --><p>A <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      716:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is
                    717:   immediately followed by a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> or <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code>
1.123     mike      718:   element, or if there is no more content in the parent element.</p><!-- </tfoot> --><p>A <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      719:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element is
                    720:   immediately followed by a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element, or if there is
1.123     mike      721:   no more content in the parent element.</p><!-- </tr> --><p>A <code><a href="tabular-data.html#the-tr-element">tr</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      722:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
                    723:   immediately followed by another <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, or if there
1.123     mike      724:   is no more content in the parent element.</p><!-- </td> --><p>A <code><a href="tabular-data.html#the-td-element">td</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      725:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-td-element">td</a></code> element is
                    726:   immediately followed by a <code><a href="tabular-data.html#the-td-element">td</a></code> or <code><a href="tabular-data.html#the-th-element">th</a></code>
1.123     mike      727:   element, or if there is no more content in the parent element.</p><!-- </th> --><p>A <code><a href="tabular-data.html#the-th-element">th</a></code> element's <a href="#syntax-end-tag" title="syntax-end-tag">end
1.1       mike      728:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-th-element">th</a></code> element is
                    729:   immediately followed by a <code><a href="tabular-data.html#the-td-element">td</a></code> or <code><a href="tabular-data.html#the-th-element">th</a></code>
1.123     mike      730:   element, or if there is no more content in the parent element.</p><p><strong>However</strong>, a <a href="#syntax-start-tag" title="syntax-start-tag">start
                    731:   tag</a> must never be omitted if it has any attributes.</p><h5 id="element-restrictions"><span class="secno">9.1.2.5 </span>Restrictions on content models</h5><p>For historical reasons, certain elements have extra restrictions
                    732:   beyond even the restrictions given by their content model.</p><p>A <code><a href="tabular-data.html#the-table-element">table</a></code> element must not contain <code><a href="tabular-data.html#the-tr-element">tr</a></code>
1.1       mike      733:   elements, even though these elements are technically allowed inside
                    734:   <code><a href="tabular-data.html#the-table-element">table</a></code> elements according to the content models
                    735:   described in this specification. (If a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
                    736:   put inside a <code><a href="tabular-data.html#the-table-element">table</a></code> in the markup, it will in fact imply
1.304     mike      737:   a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> start tag before it.)</p><p>A single <a href="#syntax-newlines" title="syntax-newlines">newline</a> may be
                    738:   placed immediately after the <a href="#syntax-start-tag" title="syntax-start-tag">start
1.1       mike      739:   tag</a> of <code><a href="semantics.html#the-pre-element">pre</a></code> and <code><a href="forms.html#the-textarea-element">textarea</a></code>
                    740:   elements. This does not affect the processing of the element. The
1.304     mike      741:   otherwise optional <a href="#syntax-newlines" title="syntax-newlines">newline</a>
1.381     mike      742:   <em>must</em> be included if the element's contents themselves start
                    743:   with a <a href="#syntax-newlines" title="syntax-newlines">newline</a> (because
                    744:   otherwise the leading newline in the contents would be treated like
                    745:   the optional newline, and ignored).</p><div class="example">
1.1       mike      746:    <p>The following two <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are equivalent:</p>
                    747:    <pre>&lt;pre&gt;Hello&lt;/pre&gt;</pre>
                    748:    <pre>&lt;pre&gt;<br>Hello&lt;/pre&gt;</pre>
1.373     mike      749:   </div><h5 id="cdata-rcdata-restrictions"><span class="secno">9.1.2.6 </span>Restrictions on the contents of raw text and RCDATA elements</h5><p>The text in <a href="#raw-text-elements" title="raw text elements">raw text</a> and
                    750:   <a href="#rcdata-elements" title="RCDATA elements">RCDATAs</a> element must not
                    751:   contain any occurrences of the string "<code title="">&lt;/</code>"
                    752:   (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that
1.1       mike      753:   case-insensitively match the tag name of the element followed by one
                    754:   of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM
1.304     mike      755:   FEED (FF), U+000D CARRIAGE RETURN (CR), U+0020 SPACE, U+003E
1.542     mike      756:   GREATER-THAN SIGN (&gt;), or U+002F SOLIDUS (/).</p><h4 id="text-0"><span class="secno">9.1.3 </span>Text</h4><p><dfn id="syntax-text" title="syntax-text">Text</dfn> is allowed inside elements,
1.1       mike      757:   attributes, and comments. Text must consist of Unicode characters.
                    758:   Text must not contain U+0000 characters. Text must not contain
1.316     mike      759:   permanently undefined Unicode characters (noncharacters). Text must
                    760:   not contain control characters other than <a href="infrastructure.html#space-character" title="space
                    761:   character">space characters</a>. Extra constraints are placed on
                    762:   what is and what is not allowed in text based on where the text is
                    763:   to be put, as described in the other sections.</p><h5 id="newlines"><span class="secno">9.1.3.1 </span>Newlines</h5><p><dfn id="syntax-newlines" title="syntax-newlines">Newlines</dfn> in HTML may be
1.1       mike      764:   represented either as U+000D CARRIAGE RETURN (CR) characters, U+000A
                    765:   LINE FEED (LF) characters, or pairs of U+000D CARRIAGE RETURN (CR),
1.123     mike      766:   U+000A LINE FEED (LF) characters in that order.</p><h4 id="character-references"><span class="secno">9.1.4 </span>Character references</h4><p>In certain cases described in other sections, <a href="#syntax-text" title="syntax-text">text</a> may be mixed with <dfn id="syntax-charref" title="syntax-charref">character references</dfn>. These can be used
1.1       mike      767:   to escape characters that couldn't otherwise legally be included in
1.123     mike      768:   <a href="#syntax-text" title="syntax-text">text</a>.</p><p>Character references must start with a U+0026 AMPERSAND
1.1       mike      769:   (<code>&amp;</code>). Following this, there are three possible kinds
1.123     mike      770:   of character references:</p><dl><dt>Named character references</dt>
1.1       mike      771: 
                    772:    <dd>The ampersand must be followed by one of the names given in the
                    773:    <a href="named-character-references.html#named-character-references">named character references</a> section, using the same
                    774:    case. The name must be one that is terminated by a U+003B SEMICOLON
1.464     mike      775:    character (;).</dd>
1.1       mike      776: 
                    777: 
                    778:    <dt>Decimal numeric character reference</dt>
                    779: 
                    780:    <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
                    781:    (<code>#</code>) character, followed by one or more digits in the
1.464     mike      782:    range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), representing
                    783:    a base-ten integer that corresponds to a Unicode code point that is
1.378     mike      784:    allowed according to the definition below. The digits must then be
1.464     mike      785:    followed by a U+003B SEMICOLON character (;).</dd>
1.1       mike      786: 
                    787: 
                    788:    <dt>Hexadecimal numeric character reference</dt>
                    789: 
                    790:    <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
                    791:    (<code>#</code>) character, which must be followed by either a
1.464     mike      792:    U+0078 LATIN SMALL LETTER X character (x) or a U+0058 LATIN CAPITAL
                    793:    LETTER X character (X), which must then be followed by one or more
                    794:    digits in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9),
                    795:    U+0061 LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and
                    796:    U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F,
                    797:    representing a base-sixteen integer that corresponds to a Unicode
                    798:    code point that is allowed according to the definition below. The
                    799:    digits must then be followed by a U+003B SEMICOLON character
                    800:    (;).</dd>
1.378     mike      801: 
                    802:   </dl><p>The numeric character reference forms described above are allowed
                    803:   to reference any Unicode code point other than U+0000, permanently
                    804:   undefined Unicode characters (noncharacters), and control characters
                    805:   other than <a href="infrastructure.html#space-character" title="space character">space
                    806:   characters</a>.</p><p>An <dfn id="syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous
1.464     mike      807:   ampersand</dfn> is a U+0026 AMPERSAND character (&amp;) that is
                    808:   followed by some <a href="#syntax-text" title="syntax-text">text</a> other than a
                    809:   <a href="infrastructure.html#space-character">space character</a>, a U+003C LESS-THAN SIGN character
                    810:   (&lt;), or another U+0026 AMPERSAND character
                    811:   (<code>&amp;</code>).</p><h4 id="cdata-sections"><span class="secno">9.1.5 </span>CDATA sections</h4><p><dfn id="syntax-cdata" title="syntax-cdata">CDATA sections</dfn> must start with
1.1       mike      812:   the character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
                    813:   MARK, U+005B LEFT SQUARE BRACKET, U+0043 LATIN CAPITAL LETTER C,
                    814:   U+0044 LATIN CAPITAL LETTER D, U+0041 LATIN CAPITAL LETTER A, U+0054
                    815:   LATIN CAPITAL LETTER T, U+0041 LATIN CAPITAL LETTER A, U+005B LEFT
                    816:   SQUARE BRACKET (<code title="">&lt;![CDATA[</code>). Following this
                    817:   sequence, the CDATA section may have <a href="#syntax-text" title="syntax-text">text</a>, with the additional restriction
                    818:   that the text must not contain the three character sequence U+005D
                    819:   RIGHT SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E
                    820:   GREATER-THAN SIGN (<code title="">]]&gt;</code>). Finally, the CDATA
                    821:   section must be ended by the three character sequence U+005D RIGHT
                    822:   SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E GREATER-THAN
1.159     mike      823:   SIGN (<code title="">]]&gt;</code>).</p><h4 id="comments"><span class="secno">9.1.6 </span>Comments</h4><p class="XXX annotation"><b>Status: </b><i>Working draft</i></p><p><dfn id="syntax-comments" title="syntax-comments">Comments</dfn> must start with the
1.1       mike      824:   four character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
                    825:   MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS (<code title="">&lt;!--</code>). Following this sequence, the comment may
                    826:   have <a href="#syntax-text" title="syntax-text">text</a>, with the additional
                    827:   restriction that the text must not start with a single U+003E
1.464     mike      828:   GREATER-THAN SIGN (&gt;) character, nor start with a U+002D
                    829:   HYPHEN-MINUS character (-) followed by a
                    830:   U+003E GREATER-THAN SIGN (&gt;) character, nor contain two
1.1       mike      831:   consecutive U+002D HYPHEN-MINUS (<code title="">-</code>)
                    832:   characters, nor end with a U+002D HYPHEN-MINUS (<code title="">-</code>) character. Finally, the comment must be ended by
                    833:   the three character sequence U+002D HYPHEN-MINUS, U+002D
1.123     mike      834:   HYPHEN-MINUS, U+003E GREATER-THAN SIGN (<code title="">--&gt;</code>).</p><div class="impl">
1.1       mike      835: 
1.159     mike      836:   <h3 id="parsing"><span class="secno">9.2 </span>Parsing HTML documents</h3><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike      837: 
                    838:   <p><i>This section only applies to user agents, data mining tools,
                    839:   and conformance checkers.</i></p>
                    840: 
                    841:   <p class="note">The rules for parsing XML documents into DOM trees
                    842:   are covered by the next section, entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
                    843:   syntax</a>".</p>
                    844: 
                    845:   <p>For <a href="dom.html#html-documents">HTML documents</a>, user agents must use the parsing
                    846:   rules described in this section to generate the DOM trees. Together,
                    847:   these rules define what is referred to as the <dfn id="html-parser">HTML
                    848:   parser</dfn>.</p>
                    849: 
                    850:   <div class="note">
                    851: 
                    852:    <p>While the HTML syntax described in this specification bears a
                    853:    close resemblance to SGML and XML, it is a separate language with
                    854:    its own parsing rules.</p>
                    855: 
1.183     mike      856:    <p>Some earlier versions of HTML (in particular from HTML2 to
                    857:    HTML4) were based on SGML and used SGML parsing rules. However, few
1.1       mike      858:    (if any) web browsers ever implemented true SGML parsing for HTML
                    859:    documents; the only user agents to strictly handle HTML as an SGML
                    860:    application have historically been validators. The resulting
                    861:    confusion &#8212; with validators claiming documents to have one
                    862:    representation while widely deployed Web browsers interoperably
                    863:    implemented a different representation &#8212; has wasted decades
                    864:    of productivity. This version of HTML thus returns to a non-SGML
                    865:    basis.</p>
                    866: 
                    867:    <p>Authors interested in using SGML tools in their authoring
                    868:    pipeline are encouraged to use XML tools and the XML serialization
                    869:    of HTML.</p>
                    870: 
                    871:   </div>
                    872: 
                    873:   <p>This specification defines the parsing rules for HTML documents,
                    874:   whether they are syntactically correct or not. Certain points in the
                    875:   parsing algorithm are said to be <dfn id="parse-error" title="parse error">parse
                    876:   errors</dfn>. The error handling for parse errors is well-defined:
                    877:   user agents must either act as described below when encountering
                    878:   such problems, or must abort processing at the first error that they
                    879:   encounter for which they do not wish to apply the rules described
                    880:   below.</p>
                    881: 
                    882:   <p>Conformance checkers must report at least one parse error
                    883:   condition to the user if one or more parse error conditions exist in
                    884:   the document and must not report parse error conditions if none
                    885:   exist in the document. Conformance checkers may report more than one
1.174     mike      886:   parse error condition if more than one parse error condition exists
1.1       mike      887:   in the document. Conformance checkers are not required to recover
                    888:   from parse errors.</p>
                    889: 
                    890:   <p class="note">Parse errors are only errors with the
                    891:   <em>syntax</em> of HTML. In addition to checking for parse errors,
                    892:   conformance checkers will also verify that the document obeys all
                    893:   the other conformance requirements described in this
                    894:   specification.</p>
                    895: 
                    896:   <p>For the purposes of conformance checkers, if a resource is
                    897:   determined to be in <a href="#syntax">the HTML syntax</a>, then it is an
                    898:   <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
                    899: 
1.266     mike      900:   </div><div class="impl">
1.1       mike      901: 
                    902:   <h4 id="overview-of-the-parsing-model"><span class="secno">9.2.1 </span>Overview of the parsing model</h4>
                    903: 
                    904:   <p>The input to the HTML parsing process consists of a stream of
                    905:   Unicode characters, which is passed through a
                    906:   <a href="#tokenization">tokenization</a> stage followed by a <a href="#tree-construction">tree
                    907:   construction</a> stage. The output is a <code>Document</code>
                    908:   object.</p>
                    909: 
                    910:   <p class="note">Implementations that <a href="infrastructure.html#non-scripted">do not
                    911:   support scripting</a> do not have to actually create a DOM
                    912:   <code>Document</code> object, but the DOM tree in such cases is
                    913:   still used as the model for the rest of the specification.</p>
                    914: 
                    915:   <p>In the common case, the data handled by the tokenization stage
1.159     mike      916:   comes from the network, but <a href="embedded-content-0.html#dynamic-markup-insertion" title="dynamic markup
                    917:   insertion">it can also come from script</a>, e.g. using the <code title="dom-document-write"><a href="embedded-content-0.html#dom-document-write">document.write()</a></code> API.</p>
1.1       mike      918: 
                    919:   <p><img alt="" src="images/parsing-model-overview.png"></p>
                    920: 
                    921:   <p id="nestedParsing">There is only one set of states for the
                    922:   tokenizer stage and the tree construction stage, but the tree
                    923:   construction stage is reentrant, meaning that while the tree
                    924:   construction stage is handling one token, the tokenizer might be
                    925:   resumed, causing further tokens to be emitted and processed before
                    926:   the first token's processing is complete.</p>
                    927: 
                    928:   <div class="example">
                    929: 
                    930:    <p>In the following example, the tree construction stage will be
                    931:    called upon to handle a "p" start tag token while handling the
                    932:    "script" start tag token:</p>
                    933: 
                    934:    <pre>...
                    935: &lt;script&gt;
                    936:  document.write('&lt;p&gt;');
                    937: &lt;/script&gt;
                    938: ...</pre>
                    939: 
                    940:   </div>
                    941: 
                    942:   <p>To handle these cases, parsers have a <dfn id="script-nesting-level">script nesting
                    943:   level</dfn>, which must be initially set to zero, and a <dfn id="parser-pause-flag">parser
                    944:   pause flag</dfn>, which must be initially set to false.</p>
                    945: 
1.266     mike      946:   </div><div class="impl">
1.1       mike      947: 
                    948:   <h4 id="the-input-stream"><span class="secno">9.2.2 </span>The <dfn>input stream</dfn></h4>
                    949: 
                    950:   <p>The stream of Unicode characters that comprises the input to the
                    951:   tokenization stage will be initially seen by the user agent as a
                    952:   stream of bytes (typically coming over the network or from the local
                    953:   file system). The bytes encode the actual characters according to a
                    954:   particular <em>character encoding</em>, which the user agent must
                    955:   use to decode the bytes into characters.</p>
                    956: 
                    957:   <p class="note">For XML documents, the algorithm user agents must
                    958:   use to determine the character encoding is given by the XML
1.104     mike      959:   specification. This section does not apply to XML documents. <a href="references.html#refsXML">[XML]</a></p>
1.1       mike      960: 
                    961: 
1.168     mike      962:   <h5 id="determining-the-character-encoding"><span class="secno">9.2.2.1 </span>Determining the character encoding</h5><p class="XXX annotation"><b>Status: </b><i>Working draft</i></p>
1.1       mike      963: 
                    964:   <p>In some cases, it might be impractical to unambiguously determine
                    965:   the encoding before parsing the document. Because of this, this
                    966:   specification provides for a two-pass mechanism with an optional
                    967:   pre-scan. Implementations are allowed, as described below, to apply
                    968:   a simplified parsing algorithm to whatever bytes they have available
                    969:   before beginning to parse the document. Then, the real parser is
                    970:   started, using a tentative encoding derived from this pre-parse and
                    971:   other out-of-band metadata. If, while the document is being loaded,
                    972:   the user agent discovers an encoding declaration that conflicts with
                    973:   this information, then the parser can get reinvoked to perform a
                    974:   parse of the document with the real encoding.</p>
                    975: 
                    976:   <p id="documentEncoding">User agents must use the following
                    977:   algorithm (the <dfn id="encoding-sniffing-algorithm">encoding sniffing algorithm</dfn>) to determine
                    978:   the character encoding to use when decoding a document in the first
                    979:   pass. This algorithm takes as input any out-of-band metadata
                    980:   available to the user agent (e.g. the <a href="infrastructure.html#content-type" title="Content-Type">Content-Type metadata</a> of the document)
                    981:   and all the bytes available so far, and returns an encoding and a
                    982:   <dfn id="concept-encoding-confidence" title="concept-encoding-confidence">confidence</dfn>. The
                    983:   confidence is either <i>tentative</i>, <i>certain</i>, or
                    984:   <i>irrelevant</i>. The encoding used, and whether the confidence in
                    985:   that encoding is <i>tentative</i> or <i>certain</i>, is <a href="#meta-charset-during-parse">used during the parsing</a> to
                    986:   determine whether to <a href="#change-the-encoding">change the encoding</a>. If no
                    987:   encoding is necessary, e.g. because the parser is operating on a
                    988:   stream of Unicode characters and doesn't have to use an encoding at
                    989:   all, then the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
                    990:   <i>irrelevant</i>.</p>
                    991: 
                    992:   <ol><li><p>If the transport layer specifies an encoding, and it is
                    993:    supported, return that encoding with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                    994:    <i>certain</i>, and abort these steps.</p></li>
                    995: 
                    996:    <li><p>The user agent may wait for more bytes of the resource to be
                    997:    available, either in this step or at any later step in this
                    998:    algorithm. For instance, a user agent might wait 500ms or 512
                    999:    bytes, whichever came first. In general preparsing the source to
                   1000:    find the encoding improves performance, as it reduces the need to
                   1001:    throw away the data structures used when parsing upon finding the
                   1002:    encoding information. However, if the user agent delays too long to
                   1003:    obtain data to determine the encoding, then the cost of the delay
                   1004:    could outweigh any performance improvements from the
                   1005:    preparse.</p></li>
                   1006: 
                   1007:    <li><p>For each of the rows in the following table, starting with
                   1008:    the first one and going down, if there are as many or more bytes
                   1009:    available than the number of bytes in the first column, and the
                   1010:    first bytes of the file match the bytes given in the first column,
                   1011:    then return the encoding given in the cell in the second column of
                   1012:    that row, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1013:    <i>certain</i>, and abort these steps:</p>
                   1014: 
                   1015:     <!-- this table is present in several forms in this file; keep them in sync -->
                   1016:     <table><thead><tr><th>Bytes in Hexadecimal
                   1017:        </th><th>Encoding
                   1018:      </th></tr></thead><tbody><!-- nobody uses this
                   1019:       <tr>
                   1020:        <td>00 00 FE FF
                   1021:        <td>UTF-32BE
                   1022:       <tr>
                   1023:        <td>FF FE 00 00
                   1024:        <td>UTF-32LE
                   1025: --><tr><td>FE FF
                   1026:        </td><td>UTF-16BE
                   1027:       </td></tr><tr><td>FF FE
                   1028:        </td><td>UTF-16LE
                   1029:       </td></tr><tr><td>EF BB BF
                   1030:        </td><td>UTF-8
                   1031: <!-- nobody uses this
                   1032:       <tr>
                   1033:        <td>DD 73 66 73
                   1034:        <td>UTF-EBCDIC
                   1035: -->
                   1036:     </td></tr></tbody></table><p class="note">This step looks for Unicode Byte Order Marks
                   1037:    (BOMs).</p></li>
                   1038: 
                   1039:    <li><p>Otherwise, the user agent will have to search for explicit
                   1040:    character encoding information in the file itself. This should
                   1041:    proceed as follows:
                   1042: 
                   1043:     </p><p>Let <var title="">position</var> be a pointer to a byte in the
                   1044:     input stream, initially pointing at the first byte. If at any
                   1045:     point during these substeps the user agent either runs out of
                   1046:     bytes or decides that scanning further bytes would not be
                   1047:     efficient, then skip to the next step of the overall character
                   1048:     encoding detection algorithm. User agents may decide that scanning
                   1049:     <em>any</em> bytes is not efficient, in which case these substeps
                   1050:     are entirely skipped.</p>
                   1051: 
                   1052:     <p>Now, repeat the following "two" steps until the algorithm
                   1053:     aborts (either because user agent aborts, as described above, or
                   1054:     because a character encoding is found):</p>
                   1055: 
                   1056:     <ol><li><p>If <var title="">position</var> points to:</p>
                   1057: 
                   1058:       <dl class="switch"><dt>A sequence of bytes starting with: 0x3C 0x21 0x2D 0x2D (ASCII '&lt;!--')</dt>
                   1059:        <dd>
                   1060: 
                   1061:         <p>Advance the <var title="">position</var> pointer so that it
                   1062:         points at the first 0x3E byte which is preceded by two 0x2D
                   1063:         bytes (i.e. at the end of an ASCII '--&gt;' sequence) and comes
                   1064:         after the 0x3C byte that was found. (The two 0x2D bytes can be
                   1065:         the same as the those in the '&lt;!--' sequence.)</p>
                   1066: 
                   1067:        </dd>
                   1068: 
                   1069:        <dt>A sequence of bytes starting with: 0x3C, 0x4D or 0x6D, 0x45 or 0x65, 0x54 or 0x74, 0x41 or 0x61, and finally one of 0x09, 0x0A, 0x0C, 0x0D, 0x20, 0x2F (case-insensitive ASCII '&lt;meta' followed by a space or slash)</dt>
                   1070:        <dd>
                   1071: 
                   1072:         <ol><li><p>Advance the <var title="">position</var> pointer so
                   1073:          that it points at the next 0x09, 0x0A, 0x0C, 0x0D, 0x20, or
                   1074:          0x2F byte (the one in sequence of characters matched
                   1075:          above).</p></li>
                   1076: 
                   1077:          <li><p><a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">Get
                   1078:          an attribute</a> and its value. If no attribute was
                   1079:          sniffed, then skip this inner set of steps, and jump to the
                   1080:          second step in the overall "two step" algorithm.</p></li>
                   1081: 
                   1082:          <li><p>If the attribute's name is neither "<code title="">charset</code>" nor "<code title="">content</code>",
                   1083:          then return to step 2 in these inner steps.</p></li>
                   1084: 
                   1085:          <li><p>If the attribute's name is "<code title="">charset</code>", let <var title="">charset</var> be
                   1086:          the attribute's value, interpreted as a character
                   1087:          encoding.</p></li>
                   1088: 
                   1089:          <li><p>Otherwise, the attribute's name is "<code title="">content</code>": apply the <a href="infrastructure.html#algorithm-for-extracting-an-encoding-from-a-content-type">algorithm for
                   1090:          extracting an encoding from a Content-Type</a>, giving the
                   1091:          attribute's value as the string to parse. If an encoding is
                   1092:          returned, let <var title="">charset</var> be that
                   1093:          encoding. Otherwise, return to step 2 in these inner
                   1094:          steps.</p></li>
                   1095: 
                   1096:          <li><p>If <var title="">charset</var> is a UTF-16 encoding,
                   1097:          change the value of <var title="">charset</var> to
                   1098:          UTF-8.</p></li>
                   1099: 
                   1100:          <li><p>If <var title="">charset</var> is a supported
                   1101:          character encoding, then return the given encoding, with
                   1102:          <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1103:          <i>tentative</i>, and abort all these steps.</p></li>
                   1104: 
                   1105:          <li><p>Otherwise, return to step 2 in these inner
                   1106:          steps.</p></li>
                   1107: 
                   1108:         </ol></dd>
                   1109: 
1.464     mike     1110:        <dt>A sequence of bytes starting with a 0x3C byte (ASCII &lt;), optionally a 0x2F byte (ASCII /), and finally a byte in the range 0x41-0x5A or 0x61-0x7A (an ASCII letter)</dt>
1.1       mike     1111:        <dd>
                   1112: 
                   1113:         <ol><li><p>Advance the <var title="">position</var> pointer so
                   1114:          that it points at the next 0x09 (ASCII TAB), 0x0A (ASCII LF),
                   1115:          0x0C (ASCII FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E
1.464     mike     1116:          (ASCII &gt;) byte.</p></li>
1.1       mike     1117: 
                   1118:          <li><p>Repeatedly <a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">get an
                   1119:          attribute</a> until no further attributes can be found,
                   1120:          then jump to the second step in the overall "two step"
                   1121:          algorithm.</p></li>
                   1122: 
                   1123:         </ol></dd>
                   1124: 
                   1125:        <dt>A sequence of bytes starting with: 0x3C 0x21 (ASCII '&lt;!')</dt>
                   1126:        <dt>A sequence of bytes starting with: 0x3C 0x2F (ASCII '&lt;/')</dt>
                   1127:        <dt>A sequence of bytes starting with: 0x3C 0x3F (ASCII '&lt;?')</dt>
                   1128:        <dd>
                   1129: 
                   1130:         <p>Advance the <var title="">position</var> pointer so that it
1.464     mike     1131:         points at the first 0x3E byte (ASCII &gt;) that comes after the
1.1       mike     1132:         0x3C byte that was found.</p>
                   1133: 
                   1134:        </dd>
                   1135: 
                   1136:        <dt>Any other byte</dt>
                   1137:        <dd>
                   1138: 
                   1139:         <p>Do nothing with that byte.</p>
                   1140: 
                   1141:        </dd>
                   1142: 
                   1143:       </dl></li>
                   1144: 
                   1145:      <li>Move <var title="">position</var> so it points at the next
                   1146:      byte in the input stream, and return to the first step of this
                   1147:      "two step" algorithm.</li>
                   1148: 
                   1149:     </ol><p>When the above "two step" algorithm says to <dfn id="concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">get an
                   1150:     attribute</dfn>, it means doing this:</p>
                   1151: 
                   1152:     <ol><li><p>If the byte at <var title="">position</var> is one of 0x09
                   1153:      (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR),
1.464     mike     1154:      0x20 (ASCII space), or 0x2F (ASCII /) then advance <var title="">position</var> to the next byte and redo this
1.1       mike     1155:      substep.</p></li>
                   1156: 
                   1157:      <li><p>If the byte at <var title="">position</var> is 0x3E (ASCII
1.464     mike     1158:      &gt;), then abort the "get an attribute" algorithm. There isn't
1.1       mike     1159:      one.</p></li>
                   1160: 
                   1161:      <li><p>Otherwise, the byte at <var title="">position</var> is the
                   1162:      start of the attribute name. Let <var title="">attribute
                   1163:      name</var> and <var title="">attribute value</var> be the empty
                   1164:      string.</p></li>
                   1165: 
                   1166:      <li><p><i>Attribute name</i>: Process the byte at <var title="">position</var> as follows:</p>
                   1167: 
1.464     mike     1168:       <dl class="switch"><dt>If it is 0x3D (ASCII =), and the <var title="">attribute
1.1       mike     1169:        name</var> is longer than the empty string</dt>
                   1170: 
                   1171:        <dd>Advance <var title="">position</var> to the next byte and
                   1172:        jump to the step below labeled <i>value</i>.</dd>
                   1173: 
                   1174:        <dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
                   1175:        FF), 0x0D (ASCII CR), or 0x20 (ASCII space)</dt>
                   1176: 
                   1177:        <dd>Jump to the step below labeled <i>spaces</i>.</dd>
                   1178: 
1.464     mike     1179:        <dt>If it is 0x2F (ASCII /) or 0x3E (ASCII &gt;)</dt>
1.1       mike     1180: 
                   1181:        <dd>Abort the "get an attribute" algorithm. The attribute's
                   1182:        name is the value of <var title="">attribute name</var>, its
                   1183:        value is the empty string.</dd>
                   1184: 
1.464     mike     1185:        <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
                   1186:        Z)</dt>
1.1       mike     1187: 
                   1188:        <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
                   1189:        name</var> (where <var title="">b</var> is the value of the
                   1190:        byte at <var title="">position</var>).</dd>
                   1191: 
                   1192:        <dt>Anything else</dt>
                   1193: 
                   1194:        <dd>Append the Unicode character with the same code point as the
                   1195:        value of the byte at <var title="">position</var>) to <var title="">attribute name</var>. (It doesn't actually matter how
                   1196:        bytes outside the ASCII range are handled here, since only
                   1197:        ASCII characters can contribute to the detection of a character
                   1198:        encoding.)</dd>
                   1199: 
                   1200:       </dl></li>
                   1201: 
                   1202:      <li><p>Advance <var title="">position</var> to the next byte and
                   1203:      return to the previous step.</p></li>
                   1204: 
                   1205:      <li><p><i>Spaces</i>: If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
                   1206:      LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
                   1207:      advance <var title="">position</var> to the next byte, then,
                   1208:      repeat this step.</p></li>
                   1209: 
                   1210:      <li><p>If the byte at <var title="">position</var> is
1.464     mike     1211:      <em>not</em> 0x3D (ASCII =), abort the "get an attribute"
1.1       mike     1212:      algorithm. The attribute's name is the value of <var title="">attribute name</var>, its value is the empty
                   1213:      string.</p></li>
                   1214: 
                   1215:      <li><p>Advance <var title="">position</var> past the 0x3D (ASCII
1.464     mike     1216:      =) byte.</p></li>
1.1       mike     1217: 
                   1218:      <li><p><i>Value:</i> If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
                   1219:      LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
                   1220:      advance <var title="">position</var> to the next byte, then,
                   1221:      repeat this step.</p></li>
                   1222: 
                   1223:      <li><p>Process the byte at <var title="">position</var> as
                   1224:      follows:</p>
                   1225: 
1.464     mike     1226:       <dl class="switch"><dt>If it is 0x22 (ASCII ") or 0x27 (ASCII ')</dt>
1.1       mike     1227: 
                   1228:        <dd>
                   1229: 
                   1230:         <ol><li>Let <var title="">b</var> be the value of the byte at
                   1231:          <var title="">position</var>.</li>
                   1232: 
                   1233:          <li>Advance <var title="">position</var> to the next
                   1234:          byte.</li>
                   1235: 
                   1236:          <li>If the value of the byte at <var title="">position</var>
                   1237:          is the value of <var title="">b</var>, then advance <var title="">position</var> to the next byte and abort the "get
                   1238:          an attribute" algorithm. The attribute's name is the value of
                   1239:          <var title="">attribute name</var>, and its value is the
                   1240:          value of <var title="">attribute value</var>.</li>
                   1241: 
1.464     mike     1242:          <li>Otherwise, if the value of the byte at <var title="">position</var> is in the range 0x41 (ASCII A) to
                   1243:          0x5A (ASCII Z), then append a Unicode character to <var title="">attribute value</var> whose code point is 0x20 more
1.1       mike     1244:          than the value of the byte at <var title="">position</var>.</li>
                   1245: 
                   1246:          <li>Otherwise, append a Unicode character to <var title="">attribute value</var> whose code point is the same as
                   1247:          the value of the byte at <var title="">position</var>.</li>
                   1248: 
                   1249:          <li>Return to the second step in these substeps.</li>
                   1250: 
                   1251:         </ol></dd>
                   1252: 
1.464     mike     1253:        <dt>If it is 0x3E (ASCII &gt;)</dt>
1.1       mike     1254: 
                   1255:        <dd>Abort the "get an attribute" algorithm. The attribute's
                   1256:        name is the value of <var title="">attribute name</var>, its
                   1257:        value is the empty string.</dd>
                   1258: 
                   1259: 
1.464     mike     1260:        <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
                   1261:        Z)</dt>
1.1       mike     1262: 
                   1263:        <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
                   1264:        value</var> (where <var title="">b</var> is the value of the
                   1265:        byte at <var title="">position</var>). Advance <var title="">position</var> to the next byte.</dd>
                   1266: 
                   1267:        <dt>Anything else</dt>
                   1268: 
                   1269:        <dd>Append the Unicode character with the same code point as the
                   1270:        value of the byte at <var title="">position</var>) to <var title="">attribute value</var>. Advance <var title="">position</var> to the next byte.</dd>
                   1271: 
                   1272:       </dl></li>
                   1273: 
                   1274:      <li><p>Process the byte at <var title="">position</var> as
                   1275:      follows:</p>
                   1276: 
                   1277:       <dl class="switch"><dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
                   1278:        FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E (ASCII
1.464     mike     1279:        &gt;)</dt>
1.1       mike     1280: 
                   1281:        <dd>Abort the "get an attribute" algorithm. The attribute's
                   1282:        name is the value of <var title="">attribute name</var> and its
                   1283:        value is the value of <var title="">attribute value</var>.</dd>
                   1284: 
1.464     mike     1285:        <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
                   1286:        Z)</dt>
1.1       mike     1287: 
                   1288:        <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
                   1289:        value</var> (where <var title="">b</var> is the value of the
                   1290:        byte at <var title="">position</var>).</dd>
                   1291: 
                   1292:        <dt>Anything else</dt>
                   1293: 
                   1294:        <dd>Append the Unicode character with the same code point as the
                   1295:        value of the byte at <var title="">position</var>) to <var title="">attribute value</var>.</dd>
                   1296: 
                   1297:       </dl></li>
                   1298: 
                   1299:      <li><p>Advance <var title="">position</var> to the next byte and
                   1300:      return to the previous step.</p></li>
                   1301: 
                   1302:     </ol><p>For the sake of interoperability, user agents should not use a
                   1303:     pre-scan algorithm that returns different results than the one
                   1304:     described above. (But, if you do, please at least let us know, so
                   1305:     that we can improve this algorithm and benefit everyone...)</p>
                   1306: 
                   1307:    </li>
                   1308: 
                   1309:    <li><p>If the user agent has information on the likely encoding for
                   1310:    this page, e.g. based on the encoding of the page when it was last
                   1311:    visited, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1312:    <i>tentative</i>, and abort these steps.</p></li>
                   1313: 
1.322     mike     1314:    <li>
                   1315: 
                   1316:     <p>The user agent may attempt to autodetect the character encoding
                   1317:     from applying frequency analysis or other algorithms to the data
                   1318:     stream. If autodetection succeeds in determining a character
                   1319:     encoding, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1320:     <i>tentative</i>, and abort these steps. <a href="references.html#refsUNIVCHARDET">[UNIVCHARDET]</a></p>
                   1321: 
                   1322:     <p class="note">The UTF-8 encoding has a highly detectable bit
                   1323:     pattern. Documents that contain bytes with values greater than
                   1324:     0x7F which match the UTF-8 pattern are very likely to be UTF-8,
                   1325:     while documents with byte sequences that do not match it are very
                   1326:     likely not. User-agents are therefore encouraged to search for
1.485     mike     1327:     this common encoding. <a href="references.html#refsPPUTF8">[PPUTF8]</a> <a href="references.html#refsUTF8DET">[UTF8DET]</a></p>
1.322     mike     1328: 
                   1329:    </li>
1.1       mike     1330: 
1.501     mike     1331:    <li>
                   1332: 
                   1333:     <p>Otherwise, return an implementation-defined or user-specified
                   1334:     default character encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1335:     <i>tentative</i>.</p>
                   1336: 
                   1337:     <p>In controlled environments or in environments where the
                   1338:     encoding of documents can be prescribed (for example, for user
                   1339:     agents intended for dedicated use in new networks), the
                   1340:     comprehensive <code title="">UTF-8</code> encoding is
                   1341:     suggested.</p>
                   1342: 
                   1343:     <p>In other environments, the default encoding is typically
                   1344:     dependent on the user's locale (an approximation of the languages,
                   1345:     and thus typically encodings, of the pages that the user is likely
                   1346:     to frequent). The following table gives suggested defaults based
1.504     mike     1347:     on the user's locale, for compatibility with legacy
                   1348:     content. Locales are identified by BCP 47 language codes. <a href="references.html#refsBCP47">[BCP47]</a></p>
1.501     mike     1349: 
                   1350:     <!-- based on mozilla 1.9.1 localizations: 
                   1351:          http://mxr.mozilla.org/l10n-mozilla1.9.1/find?string=global%2Fintl.properties&tree=l10n-mozilla1.9.1&hint= -->
                   1352: 
1.504     mike     1353:     <table><thead><tr><th>Locale language
1.501     mike     1354:        </th><th>Suggested default encoding
                   1355:      </th></tr></thead><tbody><tr><td>ar
                   1356:        </td><td>UTF-8
                   1357: 
                   1358:       </td></tr><tr><td>be
                   1359:        </td><td>ISO-8859-5
                   1360: 
                   1361:       </td></tr><tr><td>bg
                   1362:        </td><td>windows-1251
                   1363: 
                   1364:       </td></tr><tr><td>cs<!-- -CZ -->
                   1365:        </td><td>ISO-8859-2
                   1366: 
                   1367:       </td></tr><tr><td>cy
                   1368:        </td><td>UTF-8
                   1369: 
                   1370:       </td></tr><tr><td>fa<!-- -IR -->
                   1371:        </td><td>UTF-8
                   1372: 
                   1373:       </td></tr><tr><td>he<!-- -IL -->
                   1374:        </td><td>windows-1255
                   1375: 
                   1376:       </td></tr><tr><td>hr
                   1377:        </td><td>UTF-8
                   1378: 
                   1379:       </td></tr><tr><td>hu<!-- -HU -->
                   1380:        </td><td>ISO-8859-2
                   1381: 
                   1382:       </td></tr><tr><td>ja <!-- and ja-JP-mac -->
                   1383:        </td><td>windows-31J <!-- Shift_JIS -->
                   1384: 
                   1385:       </td></tr><tr><td>kk
                   1386:        </td><td>UTF-8
                   1387: 
                   1388:       </td></tr><tr><td>ko<!-- -KR -->
                   1389:        </td><td>windows-949 <!-- EUC-KR -->
                   1390: 
                   1391:       </td></tr><tr><td>ku
                   1392:        </td><td>windows-1254 <!-- ISO-8859-9 -->
                   1393: 
                   1394:       </td></tr><tr><td>lt
                   1395:        </td><td>windows-1257
                   1396: 
                   1397:       </td></tr><tr><td>lv<!-- -LV -->
                   1398:        </td><td>ISO-8859-13
                   1399: 
                   1400:       </td></tr><tr><td>mk<!-- -MK -->
                   1401:        </td><td>UTF-8
                   1402: 
                   1403:       </td></tr><tr><td>or
                   1404:        </td><td>UTF-8
                   1405: 
                   1406:       </td></tr><tr><td>pl<!-- -PL -->
                   1407:        </td><td>ISO-8859-2
                   1408: 
                   1409:       </td></tr><tr><td>ro
                   1410:        </td><td>UTF-8
                   1411: 
                   1412:       </td></tr><tr><td>ru
                   1413:        </td><td>windows-1251
                   1414: 
                   1415:       </td></tr><tr><td>sk
                   1416:        </td><td>windows-1250
                   1417: 
                   1418:       </td></tr><tr><td>sl
                   1419:        </td><td>ISO-8859-2
                   1420: 
                   1421:       </td></tr><tr><td>sr
                   1422:        </td><td>UTF-8
                   1423: 
                   1424:       </td></tr><tr><td>th
                   1425:        </td><td>windows-874 <!-- TIS-620 -->
                   1426: 
                   1427:       </td></tr><tr><td>tr<!-- -TR -->
                   1428:        </td><td>windows-1254 <!-- ISO-8859-9 -->
                   1429: 
1.503     mike     1430:       </td></tr><tr><td>uk
1.501     mike     1431:        </td><td>windows-1251
                   1432: 
                   1433:       </td></tr><tr><td>vi
                   1434:        </td><td>UTF-8
                   1435: 
                   1436:       </td></tr><tr><td>zh-CN
                   1437:        </td><td>GB18030
                   1438: 
                   1439:       </td></tr><tr><td>zh-TW
                   1440:        </td><td>Big5
                   1441: 
                   1442:       </td></tr><tr><td>All other locales
                   1443:        </td><td>windows-1252
                   1444: 
                   1445:     </td></tr></tbody></table></li>
1.1       mike     1446: 
                   1447:   </ol><p>The <a href="dom.html#document-s-character-encoding">document's character encoding</a> must immediately
                   1448:   be set to the value returned from this algorithm, at the same time
                   1449:   as the user agent uses the returned value to select the decoder to
                   1450:   use for the input stream.</p>
                   1451: 
                   1452: 
1.237     mike     1453:   <h5 id="character-encodings-0"><span class="secno">9.2.2.2 </span>Character encodings</h5><p class="XXX annotation"><b>Status: </b><i>Working draft</i></p>
1.1       mike     1454: 
1.237     mike     1455:   <p>User agents must at a minimum support the UTF-8 and Windows-1252
                   1456:   encodings, but may support more.</p>
                   1457: 
                   1458:   <p class="note">It is not unusual for Web browsers to support dozens
                   1459:   if not upwards of a hundred distinct character encodings.</p>
                   1460: 
1.365     mike     1461:   <p>User agents must support the <a href="infrastructure.html#preferred-mime-name">preferred MIME name</a> of
                   1462:   every character encoding they support, and should support all the
                   1463:   IANA-registered names and aliases of every character encoding they
                   1464:   support. <a href="references.html#refsIANACHARSET">[IANACHARSET]</a></p>
1.237     mike     1465: 
                   1466:   <p>When comparing a string specifying a character encoding with the
                   1467:   name or alias of a character encoding to determine if they are
                   1468:   equal, user agents must remove any leading or trailing <a href="infrastructure.html#space-character" title="space character">space characters</a> in both names, and
                   1469:   then perform the comparison in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   1470:   case-insensitive</a> manner.</p>
                   1471: 
1.539     mike     1472:   <hr><p>When a user agent would otherwise use an encoding given in the
1.237     mike     1473:   first column of the following table to either convert content to
                   1474:   Unicode characters or convert Unicode characters to bytes, it must
                   1475:   instead use the encoding given in the cell in the second column of
                   1476:   the same row. When a byte or sequence of bytes is treated
                   1477:   differently due to this encoding aliasing, it is said to have been
                   1478:   <dfn id="misinterpreted-for-compatibility">misinterpreted for compatibility</dfn>.</p>
                   1479: 
                   1480:   <table><caption>Character encoding overrides</caption>
                   1481:    <thead><tr><th> Input encoding </th><th> Replacement encoding </th><th> References
                   1482:    </th></tr></thead><tbody><!-- how about EUC-JP? --><tr><td> EUC-KR </td><td> windows-949 </td><td>
                   1483:          <a href="references.html#refsEUCKR">[EUCKR]</a>
                   1484:          <a href="references.html#refsWIN949">[WIN949]</a>
                   1485:     </td></tr><tr><td> GB2312 </td><td> GBK </td><td>
                   1486:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1487:          <a href="references.html#refsGBK">[GBK]</a>
                   1488:     </td></tr><tr><td> GB_2312-80 </td><td> GBK </td><td>
                   1489:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1490:          <a href="references.html#refsGBK">[GBK]</a>
                   1491:     </td></tr><tr><td> ISO-8859-1 </td><td> windows-1252 </td><td>
                   1492:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1493:          <a href="references.html#refsWIN1252">[WIN1252]</a>
                   1494:     </td></tr><tr><td> ISO-8859-9 </td><td> windows-1254 </td><td>
                   1495:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1496:          <a href="references.html#refsWIN1254">[WIN1254]</a>
                   1497:     </td></tr><tr><td> ISO-8859-11 </td><td> windows-874 </td><td>
                   1498:          <a href="references.html#refsISO885911">[ISO885911]</a>
                   1499:          <a href="references.html#refsWIN874">[WIN874]</a>
                   1500:     </td></tr><tr><td> KS_C_5601-1987 </td><td> windows-949 </td><td>
                   1501:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1502:          <a href="references.html#refsWIN949">[WIN949]</a>
                   1503:     </td></tr><tr><td> Shift_JIS </td><td> windows-31J </td><td>
                   1504:          <a href="references.html#refsSHIFTJIS">[SHIFTJIS]</a>
                   1505:          <a href="references.html#refsWIN31J">[WIN31J]</a>
                   1506:     </td></tr><tr><td> TIS-620 </td><td> windows-874 </td><td>
                   1507:          <a href="references.html#refsTIS620">[TIS620]</a>
                   1508:          <a href="references.html#refsWIN874">[WIN874]</a>
                   1509:     </td></tr><tr><td> US-ASCII </td><td> windows-1252 </td><td>
                   1510:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1511:          <a href="references.html#refsWIN1252">[WIN1252]</a>
                   1512:    </td></tr></tbody></table><p class="note">The requirement to treat certain encodings as other
                   1513:   encodings according to the table above is a <a href="introduction.html#willful-violation">willful
                   1514:   violation</a> of the W3C Character Model specification, motivated
                   1515:   by a desire for compatibility with legacy content. <a href="references.html#refsCHARMOD">[CHARMOD]</a></p>
                   1516: 
                   1517:   <p>When a user agent is to use the UTF-16 encoding but no BOM has
                   1518:   been found, user agents must default to UTF-16LE.</p>
                   1519: 
                   1520:   <p class="note">The requirement to default UTF-16 to LE rather than
                   1521:   BE is a <a href="introduction.html#willful-violation">willful violation</a> of RFC 2781, motivated by a
                   1522:   desire for compatibility with legacy content. <a href="references.html#refsCHARMOD">[CHARMOD]</a></p>
                   1523: 
                   1524:   <hr><p>User agents must not support the CESU-8, UTF-7, BOCU-1 and SCSU
                   1525:   encodings. <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>
                   1526: 
                   1527:   <p>Support for encodings based on EBCDIC is not recommended. This
                   1528:   encoding is rarely used for publicly-facing Web content.</p>
                   1529: 
                   1530:   <p>Support for UTF-32 is not recommended. This encoding is rarely
                   1531:   used, and frequently implemented incorrectly.</p>
                   1532: 
                   1533:   <p class="note">This specification does not make any attempt to
                   1534:   support EBCDIC-based encodings and UTF-32 in its algorithms; support
                   1535:   and use of these encodings can thus lead to unexpected behavior in
                   1536:   implementations of this specification.</p>
                   1537: 
                   1538: 
                   1539: 
                   1540:   <h5 id="preprocessing-the-input-stream"><span class="secno">9.2.2.3 </span>Preprocessing the input stream</h5>
1.1       mike     1541: 
                   1542:   <p>Given an encoding, the bytes in the input stream must be
                   1543:   converted to Unicode characters for the tokenizer, as described by
                   1544:   the rules for that encoding, except that the leading U+FEFF BYTE
                   1545:   ORDER MARK character, if any, must not be stripped by the encoding
                   1546:   layer (it is stripped by the rule below).</p> <!-- this is to
                   1547:   prevent two leading BOMs from being both stripped, once by the
                   1548:   decoder, and once by the parser -->
                   1549: 
                   1550:   <p>Bytes or sequences of bytes in the original byte stream that
1.393     mike     1551:   could not be converted to Unicode code points must be converted to
                   1552:   U+FFFD REPLACEMENT CHARACTERs.</p>
1.1       mike     1553: 
                   1554:   <p class="note">Bytes or sequences of bytes in the original byte
                   1555:   stream that did not conform to the encoding specification
                   1556:   (e.g. invalid UTF-8 byte sequences in a UTF-8 input stream) are
                   1557:   errors that conformance checkers are expected to report.</p>
                   1558: 
1.438     mike     1559:   <p>Any byte or sequence of bytes in the original byte stream that is
                   1560:   <a href="#misinterpreted-for-compatibility">misinterpreted for compatibility</a> is a <a href="#parse-error">parse
1.1       mike     1561:   error</a>.</p>
                   1562: 
                   1563:   <p>One leading U+FEFF BYTE ORDER MARK character must be ignored if
                   1564:   any are present.</p>
                   1565: 
1.300     mike     1566:   <p class="note">The requirement to strip a U+FEFF BYTE ORDER MARK
                   1567:   character regardless of whether that character was used to determine
                   1568:   the byte order is a <a href="introduction.html#willful-violation">willful violation</a> of Unicode,
                   1569:   motivated by a desire to increase the resilience of user agents in
                   1570:   the face of na&#239;ve transcoders.</p>
                   1571: 
1.316     mike     1572:   <p>All U+0000 NULL characters and code points in the range U+D800 to
1.315     mike     1573:   U+DFFF<!-- surrogates not allowed e.g. in UTF-8, and we don't want
                   1574:   them to suddenly turn into codepoints when they go through a UTF-16
                   1575:   pipe --> in the input must be replaced by U+FFFD REPLACEMENT
1.316     mike     1576:   CHARACTERs. Any occurrences of such characters and code points are
                   1577:   <a href="#parse-error" title="parse error">parse errors</a>.</p>
1.1       mike     1578: 
                   1579:   <p>Any occurrences of any characters in the ranges U+0001 to U+0008,
                   1580:   <!-- HT, LF allowed --> <!-- U+000B is in the next list --> <!-- FF,
                   1581:   CR allowed --> U+000E to U+001F, <!-- ASCII allowed --> U+007F
1.315     mike     1582:   <!--to U+0084, (U+0085 NEL not allowed), U+0086--> to U+009F, U+FDD0
                   1583:   to U+FDEF, and characters U+000B, U+FFFE, U+FFFF, U+1FFFE, U+1FFFF,
                   1584:   U+2FFFE, U+2FFFF, U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE,
                   1585:   U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF,
                   1586:   U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE,
                   1587:   U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF,
                   1588:   U+10FFFE, and U+10FFFF are <a href="#parse-error" title="parse error">parse
1.316     mike     1589:   errors</a>. These are all control characters or permanently
                   1590:   undefined Unicode characters (noncharacters).</p>
1.1       mike     1591: 
                   1592:   <p>U+000D CARRIAGE RETURN (CR) characters and U+000A LINE FEED (LF)
                   1593:   characters are treated specially. Any CR characters that are
                   1594:   followed by LF characters must be removed, and any CR characters not
                   1595:   followed by LF characters must be converted to LF characters. Thus,
                   1596:   newlines in HTML DOMs are represented by LF characters, and there
                   1597:   are never any CR characters in the input to the
                   1598:   <a href="#tokenization">tokenization</a> stage.</p>
                   1599: 
                   1600:   <p>The <dfn id="next-input-character">next input character</dfn> is the first character in the
                   1601:   input stream that has not yet been <dfn id="consumed">consumed</dfn>. Initially,
                   1602:   the <i><a href="#next-input-character">next input character</a></i> is the first character in the
                   1603:   input. The <dfn id="current-input-character">current input character</dfn> is the last character
                   1604:   to have been <i><a href="#consumed">consumed</a></i>.</p>
                   1605: 
                   1606:   <p>The <dfn id="insertion-point">insertion point</dfn> is the position (just before a
                   1607:   character or just before the end of the input stream) where content
1.159     mike     1608:   inserted using <code title="dom-document-write"><a href="embedded-content-0.html#dom-document-write">document.write()</a></code> is actually
1.1       mike     1609:   inserted. The insertion point is relative to the position of the
                   1610:   character immediately after it, it is not an absolute offset into
                   1611:   the input stream. Initially, the insertion point is
1.10      mike     1612:   undefined.</p>
1.1       mike     1613: 
                   1614:   <p>The "EOF" character in the tables below is a conceptual character
                   1615:   representing the end of the <a href="#the-input-stream">input stream</a>. If the parser
1.159     mike     1616:   is a <a href="embedded-content-0.html#script-created-parser">script-created parser</a>, then the end of the
1.1       mike     1617:   <a href="#the-input-stream">input stream</a> is reached when an <dfn id="explicit-eof-character">explicit "EOF"
1.159     mike     1618:   character</dfn> (inserted by the <code title="dom-document-close"><a href="embedded-content-0.html#dom-document-close">document.close()</a></code> method) is
1.1       mike     1619:   consumed. Otherwise, the "EOF" character is not a real character in
                   1620:   the stream, but rather the lack of any further characters.</p>
                   1621: 
                   1622: 
1.237     mike     1623:   <h5 id="changing-the-encoding-while-parsing"><span class="secno">9.2.2.4 </span>Changing the encoding while parsing</h5>
1.1       mike     1624: 
                   1625:   <p>When the parser requires the user agent to <dfn id="change-the-encoding">change the
                   1626:   encoding</dfn>, it must run the following steps. This might happen
                   1627:   if the <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> described above
                   1628:   failed to find an encoding, or if it found an encoding that was not
                   1629:   the actual encoding of the file.</p>
                   1630: 
                   1631:   <ol><li>If the new encoding is identical or equivalent to the encoding
                   1632:    that is already being used to interpret the input stream, then set
                   1633:    the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1634:    <i>certain</i> and abort these steps. This happens when the
                   1635:    encoding information found in the file matches what the
                   1636:    <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> determined to be the
                   1637:    encoding, and in the second pass through the parser if the first
                   1638:    pass found that the encoding sniffing algorithm described in the
                   1639:    earlier section failed to find the right encoding.</li>
                   1640: 
                   1641:    <li>If the encoding that is already being used to interpret the
                   1642:    input stream is a UTF-16 encoding, then set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1643:    <i>certain</i> and abort these steps. The new encoding is ignored;
                   1644:    if it was anything but the same encoding, then it would be clearly
                   1645:    incorrect.</li>
                   1646: 
                   1647:    <li>If the new encoding is a UTF-16 encoding, change it to
                   1648:    UTF-8.</li>
                   1649: 
                   1650:    <li>If all the bytes up to the last byte converted by the current
                   1651:    decoder have the same Unicode interpretations in both the current
                   1652:    encoding and the new encoding, and if the user agent supports
                   1653:    changing the converter on the fly, then the user agent may change
                   1654:    to the new converter for the encoding on the fly. Set the
                   1655:    <a href="dom.html#document-s-character-encoding">document's character encoding</a> and the encoding used to
                   1656:    convert the input stream to the new encoding, set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1657:    <i>certain</i>, and abort these steps.</li>
                   1658: 
                   1659:    <li>Otherwise, <a href="history.html#navigate">navigate</a> to the document again, with
                   1660:    <a href="history.html#replacement-enabled">replacement enabled</a>, and using the same <a href="history.html#source-browsing-context">source
                   1661:    browsing context</a>, but this time skip the <a href="#encoding-sniffing-algorithm">encoding
                   1662:    sniffing algorithm</a> and instead just set the encoding to the
                   1663:    new encoding and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1664:    <i>certain</i>. Whenever possible, this should be done without
                   1665:    actually contacting the network layer (the bytes should be
                   1666:    re-parsed from memory), even if, e.g., the document is marked as
                   1667:    not being cacheable. If this is not possible and contacting the
                   1668:    network layer would involve repeating a request that uses a method
                   1669:    other than HTTP GET (<a href="infrastructure.html#concept-http-equivalent-get" title="concept-http-equivalent-get">or
                   1670:    equivalent</a> for non-HTTP URLs), then instead set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1671:    <i>certain</i> and ignore the new encoding. The resource will be
                   1672:    misinterpreted. User agents may notify the user of the situation,
                   1673:    to aid in application development.</li>
                   1674: 
1.266     mike     1675:   </ol></div><div class="impl">
                   1676: 
                   1677:   <h4 id="parse-state"><span class="secno">9.2.3 </span>Parse state</h4>
1.1       mike     1678: 
                   1679:   <h5 id="the-insertion-mode"><span class="secno">9.2.3.1 </span>The insertion mode</h5>
                   1680: 
                   1681:   <p>The <dfn id="insertion-mode">insertion mode</dfn> is a state variable that controls
                   1682:   the primary operation of the tree construction stage.</p>
                   1683: 
                   1684:   <p>Initially, the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-initial-insertion-mode" title="insertion mode: initial">initial</a>". It can change to
                   1685:   "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before html</a>",
                   1686:   "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before head</a>",
                   1687:   "<a href="#parsing-main-inhead" title="insertion mode: in head">in head</a>", "<a href="#parsing-main-inheadnoscript" title="insertion mode: in head noscript">in head noscript</a>",
1.540     mike     1688:   "<a href="#the-after-head-insertion-mode" title="insertion mode: after head">after head</a>", "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>", "<a href="#parsing-main-incdata" title="insertion mode: text">text</a>",
1.1       mike     1689:   "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>", "<a href="#parsing-main-intabletext" title="insertion mode: in table text">in table text</a>", "<a href="#parsing-main-incaption" title="insertion mode: in caption">in caption</a>", "<a href="#parsing-main-incolgroup" title="insertion mode: in column group">in column group</a>",
                   1690:   "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table body</a>",
                   1691:   "<a href="#parsing-main-intr" title="insertion mode: in row">in row</a>", "<a href="#parsing-main-intd" title="insertion mode: in cell">in cell</a>", "<a href="#parsing-main-inselect" title="insertion mode: in select">in select</a>", "<a href="#parsing-main-inselectintable" title="insertion mode: in select in table">in select in
                   1692:   table</a>", "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in
                   1693:   foreign content</a>", "<a href="#parsing-main-afterbody" title="insertion mode: after
                   1694:   body">after body</a>", "<a href="#parsing-main-inframeset" title="insertion mode: in
                   1695:   frameset">in frameset</a>", "<a href="#parsing-main-afterframeset" title="insertion mode: after
                   1696:   frameset">after frameset</a>", "<a href="#the-after-after-body-insertion-mode" title="insertion mode:
                   1697:   after after body">after after body</a>", and "<a href="#the-after-after-frameset-insertion-mode" title="insertion mode: after after frameset">after after
                   1698:   frameset</a>" during the course of the parsing, as described in
                   1699:   the <a href="#tree-construction">tree construction</a> stage. The insertion mode affects
                   1700:   how tokens are processed and whether CDATA sections are
                   1701:   supported.</p>
                   1702: 
                   1703:   <p>Seven of these modes, namely "<a href="#parsing-main-inhead" title="insertion mode: in
                   1704:   head">in head</a>", "<a href="#parsing-main-inbody" title="insertion mode: in body">in
                   1705:   body</a>", "<a href="#parsing-main-intable" title="insertion mode: in table">in
                   1706:   table</a>", "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   1707:   body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in row</a>",
                   1708:   "<a href="#parsing-main-intd" title="insertion mode: in cell">in cell</a>", and "<a href="#parsing-main-inselect" title="insertion mode: in select">in select</a>", are special, in
                   1709:   that the other modes defer to them at various times. When the
                   1710:   algorithm below says that the user agent is to do something
                   1711:   "<dfn id="using-the-rules-for">using the rules for</dfn> the <var title="">m</var> insertion
                   1712:   mode", where <var title="">m</var> is one of these modes, the user
                   1713:   agent must use the rules described under the <var title="">m</var>
                   1714:   <a href="#insertion-mode">insertion mode</a>'s section, but must leave the
                   1715:   <a href="#insertion-mode">insertion mode</a> unchanged unless the rules in <var title="">m</var> themselves switch the <a href="#insertion-mode">insertion mode</a>
                   1716:   to a new value.</p>
                   1717: 
                   1718:   <p>When the insertion mode is switched to "<a href="#parsing-main-incdata" title="insertion
1.540     mike     1719:   mode: text">text</a>" or "<a href="#parsing-main-intabletext" title="insertion mode: in table
                   1720:   text">in table text</a>", the <dfn id="original-insertion-mode">original insertion mode</dfn>
                   1721:   is also set. This is the insertion mode to which the tree
                   1722:   construction stage will return.</p>
1.1       mike     1723: 
                   1724:   <p>When the insertion mode is switched to "<a href="#parsing-main-inforeign" title="insertion
                   1725:   mode: in foreign content">in foreign content</a>", the
                   1726:   <dfn id="secondary-insertion-mode">secondary insertion mode</dfn> is also set. This secondary mode
                   1727:   is used within the rules for the "<a href="#parsing-main-inforeign" title="insertion mode: in
                   1728:   foreign content">in foreign content</a>" mode to handle HTML
                   1729:   (i.e. not foreign) content.</p>
                   1730: 
                   1731:   <hr><p>When the steps below require the UA to <dfn id="reset-the-insertion-mode-appropriately">reset the insertion
                   1732:   mode appropriately</dfn>, it means the UA must follow these
                   1733:   steps:</p>
                   1734: 
                   1735:   <ol><li>Let <var title="">last</var> be false.</li>
                   1736: 
                   1737:    <li>Let <var title="">node</var> be the last node in the
                   1738:    <a href="#stack-of-open-elements">stack of open elements</a>.</li>
                   1739: 
                   1740:    <li>If <var title="">node</var> is the first node in the stack of
                   1741:    open elements, then set <var title="">last</var> to true and set
                   1742:    <var title="">node</var> to the <var title="">context</var>
                   1743:    element. (<a href="#fragment-case">fragment case</a>)</li>
                   1744: 
                   1745:    <li>If <var title="">node</var> is a <code><a href="forms.html#the-select-element">select</a></code> element,
                   1746:    then switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inselect" title="insertion mode: in select">in select</a>" and abort these
                   1747:    steps. (<a href="#fragment-case">fragment case</a>)</li>
                   1748: 
                   1749:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-td-element">td</a></code> or
                   1750:    <code><a href="tabular-data.html#the-th-element">th</a></code> element and <var title="">last</var> is false, then
                   1751:    switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion
                   1752:    mode: in cell">in cell</a>" and abort these steps.</li>
                   1753: 
                   1754:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then
                   1755:    switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion
                   1756:    mode: in row">in row</a>" and abort these steps.</li>
                   1757: 
                   1758:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>,
                   1759:    <code><a href="tabular-data.html#the-thead-element">thead</a></code>, or <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element, then switch the
                   1760:    <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in
                   1761:    table body">in table body</a>" and abort these steps.</li>
                   1762: 
                   1763:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-caption-element">caption</a></code> element,
                   1764:    then switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incaption" title="insertion mode: in caption">in caption</a>" and abort
                   1765:    these steps.</li>
                   1766: 
                   1767:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element,
                   1768:    then switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incolgroup" title="insertion mode: in column group">in column group</a>" and
                   1769:    abort these steps. (<a href="#fragment-case">fragment case</a>)</li>
                   1770: 
                   1771:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-table-element">table</a></code> element,
                   1772:    then switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>" and abort these
                   1773:    steps.</li>
                   1774: 
                   1775:    <li>If <var title="">node</var> is an element from the <a href="#mathml-namespace">MathML
                   1776:    namespace</a> or the <a href="#svg-namespace">SVG namespace</a>, then switch the
                   1777:    <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
                   1778:    foreign content">in foreign content</a>", let the
                   1779:    <a href="#secondary-insertion-mode">secondary insertion mode</a> be "<a href="#parsing-main-inbody" title="insertion
                   1780:    mode: in body">in body</a>", and abort these steps.</li>
                   1781: 
1.159     mike     1782:    <li>If <var title="">node</var> is a <code><a href="semantics.html#the-head-element-0">head</a></code> element,
1.1       mike     1783:    then switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" ("<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>"! <em> not "<a href="#parsing-main-inhead" title="insertion mode: in head">in head</a>"</em>!) and abort
                   1784:    these steps. (<a href="#fragment-case">fragment case</a>)</li> <!-- This is only
                   1785:    here for now in case people think that the spec accidentally
                   1786:    omitted it and try to "fix" it. Note that noscript-in-head is also
                   1787:    handled this way. This is all intentional. The only thing it
                   1788:    doesn't handle is the scripting-disabled fragment parsing case for
                   1789:    a <head> element containing a <noscript> which itself contains
                   1790:    something other than a <link> or a <style> element; you'd expect
                   1791:    that to break out of the <noscript> but it doesn't. This is an edge
                   1792:    case that doesn't affect the spec, since the algorithm for fragment
                   1793:    parsing is only used for innerHTML/outerHTML/insertAdjacentHTML(),
1.333     mike     1794:    where we know scripting is enabled. -->
1.1       mike     1795: 
1.159     mike     1796:    <li>If <var title="">node</var> is a <code><a href="semantics.html#the-body-element-0">body</a></code> element,
1.1       mike     1797:    then switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" and abort these
                   1798:    steps.</li>
                   1799: 
1.5       mike     1800:    <li>If <var title="">node</var> is a <code><a href="obsolete.html#frameset">frameset</a></code> element,
1.1       mike     1801:    then switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inframeset" title="insertion mode: in frameset">in frameset</a>" and abort
                   1802:    these steps. (<a href="#fragment-case">fragment case</a>)</li>
                   1803: 
1.159     mike     1804:    <li>If <var title="">node</var> is an <code><a href="semantics.html#the-html-element-0">html</a></code> element,
1.333     mike     1805:    then <!--: if the <span><code title="">head</code> element
                   1806:    pointer</span> is null,--> switch the <a href="#insertion-mode">insertion mode</a>
                   1807:    to "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before
                   1808:    head</a>"<!--, otherwise, switch the <span>insertion mode</span>
                   1809:    to "<span title="insertion mode: after head">after head</span>".-->
                   1810:    Then, <!-- in either case, --> abort these steps. (<a href="#fragment-case">fragment
                   1811:    case</a>)</li> <!-- if the head element pointer can ever be
                   1812:    non-null when we're going through these steps, we'll need to
                   1813:    uncomment out the commented-out bits -->
1.1       mike     1814: 
                   1815:    <li>If <var title="">last</var> is true, then switch the
                   1816:    <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in
                   1817:    body">in body</a>" and abort these steps. (<a href="#fragment-case">fragment
                   1818:    case</a>)</li>
                   1819: 
                   1820:    <li>Let <var title="">node</var> now be the node before <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
                   1821:    elements</a>.</li>
                   1822: 
                   1823:    <li>Return to step 3.</li>
                   1824: 
                   1825:   </ol><h5 id="the-stack-of-open-elements"><span class="secno">9.2.3.2 </span>The stack of open elements</h5>
                   1826: 
                   1827:   <p>Initially, the <dfn id="stack-of-open-elements">stack of open elements</dfn> is empty. The
                   1828:   stack grows downwards; the topmost node on the stack is the first
                   1829:   one added to the stack, and the bottommost node of the stack is the
                   1830:   most recently added node in the stack (notwithstanding when the
                   1831:   stack is manipulated in a random access fashion as part of <a href="#adoptionAgency">the handling for misnested tags</a>).</p>
                   1832: 
                   1833:   <p>The "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before
                   1834:   html</a>" <a href="#insertion-mode">insertion mode</a> creates the
1.159     mike     1835:   <code><a href="semantics.html#the-html-element-0">html</a></code> root element node, which is then added to the
1.1       mike     1836:   stack.</p>
                   1837: 
                   1838:   <p>In the <a href="#fragment-case">fragment case</a>, the <a href="#stack-of-open-elements">stack of open
1.159     mike     1839:   elements</a> is initialized to contain an <code><a href="semantics.html#the-html-element-0">html</a></code>
1.1       mike     1840:   element that is created as part of <a href="#html-fragment-parsing-algorithm" title="html fragment
                   1841:   parsing algorithm">that algorithm</a>. (The <a href="#fragment-case">fragment
                   1842:   case</a> skips the "<a href="#the-before-html-insertion-mode" title="insertion mode: before
                   1843:   html">before html</a>" <a href="#insertion-mode">insertion mode</a>.)</p>
                   1844: 
1.159     mike     1845:   <p>The <code><a href="semantics.html#the-html-element-0">html</a></code> node, however it is created, is the topmost
1.1       mike     1846:   node of the stack. It never gets popped off the stack.</p>
                   1847: 
                   1848:   <p>The <dfn id="current-node">current node</dfn> is the bottommost node in this
                   1849:   stack.</p>
                   1850: 
                   1851:   <p>The <dfn id="current-table">current table</dfn> is the last <code><a href="tabular-data.html#the-table-element">table</a></code>
                   1852:   element in the <a href="#stack-of-open-elements">stack of open elements</a>, if there is
                   1853:   one. If there is no <code><a href="tabular-data.html#the-table-element">table</a></code> element in the <a href="#stack-of-open-elements">stack of
                   1854:   open elements</a> (<a href="#fragment-case">fragment case</a>), then the
                   1855:   <a href="#current-table">current table</a> is the first element in the <a href="#stack-of-open-elements">stack
1.159     mike     1856:   of open elements</a> (the <code><a href="semantics.html#the-html-element-0">html</a></code> element).</p>
1.1       mike     1857: 
                   1858:   <p>Elements in the stack fall into the following categories:</p>
                   1859: 
                   1860:   <dl><dt><dfn id="special">Special</dfn></dt>
                   1861: 
                   1862:    <dd><p>The following HTML elements have varying levels of special
                   1863:    parsing rules: <code><a href="semantics.html#the-address-element">address</a></code>, <code><a href="the-canvas-element.html#the-area-element">area</a></code>,
                   1864:    <code><a href="semantics.html#the-article-element">article</a></code>, <code><a href="semantics.html#the-aside-element">aside</a></code>, <code><a href="semantics.html#the-base-element">base</a></code>,
1.5       mike     1865:    <code><a href="obsolete.html#basefont">basefont</a></code>, <code>bgsound</code>,
1.159     mike     1866:    <code><a href="semantics.html#the-blockquote-element">blockquote</a></code>, <code><a href="semantics.html#the-body-element-0">body</a></code>, <code><a href="semantics.html#the-br-element">br</a></code>,
1.5       mike     1867:    <code><a href="obsolete.html#center">center</a></code>, <code><a href="tabular-data.html#the-col-element">col</a></code>, <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code>,
1.86      mike     1868:    <code><a href="interactive-elements.html#the-command">command</a></code>, <!--v2DDATAGRID--><code>datagrid</code>,
1.422     mike     1869:    <code><a href="semantics.html#the-dd-element">dd</a></code>, <code><a href="interactive-elements.html#the-details-element">details</a></code>, <code><a href="obsolete.html#dir">dir</a></code>,
                   1870:    <code><a href="semantics.html#the-div-element">div</a></code>, <code><a href="semantics.html#the-dl-element">dl</a></code>, <code><a href="semantics.html#the-dt-element">dt</a></code>,
                   1871:    <code><a href="text-level-semantics.html#the-embed-element">embed</a></code>, <code><a href="forms.html#the-fieldset-element">fieldset</a></code>, <code><a href="text-level-semantics.html#the-figure-element">figure</a></code>,
                   1872:    <code><a href="semantics.html#the-footer-element">footer</a></code>, <code><a href="forms.html#the-form-element">form</a></code>, <code><a href="obsolete.html#frame">frame</a></code>,
                   1873:    <code><a href="obsolete.html#frameset">frameset</a></code>, <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h1</a></code>, <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h2</a></code>,
                   1874:    <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h3</a></code>, <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h4</a></code>, <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h5</a></code>, <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h6</a></code>,
                   1875:    <code><a href="semantics.html#the-head-element-0">head</a></code>, <code><a href="semantics.html#the-header-element">header</a></code>, <code><a href="semantics.html#the-hgroup-element">hgroup</a></code>,
                   1876:    <code><a href="semantics.html#the-hr-element">hr</a></code>, <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code>, <!-- <code>image</code>,
                   1877:    (commented out because this isn't an element that can end up on the
                   1878:    stack, so it doesn't matter) --> <code><a href="text-level-semantics.html#the-img-element">img</a></code>,
                   1879:    <code><a href="forms.html#the-input-element">input</a></code>, <code><a href="obsolete.html#isindex-0">isindex</a></code>, <code><a href="semantics.html#the-li-element">li</a></code>,
                   1880:    <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="obsolete.html#listing">listing</a></code>, <code><a href="interactive-elements.html#menus">menu</a></code>,
                   1881:    <code><a href="semantics.html#meta">meta</a></code>, <code><a href="semantics.html#the-nav-element">nav</a></code>, <code><a href="obsolete.html#noembed">noembed</a></code>,
                   1882:    <code><a href="obsolete.html#noframes">noframes</a></code>, <code><a href="semantics.html#the-noscript-element">noscript</a></code>, <code><a href="semantics.html#the-ol-element">ol</a></code>,
                   1883:    <code><a href="semantics.html#the-p-element">p</a></code>, <code><a href="text-level-semantics.html#the-param-element">param</a></code>, <code><a href="obsolete.html#plaintext">plaintext</a></code>,
                   1884:    <code><a href="semantics.html#the-pre-element">pre</a></code>, <code><a href="semantics.html#script">script</a></code>, <code><a href="semantics.html#the-section-element">section</a></code>,
                   1885:    <code><a href="forms.html#the-select-element">select</a></code>, <code><a href="obsolete.html#spacer">spacer</a></code>, <code><a href="semantics.html#the-style-element">style</a></code>,
                   1886:    <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>, <code><a href="forms.html#the-textarea-element">textarea</a></code>, <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code>,
                   1887:    <code><a href="tabular-data.html#the-thead-element">thead</a></code>, <code><a href="semantics.html#the-title-element-0">title</a></code>, <code><a href="tabular-data.html#the-tr-element">tr</a></code>,
                   1888:    <code><a href="semantics.html#the-ul-element">ul</a></code>, <code>wbr</code>, and <code><a href="obsolete.html#xmp">xmp</a></code>.</p></dd>
1.1       mike     1889: 
                   1890:    <dt><dfn id="scoping">Scoping</dfn></dt>
                   1891:    <dd><p>The following HTML elements introduce new <a href="#has-an-element-in-scope" title="has
                   1892:    an element in scope">scopes</a> for various parts of the
1.5       mike     1893:    parsing: <code><a href="obsolete.html#the-applet-element">applet</a></code>, <code><a href="forms.html#the-button-element">button</a></code>,
1.159     mike     1894:    <code><a href="tabular-data.html#the-caption-element">caption</a></code>, <code><a href="semantics.html#the-html-element-0">html</a></code>, <code><a href="obsolete.html#the-marquee-element">marquee</a></code>,
                   1895:    <code><a href="text-level-semantics.html#the-object-element">object</a></code>, <code><a href="tabular-data.html#the-table-element">table</a></code>, <code><a href="tabular-data.html#the-td-element">td</a></code>,
1.1       mike     1896:    <code><a href="tabular-data.html#the-th-element">th</a></code>, and SVG's <code>foreignObject</code>.</p></dd>
                   1897: 
                   1898:    <dt><dfn id="formatting">Formatting</dfn></dt>
                   1899:    <dd><p>The following HTML elements are those that end up in the
                   1900:    <a href="#list-of-active-formatting-elements">list of active formatting elements</a>: <code><a href="text-level-semantics.html#the-a-element">a</a></code>,
1.5       mike     1901:    <code><a href="text-level-semantics.html#the-b-element">b</a></code>, <code><a href="obsolete.html#big">big</a></code>, <code><a href="text-level-semantics.html#the-code-element">code</a></code>,
                   1902:    <code><a href="text-level-semantics.html#the-em-element">em</a></code>, <code><a href="obsolete.html#font">font</a></code>, <code><a href="text-level-semantics.html#the-i-element">i</a></code>,
                   1903:    <code>nobr</code>, <code><a href="obsolete.html#s">s</a></code>, <code><a href="text-level-semantics.html#the-small-element">small</a></code>,
                   1904:    <code><a href="obsolete.html#strike">strike</a></code>, <code><a href="text-level-semantics.html#the-strong-element">strong</a></code>, <code><a href="obsolete.html#tt">tt</a></code>, and
                   1905:    <code><a href="obsolete.html#u">u</a></code>.</p></dd>
1.1       mike     1906: 
                   1907:    <dt><dfn id="phrasing">Phrasing</dfn></dt>
                   1908:    <dd><p>All other elements found while parsing an HTML
                   1909:    document.</p></dd>
                   1910: 
1.234     mike     1911:   </dl><p>The <a href="#stack-of-open-elements">stack of open elements</a> is said to <dfn id="has-an-element-in-the-specific-scope" title="has an element in the specific scope">have an element in a
                   1912:   specific scope</dfn> consisting of a list of element types <var title="">list</var> when the following algorithm terminates in a
                   1913:   match state:</p>
1.1       mike     1914: 
                   1915:   <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
                   1916:    node</a> (the bottommost node of the stack).</p></li>
                   1917: 
                   1918:    <li><p>If <var title="">node</var> is the target node, terminate in
                   1919:    a match state.</p></li>
                   1920: 
1.234     mike     1921:    <li><p>Otherwise, if <var title="">node</var> is one of the element
                   1922:    types in <var title="">list</var>, terminate in a failure
                   1923:    state.</p></li>
1.1       mike     1924: 
                   1925:    <li><p>Otherwise, set <var title="">node</var> to the previous
                   1926:    entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to step
                   1927:    2. (This will never fail, since the loop will always terminate in
                   1928:    the previous step if the top of the stack &#8212; an
1.159     mike     1929:    <code><a href="semantics.html#the-html-element-0">html</a></code> element &#8212; is reached.)</p></li>
1.1       mike     1930: 
1.234     mike     1931:   </ol><p>The <a href="#stack-of-open-elements">stack of open elements</a> is said to <dfn id="has-an-element-in-scope" title="has an element in scope">have an element in scope</dfn> when
                   1932:   it <a href="#has-an-element-in-the-specific-scope">has an element in the specific scope</a> consisting
                   1933:   of the following element types:</p>
                   1934: 
                   1935:   <ul class="brief"><li><code><a href="obsolete.html#the-applet-element">applet</a></code> in the HTML namespace</li>
                   1936:    <li><code><a href="tabular-data.html#the-caption-element">caption</a></code> in the HTML namespace</li>
                   1937:    <li><code><a href="semantics.html#the-html-element-0">html</a></code> in the HTML namespace</li> <!-- (This can only happen if the <var title="">node</var> is the topmost node of the <span>stack of open elements</span>, and prevents the next step from being invoked if there are no more elements in the stack.) -->
                   1938:    <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
                   1939:    <li><code><a href="tabular-data.html#the-td-element">td</a></code> in the HTML namespace</li>
                   1940:    <li><code><a href="tabular-data.html#the-th-element">th</a></code> in the HTML namespace</li>
                   1941:    <li><code><a href="forms.html#the-button-element">button</a></code> in the HTML namespace</li>
                   1942:    <li><code><a href="obsolete.html#the-marquee-element">marquee</a></code> in the HTML namespace</li>
                   1943:    <li><code><a href="text-level-semantics.html#the-object-element">object</a></code> in the HTML namespace</li>
                   1944:    <li><code title="">foreignObject</code> in the SVG namespace</li>
                   1945:   </ul><p>The <a href="#stack-of-open-elements">stack of open elements</a> is said to <dfn id="has-an-element-in-list-item-scope" title="has an element in list item scope">have an element in list
                   1946:   item scope</dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
                   1947:   scope</a> consisting of the following element types:</p>
                   1948: 
                   1949:   <ul class="brief"><li>All the element types listed above for the <i><a href="#has-an-element-in-scope">has an element
                   1950:    in scope</a></i> algorithm.</li>
                   1951:    <li><code><a href="semantics.html#the-ol-element">ol</a></code> in the HTML namespace</li>
                   1952:    <li><code><a href="semantics.html#the-ul-element">ul</a></code> in the HTML namespace</li>
                   1953:   </ul><p>The <a href="#stack-of-open-elements">stack of open elements</a> is said to <dfn id="has-an-element-in-table-scope" title="has an element in table scope">have an element in <em>table
                   1954:   scope</em></dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
                   1955:   scope</a> consisting of the following element types:</p>
                   1956: 
                   1957:   <ul class="brief"><li><code><a href="semantics.html#the-html-element-0">html</a></code> in the HTML namespace</li> <!-- (This can only happen if the <var title="">node</var> is the topmost node of the <span>stack of open elements</span>, and prevents the next step from being invoked if there are no more elements in the stack.) -->
                   1958:    <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
                   1959:   </ul><p>Nothing happens if at any time any of the elements in the
1.1       mike     1960:   <a href="#stack-of-open-elements">stack of open elements</a> are moved to a new location in,
                   1961:   or removed from, the <code>Document</code> tree. In particular, the
                   1962:   stack is not changed in this situation. This can cause, amongst
                   1963:   other strange effects, content to be appended to nodes that are no
                   1964:   longer in the DOM.</p>
                   1965: 
                   1966:   <p class="note">In some cases (namely, when <a href="#adoptionAgency">closing misnested formatting elements</a>),
                   1967:   the stack is manipulated in a random-access fashion.</p>
                   1968: 
                   1969: 
                   1970:   <h5 id="the-list-of-active-formatting-elements"><span class="secno">9.2.3.3 </span>The list of active formatting elements</h5>
                   1971: 
                   1972:   <p>Initially, the <dfn id="list-of-active-formatting-elements">list of active formatting elements</dfn> is
                   1973:   empty. It is used to handle mis-nested <a href="#formatting" title="formatting">formatting element tags</a>.</p>
                   1974: 
                   1975:   <p>The list contains elements in the <a href="#formatting">formatting</a>
                   1976:   category, and scope markers. The scope markers are inserted when
1.159     mike     1977:   entering <code><a href="obsolete.html#the-applet-element">applet</a></code> elements, buttons, <code><a href="text-level-semantics.html#the-object-element">object</a></code>
1.1       mike     1978:   elements, marquees, table cells, and table captions, and are used to
1.5       mike     1979:   prevent formatting from "leaking" <em>into</em> <code><a href="obsolete.html#the-applet-element">applet</a></code>
1.159     mike     1980:   elements, buttons, <code><a href="text-level-semantics.html#the-object-element">object</a></code> elements, marquees, and
1.1       mike     1981:   tables.</p>
                   1982: 
                   1983:   <p class="note">The scope markers are unrelated to the concept of an
                   1984:   element being <a href="#has-an-element-in-scope" title="has an element in scope">in
                   1985:   scope</a>.</p>
                   1986: 
                   1987:   <p>In addition, each element in the <a href="#list-of-active-formatting-elements">list of active formatting
                   1988:   elements</a> is associated with the token for which it was
                   1989:   created, so that further elements can be created for that token if
                   1990:   necessary.</p>
                   1991: 
                   1992:   <p>When the steps below require the UA to <dfn id="reconstruct-the-active-formatting-elements">reconstruct the
                   1993:   active formatting elements</dfn>, the UA must perform the following
                   1994:   steps:</p>
                   1995: 
                   1996:   <ol><li>If there are no entries in the <a href="#list-of-active-formatting-elements">list of active formatting
                   1997:    elements</a>, then there is nothing to reconstruct; stop this
                   1998:    algorithm.</li>
                   1999: 
                   2000:    <li>If the last (most recently added) entry in the <a href="#list-of-active-formatting-elements">list of
                   2001:    active formatting elements</a> is a marker, or if it is an
                   2002:    element that is in the <a href="#stack-of-open-elements">stack of open elements</a>, then
                   2003:    there is nothing to reconstruct; stop this algorithm.</li>
                   2004: 
                   2005:    <li>Let <var title="">entry</var> be the last (most recently added)
                   2006:    element in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2007:    elements</a>.</li>
                   2008: 
                   2009:    <li>If there are no entries before <var title="">entry</var> in the
                   2010:    <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, then jump to step
                   2011:    8.</li>
                   2012: 
                   2013:    <li>Let <var title="">entry</var> be the entry one earlier than
                   2014:    <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2015:    elements</a>.</li>
                   2016: 
                   2017:    <li>If <var title="">entry</var> is neither a marker nor an element
                   2018:    that is also in the <a href="#stack-of-open-elements">stack of open elements</a>, go to step
                   2019:    4.</li>
                   2020: 
                   2021:    <li>Let <var title="">entry</var> be the element one later than
                   2022:    <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2023:    elements</a>.</li>
                   2024: 
                   2025:    <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
                   2026:    element <var title="">entry</var> was created, to obtain <var title="">new element</var>.</li>
                   2027: 
                   2028:    <li>Append <var title="">new element</var> to the <a href="#current-node">current
                   2029:    node</a> and push it onto the <a href="#stack-of-open-elements">stack of open
                   2030:    elements</a> so that it is the new <a href="#current-node">current
                   2031:    node</a>.</li>
                   2032: 
                   2033:    <li>Replace the entry for <var title="">entry</var> in the list
                   2034:    with an entry for <var title="">new element</var>.</li>
                   2035: 
                   2036:    <li>If the entry for <var title="">new element</var> in the
                   2037:    <a href="#list-of-active-formatting-elements">list of active formatting elements</a> is not the last
                   2038:    entry in the list, return to step 7.</li>
                   2039: 
                   2040:   </ol><p>This has the effect of reopening all the formatting elements that
                   2041:   were opened in the current body, cell, or caption (whichever is
                   2042:   youngest) that haven't been explicitly closed.</p>
                   2043: 
                   2044:   <p class="note">The way this specification is written, the
                   2045:   <a href="#list-of-active-formatting-elements">list of active formatting elements</a> always consists of
                   2046:   elements in chronological order with the least recently added
                   2047:   element first and the most recently added element last (except for
                   2048:   while steps 8 to 11 of the above algorithm are being executed, of
                   2049:   course).</p>
                   2050: 
                   2051:   <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
                   2052:   active formatting elements up to the last marker</dfn>, the UA must
                   2053:   perform the following steps:</p>
                   2054: 
                   2055:   <ol><li>Let <var title="">entry</var> be the last (most recently added)
                   2056:    entry in the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</li>
                   2057: 
                   2058:    <li>Remove <var title="">entry</var> from the <a href="#list-of-active-formatting-elements">list of active
                   2059:    formatting elements</a>.</li>
                   2060: 
                   2061:    <li>If <var title="">entry</var> was a marker, then stop the
                   2062:    algorithm at this point. The list has been cleared up to the last
                   2063:    marker.</li>
                   2064: 
                   2065:    <li>Go to step 1.</li>
                   2066: 
                   2067:   </ol><h5 id="the-element-pointers"><span class="secno">9.2.3.4 </span>The element pointers</h5>
                   2068: 
                   2069:   <p>Initially, the <dfn id="head-element-pointer"><code title="">head</code> element
                   2070:   pointer</dfn> and the <dfn id="form-element-pointer"><code title="">form</code> element
                   2071:   pointer</dfn> are both null.</p>
                   2072: 
1.159     mike     2073:   <p>Once a <code><a href="semantics.html#the-head-element-0">head</a></code> element has been parsed (whether
1.1       mike     2074:   implicitly or explicitly) the <a href="#head-element-pointer"><code title="">head</code>
                   2075:   element pointer</a> gets set to point to this node.</p>
                   2076: 
                   2077:   <p>The <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
                   2078:   points to the last <code><a href="forms.html#the-form-element">form</a></code> element that was opened and
                   2079:   whose end tag has not yet been seen. It is used to make form
                   2080:   controls associate with forms in the face of dramatically bad
                   2081:   markup, for historical reasons.</p>
                   2082: 
                   2083: 
                   2084:   <h5 id="other-parsing-state-flags"><span class="secno">9.2.3.5 </span>Other parsing state flags</h5>
                   2085: 
                   2086:   <p>The <dfn id="scripting-flag">scripting flag</dfn> is set to "enabled" if <a href="browsers.html#concept-n-script" title="concept-n-script">scripting was enabled</a> for the
                   2087:   <code>Document</code> with which the parser is associated when the
                   2088:   parser was created, and "disabled" otherwise.</p>
                   2089: 
                   2090:   <p class="note">The <a href="#scripting-flag">scripting flag</a> can be enabled even
                   2091:   when the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML fragment
                   2092:   parsing algorithm</a>, even though <code><a href="semantics.html#script">script</a></code> elements
                   2093:   don't execute in that case.</p>
                   2094: 
                   2095:   <p>The <dfn id="frameset-ok-flag">frameset-ok flag</dfn> is set to "ok" when the parser is
                   2096:   created. It is set to "not ok" after certain tokens are seen.</p>
                   2097: 
1.266     mike     2098:   </div><div class="impl">
1.1       mike     2099: 
1.159     mike     2100:   <h4 id="tokenization"><span class="secno">9.2.4 </span><dfn>Tokenization</dfn></h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     2101: 
                   2102:   <p>Implementations must act as if they used the following state
                   2103:   machine to tokenize HTML. The state machine must start in the
                   2104:   <a href="#data-state">data state</a>. Most states consume a single character,
                   2105:   which may have various side-effects, and either switches the state
                   2106:   machine to a new state to <em>reconsume</em> the same character, or
                   2107:   switches it to a new state (to consume the next character), or
                   2108:   repeats the same state (to consume the next character). Some states
                   2109:   have more complicated behavior and can consume several characters
1.541     mike     2110:   before switching to another state. In some cases, the tokenizer
                   2111:   state is also changed by the tree construction stage.</p>
1.1       mike     2112: 
1.541     mike     2113:   <p>The exact behavior of certain states depends on the
                   2114:   <a href="#insertion-mode">insertion mode</a> and the <a href="#stack-of-open-elements">stack of open
                   2115:   elements</a>. Certain states also use a <dfn id="temporary-buffer"><var>temporary
                   2116:   buffer</var></dfn> to track progress.</p>
1.1       mike     2117: 
                   2118:   <p>The output of the tokenization step is a series of zero or more
                   2119:   of the following tokens: DOCTYPE, start tag, end tag, comment,
                   2120:   character, end-of-file. DOCTYPE tokens have a name, a public
                   2121:   identifier, a system identifier, and a <i>force-quirks
                   2122:   flag</i>. When a DOCTYPE token is created, its name, public
                   2123:   identifier, and system identifier must be marked as missing (which
                   2124:   is a distinct state from the empty string), and the <i>force-quirks
                   2125:   flag</i> must be set to <i>off</i> (its other state is
                   2126:   <i>on</i>). Start and end tag tokens have a tag name, a
                   2127:   <i>self-closing flag</i>, and a list of attributes, each of which
                   2128:   has a name and a value. When a start or end tag token is created,
                   2129:   its <i>self-closing flag</i> must be unset (its other state is that
                   2130:   it be set), and its attributes list must be empty. Comment and
                   2131:   character tokens have data.</p>
                   2132: 
                   2133:   <p>When a token is emitted, it must immediately be handled by the
                   2134:   <a href="#tree-construction">tree construction</a> stage. The tree construction stage
1.541     mike     2135:   can affect the state of the tokenization stage, and can insert
                   2136:   additional characters into the stream. (For example, the
1.1       mike     2137:   <code><a href="semantics.html#script">script</a></code> element can result in scripts executing and
1.159     mike     2138:   using the <a href="embedded-content-0.html#dynamic-markup-insertion">dynamic markup insertion</a> APIs to insert
1.1       mike     2139:   characters into the stream being tokenized.)</p>
                   2140: 
                   2141:   <p>When a start tag token is emitted with its <i>self-closing
                   2142:   flag</i> set, if the flag is not <dfn id="acknowledge-self-closing-flag" title="acknowledge
                   2143:   self-closing flag">acknowledged</dfn> when it is processed by the
                   2144:   tree construction stage, that is a <a href="#parse-error">parse error</a>.</p>
                   2145: 
                   2146:   <p>When an end tag token is emitted with attributes, that is a
                   2147:   <a href="#parse-error">parse error</a>.</p>
                   2148: 
                   2149:   <p>When an end tag token is emitted with its <i>self-closing
                   2150:   flag</i> set, that is a <a href="#parse-error">parse error</a>.</p>
                   2151: 
1.541     mike     2152:   <p>An <dfn id="appropriate-end-tag-token">appropriate end tag token</dfn> is an end tag token whose
                   2153:   tag name matches the tag name of the last start tag to have been
                   2154:   emitted from this tokenizer, if any. If no start tag has been
                   2155:   emitted from this tokenizer, then no end tag token is
                   2156:   appropriate.</p>
                   2157: 
1.1       mike     2158:   <p>Before each step of the tokenizer, the user agent must first
                   2159:   check the <a href="#parser-pause-flag">parser pause flag</a>. If it is true, then the
                   2160:   tokenizer must abort the processing of any nested invocations of the
1.479     mike     2161:   tokenizer, yielding control back to the caller.</p>
1.1       mike     2162: 
                   2163:   <p>The tokenizer state machine consists of the states defined in the
                   2164:   following subsections.</p>
                   2165: 
1.541     mike     2166: 
1.333     mike     2167:   <!-- Order of the lists below is supposed to be non-error then
                   2168:   error, by unicode, then EOF, ending with "anything else" -->
1.1       mike     2169: 
1.541     mike     2170: 
1.1       mike     2171:   <h5 id="data-state"><span class="secno">9.2.4.1 </span><dfn>Data state</dfn></h5>
                   2172: 
                   2173:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2174: 
                   2175:   <dl class="switch"><dt>U+0026 AMPERSAND (&amp;)</dt>
1.541     mike     2176:    <dd>Switch to the <a href="#character-reference-in-data-state">character reference in data
1.56      mike     2177:    state</a>.</dd>
1.1       mike     2178: 
1.541     mike     2179:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2180:    <dd>Switch to the <a href="#tag-open-state">tag open state</a>.</dd>
                   2181: 
                   2182:    <dt>EOF</dt>
                   2183:    <dd>Emit an end-of-file token.</dd>
                   2184: 
                   2185:    <dt>Anything else</dt>
                   2186:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2187:    token. Stay in the <a href="#data-state">data state</a>.</dd>
1.1       mike     2188: 
1.541     mike     2189:   </dl><h5 id="rcdata-state"><span class="secno">9.2.4.2 </span><dfn>RCDATA state</dfn></h5>
1.1       mike     2190: 
1.541     mike     2191:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2192: 
1.541     mike     2193:   <dl class="switch"><dt>U+0026 AMPERSAND (&amp;)</dt>
                   2194:    <dd>Switch to the <a href="#character-reference-in-data-state">character reference in data
                   2195:    state</a>.</dd>
1.1       mike     2196: 
                   2197:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
1.541     mike     2198:    <dd>Switch to the <a href="#rcdata-less-than-sign-state">RCDATA less-than sign state</a>.</dd>
                   2199: 
                   2200:    <dt>EOF</dt>
                   2201:    <dd>Emit an end-of-file token.</dd>
1.1       mike     2202: 
1.541     mike     2203:    <dt>Anything else</dt>
                   2204:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2205:    token. Stay in the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1       mike     2206: 
1.541     mike     2207:   </dl><h5 id="rawtext-state"><span class="secno">9.2.4.3 </span><dfn>RAWTEXT state</dfn></h5>
1.1       mike     2208: 
1.541     mike     2209:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2210: 
1.541     mike     2211:   <dl class="switch"><dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2212:    <dd>Switch to the <a href="#rawtext-less-than-sign-state">RAWTEXT less-than sign state</a>.</dd>
1.1       mike     2213: 
                   2214:    <dt>EOF</dt>
                   2215:    <dd>Emit an end-of-file token.</dd>
                   2216: 
                   2217:    <dt>Anything else</dt>
1.541     mike     2218:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2219:    token. Stay in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1       mike     2220: 
1.541     mike     2221:   </dl><h5 id="script-data-state"><span class="secno">9.2.4.4 </span><dfn>Script data state</dfn></h5>
1.1       mike     2222: 
1.541     mike     2223:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2224: 
1.541     mike     2225:   <dl class="switch"><dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2226:    <dd>Switch to the <a href="#script-data-less-than-sign-state">script data less-than sign state</a>.</dd>
1.1       mike     2227: 
1.541     mike     2228:    <dt>EOF</dt>
                   2229:    <dd>Emit an end-of-file token.</dd>
1.1       mike     2230: 
1.541     mike     2231:    <dt>Anything else</dt>
                   2232:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2233:    token. Stay in the <a href="#script-data-state">script data state</a>.</dd>
1.1       mike     2234: 
1.541     mike     2235:   </dl><h5 id="plaintext-state"><span class="secno">9.2.4.5 </span><dfn>PLAINTEXT state</dfn></h5>
1.1       mike     2236: 
1.541     mike     2237:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2238: 
1.541     mike     2239:   <dl class="switch"><dt>EOF</dt>
                   2240:    <dd>Emit an end-of-file token.</dd>
1.1       mike     2241: 
1.541     mike     2242:    <dt>Anything else</dt>
                   2243:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2244:    token. Stay in the <a href="#plaintext-state">PLAINTEXT state</a>.</dd>
1.1       mike     2245: 
1.541     mike     2246:   </dl><h5 id="character-reference-in-data-state"><span class="secno">9.2.4.6 </span><dfn>Character reference in data state</dfn></h5>
1.1       mike     2247: 
1.541     mike     2248:   <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>, with no
                   2249:   <a href="#additional-allowed-character">additional allowed character</a>.</p>
1.1       mike     2250: 
1.541     mike     2251:   <p>If nothing is returned, emit a U+0026 AMPERSAND character
                   2252:   token.</p>
1.1       mike     2253: 
1.541     mike     2254:   <p>Otherwise, emit the character token that was returned.</p>
1.1       mike     2255: 
1.541     mike     2256:   <p>Finally, switch to the <a href="#data-state">data state</a>.</p>
1.1       mike     2257: 
                   2258: 
1.541     mike     2259:   <h5 id="tag-open-state"><span class="secno">9.2.4.7 </span><dfn>Tag open state</dfn></h5>
1.1       mike     2260: 
1.541     mike     2261:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2262: 
1.541     mike     2263:   <dl class="switch"><dt>U+0021 EXCLAMATION MARK (!)</dt>
                   2264:    <dd>Switch to the <a href="#markup-declaration-open-state">markup declaration open state</a>.</dd>
1.1       mike     2265: 
1.541     mike     2266:    <dt>U+002F SOLIDUS (/)</dt>
                   2267:    <dd>Switch to the <a href="#close-tag-open-state">close tag open state</a>.</dd>
1.1       mike     2268: 
1.541     mike     2269:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2270:    <dd>Create a new start tag token, set its tag name to the
                   2271:    lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
                   2272:    character's code point), then switch to the <a href="#tag-name-state">tag name
                   2273:    state</a>. (Don't emit the token yet; further details will
                   2274:    be filled in before it is emitted.)</dd>
1.1       mike     2275: 
1.541     mike     2276:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2277:    <dd>Create a new start tag token, set its tag name to the
                   2278:    <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
                   2279:    name state</a>. (Don't emit the token yet; further details will
                   2280:    be filled in before it is emitted.)</dd>
1.1       mike     2281: 
1.541     mike     2282:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2283:    <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
                   2284:    character token and a U+003E GREATER-THAN SIGN character
                   2285:    token. Switch to the <a href="#data-state">data state</a>.</dd>
1.1       mike     2286: 
1.541     mike     2287:    <dt>U+003F QUESTION MARK (?)</dt>
                   2288:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
                   2289:    comment state</a>.</dd>
1.1       mike     2290: 
1.541     mike     2291:    <dt>Anything else</dt>
                   2292:    <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
                   2293:    character token and reconsume the <a href="#current-input-character">current input
                   2294:    character</a> in the <a href="#data-state">data state</a>.</dd>
1.1       mike     2295: 
1.541     mike     2296:   </dl><h5 id="close-tag-open-state"><span class="secno">9.2.4.8 </span><dfn>Close tag open state</dfn></h5>
1.1       mike     2297: 
1.541     mike     2298:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2299: 
                   2300:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2301:    <dd>Create a new end tag token, set its tag name to the lowercase
1.541     mike     2302:    version of the <a href="#current-input-character">current input character</a> (add 0x0020 to
                   2303:    the character's code point), then switch to the <a href="#tag-name-state">tag name
1.1       mike     2304:    state</a>. (Don't emit the token yet; further details will be
                   2305:    filled in before it is emitted.)</dd>
                   2306: 
                   2307:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
1.541     mike     2308:    <dd>Create a new end tag token, set its tag name to the
                   2309:    <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
                   2310:    name state</a>. (Don't emit the token yet; further details will
                   2311:    be filled in before it is emitted.)</dd>
1.1       mike     2312: 
                   2313:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2314:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#data-state">data
                   2315:    state</a>.</dd>
                   2316: 
                   2317:    <dt>EOF</dt>
                   2318:    <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
                   2319:    character token and a U+002F SOLIDUS character token. Reconsume
                   2320:    the EOF character in the <a href="#data-state">data state</a>.</dd>
                   2321: 
                   2322:    <dt>Anything else</dt>
                   2323:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
                   2324:    comment state</a>.</dd>
                   2325: 
1.541     mike     2326:   </dl><h5 id="tag-name-state"><span class="secno">9.2.4.9 </span><dfn>Tag name state</dfn></h5>
1.1       mike     2327: 
                   2328:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2329: 
                   2330:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2331:    <dt>U+000A LINE FEED (LF)</dt>
                   2332:    <dt>U+000C FORM FEED (FF)</dt>
                   2333:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2334:    <dt>U+0020 SPACE</dt>
                   2335:    <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   2336: 
                   2337:    <dt>U+002F SOLIDUS (/)</dt>
                   2338:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   2339: 
                   2340:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2341:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   2342:    state</a>.</dd>
                   2343: 
                   2344:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541     mike     2345:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2346:    character</a> (add 0x0020 to the character's code point) to the
                   2347:    current tag token's tag name. Stay in the <a href="#tag-name-state">tag name
                   2348:    state</a>.</dd>
                   2349: 
                   2350:    <dt>EOF</dt>
                   2351:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2352:    <a href="#data-state">data state</a>.</dd>
                   2353: 
                   2354:    <dt>Anything else</dt>
                   2355:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2356:    tag token's tag name. Stay in the <a href="#tag-name-state">tag name state</a>.</dd>
                   2357: 
                   2358:   </dl><h5 id="rcdata-less-than-sign-state"><span class="secno">9.2.4.10 </span><dfn>RCDATA less-than sign state</dfn></h5>
                   2359:   <!-- identical to the RAWTEXT less-than sign state, except s/RAWTEXT/RCDATA/g -->
                   2360: 
                   2361:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2362: 
                   2363:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   2364:    <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
                   2365:    to the <a href="#rcdata-end-tag-open-state">RCDATA end tag open state</a>.</dd>
                   2366: 
                   2367:    <dt>Anything else</dt>
                   2368:    <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
                   2369:    <a href="#current-input-character">current input character</a> in the <a href="#rcdata-state">RCDATA
                   2370:    state</a>.</dd>
                   2371: 
                   2372:   </dl><h5 id="rcdata-end-tag-open-state"><span class="secno">9.2.4.11 </span><dfn>RCDATA end tag open state</dfn></h5>
                   2373:   <!-- identical to the RAWTEXT (and Script data) end tag open state, except s/RAWTEXT/RCDATA/g -->
                   2374: 
                   2375:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2376: 
                   2377:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2378:    <dd>Create a new end tag token, and set its tag name to the
                   2379:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2380:    0x0020 to the character's code point). Append the <a href="#current-input-character">current
                   2381:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2382:    switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
                   2383:    the token yet; further details will be filled in before it is
                   2384:    emitted.)</dd>
                   2385: 
                   2386:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2387:    <dd>Create a new end tag token, and set its tag name to the
                   2388:    <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
                   2389:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2390:    switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
                   2391:    the token yet; further details will be filled in before it is
                   2392:    emitted.)</dd>
                   2393: 
                   2394:    <dt>Anything else</dt>
                   2395:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2396:    character token, and reconsume the <a href="#current-input-character">current input
                   2397:    character</a> in the <a href="#rcdata-state">RCDATA state</a>.</dd>
                   2398: 
                   2399:   </dl><h5 id="rcdata-end-tag-name-state"><span class="secno">9.2.4.12 </span><dfn>RCDATA end tag name state</dfn></h5>
                   2400:   <!-- identical to the RAWTEXT (and Script data) end tag name state, except s/RAWTEXT/RCDATA/g -->
                   2401: 
                   2402:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2403: 
                   2404:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2405:    <dt>U+000A LINE FEED (LF)</dt>
                   2406:    <dt>U+000C FORM FEED (FF)</dt>
                   2407:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2408:    <dt>U+0020 SPACE</dt>
                   2409:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2410:    token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
                   2411:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2412:    below.</dd>
                   2413: 
                   2414:    <dt>U+002F SOLIDUS (/)</dt>
                   2415:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2416:    token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
                   2417:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2418:    below.</dd>
                   2419: 
                   2420:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2421:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2422:    token</a>, then emit the current tag token and switch to the
                   2423:    <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
                   2424:    else" entry below.</dd>
                   2425: 
                   2426:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2427:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2428:    character</a> (add 0x0020 to the character's code point) to the
                   2429:    current tag token's tag name. Append the <a href="#current-input-character">current input
                   2430:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2431:    <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
                   2432: 
                   2433:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2434:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2435:    tag token's tag name. Append the <a href="#current-input-character">current input
                   2436:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2437:    <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
                   2438: 
                   2439:    <dt>Anything else</dt>
                   2440:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2441:    character token, a character token for each of the characters in
                   2442:    the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
                   2443:    the buffer), and reconsume the <a href="#current-input-character">current input character</a>
                   2444:    in the <a href="#rcdata-state">RCDATA state</a>.</dd>
                   2445: 
                   2446:   </dl><h5 id="rawtext-less-than-sign-state"><span class="secno">9.2.4.13 </span><dfn>RAWTEXT less-than sign state</dfn></h5>
                   2447:   <!-- identical to the RCDATA less-than sign state, except s/RCDATA/RAWTEXT/g -->
                   2448: 
                   2449:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2450: 
                   2451:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   2452:    <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
                   2453:    to the <a href="#rawtext-end-tag-open-state">RAWTEXT end tag open state</a>.</dd>
                   2454: 
                   2455:    <dt>Anything else</dt>
                   2456:    <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
                   2457:    <a href="#current-input-character">current input character</a> in the <a href="#rawtext-state">RAWTEXT
                   2458:    state</a>.</dd>
                   2459: 
                   2460:   </dl><h5 id="rawtext-end-tag-open-state"><span class="secno">9.2.4.14 </span><dfn>RAWTEXT end tag open state</dfn></h5>
                   2461:   <!-- identical to the RCDATA (and Script data) end tag open state, except s/RCDATA/RAWTEXT/g -->
                   2462: 
                   2463:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2464: 
                   2465:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2466:    <dd>Create a new end tag token, and set its tag name to the
                   2467:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2468:    0x0020 to the character's code point). Append the <a href="#current-input-character">current
                   2469:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2470:    switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
                   2471:    the token yet; further details will be filled in before it is
                   2472:    emitted.)</dd>
                   2473: 
                   2474:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2475:    <dd>Create a new end tag token, and set its tag name to the
                   2476:    <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
                   2477:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2478:    switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
                   2479:    the token yet; further details will be filled in before it is
                   2480:    emitted.)</dd>
                   2481: 
                   2482:    <dt>Anything else</dt>
                   2483:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2484:    character token, and reconsume the <a href="#current-input-character">current input
                   2485:    character</a> in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
                   2486: 
                   2487:   </dl><h5 id="rawtext-end-tag-name-state"><span class="secno">9.2.4.15 </span><dfn>RAWTEXT end tag name state</dfn></h5>
                   2488:   <!-- identical to the RCDATA (and Script data) end tag name state, except s/RCDATA/RAWTEXT/g -->
                   2489: 
                   2490:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2491: 
                   2492:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2493:    <dt>U+000A LINE FEED (LF)</dt>
                   2494:    <dt>U+000C FORM FEED (FF)</dt>
                   2495:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2496:    <dt>U+0020 SPACE</dt>
                   2497:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2498:    token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
                   2499:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2500:    below.</dd>
                   2501: 
                   2502:    <dt>U+002F SOLIDUS (/)</dt>
                   2503:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2504:    token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
                   2505:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2506:    below.</dd>
                   2507: 
                   2508:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2509:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2510:    token</a>, then emit the current tag token and switch to the
                   2511:    <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
                   2512:    else" entry below.</dd>
                   2513: 
                   2514:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2515:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2516:    character</a> (add 0x0020 to the character's code point) to the
                   2517:    current tag token's tag name. Append the <a href="#current-input-character">current input
                   2518:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2519:    <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
                   2520: 
                   2521:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2522:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2523:    tag token's tag name. Append the <a href="#current-input-character">current input
                   2524:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2525:    <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
                   2526: 
                   2527:    <dt>Anything else</dt>
                   2528:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2529:    character token, a character token for each of the characters in
                   2530:    the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
                   2531:    the buffer), and reconsume the <a href="#current-input-character">current input character</a>
                   2532:    in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
                   2533: 
                   2534:   </dl><h5 id="script-data-less-than-sign-state"><span class="secno">9.2.4.16 </span><dfn>Script data less-than sign state</dfn></h5>
                   2535: 
                   2536:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2537: 
                   2538:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   2539:    <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
                   2540:    to the <a href="#script-data-end-tag-open-state">script data end tag open state</a>.</dd>
                   2541: 
                   2542:    <dt>U+0021 EXCLAMATION MARK (!)</dt>
                   2543:    <dd>Emit a U+003C LESS-THAN SIGN character token and a U+0021
                   2544:    EXCLAMATION MARK character token. Switch to the <a href="#script-data-escape-start-state">script data
                   2545:    escape start state</a>.</dd>
                   2546: 
                   2547:    <dt>Anything else</dt>
                   2548:    <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
                   2549:    <a href="#current-input-character">current input character</a> in the <a href="#script-data-state">script data
                   2550:    state</a>.</dd>
                   2551: 
                   2552:   </dl><h5 id="script-data-end-tag-open-state"><span class="secno">9.2.4.17 </span><dfn>Script data end tag open state</dfn></h5>
                   2553:   <!-- identical to the RCDATA (and RAWTEXT) end tag open state, except s/RCDATA/Script data/g -->
                   2554: 
                   2555:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2556: 
                   2557:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2558:    <dd>Create a new end tag token, and set its tag name to the
                   2559:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2560:    0x0020 to the character's code point). Append the <a href="#current-input-character">current
                   2561:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2562:    switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
                   2563:    the token yet; further details will be filled in before it is
                   2564:    emitted.)</dd>
                   2565: 
                   2566:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2567:    <dd>Create a new end tag token, and set its tag name to the
                   2568:    <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
                   2569:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2570:    switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
                   2571:    the token yet; further details will be filled in before it is
                   2572:    emitted.)</dd>
                   2573: 
                   2574:    <dt>Anything else</dt>
                   2575:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2576:    character token, and reconsume the <a href="#current-input-character">current input
                   2577:    character</a> in the <a href="#script-data-state">script data state</a>.</dd>
                   2578: 
                   2579:   </dl><h5 id="script-data-end-tag-name-state"><span class="secno">9.2.4.18 </span><dfn>Script data end tag name state</dfn></h5>
                   2580:   <!-- identical to the RCDATA (and RAWTEXT) end tag name state, except s/RCDATA/Script data/g -->
                   2581: 
                   2582:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2583: 
                   2584:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2585:    <dt>U+000A LINE FEED (LF)</dt>
                   2586:    <dt>U+000C FORM FEED (FF)</dt>
                   2587:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2588:    <dt>U+0020 SPACE</dt>
                   2589:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2590:    token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
                   2591:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2592:    below.</dd>
                   2593: 
                   2594:    <dt>U+002F SOLIDUS (/)</dt>
                   2595:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2596:    token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
                   2597:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2598:    below.</dd>
                   2599: 
                   2600:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2601:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2602:    token</a>, then emit the current tag token and switch to the
                   2603:    <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
                   2604:    else" entry below.</dd>
                   2605: 
                   2606:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2607:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2608:    character</a> (add 0x0020 to the character's code point) to the
                   2609:    current tag token's tag name. Append the <a href="#current-input-character">current input
                   2610:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542     mike     2611:    <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541     mike     2612: 
                   2613:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2614:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2615:    tag token's tag name. Append the <a href="#current-input-character">current input
                   2616:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542     mike     2617:    <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541     mike     2618: 
                   2619:    <dt>Anything else</dt>
                   2620:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2621:    character token, a character token for each of the characters in
                   2622:    the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
                   2623:    the buffer), and reconsume the <a href="#current-input-character">current input character</a>
                   2624:    in the <a href="#script-data-state">script data state</a>.</dd>
                   2625: 
                   2626:   </dl><h5 id="script-data-escape-start-state"><span class="secno">9.2.4.19 </span><dfn>Script data escape start state</dfn></h5>
                   2627: 
                   2628:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2629: 
                   2630:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2631:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2632:    <a href="#script-data-escape-start-dash-state">script data escape start dash state</a>.</dd>
                   2633: 
                   2634:    <dt>Anything else</dt>
                   2635:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   2636:    <a href="#script-data-state">script data state</a>.</dd>
                   2637: 
                   2638:   </dl><h5 id="script-data-escape-start-dash-state"><span class="secno">9.2.4.20 </span><dfn>Script data escape start dash state</dfn></h5>
                   2639: 
                   2640:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2641: 
                   2642:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2643:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2644:    <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
                   2645: 
                   2646:    <dt>Anything else</dt>
                   2647:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   2648:    <a href="#script-data-state">script data state</a>.</dd>
                   2649: 
                   2650:   </dl><h5 id="script-data-escaped-state"><span class="secno">9.2.4.21 </span><dfn>Script data escaped state</dfn></h5>
                   2651: 
                   2652:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2653: 
                   2654:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2655:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2656:    <a href="#script-data-escaped-dash-state">script data escaped dash state</a>.</dd>
                   2657: 
1.542     mike     2658:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2659:    <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
                   2660:    state</a>.</p></dd>
                   2661: 
1.541     mike     2662:    <dt>EOF</dt>
                   2663:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2664:    <a href="#data-state">data state</a>.</dd>
                   2665: 
                   2666:    <dt>Anything else</dt>
1.542     mike     2667:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2668:    token. Stay in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541     mike     2669: 
                   2670:   </dl><h5 id="script-data-escaped-dash-state"><span class="secno">9.2.4.22 </span><dfn>Script data escaped dash state</dfn></h5>
                   2671: 
                   2672:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2673: 
                   2674:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2675:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2676:    <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
                   2677: 
1.542     mike     2678:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2679:    <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
                   2680:    state</a>.</p></dd>
                   2681: 
1.541     mike     2682:    <dt>EOF</dt>
                   2683:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2684:    <a href="#data-state">data state</a>.</dd>
                   2685: 
                   2686:    <dt>Anything else</dt>
1.542     mike     2687:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2688:    token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541     mike     2689: 
                   2690:   </dl><h5 id="script-data-escaped-dash-dash-state"><span class="secno">9.2.4.23 </span><dfn>Script data escaped dash dash state</dfn></h5>
                   2691: 
                   2692:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2693: 
                   2694:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2695:    <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
                   2696:    <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
                   2697: 
1.542     mike     2698:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2699:    <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
                   2700:    state</a>.</p></dd>
                   2701: 
1.541     mike     2702:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2703:    <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
                   2704:    <a href="#script-data-state">script data state</a>.</dd>
1.1       mike     2705: 
                   2706:    <dt>EOF</dt>
                   2707:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2708:    <a href="#data-state">data state</a>.</dd>
                   2709: 
                   2710:    <dt>Anything else</dt>
1.542     mike     2711:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2712:    token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
                   2713: 
                   2714:   </dl><h5 id="script-data-escaped-less-than-sign-state"><span class="secno">9.2.4.24 </span><dfn>Script data escaped less-than sign state</dfn></h5>
                   2715: 
                   2716:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2717: 
                   2718:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   2719:    <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
                   2720:    to the <a href="#script-data-escaped-end-tag-open-state">script data escaped end tag open state</a>.</dd>
                   2721: 
                   2722:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2723:    <dd>Emit a U+003C LESS-THAN SIGN character token and the
                   2724:    <a href="#current-input-character">current input character</a> as a character token. Set the
                   2725:    <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
                   2726:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2727:    0x0020 to the character's code point) to the <var><a href="#temporary-buffer">temporary
                   2728:    buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
                   2729:    state</a>.</dd>
                   2730: 
                   2731:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2732:    <dd>Emit a U+003C LESS-THAN SIGN character token and the
                   2733:    <a href="#current-input-character">current input character</a> as a character token. Set the
                   2734:    <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
                   2735:    <a href="#current-input-character">current input character</a> to the <var><a href="#temporary-buffer">temporary
                   2736:    buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
                   2737:    state</a>.</dd>
                   2738: 
                   2739:    <dt>Anything else</dt>
                   2740:    <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
                   2741:    <a href="#current-input-character">current input character</a> in the <a href="#script-data-escaped-state">script data
                   2742:    escaped state</a>.</dd>
                   2743: 
                   2744:   </dl><h5 id="script-data-escaped-end-tag-open-state"><span class="secno">9.2.4.25 </span><dfn>Script data escaped end tag open state</dfn></h5>
                   2745: 
                   2746:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2747: 
                   2748:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2749:    <dd>Create a new end tag token, and set its tag name to the
                   2750:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2751:    0x0020 to the character's code point). Append the <a href="#current-input-character">current
                   2752:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2753:    switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
                   2754:    state</a>. (Don't emit the token yet; further details will be
                   2755:    filled in before it is emitted.)</dd>
                   2756: 
                   2757:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2758:    <dd>Create a new end tag token, and set its tag name to the
                   2759:    <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
                   2760:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2761:    switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
                   2762:    state</a>. (Don't emit the token yet; further details will be
                   2763:    filled in before it is emitted.)</dd>
                   2764: 
                   2765:    <dt>Anything else</dt>
                   2766:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2767:    character token, and reconsume the <a href="#current-input-character">current input
                   2768:    character</a> in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
                   2769: 
                   2770:   </dl><h5 id="script-data-escaped-end-tag-name-state"><span class="secno">9.2.4.26 </span><dfn>Script data escaped end tag name state</dfn></h5>
                   2771: 
                   2772:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2773: 
                   2774:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2775:    <dt>U+000A LINE FEED (LF)</dt>
                   2776:    <dt>U+000C FORM FEED (FF)</dt>
                   2777:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2778:    <dt>U+0020 SPACE</dt>
                   2779:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2780:    token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
                   2781:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2782:    below.</dd>
                   2783: 
                   2784:    <dt>U+002F SOLIDUS (/)</dt>
                   2785:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2786:    token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
                   2787:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2788:    below.</dd>
                   2789: 
                   2790:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2791:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2792:    token</a>, then emit the current tag token and switch to the
                   2793:    <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
                   2794:    else" entry below.</dd>
                   2795: 
                   2796:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2797:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2798:    character</a> (add 0x0020 to the character's code point) to the
                   2799:    current tag token's tag name. Append the <a href="#current-input-character">current input
                   2800:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2801:    <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
                   2802: 
                   2803:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2804:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2805:    tag token's tag name. Append the <a href="#current-input-character">current input
                   2806:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2807:    <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
                   2808: 
                   2809:    <dt>Anything else</dt>
                   2810:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2811:    character token, a character token for each of the characters in
                   2812:    the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
                   2813:    the buffer), and reconsume the <a href="#current-input-character">current input character</a>
                   2814:    in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
                   2815: 
                   2816:   </dl><h5 id="script-data-double-escape-start-state"><span class="secno">9.2.4.27 </span><dfn>Script data double escape start state</dfn></h5>
                   2817: 
                   2818:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2819: 
                   2820:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2821:    <dt>U+000A LINE FEED (LF)</dt>
                   2822:    <dt>U+000C FORM FEED (FF)</dt>
                   2823:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2824:    <dt>U+0020 SPACE</dt>
                   2825:    <dt>U+002F SOLIDUS (/)</dt>
                   2826:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2827:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2828:    token. If the <var><a href="#temporary-buffer">temporary buffer</a></var> is the string "<code title="">script</code>", then switch to the <a href="#script-data-double-escaped-state">script data
                   2829:    double escaped state</a>. Otherwise, switch to the <a href="#script-data-escaped-state">script
                   2830:    data escaped state</a>.</dd>
                   2831: 
                   2832:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2833:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2834:    token. Append the lowercase version of the <a href="#current-input-character">current input
                   2835:    character</a> (add 0x0020 to the character's code point) to the
                   2836:    <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
                   2837:    escape start state</a>.</dd>
                   2838: 
                   2839:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2840:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2841:    token. Append the <a href="#current-input-character">current input character</a> to the
                   2842:    <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
                   2843:    escape start state</a>.</dd>
                   2844: 
                   2845:    <dt>Anything else</dt>
                   2846:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   2847:    <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
                   2848: 
                   2849:   </dl><h5 id="script-data-double-escaped-state"><span class="secno">9.2.4.28 </span><dfn>Script data double escaped state</dfn></h5>
                   2850: 
                   2851:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2852: 
                   2853:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2854:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2855:    <a href="#script-data-double-escaped-dash-state">script data double escaped dash state</a>.</dd>
                   2856: 
                   2857:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2858:    <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
                   2859:    <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
                   2860:    state</a>.</p></dd>
                   2861: 
                   2862:    <dt>EOF</dt>
                   2863:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2864:    <a href="#data-state">data state</a>.</dd>
                   2865: 
                   2866:    <dt>Anything else</dt>
                   2867:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2868:    token. Stay in the <a href="#script-data-double-escaped-state">script data double escaped
                   2869:    state</a>.</dd>
                   2870: 
                   2871:   </dl><h5 id="script-data-double-escaped-dash-state"><span class="secno">9.2.4.29 </span><dfn>Script data double escaped dash state</dfn></h5>
                   2872: 
                   2873:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2874: 
                   2875:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2876:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2877:    <a href="#script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>.</dd>
                   2878: 
                   2879:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2880:    <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
                   2881:    <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
                   2882:    state</a>.</p></dd>
                   2883: 
                   2884:    <dt>EOF</dt>
                   2885:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2886:    <a href="#data-state">data state</a>.</dd>
                   2887: 
                   2888:    <dt>Anything else</dt>
                   2889:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2890:    token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
                   2891:    state</a>.</dd>
                   2892: 
                   2893:   </dl><h5 id="script-data-double-escaped-dash-dash-state"><span class="secno">9.2.4.30 </span><dfn>Script data double escaped dash dash state</dfn></h5>
                   2894: 
                   2895:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2896: 
                   2897:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2898:    <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
                   2899:    <a href="#script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>.</dd>
                   2900: 
                   2901:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2902:    <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
                   2903:    <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
                   2904:    state</a>.</p></dd>
                   2905: 
                   2906:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2907:    <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
                   2908:    <a href="#script-data-state">script data state</a>.</dd>
                   2909: 
                   2910:    <dt>EOF</dt>
                   2911:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2912:    <a href="#data-state">data state</a>.</dd>
                   2913: 
                   2914:    <dt>Anything else</dt>
                   2915:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2916:    token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
                   2917:    state</a>.</dd>
                   2918: 
                   2919:   </dl><h5 id="script-data-double-escaped-less-than-sign-state"><span class="secno">9.2.4.31 </span><dfn>Script data double escaped less-than sign state</dfn></h5>
                   2920: 
                   2921:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2922: 
                   2923:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   2924:    <dd>Emit a U+002F SOLIDUS character token. Set the <var><a href="#temporary-buffer">temporary
                   2925:    buffer</a></var> to the empty string. Switch to the <a href="#script-data-double-escape-end-state">script data
                   2926:    double escape end state</a>.</dd>
                   2927: 
                   2928:    <dt>Anything else</dt>
                   2929:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   2930:    <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
                   2931: 
                   2932:   </dl><h5 id="script-data-double-escape-end-state"><span class="secno">9.2.4.32 </span><dfn>Script data double escape end state</dfn></h5>
                   2933: 
                   2934:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2935: 
                   2936:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2937:    <dt>U+000A LINE FEED (LF)</dt>
                   2938:    <dt>U+000C FORM FEED (FF)</dt>
                   2939:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2940:    <dt>U+0020 SPACE</dt>
                   2941:    <dt>U+002F SOLIDUS (/)</dt>
                   2942:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2943:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2944:    token. If the <var><a href="#temporary-buffer">temporary buffer</a></var> is the string "<code title="">script</code>", then switch to the <a href="#script-data-escaped-state">script data
                   2945:    escaped state</a>. Otherwise, switch to the <a href="#script-data-double-escaped-state">script data
                   2946:    double escaped state</a>.</dd>
                   2947: 
                   2948:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2949:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2950:    token. Append the lowercase version of the <a href="#current-input-character">current input
                   2951:    character</a> (add 0x0020 to the character's code point) to the
                   2952:    <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
                   2953:    escape end state</a>.</dd>
                   2954: 
                   2955:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2956:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2957:    token. Append the <a href="#current-input-character">current input character</a> to the
                   2958:    <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
                   2959:    escape end state</a>.</dd>
                   2960: 
                   2961:    <dt>Anything else</dt>
                   2962:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   2963:    <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
1.1       mike     2964: 
1.542     mike     2965:   </dl><h5 id="before-attribute-name-state"><span class="secno">9.2.4.33 </span><dfn>Before attribute name state</dfn></h5>
1.1       mike     2966: 
                   2967:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2968: 
                   2969:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2970:    <dt>U+000A LINE FEED (LF)</dt>
                   2971:    <dt>U+000C FORM FEED (FF)</dt>
                   2972:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2973:    <dt>U+0020 SPACE</dt>
                   2974:    <dd>Stay in the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   2975: 
                   2976:    <dt>U+002F SOLIDUS (/)</dt>
                   2977:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   2978: 
                   2979:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2980:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   2981:    state</a>.</dd>
                   2982: 
                   2983:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2984:    <dd>Start a new attribute in the current tag token. Set that
                   2985:    attribute's name to the lowercase version of the <a href="#current-input-character">current input
                   2986:    character</a> (add 0x0020 to the character's code point), and its
                   2987:    value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
                   2988:    state</a>.</dd>
                   2989: 
                   2990:    <dt>U+0022 QUOTATION MARK (")</dt>
                   2991:    <dt>U+0027 APOSTROPHE (')</dt>
                   2992:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2993:    <dt>U+003D EQUALS SIGN (=)</dt>
                   2994:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   2995:    entry below.</dd>
                   2996: 
                   2997:    <dt>EOF</dt>
                   2998:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2999:    <a href="#data-state">data state</a>.</dd>
                   3000: 
                   3001:    <dt>Anything else</dt>
                   3002:    <dd>Start a new attribute in the current tag token. Set that
                   3003:    attribute's name to the <a href="#current-input-character">current input character</a>, and its value to
                   3004:    the empty string. Switch to the <a href="#attribute-name-state">attribute name
                   3005:    state</a>.</dd>
                   3006: 
1.542     mike     3007:   </dl><h5 id="attribute-name-state"><span class="secno">9.2.4.34 </span><dfn>Attribute name state</dfn></h5>
1.1       mike     3008: 
                   3009:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3010: 
                   3011:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3012:    <dt>U+000A LINE FEED (LF)</dt>
                   3013:    <dt>U+000C FORM FEED (FF)</dt>
                   3014:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3015:    <dt>U+0020 SPACE</dt>
                   3016:    <dd>Switch to the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
                   3017: 
                   3018:    <dt>U+002F SOLIDUS (/)</dt>
                   3019:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   3020: 
                   3021:    <dt>U+003D EQUALS SIGN (=)</dt>
                   3022:    <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
                   3023: 
                   3024:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3025:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3026:    state</a>.</dd>
                   3027: 
                   3028:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541     mike     3029:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   3030:    character</a> (add 0x0020 to the character's code point) to the
                   3031:    current attribute's name. Stay in the <a href="#attribute-name-state">attribute name
1.1       mike     3032:    state</a>.</dd>
                   3033: 
                   3034:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3035:    <dt>U+0027 APOSTROPHE (')</dt>
                   3036:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3037:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3038:    entry below.</dd>
                   3039: 
                   3040:    <dt>EOF</dt>
                   3041:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3042:    <a href="#data-state">data state</a>.</dd>
                   3043: 
                   3044:    <dt>Anything else</dt>
1.541     mike     3045:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3046:    attribute's name. Stay in the <a href="#attribute-name-state">attribute name
                   3047:    state</a>.</dd>
1.1       mike     3048: 
                   3049:   </dl><p>When the user agent leaves the attribute name state (and before
                   3050:   emitting the tag token, if appropriate), the complete attribute's
                   3051:   name must be compared to the other attributes on the same token;
                   3052:   if there is already an attribute on the token with the exact same
                   3053:   name, then this is a <a href="#parse-error">parse error</a> and the new
                   3054:   attribute must be dropped, along with the value that gets
                   3055:   associated with it (if any).</p>
                   3056: 
                   3057: 
1.542     mike     3058:   <h5 id="after-attribute-name-state"><span class="secno">9.2.4.35 </span><dfn>After attribute name state</dfn></h5>
1.1       mike     3059: 
                   3060:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3061: 
                   3062:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3063:    <dt>U+000A LINE FEED (LF)</dt>
                   3064:    <dt>U+000C FORM FEED (FF)</dt>
                   3065:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3066:    <dt>U+0020 SPACE</dt>
                   3067:    <dd>Stay in the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
                   3068: 
                   3069:    <dt>U+002F SOLIDUS (/)</dt>
                   3070:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   3071: 
                   3072:    <dt>U+003D EQUALS SIGN (=)</dt>
                   3073:    <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
                   3074: 
                   3075:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3076:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3077:    state</a>.</dd>
                   3078: 
                   3079:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   3080:    <dd>Start a new attribute in the current tag token. Set that
1.541     mike     3081:    attribute's name to the lowercase version of the <a href="#current-input-character">current
                   3082:    input character</a> (add 0x0020 to the character's code point),
                   3083:    and its value to the empty string. Switch to the <a href="#attribute-name-state">attribute
                   3084:    name state</a>.</dd>
1.1       mike     3085: 
                   3086:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3087:    <dt>U+0027 APOSTROPHE (')</dt>
                   3088:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3089:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3090:    entry below.</dd>
                   3091: 
                   3092:    <dt>EOF</dt>
                   3093:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3094:    <a href="#data-state">data state</a>.</dd>
                   3095: 
                   3096:    <dt>Anything else</dt>
                   3097:    <dd>Start a new attribute in the current tag token. Set that
1.541     mike     3098:    attribute's name to the <a href="#current-input-character">current input character</a>, and
                   3099:    its value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
1.1       mike     3100:    state</a>.</dd>
                   3101: 
1.542     mike     3102:   </dl><h5 id="before-attribute-value-state"><span class="secno">9.2.4.36 </span><dfn>Before attribute value state</dfn></h5>
1.1       mike     3103: 
                   3104:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3105: 
                   3106:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3107:    <dt>U+000A LINE FEED (LF)</dt>
                   3108:    <dt>U+000C FORM FEED (FF)</dt>
                   3109:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3110:    <dt>U+0020 SPACE</dt>
                   3111:    <dd>Stay in the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
                   3112: 
                   3113:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3114:    <dd>Switch to the <a href="#attribute-value-double-quoted-state">attribute value (double-quoted) state</a>.</dd>
                   3115: 
                   3116:    <dt>U+0026 AMPERSAND (&amp;)</dt>
                   3117:    <dd>Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted) state</a>
1.541     mike     3118:    and reconsume this <a href="#current-input-character">current input character</a>.</dd>
1.1       mike     3119: 
                   3120:    <dt>U+0027 APOSTROPHE (')</dt>
                   3121:    <dd>Switch to the <a href="#attribute-value-single-quoted-state">attribute value (single-quoted) state</a>.</dd>
                   3122: 
                   3123:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3124:    <dd><a href="#parse-error">Parse error</a>. Emit the current tag token. Switch to
                   3125:    the <a href="#data-state">data state</a>.</dd>
                   3126: 
                   3127:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3128:    <dt>U+003D EQUALS SIGN (=)</dt>
1.463     mike     3129:    <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1       mike     3130:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3131:    entry below.</dd>
                   3132: 
                   3133:    <dt>EOF</dt>
                   3134:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3135:    <a href="#data-state">data state</a>.</dd>
                   3136: 
                   3137:    <dt>Anything else</dt>
                   3138:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3139:    attribute's value. Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
                   3140:    state</a>.</dd>
                   3141: 
1.542     mike     3142:   </dl><h5 id="attribute-value-double-quoted-state"><span class="secno">9.2.4.37 </span><dfn>Attribute value (double-quoted) state</dfn></h5>
1.1       mike     3143: 
                   3144:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3145: 
                   3146:   <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
                   3147:    <dd>Switch to the <a href="#after-attribute-value-quoted-state">after attribute value (quoted)
                   3148:    state</a>.</dd>
                   3149: 
                   3150:    <dt>U+0026 AMPERSAND (&amp;)</dt>
                   3151:    <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
                   3152:    state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
                   3153:    being U+0022 QUOTATION MARK (").</dd>
                   3154: 
                   3155:    <dt>EOF</dt>
                   3156:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3157:    <a href="#data-state">data state</a>.</dd>
                   3158: 
                   3159:    <dt>Anything else</dt>
1.541     mike     3160:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3161:    attribute's value. Stay in the <a href="#attribute-value-double-quoted-state">attribute value
                   3162:    (double-quoted) state</a>.</dd>
1.1       mike     3163: 
1.542     mike     3164:   </dl><h5 id="attribute-value-single-quoted-state"><span class="secno">9.2.4.38 </span><dfn>Attribute value (single-quoted) state</dfn></h5>
1.1       mike     3165: 
                   3166:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3167: 
                   3168:   <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
                   3169:    <dd>Switch to the <a href="#after-attribute-value-quoted-state">after attribute value (quoted)
                   3170:    state</a>.</dd>
                   3171: 
                   3172:    <dt>U+0026 AMPERSAND (&amp;)</dt>
                   3173:    <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
                   3174:    state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
                   3175:    being U+0027 APOSTROPHE (').</dd>
                   3176: 
                   3177:    <dt>EOF</dt>
                   3178:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3179:    <a href="#data-state">data state</a>.</dd>
                   3180: 
                   3181:    <dt>Anything else</dt>
1.541     mike     3182:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3183:    attribute's value. Stay in the <a href="#attribute-value-single-quoted-state">attribute value
                   3184:    (single-quoted) state</a>.</dd>
1.1       mike     3185: 
1.542     mike     3186:   </dl><h5 id="attribute-value-unquoted-state"><span class="secno">9.2.4.39 </span><dfn>Attribute value (unquoted) state</dfn></h5>
1.1       mike     3187: 
                   3188:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3189: 
                   3190:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3191:    <dt>U+000A LINE FEED (LF)</dt>
                   3192:    <dt>U+000C FORM FEED (FF)</dt>
                   3193:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3194:    <dt>U+0020 SPACE</dt>
                   3195:    <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3196: 
                   3197:    <dt>U+0026 AMPERSAND (&amp;)</dt>
                   3198:    <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
1.299     mike     3199:    state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
                   3200:    being U+003E GREATER-THAN SIGN (&gt;).</dd>
1.1       mike     3201: 
                   3202:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3203:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3204:    state</a>.</dd>
                   3205: 
                   3206:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3207:    <dt>U+0027 APOSTROPHE (')</dt>
                   3208:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3209:    <dt>U+003D EQUALS SIGN (=)</dt>
1.463     mike     3210:    <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1       mike     3211:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3212:    entry below.</dd>
                   3213: 
                   3214:    <dt>EOF</dt>
                   3215:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3216:    <a href="#data-state">data state</a>.</dd>
                   3217: 
                   3218:    <dt>Anything else</dt>
1.541     mike     3219:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3220:    attribute's value. Stay in the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
1.1       mike     3221:    state</a>.</dd>
                   3222: 
1.542     mike     3223:   </dl><h5 id="character-reference-in-attribute-value-state"><span class="secno">9.2.4.40 </span><dfn>Character reference in attribute value state</dfn></h5>
1.1       mike     3224: 
                   3225:   <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>.</p>
                   3226: 
                   3227:   <p>If nothing is returned, append a U+0026 AMPERSAND character to
                   3228:   the current attribute's value.</p>
                   3229: 
                   3230:   <p>Otherwise, append the returned character token to the current
                   3231:   attribute's value.</p>
                   3232: 
                   3233:   <p>Finally, switch back to the attribute value state that you were
                   3234:   in when were switched into this state.</p>
                   3235: 
                   3236: 
1.542     mike     3237:   <h5 id="after-attribute-value-quoted-state"><span class="secno">9.2.4.41 </span><dfn>After attribute value (quoted) state</dfn></h5>
1.1       mike     3238: 
                   3239:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3240: 
                   3241:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3242:    <dt>U+000A LINE FEED (LF)</dt>
                   3243:    <dt>U+000C FORM FEED (FF)</dt>
                   3244:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3245:    <dt>U+0020 SPACE</dt>
                   3246:    <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3247: 
                   3248:    <dt>U+002F SOLIDUS (/)</dt>
                   3249:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   3250: 
                   3251:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3252:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3253:    state</a>.</dd>
                   3254: 
                   3255:    <dt>EOF</dt>
                   3256:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3257:    <a href="#data-state">data state</a>.</dd>
                   3258: 
                   3259:    <dt>Anything else</dt>
                   3260:    <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
                   3261:    the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3262: 
1.542     mike     3263:   </dl><h5 id="self-closing-start-tag-state"><span class="secno">9.2.4.42 </span><dfn>Self-closing start tag state</dfn></h5>
1.1       mike     3264: 
                   3265:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3266: 
                   3267:   <dl class="switch"><dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3268:    <dd>Set the <i>self-closing flag</i> of the current tag
                   3269:    token. Emit the current tag token. Switch to the <a href="#data-state">data
                   3270:    state</a>.</dd>
                   3271: 
                   3272:    <dt>EOF</dt>
                   3273:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3274:    <a href="#data-state">data state</a>.</dd>
                   3275: 
                   3276:    <dt>Anything else</dt>
                   3277:    <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
                   3278:    the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3279: 
1.542     mike     3280:   </dl><h5 id="bogus-comment-state"><span class="secno">9.2.4.43 </span><dfn>Bogus comment state</dfn></h5>
1.1       mike     3281: 
                   3282:   <p>Consume every character up to and including the first U+003E
                   3283:   GREATER-THAN SIGN character (&gt;) or the end of the file (EOF),
                   3284:   whichever comes first. Emit a comment token whose data is the
                   3285:   concatenation of all the characters starting from and including
                   3286:   the character that caused the state machine to switch into the
                   3287:   bogus comment state, up to and including the character immediately
                   3288:   before the last consumed character (i.e. up to the character just
                   3289:   before the U+003E or EOF character). (If the comment was started
                   3290:   by the end of the file (EOF), the token is empty.)</p>
                   3291: 
                   3292:   <p>Switch to the <a href="#data-state">data state</a>.</p>
                   3293: 
                   3294:   <p>If the end of the file was reached, reconsume the EOF
                   3295:   character.</p>
                   3296: 
                   3297: 
1.542     mike     3298:   <h5 id="markup-declaration-open-state"><span class="secno">9.2.4.44 </span><dfn>Markup declaration open state</dfn></h5>
1.1       mike     3299: 
                   3300:   <p>If the next two characters are both U+002D HYPHEN-MINUS (-)
                   3301:   characters, consume those two characters, create a comment token
                   3302:   whose data is the empty string, and switch to the <a href="#comment-start-state">comment
                   3303:   start state</a>.</p>
                   3304: 
                   3305:   <p>Otherwise, if the next seven characters are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   3306:   case-insensitive</a> match for the word "DOCTYPE", then consume
                   3307:   those characters and switch to the <a href="#doctype-state">DOCTYPE state</a>.</p>
                   3308: 
                   3309:   <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
                   3310:   content</a>" and the <a href="#current-node">current node</a> is not an element
                   3311:   in the <a href="#html-namespace-0">HTML namespace</a> and the next seven characters are
                   3312:   an <span>ASCII case-sensitive</span> match for the string "[CDATA["
                   3313:   (the five uppercase letters "CDATA" with a U+005B LEFT SQUARE
                   3314:   BRACKET character before and after), then consume those characters
1.91      mike     3315:   and switch to the <a href="#cdata-section-state">CDATA section state</a>.</p>
1.1       mike     3316: 
                   3317:   <p>Otherwise, this is a <a href="#parse-error">parse error</a>. Switch to the
                   3318:   <a href="#bogus-comment-state">bogus comment state</a>. The next character that is
                   3319:   consumed, if any, is the first character that will be in the
                   3320:   comment.</p>
                   3321: 
                   3322: 
1.542     mike     3323:   <h5 id="comment-start-state"><span class="secno">9.2.4.45 </span><dfn>Comment start state</dfn></h5>
1.1       mike     3324: 
                   3325:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3326: 
                   3327:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3328:    <dd>Switch to the <a href="#comment-start-dash-state">comment start dash state</a>.</dd>
                   3329: 
                   3330:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3331:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to the
                   3332:    <a href="#data-state">data state</a>.</dd> <!-- see comment in comment end state
                   3333:    -->
                   3334: 
                   3335:    <dt>EOF</dt>
                   3336:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
                   3337:    the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3338: 
                   3339:    <dt>Anything else</dt>
1.541     mike     3340:    <dd>Append the <a href="#current-input-character">current input character</a> to the comment
                   3341:    token's data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3342: 
1.542     mike     3343:   </dl><h5 id="comment-start-dash-state"><span class="secno">9.2.4.46 </span><dfn>Comment start dash state</dfn></h5>
1.1       mike     3344: 
                   3345:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3346: 
                   3347:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3348:    <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
                   3349: 
                   3350:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3351:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to
                   3352:    the <a href="#data-state">data state</a>.</dd>
                   3353: 
                   3354:    <dt>EOF</dt>
                   3355:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
                   3356:    EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
                   3357:    in comment end state -->
                   3358: 
                   3359:    <dt>Anything else</dt>
1.541     mike     3360:    <dd>Append a U+002D HYPHEN-MINUS character (-) and the
                   3361:    <a href="#current-input-character">current input character</a> to the comment token's
                   3362:    data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3363: 
1.542     mike     3364:   </dl><h5 id="comment-state"><span class="secno">9.2.4.47 </span><dfn id="comment">Comment state</dfn></h5>
1.1       mike     3365: 
                   3366:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3367: 
                   3368:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3369:    <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a></dd>
                   3370: 
                   3371:    <dt>EOF</dt>
                   3372:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
                   3373:    EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
                   3374:    in comment end state -->
                   3375: 
                   3376:    <dt>Anything else</dt>
1.541     mike     3377:    <dd>Append the <a href="#current-input-character">current input character</a> to the comment
                   3378:    token's data. Stay in the <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3379: 
1.542     mike     3380:   </dl><h5 id="comment-end-dash-state"><span class="secno">9.2.4.48 </span><dfn>Comment end dash state</dfn></h5>
1.1       mike     3381: 
                   3382:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3383: 
                   3384:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3385:    <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
                   3386: 
                   3387:    <dt>EOF</dt>
                   3388:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
                   3389:    EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
                   3390:    in comment end state -->
                   3391: 
                   3392:    <dt>Anything else</dt>
1.541     mike     3393:    <dd>Append a U+002D HYPHEN-MINUS character (-) and the
                   3394:    <a href="#current-input-character">current input character</a> to the comment token's
                   3395:    data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3396: 
1.542     mike     3397:   </dl><h5 id="comment-end-state"><span class="secno">9.2.4.49 </span><dfn>Comment end state</dfn></h5>
1.1       mike     3398: 
                   3399:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3400: 
                   3401:   <dl class="switch"><dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3402:    <dd>Emit the comment token. Switch to the <a href="#data-state">data
                   3403:    state</a>.</dd>
                   3404: 
                   3405:    <dt>U+0009 CHARACTER TABULATION</dt>
                   3406:    <dt>U+000A LINE FEED (LF)</dt>
                   3407:    <dt>U+000C FORM FEED (FF)</dt>
                   3408:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3409:    <dt>U+0020 SPACE</dt>
                   3410:    <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS (-)
1.541     mike     3411:    characters and the <a href="#current-input-character">current input character</a> to the
                   3412:    comment token's data. Switch to the <a href="#comment-end-space-state">comment end space
                   3413:    state</a>.</dd>
1.1       mike     3414: 
                   3415:    <dt>U+0021 EXCLAMATION MARK (!)</dt>
                   3416:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#comment-end-bang-state">comment end bang
                   3417:    state</a>.</dd>
                   3418: 
1.333     mike     3419:    <dt>U+002D HYPHEN-MINUS (-)</dt>
                   3420:    <dd><a href="#parse-error">Parse error</a>. Append a U+002D HYPHEN-MINUS
1.464     mike     3421:    character (-) to the comment token's data. Stay in the
1.333     mike     3422:    <a href="#comment-end-state">comment end state</a>.</dd>
                   3423: 
1.1       mike     3424:    <dt>EOF</dt>
                   3425:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
                   3426:    the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- For
                   3427:    security reasons: otherwise, hostile user could put a <script> in
                   3428:    a comment e.g. in a blog comment and then DOS the server so that
                   3429:    the end tag isn't read, and then the commented <script> tag would
                   3430:    be treated as live code -->
                   3431: 
                   3432:    <dt>Anything else</dt>
                   3433:    <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS (-)
1.541     mike     3434:    characters and the <a href="#current-input-character">current input character</a> to the
                   3435:    comment token's data. Switch to the <a href="#comment-state">comment
                   3436:    state</a>.</dd>
1.1       mike     3437: 
1.542     mike     3438:   </dl><h5 id="comment-end-bang-state"><span class="secno">9.2.4.50 </span><dfn>Comment end bang state</dfn></h5>
1.1       mike     3439: 
                   3440:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3441: 
1.333     mike     3442:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
1.1       mike     3443:    <dd>Append two U+002D HYPHEN-MINUS (-) characters and a U+0021
1.464     mike     3444:    EXCLAMATION MARK character (!) to the comment token's data. Switch
1.1       mike     3445:    to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
                   3446: 
1.333     mike     3447:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3448:    <dd>Emit the comment token. Switch to the <a href="#data-state">data
                   3449:    state</a>.</dd>
                   3450: 
1.1       mike     3451:    <dt>EOF</dt>
                   3452:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
                   3453:    the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
                   3454:    comment in comment end state -->
                   3455: 
                   3456:    <dt>Anything else</dt>
                   3457:    <dd>Append two U+002D HYPHEN-MINUS (-) characters, a U+0021
1.541     mike     3458:    EXCLAMATION MARK character (!), and the <a href="#current-input-character">current input
                   3459:    character</a> to the comment token's data. Switch to the
                   3460:    <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3461: 
1.542     mike     3462:   </dl><h5 id="comment-end-space-state"><span class="secno">9.2.4.51 </span><dfn>Comment end space state</dfn></h5>
1.1       mike     3463: 
                   3464:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3465: 
1.333     mike     3466:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
1.1       mike     3467:    <dt>U+000A LINE FEED (LF)</dt>
                   3468:    <dt>U+000C FORM FEED (FF)</dt>
                   3469:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3470:    <dt>U+0020 SPACE</dt>
1.541     mike     3471:    <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Stay in
1.1       mike     3472:    the <a href="#comment-end-space-state">comment end space state</a>.</dd>
                   3473: 
1.333     mike     3474:    <dt>U+002D HYPHEN-MINUS (-)</dt>
                   3475:    <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
                   3476: 
                   3477:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3478:    <dd>Emit the comment token. Switch to the <a href="#data-state">data
                   3479:    state</a>.</dd>
                   3480: 
1.1       mike     3481:    <dt>EOF</dt>
                   3482:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
                   3483:    the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
                   3484:    comment in comment end state -->
                   3485: 
                   3486:    <dt>Anything else</dt>
1.541     mike     3487:    <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Switch
1.1       mike     3488:    to the <a href="#comment-state">comment state</a>.</dd>
                   3489: 
1.542     mike     3490:   </dl><h5 id="doctype-state"><span class="secno">9.2.4.52 </span><dfn>DOCTYPE state</dfn></h5>
1.1       mike     3491: 
                   3492:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3493: 
                   3494:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3495:    <dt>U+000A LINE FEED (LF)</dt>
                   3496:    <dt>U+000C FORM FEED (FF)</dt>
                   3497:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3498:    <dt>U+0020 SPACE</dt>
                   3499:    <dd>Switch to the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
                   3500: 
                   3501:    <dt>EOF</dt>
                   3502:    <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
                   3503:    <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
                   3504:    the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3505: 
                   3506:    <dt>Anything else</dt>
                   3507:    <dd><a href="#parse-error">Parse error</a>. Reconsume the current
                   3508:    character in the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
                   3509: 
1.542     mike     3510:   </dl><h5 id="before-doctype-name-state"><span class="secno">9.2.4.53 </span><dfn>Before DOCTYPE name state</dfn></h5>
1.1       mike     3511: 
                   3512:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3513: 
                   3514:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3515:    <dt>U+000A LINE FEED (LF)</dt>
                   3516:    <dt>U+000C FORM FEED (FF)</dt>
                   3517:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3518:    <dt>U+0020 SPACE</dt>
                   3519:    <dd>Stay in the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
                   3520: 
                   3521:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   3522:    <dd>Create a new DOCTYPE token. Set the token's name to the
1.541     mike     3523:    lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
1.1       mike     3524:    character's code point). Switch to the <a href="#doctype-name-state">DOCTYPE name
                   3525:    state</a>.</dd>
                   3526: 
1.333     mike     3527:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3528:    <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
                   3529:    <i>force-quirks flag</i> to <i>on</i>. Emit the token. Switch to
                   3530:    the <a href="#data-state">data state</a>.</dd>
                   3531: 
1.1       mike     3532:    <dt>EOF</dt>
                   3533:    <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
                   3534:    <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
                   3535:    the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3536: 
                   3537:    <dt>Anything else</dt>
                   3538:    <dd>Create a new DOCTYPE token. Set the token's name to the
                   3539:    <a href="#current-input-character">current input character</a>. Switch to the <a href="#doctype-name-state">DOCTYPE name
                   3540:    state</a>.</dd>
                   3541: 
1.542     mike     3542:   </dl><h5 id="doctype-name-state"><span class="secno">9.2.4.54 </span><dfn>DOCTYPE name state</dfn></h5>
1.1       mike     3543: 
                   3544:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3545: 
                   3546:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3547:    <dt>U+000A LINE FEED (LF)</dt>
                   3548:    <dt>U+000C FORM FEED (FF)</dt>
                   3549:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3550:    <dt>U+0020 SPACE</dt>
                   3551:    <dd>Switch to the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
                   3552: 
                   3553:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3554:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   3555:    state</a>.</dd>
                   3556: 
                   3557:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541     mike     3558:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   3559:    character</a> (add 0x0020 to the character's code point) to the
                   3560:    current DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
                   3561:    state</a>.</dd>
1.1       mike     3562: 
                   3563:    <dt>EOF</dt>
                   3564:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3565:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3566:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3567: 
                   3568:    <dt>Anything else</dt>
1.541     mike     3569:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3570:    DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
                   3571:    state</a>.</dd>
1.1       mike     3572: 
1.542     mike     3573:   </dl><h5 id="after-doctype-name-state"><span class="secno">9.2.4.55 </span><dfn>After DOCTYPE name state</dfn></h5>
1.1       mike     3574: 
                   3575:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3576: 
                   3577:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3578:    <dt>U+000A LINE FEED (LF)</dt>
                   3579:    <dt>U+000C FORM FEED (FF)</dt>
                   3580:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3581:    <dt>U+0020 SPACE</dt>
                   3582:    <dd>Stay in the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
                   3583: 
                   3584:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3585:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   3586:    state</a>.</dd>
                   3587: 
                   3588:    <dt>EOF</dt>
                   3589:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3590:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3591:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3592: 
                   3593:    <dt>Anything else</dt>
                   3594:    <dd>
                   3595: 
                   3596:     <p>If the six characters starting from the <a href="#current-input-character">current input
                   3597:     character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match
                   3598:     for the word "PUBLIC", then consume those characters and switch to
1.444     mike     3599:     the <a href="#after-doctype-public-keyword-state">after DOCTYPE public keyword state</a>.</p>
1.1       mike     3600: 
                   3601:     <p>Otherwise, if the six characters starting from the
                   3602:     <a href="#current-input-character">current input character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   3603:     case-insensitive</a> match for the word "SYSTEM", then consume
1.444     mike     3604:     those characters and switch to the <a href="#after-doctype-system-keyword-state">after DOCTYPE system
                   3605:     keyword state</a>.</p>
1.1       mike     3606: 
                   3607:     <p>Otherwise, this is the <a href="#parse-error">parse error</a>. Set the
                   3608:     DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to
                   3609:     the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</p>
                   3610: 
                   3611:    </dd>
                   3612: 
1.542     mike     3613:   </dl><h5 id="after-doctype-public-keyword-state"><span class="secno">9.2.4.56 </span><dfn>After DOCTYPE public keyword state</dfn></h5>
1.444     mike     3614: 
                   3615:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3616: 
                   3617:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3618:    <dt>U+000A LINE FEED (LF)</dt>
                   3619:    <dt>U+000C FORM FEED (FF)</dt>
                   3620:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3621:    <dt>U+0020 SPACE</dt>
                   3622:    <dd>Switch to the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier
                   3623:    state</a>.</dd>
                   3624: 
                   3625:    <dt>EOF</dt>
                   3626:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3627:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3628:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3629: 
                   3630:    <dt>Anything else</dt>
                   3631:    <dd><a href="#parse-error">Parse error</a>. Reconsume the current character in
                   3632:    the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier state</a>.</dd>
                   3633: 
1.542     mike     3634:   </dl><h5 id="before-doctype-public-identifier-state"><span class="secno">9.2.4.57 </span><dfn>Before DOCTYPE public identifier state</dfn></h5>
1.1       mike     3635: 
                   3636:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3637: 
                   3638:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3639:    <dt>U+000A LINE FEED (LF)</dt>
                   3640:    <dt>U+000C FORM FEED (FF)</dt>
                   3641:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3642:    <dt>U+0020 SPACE</dt>
                   3643:    <dd>Stay in the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier state</a>.</dd>
                   3644: 
                   3645:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3646:    <dd>Set the DOCTYPE token's public identifier to the empty string
                   3647:    (not missing), then switch to the <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public identifier
                   3648:    (double-quoted) state</a>.</dd>
                   3649: 
                   3650:    <dt>U+0027 APOSTROPHE (')</dt>
                   3651:    <dd>Set the DOCTYPE token's public identifier to the empty string
                   3652:    (not missing), then switch to the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public identifier
                   3653:    (single-quoted) state</a>.</dd>
                   3654: 
                   3655:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3656:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3657:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3658:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3659: 
                   3660:    <dt>EOF</dt>
                   3661:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3662:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3663:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3664: 
                   3665:    <dt>Anything else</dt>
                   3666:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3667:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3668:    DOCTYPE state</a>.</dd>
                   3669: 
1.542     mike     3670:   </dl><h5 id="doctype-public-identifier-double-quoted-state"><span class="secno">9.2.4.58 </span><dfn>DOCTYPE public identifier (double-quoted) state</dfn></h5>
1.1       mike     3671: 
                   3672:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3673: 
                   3674:   <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
                   3675:    <dd>Switch to the <a href="#after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd>
                   3676: 
                   3677:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3678:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3679:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3680:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3681: 
                   3682:    <dt>EOF</dt>
                   3683:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3684:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3685:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3686: 
                   3687:    <dt>Anything else</dt>
                   3688:    <dd>Append the <a href="#current-input-character">current input character</a> to the current DOCTYPE
                   3689:    token's public identifier. Stay in the <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public
                   3690:    identifier (double-quoted) state</a>.</dd>
                   3691: 
1.542     mike     3692:   </dl><h5 id="doctype-public-identifier-single-quoted-state"><span class="secno">9.2.4.59 </span><dfn>DOCTYPE public identifier (single-quoted) state</dfn></h5>
1.1       mike     3693: 
                   3694:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3695: 
                   3696:   <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
                   3697:    <dd>Switch to the <a href="#after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd>
                   3698: 
                   3699:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3700:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3701:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3702:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3703: 
                   3704:    <dt>EOF</dt>
                   3705:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3706:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3707:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3708: 
                   3709:    <dt>Anything else</dt>
                   3710:    <dd>Append the <a href="#current-input-character">current input character</a> to the current DOCTYPE
                   3711:    token's public identifier. Stay in the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public
                   3712:    identifier (single-quoted) state</a>.</dd>
                   3713: 
1.542     mike     3714:   </dl><h5 id="after-doctype-public-identifier-state"><span class="secno">9.2.4.60 </span><dfn>After DOCTYPE public identifier state</dfn></h5>
1.1       mike     3715: 
                   3716:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3717: 
                   3718:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3719:    <dt>U+000A LINE FEED (LF)</dt>
                   3720:    <dt>U+000C FORM FEED (FF)</dt>
                   3721:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3722:    <dt>U+0020 SPACE</dt>
1.541     mike     3723:    <dd>Switch to the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system
                   3724:    identifiers state</a>.</dd>
1.444     mike     3725: 
                   3726:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3727:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   3728:    state</a>.</dd>
                   3729: 
                   3730:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3731:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
                   3732:    identifier to the empty string (not missing), then switch to the
                   3733:    <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier (double-quoted) state</a>.</dd>
                   3734: 
                   3735:    <dt>U+0027 APOSTROPHE (')</dt>
                   3736:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
                   3737:    identifier to the empty string (not missing), then switch to the
                   3738:    <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier (single-quoted) state</a>.</dd>
                   3739: 
                   3740:    <dt>EOF</dt>
                   3741:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3742:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3743:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3744: 
                   3745:    <dt>Anything else</dt>
                   3746:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3747:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3748:    DOCTYPE state</a>.</dd>
                   3749: 
1.542     mike     3750:   </dl><h5 id="between-doctype-public-and-system-identifiers-state"><span class="secno">9.2.4.61 </span><dfn>Between DOCTYPE public and system identifiers state</dfn></h5>
1.444     mike     3751: 
                   3752:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3753: 
                   3754:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3755:    <dt>U+000A LINE FEED (LF)</dt>
                   3756:    <dt>U+000C FORM FEED (FF)</dt>
                   3757:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3758:    <dt>U+0020 SPACE</dt>
1.541     mike     3759:    <dd>Stay in the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system identifiers
                   3760:    state</a>.</dd>
1.444     mike     3761: 
                   3762:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3763:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   3764:    state</a>.</dd>
1.1       mike     3765: 
                   3766:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3767:    <dd>Set the DOCTYPE token's system identifier to the empty string
                   3768:    (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
                   3769:    (double-quoted) state</a>.</dd>
                   3770: 
                   3771:    <dt>U+0027 APOSTROPHE (')</dt>
                   3772:    <dd>Set the DOCTYPE token's system identifier to the empty string
                   3773:    (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
                   3774:    (single-quoted) state</a>.</dd>
                   3775: 
                   3776:    <dt>EOF</dt>
                   3777:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3778:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3779:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3780: 
                   3781:    <dt>Anything else</dt>
                   3782:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3783:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3784:    DOCTYPE state</a>.</dd>
                   3785: 
1.542     mike     3786:   </dl><h5 id="after-doctype-system-keyword-state"><span class="secno">9.2.4.62 </span><dfn>After DOCTYPE system keyword state</dfn></h5>
1.444     mike     3787: 
                   3788:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3789: 
                   3790:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3791:    <dt>U+000A LINE FEED (LF)</dt>
                   3792:    <dt>U+000C FORM FEED (FF)</dt>
                   3793:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3794:    <dt>U+0020 SPACE</dt>
                   3795:    <dd>Switch to the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier
                   3796:    state</a>.</dd>
                   3797: 
                   3798:    <dt>EOF</dt>
                   3799:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3800:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3801:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3802: 
                   3803:    <dt>Anything else</dt>
                   3804:    <dd><a href="#parse-error">Parse error</a>. Reconsume the current character in
                   3805:    the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier state</a>.</dd>
                   3806: 
1.542     mike     3807:   </dl><h5 id="before-doctype-system-identifier-state"><span class="secno">9.2.4.63 </span><dfn>Before DOCTYPE system identifier state</dfn></h5>
1.1       mike     3808: 
                   3809:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3810: 
                   3811:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3812:    <dt>U+000A LINE FEED (LF)</dt>
                   3813:    <dt>U+000C FORM FEED (FF)</dt>
                   3814:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3815:    <dt>U+0020 SPACE</dt>
                   3816:    <dd>Stay in the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier state</a>.</dd>
                   3817: 
                   3818:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3819:    <dd>Set the DOCTYPE token's system identifier to the empty string
                   3820:    (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
                   3821:    (double-quoted) state</a>.</dd>
                   3822: 
                   3823:    <dt>U+0027 APOSTROPHE (')</dt>
                   3824:    <dd>Set the DOCTYPE token's system identifier to the empty string
                   3825:    (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
                   3826:    (single-quoted) state</a>.</dd>
                   3827: 
                   3828:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3829:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3830:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3831:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3832: 
                   3833:    <dt>EOF</dt>
                   3834:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3835:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3836:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3837: 
                   3838:    <dt>Anything else</dt>
                   3839:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3840:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3841:    DOCTYPE state</a>.</dd>
                   3842: 
1.542     mike     3843:   </dl><h5 id="doctype-system-identifier-double-quoted-state"><span class="secno">9.2.4.64 </span><dfn>DOCTYPE system identifier (double-quoted) state</dfn></h5>
1.1       mike     3844: 
                   3845:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3846: 
                   3847:   <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
1.541     mike     3848:    <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
                   3849:    state</a>.</dd>
1.1       mike     3850: 
                   3851:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3852:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3853:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3854:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3855: 
                   3856:    <dt>EOF</dt>
                   3857:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3858:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3859:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3860: 
                   3861:    <dt>Anything else</dt>
1.541     mike     3862:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3863:    DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system
1.1       mike     3864:    identifier (double-quoted) state</a>.</dd>
                   3865: 
1.542     mike     3866:   </dl><h5 id="doctype-system-identifier-single-quoted-state"><span class="secno">9.2.4.65 </span><dfn>DOCTYPE system identifier (single-quoted) state</dfn></h5>
1.1       mike     3867: 
                   3868:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3869: 
                   3870:   <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
1.541     mike     3871:    <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
                   3872:    state</a>.</dd>
1.1       mike     3873: 
                   3874:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3875:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3876:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3877:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3878: 
                   3879:    <dt>EOF</dt>
                   3880:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3881:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3882:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3883: 
                   3884:    <dt>Anything else</dt>
1.541     mike     3885:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3886:    DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system
1.1       mike     3887:    identifier (single-quoted) state</a>.</dd>
                   3888: 
1.542     mike     3889:   </dl><h5 id="after-doctype-system-identifier-state"><span class="secno">9.2.4.66 </span><dfn>After DOCTYPE system identifier state</dfn></h5>
1.1       mike     3890: 
                   3891:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3892: 
                   3893:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3894:    <dt>U+000A LINE FEED (LF)</dt>
                   3895:    <dt>U+000C FORM FEED (FF)</dt>
                   3896:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3897:    <dt>U+0020 SPACE</dt>
1.541     mike     3898:    <dd>Stay in the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
                   3899:    state</a>.</dd>
1.1       mike     3900: 
                   3901:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3902:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   3903:    state</a>.</dd>
                   3904: 
                   3905:    <dt>EOF</dt>
                   3906:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3907:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3908:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3909: 
                   3910:    <dt>Anything else</dt>
                   3911:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-doctype-state">bogus DOCTYPE
                   3912:    state</a>. (This does <em>not</em> set the DOCTYPE token's
                   3913:    <i>force-quirks flag</i> to <i>on</i>.)</dd>
                   3914: 
1.542     mike     3915:   </dl><h5 id="bogus-doctype-state"><span class="secno">9.2.4.67 </span><dfn>Bogus DOCTYPE state</dfn></h5>
1.1       mike     3916: 
                   3917:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3918: 
                   3919:   <dl class="switch"><dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3920:    <dd>Emit the DOCTYPE token. Switch to the <a href="#data-state">data
                   3921:    state</a>.</dd>
                   3922: 
                   3923:    <dt>EOF</dt>
                   3924:    <dd>Emit the DOCTYPE token. Reconsume the EOF character in the
                   3925:    <a href="#data-state">data state</a>.</dd>
                   3926: 
                   3927:    <dt>Anything else</dt>
                   3928:    <dd>Stay in the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</dd>
                   3929: 
1.542     mike     3930:   </dl><h5 id="cdata-section-state"><span class="secno">9.2.4.68 </span><dfn>CDATA section state</dfn></h5>
1.1       mike     3931: 
                   3932:   <p>Consume every character up to the next occurrence of the three
                   3933:   character sequence U+005D RIGHT SQUARE BRACKET U+005D RIGHT SQUARE
                   3934:   BRACKET U+003E GREATER-THAN SIGN (<code title="">]]&gt;</code>), or the
                   3935:   end of the file (EOF), whichever comes first. Emit a series of
                   3936:   character tokens consisting of all the characters consumed except
                   3937:   the matching three character sequence at the end (if one was found
                   3938:   before the end of the file).</p>
                   3939: 
                   3940:   <p>Switch to the <a href="#data-state">data state</a>.</p>
                   3941: 
                   3942:   <p>If the end of the file was reached, reconsume the EOF
                   3943:   character.</p>
                   3944: 
                   3945: 
                   3946: 
1.542     mike     3947:   <h5 id="tokenizing-character-references"><span class="secno">9.2.4.69 </span>Tokenizing character references</h5>
1.1       mike     3948: 
                   3949:   <p>This section defines how to <dfn id="consume-a-character-reference">consume a character
                   3950:   reference</dfn>. This definition is used when parsing character
1.299     mike     3951:   references <a href="#character-reference-in-data-state" title="character reference in data state">in
1.1       mike     3952:   text</a> and <a href="#character-reference-in-attribute-value-state" title="character reference in attribute value
                   3953:   state">in attributes</a>.</p>
                   3954: 
                   3955:   <p>The behavior depends on the identity of the next character (the
                   3956:   one immediately after the U+0026 AMPERSAND character):</p>
                   3957: 
                   3958:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3959:    <dt>U+000A LINE FEED (LF)</dt>
                   3960:    <dt>U+000C FORM FEED (FF)</dt>
                   3961:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3962:    <dt>U+0020 SPACE</dt>
                   3963:    <dt>U+003C LESS-THAN SIGN</dt>
                   3964:    <dt>U+0026 AMPERSAND</dt>
                   3965:    <dt>EOF</dt>
                   3966:    <dt>The <dfn id="additional-allowed-character">additional allowed character</dfn>, if there is one</dt>
                   3967: 
                   3968:    <dd>Not a character reference. No characters are consumed, and
                   3969:    nothing is returned. (This is not an error, either.)</dd>
                   3970: 
                   3971: 
                   3972:    <dt>U+0023 NUMBER SIGN (#)</dt>
                   3973: 
                   3974:    <dd>
                   3975: 
                   3976:     <p>Consume the U+0023 NUMBER SIGN.</p>
                   3977: 
                   3978:     <p>The behavior further depends on the character after the U+0023
                   3979:     NUMBER SIGN:</p>
                   3980: 
                   3981:     <dl class="switch"><dt>U+0078 LATIN SMALL LETTER X</dt>
                   3982:      <dt>U+0058 LATIN CAPITAL LETTER X</dt>
                   3983: 
                   3984:      <dd>
                   3985: 
                   3986:       <p>Consume the X.</p>
                   3987: 
                   3988:       <p>Follow the steps below, but using the range of characters
1.464     mike     3989:       U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061 LATIN
                   3990:       SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041 LATIN
                   3991:       CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F (in other
                   3992:       words, 0-9, A-F, a-f).</p>
1.1       mike     3993: 
                   3994:       <p>When it comes to interpreting the number, interpret it as a
                   3995:       hexadecimal number.</p>
                   3996: 
                   3997:      </dd>
                   3998: 
                   3999: 
                   4000:      <dt>Anything else</dt>
                   4001: 
                   4002:      <dd>
                   4003: 
                   4004:       <p>Follow the steps below, but using the range of characters
1.464     mike     4005:       U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</p>
1.1       mike     4006: 
                   4007:       <p>When it comes to interpreting the number, interpret it as a
                   4008:       decimal number.</p>
                   4009: 
                   4010:      </dd>
                   4011: 
                   4012:     </dl><p>Consume as many characters as match the range of characters
                   4013:     given above.</p>
                   4014: 
                   4015:     <p>If no characters match the range, then don't consume any
                   4016:     characters (and unconsume the U+0023 NUMBER SIGN character and, if
                   4017:     appropriate, the X character). This is a <a href="#parse-error">parse
                   4018:     error</a>; nothing is returned.</p>
                   4019: 
                   4020:     <p>Otherwise, if the next character is a U+003B SEMICOLON, consume
                   4021:     that too. If it isn't, there is a <a href="#parse-error">parse
                   4022:     error</a>.</p>
                   4023: 
                   4024:     <p>If one or more characters match the range, then take them all
                   4025:     and interpret the string of characters as a number (either
                   4026:     hexadecimal or decimal as appropriate).</p>
                   4027: 
                   4028:     <p>If that number is one of the numbers in the first column of the
                   4029:     following table, then this is a <a href="#parse-error">parse error</a>. Find the
                   4030:     row with that number in the first column, and return a character
                   4031:     token for the Unicode character given in the second column of that
                   4032:     row.</p>
                   4033: 
                   4034:     <table><thead><tr><th>Number </th><th colspan="2">Unicode character
                   4035:      </th></tr></thead><tbody><tr><td>0x00 </td><td>U+FFFD </td><td>REPLACEMENT CHARACTER
                   4036:       </td></tr><tr><td>0x0D </td><td>U+000A </td><td>LINE FEED (LF)
1.464     mike     4037:       </td></tr><tr><td>0x80 </td><td>U+20AC </td><td>EURO SIGN (&#8364;)
1.1       mike     4038:       </td></tr><tr><td>0x81 </td><td>U+0081 </td><td>&lt;control&gt;
1.464     mike     4039:       </td></tr><tr><td>0x82 </td><td>U+201A </td><td>SINGLE LOW-9 QUOTATION MARK (&#8218;)
                   4040:       </td></tr><tr><td>0x83 </td><td>U+0192 </td><td>LATIN SMALL LETTER F WITH HOOK (&#402;)
                   4041:       </td></tr><tr><td>0x84 </td><td>U+201E </td><td>DOUBLE LOW-9 QUOTATION MARK (&#8222;)
                   4042:       </td></tr><tr><td>0x85 </td><td>U+2026 </td><td>HORIZONTAL ELLIPSIS (&#8230;)
                   4043:       </td></tr><tr><td>0x86 </td><td>U+2020 </td><td>DAGGER (&#8224;)
                   4044:       </td></tr><tr><td>0x87 </td><td>U+2021 </td><td>DOUBLE DAGGER (&#8225;)
                   4045:       </td></tr><tr><td>0x88 </td><td>U+02C6 </td><td>MODIFIER LETTER CIRCUMFLEX ACCENT (&#710;)
                   4046:       </td></tr><tr><td>0x89 </td><td>U+2030 </td><td>PER MILLE SIGN (&#8240;)
                   4047:       </td></tr><tr><td>0x8A </td><td>U+0160 </td><td>LATIN CAPITAL LETTER S WITH CARON (&#352;)
                   4048:       </td></tr><tr><td>0x8B </td><td>U+2039 </td><td>SINGLE LEFT-POINTING ANGLE QUOTATION MARK (&#8249;)
                   4049:       </td></tr><tr><td>0x8C </td><td>U+0152 </td><td>LATIN CAPITAL LIGATURE OE (&#338;)
1.1       mike     4050:       </td></tr><tr><td>0x8D </td><td>U+008D </td><td>&lt;control&gt;
1.464     mike     4051:       </td></tr><tr><td>0x8E </td><td>U+017D </td><td>LATIN CAPITAL LETTER Z WITH CARON (&#381;)
1.1       mike     4052:       </td></tr><tr><td>0x8F </td><td>U+008F </td><td>&lt;control&gt;
                   4053:       </td></tr><tr><td>0x90 </td><td>U+0090 </td><td>&lt;control&gt;
1.464     mike     4054:       </td></tr><tr><td>0x91 </td><td>U+2018 </td><td>LEFT SINGLE QUOTATION MARK (&#8216;)
                   4055:       </td></tr><tr><td>0x92 </td><td>U+2019 </td><td>RIGHT SINGLE QUOTATION MARK (&#8217;)
                   4056:       </td></tr><tr><td>0x93 </td><td>U+201C </td><td>LEFT DOUBLE QUOTATION MARK (&#8220;)
                   4057:       </td></tr><tr><td>0x94 </td><td>U+201D </td><td>RIGHT DOUBLE QUOTATION MARK (&#8221;)
                   4058:       </td></tr><tr><td>0x95 </td><td>U+2022 </td><td>BULLET (&#8226;)
                   4059:       </td></tr><tr><td>0x96 </td><td>U+2013 </td><td>EN DASH (&#8211;)
                   4060:       </td></tr><tr><td>0x97 </td><td>U+2014 </td><td>EM DASH (&#8212;)
                   4061:       </td></tr><tr><td>0x98 </td><td>U+02DC </td><td>SMALL TILDE (&#732;)
                   4062:       </td></tr><tr><td>0x99 </td><td>U+2122 </td><td>TRADE MARK SIGN (&#8482;)
                   4063:       </td></tr><tr><td>0x9A </td><td>U+0161 </td><td>LATIN SMALL LETTER S WITH CARON (&#353;)
                   4064:       </td></tr><tr><td>0x9B </td><td>U+203A </td><td>SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (&#8250;)
                   4065:       </td></tr><tr><td>0x9C </td><td>U+0153 </td><td>LATIN SMALL LIGATURE OE (&#339;)
1.1       mike     4066:       </td></tr><tr><td>0x9D </td><td>U+009D </td><td>&lt;control&gt;
1.464     mike     4067:       </td></tr><tr><td>0x9E </td><td>U+017E </td><td>LATIN SMALL LETTER Z WITH CARON (&#382;)
                   4068:       </td></tr><tr><td>0x9F </td><td>U+0178 </td><td>LATIN CAPITAL LETTER Y WITH DIAERESIS (&#376;)
1.315     mike     4069:     </td></tr></tbody></table><p>Otherwise, if the number is in the range 0xD800 to 0xDFFF<!--
                   4070:     surrogates not allowed; see the comment in the "preprocessing the
                   4071:     input stream" section for details --> or is greater than 0x10FFFF,
                   4072:     then this is a <a href="#parse-error">parse error</a>. Return a U+FFFD
                   4073:     REPLACEMENT CHARACTER.</p>
1.18      mike     4074: 
                   4075:     <p>Otherwise, return a character token for the Unicode character
1.1       mike     4076:     whose code point is that number.
                   4077: 
                   4078:     <!-- this is the same as the equivalent list in the input stream
                   4079:     section -->
                   4080:     If the number is in the range 0x0001 to 0x0008, <!-- HT, LF
                   4081:     allowed --> <!-- U+000B is in the next list --> <!-- FF, CR
                   4082:     allowed --> 0x000E to 0x001F, <!-- ASCII allowed --> 0x007F <!--to
1.315     mike     4083:     0x0084, (0x0085 NEL not allowed), 0x0086--> to 0x009F, 0xFDD0 to
                   4084:     0xFDEF, or is one of 0x000B, 0xFFFE, 0xFFFF, 0x1FFFE, 0x1FFFF,
                   4085:     0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE,
                   4086:     0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF,
                   4087:     0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF, 0xCFFFE,
                   4088:     0xCFFFF, 0xDFFFE, 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF,
                   4089:     0x10FFFE, or 0x10FFFF, then this is a <a href="#parse-error">parse
                   4090:     error</a>.</p>
1.1       mike     4091: 
                   4092:    </dd>
                   4093: 
                   4094: 
                   4095:    <dt>Anything else</dt>
                   4096: 
                   4097:    <dd>
                   4098: 
                   4099:     <p>Consume the maximum number of characters possible, with the
                   4100:     consumed characters matching one of the identifiers in the first
                   4101:     column of the <a href="named-character-references.html#named-character-references">named character references</a> table (in a
                   4102:     <a href="infrastructure.html#case-sensitive">case-sensitive</a> manner).</p>
                   4103: 
                   4104:     <p>If no match can be made, then this is a <a href="#parse-error">parse
                   4105:     error</a>. No characters are consumed, and nothing is
                   4106:     returned.</p>
                   4107: 
                   4108:     <p>If the last character matched is not a U+003B SEMICOLON (<code title="">;</code>), there is a <a href="#parse-error">parse error</a>.</p>
                   4109: 
                   4110:     <p>If the character reference is being consumed <a href="#character-reference-in-attribute-value-state" title="character reference in attribute value state">as part of an
                   4111:     attribute</a>, and the last character matched is not a U+003B
1.464     mike     4112:     SEMICOLON character (<code title="">;</code>), and the next
                   4113:     character is in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
                   4114:     NINE (9), U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL
                   4115:     LETTER Z, or U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL
                   4116:     LETTER Z, then, for historical reasons, all the characters that
                   4117:     were matched after the U+0026 AMPERSAND character (&amp;) must be
                   4118:     unconsumed, and nothing is returned.</p>
1.1       mike     4119: 
                   4120:     <p>Otherwise, return a character token for the character
                   4121:     corresponding to the character reference name (as given by the
                   4122:     second column of the <a href="named-character-references.html#named-character-references">named character references</a>
                   4123:     table).</p>
                   4124: 
                   4125:     <div class="example">
                   4126: 
                   4127:      <p>If the markup contains <code title="">I'm &amp;notit; I tell
                   4128:      you</code>, the character reference is parsed as "not", as in,
                   4129:      <code title="">I'm &#172;it; I tell you</code>. But if the markup
                   4130:      was <code title="">I'm &amp;notin; I tell you</code>, the
                   4131:      character reference would be parsed as "notin;", resulting in
                   4132:      <code title="">I'm &#8713; I tell you</code>.</p>
                   4133: 
                   4134:     </div>
                   4135: 
                   4136:    </dd>
                   4137: 
1.266     mike     4138:   </dl></div><div class="impl">
                   4139: 
1.363     mike     4140:   <!-- v2: One thing that this doesn't define is handling deeply
                   4141:   nested documents. There are compatibility requirements around that:
                   4142:   you can't throw away the elements altogether, consider Tux made only
                   4143:   with opening <font> elements, one per character. Seems that the best
                   4144:   thing to do is to close some formatting elements from the middle of
                   4145:   the stack when you hit a limit, or something. -->
                   4146: 
1.266     mike     4147:   <h4 id="tree-construction"><span class="secno">9.2.5 </span><dfn>Tree construction</dfn></h4>
1.1       mike     4148: 
                   4149:   <p>The input to the tree construction stage is a sequence of tokens
                   4150:   from the <a href="#tokenization">tokenization</a> stage. The tree construction
                   4151:   stage is associated with a DOM <code>Document</code> object when a
                   4152:   parser is created. The "output" of this stage consists of
                   4153:   dynamically modifying or extending that document's DOM tree.</p>
                   4154: 
                   4155:   <p>This specification does not define when an interactive user agent
                   4156:   has to render the <code>Document</code> so that it is available to
                   4157:   the user, or when it has to begin accepting user input.</p>
                   4158: 
                   4159:   <p>As each token is emitted from the tokenizer, the user agent must
                   4160:   process the token according to the rules given in the section
                   4161:   corresponding to the current <a href="#insertion-mode">insertion mode</a>.</p>
                   4162: 
                   4163:   <p>When the steps below require the UA to <dfn id="insert-a-character">insert a
                   4164:   character</dfn> into a node, if that node has a child immediately
                   4165:   before where the character is to be inserted, and that child is a
                   4166:   <code>Text</code> node, and that <code>Text</code> node was the last
                   4167:   node that the parser inserted into the document, then the character
                   4168:   must be appended to that <code>Text</code> node; otherwise, a new
                   4169:   <code>Text</code> node whose data is just that character must be
                   4170:   inserted in the appropriate place.</p>
                   4171: 
                   4172:   <div class="example">
                   4173: 
                   4174:    <p>Here are some sample inputs to the parser and the corresponding
                   4175:    number of text nodes that they result in, assuming a user agent
                   4176:    that executes scripts.</p>
                   4177: 
                   4178:    <table><thead><tr><th>Input </th><th>Number of text nodes
                   4179:     </th></tr></thead><tbody><tr><td><pre>A&lt;script&gt;
                   4180: var&#160;script&#160;=&#160;document.getElementsByTagName('script')[0];
                   4181: document.body.removeChild(script);
                   4182: &lt;/script&gt;B</pre>
                   4183:       </td><td>Two adjacent text nodes in the document, containing "A" and "B".
                   4184:      </td></tr><tr><td><pre>A&lt;script&gt;
                   4185: var&#160;text&#160;=&#160;document.createTextNode('B');
                   4186: document.body.appendChild(text);
                   4187: &lt;/script&gt;C</pre>
                   4188:       </td><td>Four text nodes; "A" before the script, the script's contents, "B" after the script, and then, immediately after that, "C".
                   4189:      </td></tr><tr><td><pre>A&lt;script&gt;
                   4190: var&#160;text&#160;=&#160;document.getElementsByTagName('script')[0].firstChild;
                   4191: text.data&#160;=&#160;'B';
                   4192: document.body.appendChild(text);
                   4193: &lt;/script&gt;B</pre>
                   4194:       </td><td>Two adjacent text nodes in the document, containing "A" and "BB".
                   4195:      </td></tr><tr><td><pre>A&lt;table&gt;B&lt;tr&gt;C&lt;/tr&gt;C&lt;/table&gt;</pre>
                   4196:       </td><td>Three adjacent text nodes before the table, containing "A", "B", and "CC" respectively. (This is caused by <a href="#foster-parent" title="foster parent">foster parenting</a>.)
                   4197:      </td></tr><tr><td><pre>A&lt;table&gt;&lt;tr&gt;&#160;B&lt;/tr&gt;&#160;B&lt;/table&gt;</pre>
                   4198:       </td><td>Two adjacent text nodes before the table, containing "A" and "&#160;B&#160;B" (space-B-space-B) respectively. (This is caused by <a href="#foster-parent" title="foster parent">foster parenting</a>.)
                   4199:      </td></tr><tr><td><pre>A&lt;table&gt;&lt;tr&gt;&#160;B&lt;/tr&gt;&#160;&lt;/em&gt;C&lt;/table&gt;</pre>
                   4200:       </td><td>Three adjacent text nodes before the table, containing "A", "&#160;B" (space-B), and "C" respectively, and one text node inside the table (as a child of a <code><a href="tabular-data.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" title="foster parent">foster parenting</a>, even if those other tokens then get ignored.)
                   4201:    </td></tr></tbody></table></div>
                   4202: 
                   4203:   <p id="mutation-during-parsing">DOM mutation events must not fire
                   4204:   for changes caused by the UA parsing the document. (Conceptually,
                   4205:   the parser is not mutating the DOM, it is constructing it.) This
1.159     mike     4206:   includes the parsing of any content inserted using <code title="dom-document-write"><a href="embedded-content-0.html#dom-document-write">document.write()</a></code> and <code title="dom-document-writeln"><a href="embedded-content-0.html#dom-document-writeln">document.writeln()</a></code> calls. <a href="references.html#refsDOMEVENTS">[DOMEVENTS]</a></p>
1.1       mike     4207: 
                   4208:   <p class="note">Not all of the tag names mentioned below are
                   4209:   conformant tag names in this specification; many are included to
                   4210:   handle legacy content. They still form part of the algorithm that
                   4211:   implementations are required to implement to claim conformance.</p>
                   4212: 
                   4213:   <p class="note">The algorithm described below places no limit on the
                   4214:   depth of the DOM tree generated, or on the length of tag names,
                   4215:   attribute names, attribute values, text nodes, etc. While
                   4216:   implementors are encouraged to avoid arbitrary limits, it is
                   4217:   recognized that <a href="infrastructure.html#hardwareLimitations">practical
1.445     mike     4218:   concerns</a> will likely force user agents to impose nesting depth
                   4219:   constraints.</p>
1.1       mike     4220: 
                   4221: 
                   4222:   <h5 id="creating-and-inserting-elements"><span class="secno">9.2.5.1 </span>Creating and inserting elements</h5>
                   4223: 
                   4224:   <p>When the steps below require the UA to <dfn id="create-an-element-for-the-token" title="create an
                   4225:   element for the token">create an element for a token</dfn> in a
                   4226:   particular namespace, the UA must create a node implementing the
                   4227:   interface appropriate for the element type corresponding to the tag
                   4228:   name of the token in the given namespace (as given in the
                   4229:   specification that defines that element, e.g. for an <code><a href="text-level-semantics.html#the-a-element">a</a></code>
                   4230:   element in the <a href="#html-namespace-0">HTML namespace</a>, this specification
                   4231:   defines it to be the <code><a href="text-level-semantics.html#htmlanchorelement">HTMLAnchorElement</a></code> interface), with
                   4232:   the tag name being the name of that element, with the node being in
                   4233:   the given namespace, and with the attributes on the node being those
                   4234:   given in the given token.</p>
                   4235: 
                   4236:   <p>The interface appropriate for an element in the <a href="#html-namespace-0">HTML
1.426     mike     4237:   namespace</a> that is not defined in this specification (or
                   4238:   <a href="infrastructure.html#other-applicable-specifications">other applicable specifications</a>) is
1.44      mike     4239:   <code><a href="dom.html#htmlunknownelement">HTMLUnknownElement</a></code>. Element in other namespaces whose
1.1       mike     4240:   interface is not defined by that namespace's specification must use
                   4241:   the interface <code>Element</code>.</p>
                   4242: 
                   4243:   <p>When a <a href="forms.html#category-reset" title="category-reset">resettable</a> element is
                   4244:   created in this manner, its <a href="forms.html#concept-form-reset-control" title="concept-form-reset-control">reset algorithm</a> must be
                   4245:   invoked once the attributes are set. (This initializes the element's
                   4246:   <a href="forms.html#concept-fe-value" title="concept-fe-value">value</a> and <a href="forms.html#concept-fe-checked" title="concept-fe-checked">checkedness</a> based on the element's
                   4247:   attributes.)</p>
                   4248: 
                   4249:   <hr><p>When the steps below require the UA to <dfn id="insert-an-html-element">insert an HTML
                   4250:   element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
                   4251:   for the token</a> in the <a href="#html-namespace-0">HTML namespace</a>, and then
                   4252:   append this node to the <a href="#current-node">current node</a>, and push it onto
                   4253:   the <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
                   4254:   <a href="#current-node">current node</a>.</p>
                   4255: 
                   4256:   <p>The steps below may also require that the UA insert an HTML
                   4257:   element in a particular place, in which case the UA must follow the
                   4258:   same steps except that it must insert or append the new node in the
                   4259:   location specified instead of appending it to the <a href="#current-node">current
                   4260:   node</a>. (This happens in particular during the parsing of
                   4261:   tables with invalid content.)</p>
                   4262: 
                   4263:   <p>If an element created by the <a href="#insert-an-html-element">insert an HTML element</a>
                   4264:   algorithm is a <a href="forms.html#form-associated-element">form-associated element</a>, and the
                   4265:   <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is not null,
                   4266:   and the newly created element doesn't have a <code title="attr-fae-form"><a href="forms.html#attr-fae-form">form</a></code> attribute, the user agent must
                   4267:   <a href="forms.html#concept-form-association" title="concept-form-association">associate</a> the newly
                   4268:   created element with the <code><a href="forms.html#the-form-element">form</a></code> element pointed to by the
                   4269:   <a href="#form-element-pointer"><code title="">form</code> element pointer</a> before
                   4270:   inserting it wherever it is to be inserted.</p>
                   4271: 
                   4272:   <hr><p>When the steps below require the UA to <dfn id="insert-a-foreign-element">insert a foreign
                   4273:   element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
                   4274:   for the token</a> in the given namespace, and then append this
                   4275:   node to the <a href="#current-node">current node</a>, and push it onto the
                   4276:   <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
                   4277:   <a href="#current-node">current node</a>. If the newly created element has an <code title="">xmlns</code> attribute in the <a href="#xmlns-namespace">XMLNS namespace</a>
                   4278:   whose value is not exactly the same as the element's namespace, that
                   4279:   is a <a href="#parse-error">parse error</a>. Similarly, if the newly created
                   4280:   element has an <code title="">xmlns:xlink</code> attribute in the
                   4281:   <a href="#xmlns-namespace">XMLNS namespace</a> whose value is not the <a href="#xlink-namespace">XLink
                   4282:   Namespace</a>, that is a <a href="#parse-error">parse error</a>.</p>
                   4283: 
                   4284:   <p>When the steps below require the user agent to <dfn id="adjust-mathml-attributes">adjust MathML
                   4285:   attributes</dfn> for a token, then, if the token has an attribute
                   4286:   named <code title="">definitionurl</code>, change its name to <code title="">definitionURL</code> (note the case difference).</p>
                   4287: 
                   4288:   <p>When the steps below require the user agent to <dfn id="adjust-svg-attributes">adjust SVG
                   4289:   attributes</dfn> for a token, then, for each attribute on the token
                   4290:   whose attribute name is one of the ones in the first column of the
                   4291:   following table, change the attribute's name to the name given in
                   4292:   the corresponding cell in the second column. (This fixes the case of
                   4293:   SVG attributes that are not all lowercase.)</p>
                   4294: 
                   4295:   <table><thead><tr><th> Attribute name on token </th><th> Attribute name on element
                   4296:    </th></tr></thead><tbody><tr><td> <code title="">attributename</code> </td><td> <code title="">attributeName</code>
                   4297:     </td></tr><tr><td> <code title="">attributetype</code> </td><td> <code title="">attributeType</code>
                   4298:     </td></tr><tr><td> <code title="">basefrequency</code> </td><td> <code title="">baseFrequency</code>
                   4299:     </td></tr><tr><td> <code title="">baseprofile</code> </td><td> <code title="">baseProfile</code>
                   4300:     </td></tr><tr><td> <code title="">calcmode</code> </td><td> <code title="">calcMode</code>
                   4301:     </td></tr><tr><td> <code title="">clippathunits</code> </td><td> <code title="">clipPathUnits</code>
                   4302:     </td></tr><tr><td> <code title="">contentscripttype</code> </td><td> <code title="">contentScriptType</code>
                   4303:     </td></tr><tr><td> <code title="">contentstyletype</code> </td><td> <code title="">contentStyleType</code>
                   4304:     </td></tr><tr><td> <code title="">diffuseconstant</code> </td><td> <code title="">diffuseConstant</code>
                   4305:     </td></tr><tr><td> <code title="">edgemode</code> </td><td> <code title="">edgeMode</code>
                   4306:     </td></tr><tr><td> <code title="">externalresourcesrequired</code> </td><td> <code title="">externalResourcesRequired</code>
                   4307:     </td></tr><tr><td> <code title="">filterres</code> </td><td> <code title="">filterRes</code>
                   4308:     </td></tr><tr><td> <code title="">filterunits</code> </td><td> <code title="">filterUnits</code>
                   4309:     </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
                   4310:     </td></tr><tr><td> <code title="">gradienttransform</code> </td><td> <code title="">gradientTransform</code>
                   4311:     </td></tr><tr><td> <code title="">gradientunits</code> </td><td> <code title="">gradientUnits</code>
                   4312:     </td></tr><tr><td> <code title="">kernelmatrix</code> </td><td> <code title="">kernelMatrix</code>
                   4313:     </td></tr><tr><td> <code title="">kernelunitlength</code> </td><td> <code title="">kernelUnitLength</code>
                   4314:     </td></tr><tr><td> <code title="">keypoints</code> </td><td> <code title="">keyPoints</code>
                   4315:     </td></tr><tr><td> <code title="">keysplines</code> </td><td> <code title="">keySplines</code>
                   4316:     </td></tr><tr><td> <code title="">keytimes</code> </td><td> <code title="">keyTimes</code>
                   4317:     </td></tr><tr><td> <code title="">lengthadjust</code> </td><td> <code title="">lengthAdjust</code>
                   4318:     </td></tr><tr><td> <code title="">limitingconeangle</code> </td><td> <code title="">limitingConeAngle</code>
                   4319:     </td></tr><tr><td> <code title="">markerheight</code> </td><td> <code title="">markerHeight</code>
                   4320:     </td></tr><tr><td> <code title="">markerunits</code> </td><td> <code title="">markerUnits</code>
                   4321:     </td></tr><tr><td> <code title="">markerwidth</code> </td><td> <code title="">markerWidth</code>
                   4322:     </td></tr><tr><td> <code title="">maskcontentunits</code> </td><td> <code title="">maskContentUnits</code>
                   4323:     </td></tr><tr><td> <code title="">maskunits</code> </td><td> <code title="">maskUnits</code>
                   4324:     </td></tr><tr><td> <code title="">numoctaves</code> </td><td> <code title="">numOctaves</code>
                   4325:     </td></tr><tr><td> <code title="">pathlength</code> </td><td> <code title="">pathLength</code>
                   4326:     </td></tr><tr><td> <code title="">patterncontentunits</code> </td><td> <code title="">patternContentUnits</code>
                   4327:     </td></tr><tr><td> <code title="">patterntransform</code> </td><td> <code title="">patternTransform</code>
                   4328:     </td></tr><tr><td> <code title="">patternunits</code> </td><td> <code title="">patternUnits</code>
                   4329:     </td></tr><tr><td> <code title="">pointsatx</code> </td><td> <code title="">pointsAtX</code>
                   4330:     </td></tr><tr><td> <code title="">pointsaty</code> </td><td> <code title="">pointsAtY</code>
                   4331:     </td></tr><tr><td> <code title="">pointsatz</code> </td><td> <code title="">pointsAtZ</code>
                   4332:     </td></tr><tr><td> <code title="">preservealpha</code> </td><td> <code title="">preserveAlpha</code>
                   4333:     </td></tr><tr><td> <code title="">preserveaspectratio</code> </td><td> <code title="">preserveAspectRatio</code>
                   4334:     </td></tr><tr><td> <code title="">primitiveunits</code> </td><td> <code title="">primitiveUnits</code>
                   4335:     </td></tr><tr><td> <code title="">refx</code> </td><td> <code title="">refX</code>
                   4336:     </td></tr><tr><td> <code title="">refy</code> </td><td> <code title="">refY</code>
                   4337:     </td></tr><tr><td> <code title="">repeatcount</code> </td><td> <code title="">repeatCount</code>
                   4338:     </td></tr><tr><td> <code title="">repeatdur</code> </td><td> <code title="">repeatDur</code>
                   4339:     </td></tr><tr><td> <code title="">requiredextensions</code> </td><td> <code title="">requiredExtensions</code>
                   4340:     </td></tr><tr><td> <code title="">requiredfeatures</code> </td><td> <code title="">requiredFeatures</code>
                   4341:     </td></tr><tr><td> <code title="">specularconstant</code> </td><td> <code title="">specularConstant</code>
                   4342:     </td></tr><tr><td> <code title="">specularexponent</code> </td><td> <code title="">specularExponent</code>
                   4343:     </td></tr><tr><td> <code title="">spreadmethod</code> </td><td> <code title="">spreadMethod</code>
                   4344:     </td></tr><tr><td> <code title="">startoffset</code> </td><td> <code title="">startOffset</code>
                   4345:     </td></tr><tr><td> <code title="">stddeviation</code> </td><td> <code title="">stdDeviation</code>
                   4346:     </td></tr><tr><td> <code title="">stitchtiles</code> </td><td> <code title="">stitchTiles</code>
                   4347:     </td></tr><tr><td> <code title="">surfacescale</code> </td><td> <code title="">surfaceScale</code>
                   4348:     </td></tr><tr><td> <code title="">systemlanguage</code> </td><td> <code title="">systemLanguage</code>
                   4349:     </td></tr><tr><td> <code title="">tablevalues</code> </td><td> <code title="">tableValues</code>
                   4350:     </td></tr><tr><td> <code title="">targetx</code> </td><td> <code title="">targetX</code>
                   4351:     </td></tr><tr><td> <code title="">targety</code> </td><td> <code title="">targetY</code>
                   4352:     </td></tr><tr><td> <code title="">textlength</code> </td><td> <code title="">textLength</code>
                   4353:     </td></tr><tr><td> <code title="">viewbox</code> </td><td> <code title="">viewBox</code>
                   4354:     </td></tr><tr><td> <code title="">viewtarget</code> </td><td> <code title="">viewTarget</code>
                   4355:     </td></tr><tr><td> <code title="">xchannelselector</code> </td><td> <code title="">xChannelSelector</code>
                   4356:     </td></tr><tr><td> <code title="">ychannelselector</code> </td><td> <code title="">yChannelSelector</code>
                   4357:     </td></tr><tr><td> <code title="">zoomandpan</code> </td><td> <code title="">zoomAndPan</code>
                   4358:   </td></tr></tbody></table><p>When the steps below require the user agent to <dfn id="adjust-foreign-attributes">adjust
                   4359:   foreign attributes</dfn> for a token, then, if any of the attributes
                   4360:   on the token match the strings given in the first column of the
                   4361:   following table, let the attribute be a namespaced attribute, with
                   4362:   the prefix being the string given in the corresponding cell in the
                   4363:   second column, the local name being the string given in the
                   4364:   corresponding cell in the third column, and the namespace being the
                   4365:   namespace given in the corresponding cell in the fourth
                   4366:   column. (This fixes the use of namespaced attributes, in particular
                   4367:   <a href="dom.html#attr-xml-lang" title="attr-xml-lang"><code title="">lang</code> attributes in
                   4368:   the <span>XML namespace</span></a>.)</p>
                   4369: 
                   4370:   <table><thead><tr><th> Attribute name </th><th> Prefix </th><th> Local name </th><th> Namespace
                   4371:    </th></tr></thead><tbody><tr><td> <code title="">xlink:actuate</code> </td><td> <code title="">xlink</code> </td><td> <code title="">actuate</code> </td><td> <a href="#xlink-namespace">XLink namespace</a>
                   4372:     </td></tr><tr><td> <code title="">xlink:arcrole</code> </td><td> <code title="">xlink</code> </td><td> <code title="">arcrole</code> </td><td> <a href="#xlink-namespace">XLink namespace</a>
                   4373:     </td></tr><tr><td> <code title="">xlink:href</code> </td><td> <code title="">xlink</code> </td><td> <code title="">href</code> </td><td> <a href="#xlink-namespace">XLink namespace</a>
                   4374:     </td></tr><tr><td> <code title="">xlink:role</code> </td><td> <code title="">xlink</code> </td><td> <code title="">role</code> </td><td> <a href="#xlink-namespace">XLink namespace</a>
                   4375:     </td></tr><tr><td> <code title="">xlink:show</code> </td><td> <code title="">xlink</code> </td><td> <code title="">show</code> </td><td> <a href="#xlink-namespace">XLink namespace</a>
                   4376:     </td></tr><tr><td> <code title="">xlink:title</code> </td><td> <code title="">xlink</code> </td><td> <code title="">title</code> </td><td> <a href="#xlink-namespace">XLink namespace</a>
                   4377:     </td></tr><tr><td> <code title="">xlink:type</code> </td><td> <code title="">xlink</code> </td><td> <code title="">type</code> </td><td> <a href="#xlink-namespace">XLink namespace</a>
                   4378:     </td></tr><tr><td> <code title="">xml:base</code> </td><td> <code title="">xml</code> </td><td> <code title="">base</code> </td><td> <a href="#xml-namespace">XML namespace</a> <!-- attr-xml-base -->
                   4379:     </td></tr><tr><td> <code title="">xml:lang</code> </td><td> <code title="">xml</code> </td><td> <code title="">lang</code> </td><td> <a href="#xml-namespace">XML namespace</a>
                   4380:     </td></tr><tr><td> <code title="">xml:space</code> </td><td> <code title="">xml</code> </td><td> <code title="">space</code> </td><td> <a href="#xml-namespace">XML namespace</a>
                   4381:     </td></tr><tr><td> <code title="">xmlns</code> </td><td> (none) </td><td> <code title="">xmlns</code> </td><td> <a href="#xmlns-namespace">XMLNS namespace</a>
                   4382:     </td></tr><tr><td> <code title="">xmlns:xlink</code> </td><td> <code title="">xmlns</code> </td><td> <code title="">xlink</code> </td><td> <a href="#xmlns-namespace">XMLNS namespace</a>
1.91      mike     4383:   </td></tr></tbody></table><hr><p>The <dfn id="generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</dfn> and the
1.1       mike     4384:   <dfn id="generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</dfn> consist of the
                   4385:   following steps. These algorithms are always invoked in response to
                   4386:   a start tag token.</p>
                   4387: 
                   4388:   <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p></li>
                   4389: 
1.91      mike     4390:    <li><p>If the algorithm that was invoked is the <a href="#generic-raw-text-element-parsing-algorithm">generic raw
1.541     mike     4391:    text element parsing algorithm</a>, switch the tokenizer to the
                   4392:    <a href="#rawtext-state">RAWTEXT state</a>; otherwise the algorithm invoked
                   4393:    was the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>,
                   4394:    switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</p></li>
1.1       mike     4395: 
                   4396:    <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
                   4397:    <a href="#insertion-mode">insertion mode</a>.</p>
                   4398: 
1.540     mike     4399:    </li><li><p>Then, switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incdata" title="insertion mode: text">text</a>".</p></li>
1.1       mike     4400: 
                   4401:   </ol><h5 id="closing-elements-that-have-implied-end-tags"><span class="secno">9.2.5.2 </span>Closing elements that have implied end tags</h5>
                   4402: 
                   4403:   <p>When the steps below require the UA to <dfn id="generate-implied-end-tags">generate implied end
                   4404:   tags</dfn>, then, while the <a href="#current-node">current node</a> is a
1.422     mike     4405:   <code><a href="semantics.html#the-dd-element">dd</a></code> element, a <code><a href="semantics.html#the-dt-element">dt</a></code> element, an
1.1       mike     4406:   <code><a href="semantics.html#the-li-element">li</a></code> element, an <code><a href="forms.html#the-option-element">option</a></code> element, an
                   4407:   <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, a <code><a href="semantics.html#the-p-element">p</a></code> element, an
                   4408:   <code><a href="text-level-semantics.html#the-rp-element">rp</a></code> element, or an <code><a href="text-level-semantics.html#the-rt-element">rt</a></code> element, the UA must
                   4409:   pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   4410:   elements</a>.</p>
                   4411: 
                   4412:   <p>If a step requires the UA to generate implied end tags but lists
                   4413:   an element to exclude from the process, then the UA must perform the
                   4414:   above steps as if that element was not in the above list.</p>
                   4415: 
                   4416: 
                   4417:   <h5 id="foster-parenting"><span class="secno">9.2.5.3 </span>Foster parenting</h5>
                   4418: 
                   4419:   <p>Foster parenting happens when content is misnested in tables.</p>
                   4420: 
                   4421:   <p>When a node <var title="">node</var> is to be <dfn id="foster-parent" title="foster
                   4422:   parent">foster parented</dfn>, the node <var title="">node</var>
                   4423:   must be inserted into the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
                   4424: 
                   4425:   <p>The <dfn id="foster-parent-element">foster parent element</dfn> is the parent element of the
                   4426:   last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the <a href="#stack-of-open-elements">stack of open
                   4427:   elements</a>, if there is a <code><a href="tabular-data.html#the-table-element">table</a></code> element and it has
                   4428:   such a parent element. If there is no <code><a href="tabular-data.html#the-table-element">table</a></code> element in
                   4429:   the <a href="#stack-of-open-elements">stack of open elements</a> (<a href="#fragment-case">fragment
                   4430:   case</a>), then the <i><a href="#foster-parent-element">foster parent element</a></i> is the first
                   4431:   element in the <a href="#stack-of-open-elements">stack of open elements</a> (the
1.159     mike     4432:   <code><a href="semantics.html#the-html-element-0">html</a></code> element). Otherwise, if there is a
1.1       mike     4433:   <code><a href="tabular-data.html#the-table-element">table</a></code> element in the <a href="#stack-of-open-elements">stack of open
                   4434:   elements</a>, but the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
                   4435:   <a href="#stack-of-open-elements">stack of open elements</a> has no parent, or its parent
                   4436:   node is not an element, then the <i><a href="#foster-parent-element">foster parent element</a></i> is
                   4437:   the element before the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
                   4438:   <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   4439: 
                   4440:   <p>If the <i><a href="#foster-parent-element">foster parent element</a></i> is the parent element of the
                   4441:   last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the <a href="#stack-of-open-elements">stack of open
                   4442:   elements</a>, then <var title="">node</var> must be inserted
                   4443:   immediately <em>before</em> the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in
                   4444:   the <a href="#stack-of-open-elements">stack of open elements</a> in the <i><a href="#foster-parent-element">foster parent
                   4445:   element</a></i>; otherwise, <var title="">node</var> must be
                   4446:   <em>appended</em> to the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
                   4447: 
                   4448: 
                   4449: 
                   4450:   <h5 id="the-initial-insertion-mode"><span class="secno">9.2.5.4 </span>The "<dfn title="insertion mode: initial">initial</dfn>" insertion mode</h5>
                   4451: 
                   4452:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-initial-insertion-mode" title="insertion
                   4453:   mode: initial">initial</a>", tokens must be handled as follows:</p>
                   4454: 
                   4455:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   4456:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   4457:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   4458:    <dd>
                   4459:     <p>Ignore the token.</p>
                   4460:    </dd>
                   4461: 
                   4462:    <dt>A comment token</dt>
                   4463:    <dd>
                   4464:     <p>Append a <code>Comment</code> node to the <code>Document</code>
                   4465:     object with the <code title="">data</code> attribute set to the
                   4466:     data given in the comment token.</p>
                   4467:    </dd>
                   4468: 
                   4469:    <dt>A DOCTYPE token</dt>
                   4470:    <dd>
                   4471: 
                   4472:     <p>If the DOCTYPE token's name is not a
                   4473:     <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string "<code title="">html</code>", or the token's public identifier is not
                   4474:     missing, or the token's system identifier is neither missing nor a
                   4475:     <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string
1.465     mike     4476:     "<code><a href="infrastructure.html#about:legacy-compat">about:legacy-compat</a></code>", and none of the sets of
1.1       mike     4477:     conditions in the following list are matched, then there is a
                   4478:     <a href="#parse-error">parse error</a>. If one of the sets of conditions in the
                   4479:     following list is matched, then there is an <dfn id="obsolete-permitted-doctype">obsolete
                   4480:     permitted DOCTYPE</dfn>.</p>
                   4481: 
                   4482:     <ul><!-- only things that trigger no-quirks mode and were valid in
                   4483:      some other spec are allowed in this list --><li>The DOCTYPE token's name is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.98      mike     4484:      case-insensitive</a> match for the string "<code title="">html</code>", the token's public identifier is the
1.1       mike     4485:      <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">-//W3C//DTD&#160;HTML&#160;4.0//EN</code>", and the
                   4486:      token's system identifier is either missing or the
                   4487:      <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/REC-html40/strict.dtd</code>".</li>
                   4488: 
                   4489:      <li>The DOCTYPE token's name is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.98      mike     4490:      case-insensitive</a> match for the string "<code title="">html</code>", the token's public identifier is the
1.1       mike     4491:      <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">-//W3C//DTD&#160;HTML&#160;4.01//EN</code>", and the
                   4492:      token's system identifier is either missing or the
                   4493:      <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/html4/strict.dtd</code>".</li>
                   4494: 
                   4495:      <li>The DOCTYPE token's name is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.98      mike     4496:      case-insensitive</a> match for the string "<code title="">html</code>", the token's public identifier is the
1.1       mike     4497:      <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">-//W3C//DTD&#160;XHTML&#160;1.0&#160;Strict//EN</code>",
                   4498:      and the token's system identifier is the
                   4499:      <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</code>".</li>
                   4500: 
                   4501:      <li>The DOCTYPE token's name is an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.98      mike     4502:      case-insensitive</a> match for the string "<code title="">html</code>", the token's public identifier is the
1.1       mike     4503:      <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">-//W3C//DTD&#160;XHTML&#160;1.1//EN</code>", and the
                   4504:      token's system identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a>
                   4505:      string "<code title="">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</code>".</li>
                   4506: 
                   4507:     </ul><p>Conformance checkers may, based on the values (including
                   4508:     presence or lack thereof) of the DOCTYPE token's name, public
                   4509:     identifier, or system identifier, switch to a conformance checking
                   4510:     mode for another language (e.g. based on the DOCTYPE token a
                   4511:     conformance checker could recognize that the document is an
1.183     mike     4512:     HTML4-era document, and defer to an HTML4 conformance
1.1       mike     4513:     checker.)</p>
                   4514: 
                   4515:     <p>Append a <code>DocumentType</code> node to the
                   4516:     <code>Document</code> node, with the <code title="">name</code>
                   4517:     attribute set to the name given in the DOCTYPE token, or the empty
                   4518:     string if the name was missing; the <code title="">publicId</code>
                   4519:     attribute set to the public identifier given in the DOCTYPE token,
                   4520:     or the empty string if the public identifier was missing; the
                   4521:     <code title="">systemId</code> attribute set to the system
                   4522:     identifier given in the DOCTYPE token, or the empty string if the
                   4523:     system identifier was missing; and the other attributes specific
                   4524:     to <code>DocumentType</code> objects set to null and empty lists
                   4525:     as appropriate. Associate the <code>DocumentType</code> node with
                   4526:     the <code>Document</code> object so that it is returned as the
                   4527:     value of the <code title="">doctype</code> attribute of the
                   4528:     <code>Document</code> object.</p>
                   4529: 
                   4530:     <p id="quirks-mode-doctypes">Then, if the DOCTYPE token matches
                   4531:     one of the conditions in the following list, then set the
                   4532:     <code>Document</code> to <a href="dom.html#quirks-mode">quirks mode</a>:</p>
                   4533: 
                   4534:     <ul class="brief"><li> The <i>force-quirks flag</i> is set to <i>on</i>. </li>
                   4535:      <li> The name is set to anything other than "<code title="">HTML</code>". </li>
                   4536:      <li> The public identifier starts with: "<code title="">+//Silmaril//dtd html Pro v0r11 19970101//<!--EN--></code>" </li>
                   4537:      <li> The public identifier starts with: "<code title="">-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
                   4538:      <li> The public identifier starts with: "<code title="">-//AS//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
                   4539:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 1//<!--EN--></code>" </li>
                   4540:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 2//<!--EN--></code>" </li>
                   4541:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 1//<!--EN--></code>" </li>
                   4542:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 2//<!--EN--></code>" </li>
                   4543:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict//<!--EN--></code>" </li>
                   4544:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0//<!--EN--></code>" </li>
                   4545:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.1E//<!--EN--></code>" </li>
                   4546:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.0//<!--EN--></code>" </li>
                   4547:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML 3.0//EN//</code>" </li>-->
                   4548:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2 Final//<!--EN--></code>" </li>
                   4549:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2//<!--EN--></code>" </li>
                   4550:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3//<!--EN--></code>" </li>
                   4551:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 0//<!--EN--></code>" </li>
                   4552:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 0//EN//2.0</code>" </li>-->
                   4553:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 1//<!--EN--></code>" </li>
                   4554:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 1//EN//2.0</code>" </li>-->
                   4555:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 2//<!--EN--></code>" </li>
                   4556:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 2//EN//2.0</code>" </li>-->
                   4557:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 3//<!--EN--></code>" </li>
                   4558:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 3//EN//3.0</code>" </li>-->
                   4559:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 0//<!--EN--></code>" </li>
                   4560:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 0//EN//2.0</code>" </li>-->
                   4561:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 1//<!--EN--></code>" </li>
                   4562:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 1//EN//2.0</code>" </li>-->
                   4563:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 2//<!--EN--></code>" </li>
                   4564:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 2//EN//2.0</code>" </li>-->
                   4565:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 3//<!--EN--></code>" </li>
                   4566:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 3//EN//3.0</code>" </li>-->
                   4567:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict//<!--EN--></code>" </li>
                   4568:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//2.0</code>" </li>-->
                   4569:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//3.0</code>" </li>-->
                   4570:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML//<!--EN--></code>" </li>
                   4571:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//2.0</code>" </li>-->
                   4572:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//3.0</code>" </li>-->
                   4573:      <li> The public identifier starts with: "<code title="">-//Metrius//DTD Metrius Presentational//<!--EN--></code>" </li>
                   4574:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//<!--EN--></code>" </li>
                   4575:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML//<!--EN--></code>" </li>
                   4576:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 Tables//<!--EN--></code>" </li>
                   4577:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//<!--EN--></code>" </li>
                   4578:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML//<!--EN--></code>" </li>
                   4579:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 Tables//<!--EN--></code>" </li>
                   4580:      <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD HTML//<!--EN--></code>" </li>
                   4581:      <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD Strict HTML//<!--EN--></code>" </li>
                   4582:      <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML 2.0//<!--EN--></code>" </li>
                   4583:      <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended 1.0//<!--EN--></code>" </li>
                   4584:      <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//<!--EN--></code>" </li>
                   4585:      <li> The public identifier starts with: "<code title="">-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//<!--EN--></code>" </li>
                   4586:      <li> The public identifier starts with: "<code title="">-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//<!--EN--></code>" </li>
                   4587:      <li> The public identifier starts with: "<code title="">-//Spyglass//DTD HTML 2.0 Extended//<!--EN--></code>" </li>
                   4588:      <li> The public identifier starts with: "<code title="">-//SQ//DTD HTML 2.0 HoTMetaL + extensions//<!--EN--></code>" </li>
                   4589:      <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava HTML//<!--EN--></code>" </li>
                   4590:      <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava Strict HTML//<!--EN--></code>" </li>
                   4591:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3 1995-03-24//<!--EN--></code>" </li>
                   4592:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Draft//<!--EN--></code>" </li>
                   4593:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Final//<!--EN--></code>" </li>
                   4594:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2//<!--EN--></code>" </li>
                   4595:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2S Draft//<!--EN--></code>" </li>
                   4596:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Frameset//<!--EN--></code>" </li>
                   4597:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Transitional//<!--EN--></code>" </li>
                   4598:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 19960712//<!--EN--></code>" </li>
                   4599:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 970421//<!--EN--></code>" </li>
                   4600:      <li> The public identifier starts with: "<code title="">-//W3C//DTD W3 HTML//<!--EN--></code>" </li>
                   4601:      <li> The public identifier starts with: "<code title="">-//W3O//DTD W3 HTML 3.0//<!--EN--></code>" </li>
                   4602:    <!--<li> The public identifier is set to: "<code title="">-//W3O//DTD W3 HTML 3.0//EN//</code>" </li>-->
                   4603:      <li> The public identifier is set to: "<code title="">-//W3O//DTD W3 HTML Strict 3.0//EN//</code>" </li>
                   4604:      <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML 2.0//<!--EN--></code>" </li>
                   4605:      <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML//<!--EN--></code>" </li>
                   4606:      <li> The public identifier is set to: "<code title="">-/W3C/DTD HTML 4.0 Transitional/EN</code>" </li>
                   4607:      <li> The public identifier is set to: "<code title="">HTML</code>" </li>
                   4608:      <li> The system identifier is set to: "<code title="">http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd</code>" </li>
                   4609:      <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
                   4610:      <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Transitional//<!--EN--></code>" </li>
                   4611:     </ul><p>Otherwise, if the DOCTYPE token matches one of the conditions
                   4612:     in the following list, then set the <code>Document</code> to
                   4613:     <a href="dom.html#limited-quirks-mode">limited quirks mode</a>:</p>
                   4614: 
                   4615:     <ul class="brief"><li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Frameset//<!--EN--></code>" </li>
                   4616:      <li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Transitional//<!--EN--></code>" </li>
                   4617:      <li> The system identifier is not missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
                   4618:      <li> The system identifier is not missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Transitional//<!--EN--></code>" </li>
                   4619:     </ul><p>The name, system identifier, and public identifier strings must
                   4620:     be compared to the values given in the lists above in an
                   4621:     <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> manner. A system identifier
                   4622:     whose value is the empty string is not considered missing for the
                   4623:     purposes of the conditions above.</p>
                   4624: 
                   4625:     <p>Then, switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before html</a>".</p>
                   4626: 
                   4627:    </dd>
                   4628: 
                   4629:    <dt>Anything else</dt>
                   4630:    <dd>
                   4631: 
                   4632:     <p><a href="#parse-error">Parse error</a>.</p>
                   4633: 
                   4634:     <p>Set the <code>Document</code> to <a href="dom.html#quirks-mode">quirks mode</a>.</p>
                   4635: 
                   4636:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before html</a>", then
                   4637:     reprocess the current token.</p>
                   4638: 
                   4639:    </dd>
                   4640: 
                   4641:   </dl><h5 id="the-before-html-insertion-mode"><span class="secno">9.2.5.5 </span>The "<dfn title="insertion mode: before html">before html</dfn>" insertion mode</h5>
                   4642: 
                   4643:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-html-insertion-mode" title="insertion
                   4644:   mode: before html">before html</a>", tokens must be handled as follows:</p>
                   4645: 
                   4646:   <dl class="switch"><dt>A DOCTYPE token</dt>
                   4647:    <dd>
                   4648:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4649:    </dd>
                   4650: 
                   4651:    <dt>A comment token</dt>
                   4652:    <dd>
                   4653:     <p>Append a <code>Comment</code> node to the <code>Document</code>
                   4654:     object with the <code title="">data</code> attribute set to the
                   4655:     data given in the comment token.</p>
                   4656:    </dd>
                   4657: 
                   4658:    <dt>A character token that is one of U+0009 CHARACTER
                   4659:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   4660:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   4661:    <dd>
                   4662:     <p>Ignore the token.</p>
                   4663:    </dd>
                   4664: 
                   4665:    <dt>A start tag whose tag name is "html"</dt>
                   4666:    <dd>
                   4667: 
                   4668:     <p><a href="#create-an-element-for-the-token">Create an element for the token</a> in the <a href="#html-namespace-0">HTML
                   4669:     namespace</a>. Append it to the <code>Document</code>
                   4670:     object. Put this element in the <a href="#stack-of-open-elements">stack of open
                   4671:     elements</a>.</p>
                   4672: 
                   4673:     <p id="parser-appcache">If the <code>Document</code> is being
                   4674:     loaded as part of <a href="history.html#navigate" title="navigate">navigation</a> of a
                   4675:     <a href="browsers.html#browsing-context">browsing context</a>, then: if the newly created element
                   4676:     has a <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code> attribute,
                   4677:     then <a href="infrastructure.html#resolve-a-url" title="resolve a url">resolve</a> the value of that
                   4678:     attribute to an <a href="infrastructure.html#absolute-url">absolute URL</a>, relative to the newly
                   4679:     created element, and if that is successful, run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application cache selection
1.29      mike     4680:     algorithm</a> with the resulting <a href="infrastructure.html#absolute-url">absolute URL</a> with
                   4681:     any <a href="infrastructure.html#url-fragment" title="url-fragment">&lt;fragment&gt;</a> component
                   4682:     removed; otherwise, if there is no such attribute or resolving it
                   4683:     fails, run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application
                   4684:     cache selection algorithm</a> with no manifest. The algorithm
                   4685:     must be passed the <code>Document</code> object.</p>
1.1       mike     4686: 
                   4687:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before head</a>".</p>
                   4688: 
                   4689:    </dd>
                   4690: 
1.334     mike     4691:    <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
                   4692:    <dd>
                   4693:     <p>Act as described in the "anything else" entry below.</p>
                   4694:    </dd>
                   4695: 
                   4696:    <dt>Any other end tag</dt>
                   4697:    <dd>
                   4698:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4699:    </dd>
                   4700: 
1.1       mike     4701:    <dt>Anything else</dt>
                   4702:    <dd>
                   4703: 
1.159     mike     4704:     <p>Create an <code><a href="semantics.html#the-html-element-0">html</a></code> element. Append it to the
1.1       mike     4705:     <code>Document</code> object. Put this element in the <a href="#stack-of-open-elements">stack
                   4706:     of open elements</a>.</p>
                   4707: 
                   4708:     <p>If the <code>Document</code> is being loaded as part of <a href="history.html#navigate" title="navigate">navigation</a> of a <a href="browsers.html#browsing-context">browsing
                   4709:     context</a>, then: run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application cache selection
                   4710:     algorithm</a> with no manifest, passing it the
                   4711:     <code>Document</code> object.</p>
                   4712: 
                   4713:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before head</a>", then
                   4714:     reprocess the current token.</p>
                   4715: 
                   4716:    </dd>
                   4717: 
                   4718:   </dl><p>The root element can end up being removed from the
                   4719:   <code>Document</code> object, e.g. by scripts; nothing in particular
                   4720:   happens in such cases, content continues being appended to the nodes
                   4721:   as described in the next section.</p>
                   4722: 
                   4723: 
                   4724:   <h5 id="the-before-head-insertion-mode"><span class="secno">9.2.5.6 </span>The "<dfn title="insertion mode: before head">before head</dfn>" insertion mode</h5>
                   4725: 
                   4726:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-head-insertion-mode" title="insertion
                   4727:   mode: before head">before head</a>", tokens must be handled as follows:</p>
                   4728: 
                   4729:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   4730:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   4731:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   4732:    <dd>
                   4733:     <p>Ignore the token.</p> <!-- :-( -->
                   4734:    </dd>
                   4735: 
                   4736:    <dt>A comment token</dt>
                   4737:    <dd>
                   4738:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   4739:     node</a> with the <code title="">data</code> attribute set to
                   4740:     the data given in the comment token.</p>
                   4741:    </dd>
                   4742: 
                   4743:    <dt>A DOCTYPE token</dt>
                   4744:    <dd>
                   4745:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4746:    </dd>
                   4747: 
                   4748:    <dt>A start tag whose tag name is "html"</dt>
                   4749:    <dd>
                   4750:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" <a href="#insertion-mode">insertion
                   4751:     mode</a>.</p>
                   4752:    </dd>
                   4753: 
                   4754:    <dt>A start tag whose tag name is "head"</dt>
                   4755:    <dd>
                   4756: 
                   4757:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   4758: 
                   4759:     <p>Set the <a href="#head-element-pointer"><code title="">head</code> element pointer</a>
1.159     mike     4760:     to the newly created <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1       mike     4761: 
                   4762:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inhead" title="insertion mode: in head">in head</a>".</p>
                   4763: 
                   4764:    </dd>
                   4765: 
                   4766:    <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
                   4767:    <dd>
                   4768: 
                   4769:     <p>Act as if a start tag token with the tag name "head" and no
                   4770:     attributes had been seen, then reprocess the current token.</p>
                   4771: 
                   4772:    </dd>
                   4773: 
                   4774:    <dt>Any other end tag</dt>
                   4775:    <dd>
                   4776: 
                   4777:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4778: 
                   4779:    </dd>
                   4780: 
                   4781:    <dt>Anything else</dt>
                   4782:    <dd>
                   4783: 
                   4784:     <p>Act as if a start tag token with the tag name "head" and no
                   4785:     attributes had been seen, then reprocess the current
                   4786:     token.</p>
                   4787: 
                   4788:    </dd>
                   4789: 
                   4790:   </dl><h5 id="parsing-main-inhead"><span class="secno">9.2.5.7 </span>The "<dfn title="insertion mode: in head">in head</dfn>" insertion mode</h5>
                   4791: 
                   4792:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inhead" title="insertion
                   4793:   mode: in head">in head</a>", tokens must be handled as follows:</p>
                   4794: 
                   4795:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   4796:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   4797:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   4798:    <dd>
                   4799:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   4800:     the <a href="#current-node">current node</a>.</p>
                   4801:    </dd>
                   4802: 
                   4803:    <dt>A comment token</dt>
                   4804:    <dd>
                   4805:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   4806:     node</a> with the <code title="">data</code> attribute set to
                   4807:     the data given in the comment token.</p>
                   4808:    </dd>
                   4809: 
                   4810:    <dt>A DOCTYPE token</dt>
                   4811:    <dd>
                   4812:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4813:    </dd>
                   4814: 
                   4815:    <dt>A start tag whose tag name is "html"</dt>
                   4816:    <dd>
                   4817:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" <a href="#insertion-mode">insertion
                   4818:     mode</a>.</p>
                   4819:    </dd>
                   4820: 
                   4821:    <dt>A start tag whose tag name is one of: "base", "command",
                   4822:    "link"</dt>
                   4823:    <dd>
                   4824: 
                   4825:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   4826:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   4827:     elements</a>.</p>
                   4828: 
                   4829:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   4830:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   4831: 
                   4832:    </dd>
                   4833: 
                   4834:    <dt>A start tag whose tag name is "meta"</dt>
                   4835:    <dd>
                   4836: 
                   4837:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   4838:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   4839:     elements</a>.</p>
                   4840: 
                   4841:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   4842:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   4843: 
                   4844:     <p id="meta-charset-during-parse">If the element has a <code title="attr-meta-charset"><a href="semantics.html#attr-meta-charset">charset</a></code> attribute, and its
                   4845:     value is a supported encoding, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
                   4846:     currently <i>tentative</i>, then <a href="#change-the-encoding">change the
                   4847:     encoding</a> to the encoding given by the value of the
                   4848:     <code title="attr-meta-charset"><a href="semantics.html#attr-meta-charset">charset</a></code> attribute.</p>
                   4849: 
                   4850:     <p>Otherwise, if the element has a <code title="attr-meta-charset"><a href="semantics.html#attr-meta-charset">content</a></code> attribute, and
                   4851:     applying the <a href="infrastructure.html#algorithm-for-extracting-an-encoding-from-a-content-type">algorithm for extracting an encoding from a
                   4852:     Content-Type</a> to its value returns a supported encoding
                   4853:     <var title="">encoding</var>, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
                   4854:     currently <i>tentative</i>, then <a href="#change-the-encoding">change the
                   4855:     encoding</a> to the encoding <var title="">encoding</var>.</p>
                   4856: 
                   4857:    </dd>
                   4858: 
                   4859:    <dt>A start tag whose tag name is "title"</dt>
                   4860:    <dd>
                   4861:     <p>Follow the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>.</p>
                   4862:    </dd>
                   4863: 
                   4864:    <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
                   4865:    <dt>A start tag whose tag name is one of: "noframes", "style"</dt>
                   4866:    <dd>
1.91      mike     4867:     <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1       mike     4868:    </dd>
                   4869: 
                   4870:    <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is disabled</dt>
                   4871:    <dd>
                   4872: 
                   4873:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   4874: 
                   4875:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inheadnoscript" title="insertion mode: in head noscript">in head
                   4876:     noscript</a>".</p>
                   4877: 
                   4878:    </dd>
                   4879: 
                   4880:    <dt id="scriptTag">A start tag whose tag name is "script"</dt>
                   4881:    <dd>
                   4882: 
                   4883:     <ol><li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> in the
                   4884:      <a href="#html-namespace-0">HTML namespace</a>.</p></li>
                   4885: 
                   4886:      <li>
                   4887: 
                   4888:       <p>Mark the element as being <a href="semantics.html#parser-inserted">"parser-inserted"</a>.</p>
                   4889: 
                   4890:       <p class="note">This ensures that, if the script is external,
1.159     mike     4891:       any <code title="dom-document-write"><a href="embedded-content-0.html#dom-document-write">document.write()</a></code>
1.1       mike     4892:       calls in the script will execute in-line, instead of blowing the
                   4893:       document away, as would happen in most other cases. It also
                   4894:       prevents the script from executing until the end tag is
                   4895:       seen.</p>
                   4896: 
                   4897:      </li>
                   4898: 
                   4899:      <li><p>If the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML
                   4900:      fragment parsing algorithm</a>, then mark the
1.484     mike     4901:      <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
                   4902:      started"</a>. (<a href="#fragment-case">fragment case</a>)</p></li>
1.1       mike     4903: 
                   4904:      <li><p>Append the new element to the <a href="#current-node">current node</a>
                   4905:      and push it onto the <a href="#stack-of-open-elements">stack of open
                   4906:      elements</a>.</p></li>
                   4907: 
1.541     mike     4908:      <li><p>Switch the tokenizer to the <a href="#script-data-state">script data
                   4909:      state</a>.</p></li>
1.1       mike     4910: 
                   4911:      <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
                   4912:      <a href="#insertion-mode">insertion mode</a>.</p>
                   4913: 
1.540     mike     4914:      </li><li><p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incdata" title="insertion mode: text">text</a>".</p></li>
1.1       mike     4915: 
                   4916:     </ol></dd>
                   4917: 
                   4918:    <dt>An end tag whose tag name is "head"</dt>
                   4919:    <dd>
                   4920: 
                   4921:     <p>Pop the <a href="#current-node">current node</a> (which will be the
1.159     mike     4922:     <code><a href="semantics.html#the-head-element-0">head</a></code> element) off the <a href="#stack-of-open-elements">stack of open
1.1       mike     4923:     elements</a>.</p>
                   4924: 
                   4925:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#the-after-head-insertion-mode" title="insertion mode: after head">after head</a>".</p>
                   4926: 
                   4927:    </dd>
                   4928: 
                   4929:    <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
                   4930:    <dd>
                   4931:     <p>Act as described in the "anything else" entry below.</p>
                   4932:    </dd>
                   4933: 
                   4934:    <dt>A start tag whose tag name is "head"</dt>
                   4935:    <dt>Any other end tag</dt>
                   4936:    <dd>
                   4937:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4938:    </dd>
                   4939: 
                   4940:    <dt>Anything else</dt>
                   4941:    <dd>
                   4942: 
                   4943:     <!-- can't get here with an EOF and a fragment case -->
                   4944: 
                   4945:     <p>Act as if an end tag token with the tag name "head" had
                   4946:     been seen, and reprocess the current token.</p>
                   4947: 
                   4948:    </dd>
                   4949: 
                   4950:   </dl><h5 id="parsing-main-inheadnoscript"><span class="secno">9.2.5.8 </span>The "<dfn title="insertion mode: in head noscript">in head noscript</dfn>" insertion mode</h5>
                   4951: 
                   4952:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inheadnoscript" title="insertion
                   4953:   mode: in head noscript">in head noscript</a>", tokens must be handled as follows:</p>
                   4954: 
                   4955:   <dl class="switch"><dt>A DOCTYPE token</dt>
                   4956:    <dd>
                   4957:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4958:    </dd>
                   4959: 
                   4960:    <dt>A start tag whose tag name is "html"</dt>
                   4961:    <dd>
                   4962:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" <a href="#insertion-mode">insertion
                   4963:     mode</a>.</p>
                   4964:    </dd>
                   4965: 
                   4966:    <dt>An end tag whose tag name is "noscript"</dt>
                   4967:    <dd>
                   4968: 
                   4969:     <p>Pop the <a href="#current-node">current node</a> (which will be a
                   4970:     <code><a href="semantics.html#the-noscript-element">noscript</a></code> element) from the <a href="#stack-of-open-elements">stack of open
                   4971:     elements</a>; the new <a href="#current-node">current node</a> will be a
1.159     mike     4972:     <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1       mike     4973: 
                   4974:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inhead" title="insertion mode: in head">in head</a>".</p>
                   4975: 
                   4976:    </dd>
                   4977: 
                   4978:    <dt>A character token that is one of U+0009 CHARACTER
                   4979:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   4980:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   4981:    <dt>A comment token</dt>
                   4982:    <dt>A start tag whose tag name is one of: "link", "meta", "noframes", "style"</dt>
                   4983:    <dd>
                   4984:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inhead" title="insertion mode: in head">in head</a>" <a href="#insertion-mode">insertion
                   4985:     mode</a>.</p>
                   4986:    </dd>
                   4987: 
                   4988:    <dt>An end tag whose tag name is "br"</dt>
                   4989:    <dd>
                   4990:     <p>Act as described in the "anything else" entry below.</p>
                   4991:    </dd>
                   4992: 
                   4993:    <dt>A start tag whose tag name is one of: "head", "noscript"</dt>
                   4994:    <dt>Any other end tag</dt>
                   4995:    <dd>
                   4996:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4997:    </dd>
                   4998: 
                   4999:    <dt>Anything else</dt>
                   5000:    <dd>
                   5001: 
                   5002:     <!-- can't get here with an EOF and a fragment case -->
                   5003: 
                   5004:     <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
                   5005:     name "noscript" had been seen and reprocess the current
                   5006:     token.</p>
                   5007: 
                   5008:    </dd>
                   5009: 
                   5010:   </dl><h5 id="the-after-head-insertion-mode"><span class="secno">9.2.5.9 </span>The "<dfn title="insertion mode: after head">after head</dfn>" insertion mode</h5>
                   5011: 
                   5012:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-head-insertion-mode" title="insertion
                   5013:   mode: after head">after head</a>", tokens must be handled as follows:</p>
                   5014: 
                   5015:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   5016:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   5017:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   5018:    <dd>
                   5019:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   5020:     the <a href="#current-node">current node</a>.</p>
                   5021:    </dd>
                   5022: 
                   5023:    <dt>A comment token</dt>
                   5024:    <dd>
                   5025:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   5026:     node</a> with the <code title="">data</code> attribute set to
                   5027:     the data given in the comment token.</p>
                   5028:    </dd>
                   5029: 
                   5030:    <dt>A DOCTYPE token</dt>
                   5031:    <dd>
                   5032:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5033:    </dd>
                   5034: 
                   5035:    <dt>A start tag whose tag name is "html"</dt>
                   5036:    <dd>
                   5037:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" <a href="#insertion-mode">insertion
                   5038:     mode</a>.</p>
                   5039:    </dd>
                   5040: 
                   5041:    <dt>A start tag whose tag name is "body"</dt>
                   5042:    <dd>
                   5043: 
                   5044:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5045: 
                   5046:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   5047: 
                   5048:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>".</p>
                   5049: 
                   5050:    </dd>
                   5051: 
                   5052:    <dt>A start tag whose tag name is "frameset"</dt>
                   5053:    <dd>
                   5054: 
                   5055:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5056: 
                   5057:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inframeset" title="insertion mode: in frameset">in frameset</a>".</p>
                   5058: 
                   5059:    </dd>
                   5060: 
                   5061:    <dt>A start tag token whose tag name is one of: "base", "link",
                   5062:    "meta", "noframes", "script", "style", "title"</dt>
                   5063:    <dd>
                   5064: 
                   5065:     <p><a href="#parse-error">Parse error</a>.</p>
                   5066: 
                   5067:     <p>Push the node pointed to by the <a href="#head-element-pointer"><code title="">head</code> element pointer</a> onto the
                   5068:     <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   5069: 
                   5070:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inhead" title="insertion mode: in head">in head</a>" <a href="#insertion-mode">insertion
                   5071:     mode</a>.</p>
                   5072: 
                   5073:     <p>Remove the node pointed to by the <a href="#head-element-pointer"><code title="">head</code> element pointer</a> from the <a href="#stack-of-open-elements">stack
                   5074:     of open elements</a>.</p>
                   5075: 
                   5076:     <p class="note">The <a href="#head-element-pointer"><code title="">head</code> element
                   5077:     pointer</a> cannot be null at this point.</p>
                   5078: 
                   5079:    </dd>
                   5080: 
                   5081:    <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
                   5082:    <dd>
                   5083:     <p>Act as described in the "anything else" entry below.</p>
                   5084:    </dd>
                   5085: 
                   5086:    <dt>A start tag whose tag name is "head"</dt>
                   5087:    <dt>Any other end tag</dt>
                   5088:    <dd>
                   5089:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5090:    </dd>
                   5091: 
                   5092:    <dt>Anything else</dt>
                   5093:    <dd>
                   5094:     <p>Act as if a start tag token with the tag name "body" and no
                   5095:     attributes had been seen, then set the <a href="#frameset-ok-flag">frameset-ok
                   5096:     flag</a> back to "ok", and then reprocess the current
                   5097:     token.</p>
                   5098:    </dd>
                   5099: 
                   5100:   </dl><h5 id="parsing-main-inbody"><span class="secno">9.2.5.10 </span>The "<dfn title="insertion mode: in body">in body</dfn>" insertion mode</h5>
                   5101: 
                   5102:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inbody" title="insertion
                   5103:   mode: in body">in body</a>", tokens must be handled as follows:</p>
                   5104: 
                   5105:   <dl class="switch"><dt>A character token</dt>
                   5106:    <dd>
                   5107: 
                   5108:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5109:     any.</p>
                   5110: 
                   5111:     <p><a href="#insert-a-character" title="insert a character">Insert the token's
                   5112:     character</a> into the <a href="#current-node">current node</a>.</p>
                   5113: 
                   5114:     <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
                   5115:     LINE FEED (LF), U+000C FORM FEED (FF), <!--U+000D CARRIAGE RETURN
                   5116:     (CR),--> or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
                   5117:     flag</a> to "not ok".</p>
                   5118: 
                   5119:    </dd>
                   5120: 
                   5121:    <dt>A comment token</dt>
                   5122:    <dd>
                   5123:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   5124:     node</a> with the <code title="">data</code> attribute set to
                   5125:     the data given in the comment token.</p>
                   5126:    </dd>
                   5127: 
                   5128:    <dt>A DOCTYPE token</dt>
                   5129:    <dd>
                   5130:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5131:    </dd>
                   5132: 
                   5133:    <dt>A start tag whose tag name is "html"</dt>
                   5134:    <dd>
                   5135:     <p><a href="#parse-error">Parse error</a>. For each attribute on the token,
                   5136:     check to see if the attribute is already present on the top
                   5137:     element of the <a href="#stack-of-open-elements">stack of open elements</a>. If it is not,
                   5138:     add the attribute and its corresponding value to that element.</p>
                   5139:    </dd>
                   5140: 
                   5141:    <dt>A start tag token whose tag name is one of: "base", "command",
                   5142:    "link", "meta", "noframes", "script", "style", "title"</dt>
                   5143:    <dd>
                   5144:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inhead" title="insertion mode: in head">in head</a>" <a href="#insertion-mode">insertion
                   5145:     mode</a>.</p>
                   5146:    </dd>
                   5147: 
                   5148:    <dt>A start tag whose tag name is "body"</dt>
                   5149:    <dd>
                   5150: 
                   5151:     <p><a href="#parse-error">Parse error</a>.</p>
                   5152: 
                   5153:     <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159     mike     5154:     elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1       mike     5155:     <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
                   5156:     then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
                   5157: 
                   5158:     <p>Otherwise, for each attribute on the token, check to see if
1.159     mike     5159:     the attribute is already present on the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1       mike     5160:     element (the second element) on the <a href="#stack-of-open-elements">stack of open
                   5161:     elements</a>. If it is not, add the attribute and its
                   5162:     corresponding value to that element.</p>
                   5163: 
                   5164:    </dd>
                   5165: 
                   5166:    <dt>A start tag whose tag name is "frameset"</dt>
                   5167:    <dd>
                   5168: 
                   5169:     <p><a href="#parse-error">Parse error</a>.</p>
                   5170: 
                   5171:     <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159     mike     5172:     elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1       mike     5173:     <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
                   5174:     then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
                   5175: 
                   5176:     <p>If the <a href="#frameset-ok-flag">frameset-ok flag</a> is set to "not ok", ignore
                   5177:     the token.</p>
                   5178: 
                   5179:     <p>Otherwise, run the following steps:</p>
                   5180: 
                   5181:     <ol><li><p>Remove the second element on the <a href="#stack-of-open-elements">stack of open
                   5182:      elements</a> from its parent node, if it has one.</p></li>
                   5183: 
                   5184:      <li><p>Pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of
                   5185:      open elements</a>, from the <a href="#current-node">current node</a> up to,
1.159     mike     5186:      but not including, the root <code><a href="semantics.html#the-html-element-0">html</a></code> element.</p>
1.1       mike     5187: 
                   5188:      </li><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
                   5189:      token.</p></li>
                   5190: 
                   5191:      <li><p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inframeset" title="insertion mode: in frameset">in frameset</a>".</p>
                   5192: 
                   5193:     </li></ol></dd>
                   5194: 
                   5195:    <dt>An end-of-file token</dt>
                   5196:    <dd>
                   5197: 
                   5198:     <p>If there is a node in the <a href="#stack-of-open-elements">stack of open elements</a>
1.422     mike     5199:     that is not either a <code><a href="semantics.html#the-dd-element">dd</a></code> element, a <code><a href="semantics.html#the-dt-element">dt</a></code>
                   5200:     element, an <code><a href="semantics.html#the-li-element">li</a></code> element, a <code><a href="semantics.html#the-p-element">p</a></code> element, a
1.1       mike     5201:     <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element, a <code><a href="tabular-data.html#the-td-element">td</a></code> element, a
                   5202:     <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element, a <code><a href="tabular-data.html#the-th-element">th</a></code> element, a
                   5203:     <code><a href="tabular-data.html#the-thead-element">thead</a></code> element, a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, the
1.159     mike     5204:     <code><a href="semantics.html#the-body-element-0">body</a></code> element, or the <code><a href="semantics.html#the-html-element-0">html</a></code> element, then
1.1       mike     5205:     this is a <a href="#parse-error">parse error</a>.</p> <!-- (some of those are
1.422     mike     5206:     fragment cases) -->
1.1       mike     5207: 
                   5208:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   5209: 
                   5210:    </dd>
                   5211: 
                   5212:    <dt>An end tag whose tag name is "body"</dt>
                   5213:    <dd>
                   5214: 
                   5215:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-scope" title="has an element in scope">have a <code>body</code> element
                   5216:     in scope</a>, this is a <a href="#parse-error">parse error</a>; ignore the
                   5217:     token.</p>
                   5218: 
                   5219:     <!-- if we get here, the insertion mode here is forcibly "in
                   5220:     body". -->
                   5221: 
                   5222:     <p>Otherwise, if there is a node in the <a href="#stack-of-open-elements">stack of open
1.422     mike     5223:     elements</a> that is not either a <code><a href="semantics.html#the-dd-element">dd</a></code> element, a
1.1       mike     5224:     <code><a href="semantics.html#the-dt-element">dt</a></code> element, an <code><a href="semantics.html#the-li-element">li</a></code> element, an
                   5225:     <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, an <code><a href="forms.html#the-option-element">option</a></code> element, a
                   5226:     <code><a href="semantics.html#the-p-element">p</a></code> element, an <code><a href="text-level-semantics.html#the-rp-element">rp</a></code> element, an
                   5227:     <code><a href="text-level-semantics.html#the-rt-element">rt</a></code> element, a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element, a
                   5228:     <code><a href="tabular-data.html#the-td-element">td</a></code> element, a <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element, a
                   5229:     <code><a href="tabular-data.html#the-th-element">th</a></code> element, a <code><a href="tabular-data.html#the-thead-element">thead</a></code> element, a
1.159     mike     5230:     <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, the <code><a href="semantics.html#the-body-element-0">body</a></code> element, or the
                   5231:     <code><a href="semantics.html#the-html-element-0">html</a></code> element, then this is a <a href="#parse-error">parse
1.1       mike     5232:     error</a>.</p> <!-- (some of those are fragment cases, e.g. for
                   5233:     <tbody> you'd have hit the first paragraph since the <body>
1.422     mike     5234:     wouldn't be in scope, unless it was a fragment case) -->
1.1       mike     5235: 
                   5236:     <!-- If we ever change the frameset-ok flag to an insertion mode,
                   5237:     then we'd have to somehow keep track of its state when we switch
                   5238:     to after-body. -->
                   5239: 
                   5240:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-afterbody" title="insertion mode: after body">after body</a>".</p>
                   5241: 
                   5242:    </dd>
                   5243: 
                   5244:    <dt>An end tag whose tag name is "html"</dt>
                   5245:    <dd>
                   5246: 
                   5247:     <p>Act as if an end tag with tag name "body" had been seen,
                   5248:     then, if that token wasn't ignored, reprocess the current
                   5249:     token.</p>
                   5250: 
                   5251:     <p class="note">The fake end tag token here can only be
                   5252:     ignored in the <a href="#fragment-case">fragment case</a>.</p>
                   5253: 
                   5254:    </dd>
                   5255: 
                   5256:    <!-- start tags for non-phrasing flow content elements -->
                   5257: 
                   5258:    <!-- the normal ones -->
                   5259:    <dt>A start tag whose tag name is one of: "address", "article",
1.86      mike     5260:    "aside", "blockquote", "center", <!--v2DATAGRID-->"datagrid",
1.305     mike     5261:    "details", "dir", "div", "dl", "fieldset", "figure", "footer",
                   5262:    "header", "hgroup", "menu", "nav", "ol", "p", "section", "ul"</dt>
1.1       mike     5263:    <dd>
                   5264: 
                   5265:     <!-- As of May 2008 this doesn't match any browser exactly, but is
                   5266:     as close to what IE does as I can get without doing the non-tree
                   5267:     DOM nonsense, and thus should actually afford better compatibility
                   5268:     when implemented by the other browsers. -->
                   5269: 
                   5270:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5271:     an element in scope">has a <code>p</code> element in
                   5272:     scope</a>, then act as if an end tag with the tag name
                   5273:     "p" had been seen.</p>
                   5274: 
                   5275:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5276: 
                   5277:    </dd>
                   5278: 
                   5279:    <!-- as normal, but close h1-h6 if it's the current node -->
                   5280:    <dt>A start tag whose tag name is one of: "h1", "h2", "h3", "h4",
                   5281:    "h5", "h6"</dt>
                   5282:    <dd>
                   5283: 
                   5284:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5285:     an element in scope">has a <code>p</code> element in
                   5286:     scope</a>, then act as if an end tag with the tag name
                   5287:     "p" had been seen.</p>
                   5288: 
                   5289:     <p>If the <a href="#current-node">current node</a> is an element whose tag name
                   5290:     is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is a
                   5291:     <a href="#parse-error">parse error</a>; pop the <a href="#current-node">current node</a> off
                   5292:     the <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   5293:     <!-- See https://bugs.webkit.org/show_bug.cgi?id=12646 -->
                   5294: 
                   5295:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5296: 
                   5297:    </dd>
                   5298: 
                   5299:    <!-- as normal, but drops leading newline -->
                   5300:    <dt>A start tag whose tag name is one of: "pre", "listing"</dt>
                   5301:    <dd>
                   5302: 
                   5303:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5304:     an element in scope">has a <code>p</code> element in
                   5305:     scope</a>, then act as if an end tag with the tag name
                   5306:     "p" had been seen.</p>
                   5307: 
                   5308:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5309: 
                   5310:     <p>If the next token is a U+000A LINE FEED (LF) character
                   5311:     token, then ignore that token and move on to the next
                   5312:     one. (Newlines at the start of <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are
                   5313:     ignored as an authoring convenience.)</p>
                   5314: 
                   5315:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   5316: 
                   5317:    </dd>
                   5318: 
                   5319:    <!-- as normal, but interacts with the form element pointer -->
                   5320:    <dt>A start tag whose tag name is "form"</dt>
                   5321:    <dd>
                   5322: 
                   5323:     <p>If the <a href="#form-element-pointer"><code title="form">form</code> element
                   5324:     pointer</a> is not null, then this is a <a href="#parse-error">parse
                   5325:     error</a>; ignore the token.</p>
                   5326: 
                   5327:     <p>Otherwise:</p>
                   5328: 
                   5329:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5330:     an element in scope">has a <code>p</code> element in
                   5331:     scope</a>, then act as if an end tag with the tag name
                   5332:     "p" had been seen.</p>
                   5333: 
                   5334:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, and set the
                   5335:     <a href="#form-element-pointer"><code title="form">form</code> element pointer</a> to
                   5336:     point to the element created.</p>
                   5337: 
                   5338:    </dd>
                   5339: 
                   5340:    <!-- as normal, but imply </li> when there's another <li> open in weird cases -->
                   5341:    <dt>A start tag whose tag name is "li"</dt>
                   5342:    <dd>
                   5343: 
                   5344:     <p>Run the following algorithm:</p>
                   5345: 
                   5346:     <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
                   5347: 
                   5348:      <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
                   5349:      node</a> (the bottommost node of the stack).</p></li>
                   5350: 
                   5351:      <li><p>If <var title="">node</var> is an <code><a href="semantics.html#the-li-element">li</a></code> element,
                   5352:      then act as if an end tag with the tag name "li" had
                   5353:      been seen, then jump to the last step.</p></li>
                   5354: 
                   5355:      <li><p><i>Loop</i>: If <var title="">node</var> is not in the
                   5356:      <a href="#formatting">formatting</a> category, and is not in the
                   5357:      <a href="#phrasing">phrasing</a> category, and is not an
1.306     mike     5358:      <code><a href="semantics.html#the-address-element">address</a></code>, <code><a href="semantics.html#the-div-element">div</a></code>, or <code><a href="semantics.html#the-p-element">p</a></code>
1.1       mike     5359:      element, then jump to the last step.</p></li> <!-- an element
                   5360:      <foo> is in this list if the following markup:
                   5361: 
                   5362:          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><ol><li><foo><li>
                   5363: 
                   5364:      ...results in the second <li> not being (in any way) a descendant
                   5365:      of the first <li>, or if <foo> is a formatting element that gets
                   5366:      reopened later. -->
                   5367: 
                   5368:      <li><p>Otherwise, set <var title="">node</var> to the previous
                   5369:      entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
                   5370:      the step labeled <i>loop</i>.</p></li>
                   5371: 
                   5372:      <li>
                   5373: 
                   5374:       <p>This is the last step.</p>
                   5375: 
                   5376:       <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5377:       an element in scope">has a <code>p</code> element in
                   5378:       scope</a>, then act as if an end tag with the tag name
                   5379:       "p" had been seen.</p>
                   5380: 
                   5381:       <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
                   5382:       token.</p>
                   5383: 
                   5384:      </li>
                   5385: 
                   5386:     </ol></dd>
                   5387: 
                   5388:    <!-- as normal, but imply </dt> or </dd> when there's another <dt> or <dd> open in weird cases  -->
1.422     mike     5389:    <dt>A start tag whose tag name is one of: "dd", "dt"</dt>
1.1       mike     5390:    <dd>
                   5391: 
                   5392:     <p>Run the following algorithm:</p>
                   5393: 
                   5394:     <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
                   5395: 
                   5396:      <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
                   5397:      node</a> (the bottommost node of the stack).</p></li>
                   5398: 
                   5399:      <li><p><i>Loop</i>: If <var title="">node</var> is a
1.422     mike     5400:      <code><a href="semantics.html#the-dd-element">dd</a></code> or <code><a href="semantics.html#the-dt-element">dt</a></code> element, then act as if an end
                   5401:      tag with the same tag name as <var title="">node</var> had been
                   5402:      seen, then jump to the last step.</p></li>
1.1       mike     5403: 
                   5404:      <li><p>If <var title="">node</var> is not in the
                   5405:      <a href="#formatting">formatting</a> category, and is not in the
                   5406:      <a href="#phrasing">phrasing</a> category, and is not an
1.306     mike     5407:      <code><a href="semantics.html#the-address-element">address</a></code>, <code><a href="semantics.html#the-div-element">div</a></code>, or <code><a href="semantics.html#the-p-element">p</a></code>
1.1       mike     5408:      element, then jump to the last step.</p></li> <!-- an element
                   5409:      <foo> is in this list if the following markup:
                   5410: 
                   5411:          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><dl><dt><foo><dt>
                   5412: 
                   5413:      ...results in the second <dt> not being (in any way) a descendant
                   5414:      of the first <dt>, or if <foo> is a formatting element that gets
                   5415:      reopened later. -->
                   5416: 
                   5417:      <li><p>Otherwise, set <var title="">node</var> to the previous
                   5418:      entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
                   5419:      the step labeled <i>loop</i>.</p></li>
                   5420: 
                   5421:      <li>
                   5422: 
                   5423:       <p>This is the last step.</p>
                   5424: 
                   5425:       <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5426:       an element in scope">has a <code>p</code> element in
                   5427:       scope</a>, then act as if an end tag with the tag name
                   5428:       "p" had been seen.</p>
                   5429: 
                   5430:       <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
                   5431:       token.</p>
                   5432: 
                   5433:      </li>
                   5434: 
                   5435:     </ol></dd>
                   5436: 
                   5437:    <!-- same as normal, but effectively ends parsing -->
                   5438:    <dt>A start tag whose tag name is "plaintext"</dt>
                   5439:    <dd>
                   5440: 
                   5441:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5442:     an element in scope">has a <code>p</code> element in
                   5443:     scope</a>, then act as if an end tag with the tag name
                   5444:     "p" had been seen.</p>
                   5445: 
                   5446:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5447: 
1.541     mike     5448:     <p>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1       mike     5449: 
1.541     mike     5450:     <p class="note">Once a start tag with the tag name "plaintext" has
                   5451:     been seen, that will be the last token ever seen other than
                   5452:     character tokens (and the end-of-file token), because there is no
                   5453:     way to switch out of the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1       mike     5454: 
                   5455:    </dd>
                   5456: 
                   5457:    <!-- end tags for non-phrasing flow content elements -->
                   5458: 
                   5459:    <!-- the normal ones -->
                   5460:    <dt>An end tag whose tag name is one of: "address", "article",
1.86      mike     5461:    "aside", "blockquote", "center", <!--v2DATAGRID-->"datagrid",
1.305     mike     5462:    "details", "dir", "div", "dl", "fieldset", "figure", "footer",
                   5463:    "header", "hgroup", "listing", "menu", "nav", "ol", "pre",
                   5464:    "section", "ul"</dt>
1.1       mike     5465:    <dd>
                   5466: 
                   5467:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-scope" title="has an element in scope">have an element in scope</a>
                   5468:     with the same tag name as that of the token, then this is a
                   5469:     <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5470: 
                   5471:     <p>Otherwise, run these steps:</p>
                   5472: 
                   5473:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   5474: 
                   5475:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5476:      the same tag name as that of the token, then this is a
                   5477:      <a href="#parse-error">parse error</a>.</p></li>
                   5478: 
                   5479:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5480:      until an element with the same tag name as the token has been
                   5481:      popped from the stack.</p></li>
                   5482: 
                   5483:     </ol></dd>
                   5484: 
                   5485:    <!-- removes the form element pointer instead of the matching node -->
                   5486:    <dt>An end tag whose tag name is "form"</dt>
                   5487:    <dd>
                   5488: 
                   5489:     <p>Let <var title="">node</var> be the element that the
                   5490:     <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is set
                   5491:     to.</p>
                   5492: 
                   5493:     <p>Set the <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
                   5494:     to null.</p>
                   5495: 
                   5496:     <p>If <var title="">node</var> is null or the <a href="#stack-of-open-elements">stack of open
                   5497:     elements</a> does not <a href="#has-an-element-in-scope" title="has an element in
                   5498:     scope">have <var title="">node</var> in scope</a>, then this is
                   5499:     a <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5500: 
                   5501:     <p>Otherwise, run these steps:</p>
                   5502: 
                   5503:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   5504: 
                   5505:      <li><p>If the <a href="#current-node">current node</a> is not <var title="">node</var>, then this is a <a href="#parse-error">parse
                   5506:      error</a>.</p></li>
                   5507: 
                   5508:      <li><p>Remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of
                   5509:      open elements</a>.</p></li>
                   5510: 
                   5511:     </ol></dd>
                   5512: 
                   5513:    <!-- as normal, except </p> implies <p> if there's no <p> in scope, and needs care as the elements have optional tags -->
                   5514:    <dt>An end tag whose tag name is "p"</dt>
                   5515:    <dd>
                   5516: 
                   5517:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-scope" title="has an element in scope">have an element in scope</a>
                   5518:     with the same tag name as that of the token, then this is a
                   5519:     <a href="#parse-error">parse error</a>; act as if a start tag with the tag name
                   5520:     "p" had been seen, then reprocess the current token.</p>
                   5521: 
                   5522:     <p>Otherwise, run these steps:</p>
                   5523: 
                   5524:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
                   5525:      for elements with the same tag name as the token.</p></li>
                   5526: 
                   5527:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5528:      the same tag name as that of the token, then this is a
                   5529:      <a href="#parse-error">parse error</a>.</p></li>
                   5530: 
                   5531:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5532:      until an element with the same tag name as the token has been
                   5533:      popped from the stack.</p></li>
                   5534: 
                   5535:     </ol></dd>
                   5536: 
1.234     mike     5537:    <!-- as normal, but needs care as the elements have optional tags, and are further scoped by <ol>/<ul> -->
                   5538:    <dt>An end tag whose tag name is "li"</dt>
                   5539:    <dd>
                   5540: 
                   5541:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-list-item-scope" title="has an element in list item scope">have an element in list
                   5542:     item scope</a> with the same tag name as that of the token,
                   5543:     then this is a <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5544: 
                   5545:     <p>Otherwise, run these steps:</p>
                   5546: 
                   5547:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
                   5548:      for elements with the same tag name as the token.</p></li>
                   5549: 
                   5550:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5551:      the same tag name as that of the token, then this is a
                   5552:      <a href="#parse-error">parse error</a>.</p></li>
                   5553: 
                   5554:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5555:      until an element with the same tag name as the token has been
                   5556:      popped from the stack.</p></li>
                   5557: 
                   5558:     </ol></dd>
                   5559: 
1.1       mike     5560:    <!-- as normal, but needs care as the elements have optional tags -->
1.422     mike     5561:    <dt>An end tag whose tag name is one of: "dd", "dt"</dt>
1.1       mike     5562:    <dd>
                   5563: 
                   5564:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-scope" title="has an element in scope">have an element in scope</a>
                   5565:     with the same tag name as that of the token, then this is a
                   5566:     <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5567: 
                   5568:     <p>Otherwise, run these steps:</p>
                   5569: 
                   5570:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
                   5571:      for elements with the same tag name as the token.</p></li>
                   5572: 
                   5573:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5574:      the same tag name as that of the token, then this is a
                   5575:      <a href="#parse-error">parse error</a>.</p></li>
                   5576: 
                   5577:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5578:      until an element with the same tag name as the token has been
                   5579:      popped from the stack.</p></li>
                   5580: 
                   5581:     </ol></dd>
                   5582: 
                   5583:    <!-- as normal, except acts as a closer for any of the h1-h6 elements -->
                   5584:    <dt>An end tag whose tag name is one of: "h1", "h2", "h3", "h4", "h5", "h6"</dt>
                   5585:    <dd>
                   5586: 
                   5587:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-scope" title="has an element in scope">have an element in scope</a>
                   5588:     whose tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6",
                   5589:     then this is a <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5590: 
                   5591:     <p>Otherwise, run these steps:</p>
                   5592: 
                   5593:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   5594: 
                   5595:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5596:      the same tag name as that of the token, then this is a
                   5597:      <a href="#parse-error">parse error</a>.</p></li>
                   5598: 
                   5599:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5600:      until an element whose tag name is one of "h1", "h2", "h3", "h4",
                   5601:      "h5", or "h6" has been popped from the stack.</p></li>
                   5602: 
                   5603:     </ol></dd>
                   5604: 
                   5605:    <dt>An end tag whose tag name is "sarcasm"</dt>
                   5606:    <dd>
                   5607:     <p>Take a deep breath, then act as described in the "any other end
                   5608:     tag" entry below.</p>
                   5609:    </dd>
                   5610: 
                   5611:    <!-- ADOPTION AGENCY ELEMENTS
                   5612:         Mozilla-only: bdo blink del ins sub sup q
                   5613:         Safari-only: code dfn kbd nobr samp var wbr
                   5614:         Both: a b big em font i s small strike strong tt u -->
                   5615: 
                   5616:    <dt>A start tag whose tag name is "a"</dt>
                   5617:    <dd>
                   5618: 
                   5619:     <p>If the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>
                   5620:     contains an element whose tag name is "a" between the end of
                   5621:     the list and the last marker on the list (or the start of the
                   5622:     list if there is no marker on the list), then this is a
                   5623:     <a href="#parse-error">parse error</a>; act as if an end tag with the tag
                   5624:     name "a" had been seen, then remove that element from the
                   5625:     <a href="#list-of-active-formatting-elements">list of active formatting elements</a> and the
                   5626:     <a href="#stack-of-open-elements">stack of open elements</a> if the end tag didn't
                   5627:     already remove it (it might not have if the element is not
                   5628:     <a href="#has-an-element-in-table-scope" title="has an element in table scope">in table
                   5629:     scope</a>).</p>
                   5630: 
                   5631:     <p class="example">In the non-conforming stream
                   5632:     <code>&lt;a&#160;href="a"&gt;a&lt;table&gt;&lt;a&#160;href="b"&gt;b&lt;/table&gt;x</code>,
                   5633:     the first <code><a href="text-level-semantics.html#the-a-element">a</a></code> element would be closed upon seeing
                   5634:     the second one, and the "x" character would be inside a link
                   5635:     to "b", not to "a". This is despite the fact that the outer
                   5636:     <code><a href="text-level-semantics.html#the-a-element">a</a></code> element is not in table scope (meaning that a
                   5637:     regular <code>&lt;/a&gt;</code> end tag at the start of the table
                   5638:     wouldn't close the outer <code><a href="text-level-semantics.html#the-a-element">a</a></code> element).</p>
                   5639: 
                   5640:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5641:     any.</p>
                   5642: 
                   5643:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
                   5644:     element to the <a href="#list-of-active-formatting-elements">list of active formatting
                   5645:     elements</a>.</p>
                   5646: 
                   5647:    </dd>
                   5648: 
                   5649:    <dt>A start tag whose tag name is one of: "b", "big", "code", "em",
                   5650:    "font", "i", "s", "small", "strike", "strong", "tt", "u"</dt>
                   5651:    <dd>
                   5652: 
                   5653:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5654:     any.</p>
                   5655: 
                   5656:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
                   5657:     element to the <a href="#list-of-active-formatting-elements">list of active formatting
                   5658:     elements</a>.</p>
                   5659: 
                   5660:    </dd>
                   5661: 
                   5662:    <dt>A start tag whose tag name is "nobr"</dt>
                   5663:    <dd>
                   5664: 
                   5665:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5666:     any.</p>
                   5667: 
                   5668:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
                   5669:     element in scope">has a <code>nobr</code> element in scope</a>,
                   5670:     then this is a <a href="#parse-error">parse error</a>; act as if an end tag with
                   5671:     the tag name "nobr" had been seen, then once again
                   5672:     <a href="#reconstruct-the-active-formatting-elements">reconstruct the active formatting elements</a>, if
                   5673:     any.</p>
                   5674: 
                   5675:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
                   5676:     element to the <a href="#list-of-active-formatting-elements">list of active formatting
                   5677:     elements</a>.</p>
                   5678: 
                   5679:    </dd>
                   5680: 
                   5681:    <dt id="adoptionAgency">An end tag whose tag name is one of: "a",
                   5682:    "b", "big", "code", "em", "font", "i", "nobr", "s", "small",
                   5683:    "strike", "strong", "tt", "u"</dt>
                   5684:    <dd>
                   5685: 
                   5686:     <p>Follow these steps:</p>
                   5687: 
                   5688:     <ol><li>
                   5689: 
                   5690:       <p>Let the <var title="">formatting element</var> be the
                   5691:       last element in the <a href="#list-of-active-formatting-elements">list of active formatting
                   5692:       elements</a> that:</p>
                   5693: 
                   5694:       <ul><li>is between the end of the list and the last scope
                   5695:        marker in the list, if any, or the start of the list
                   5696:        otherwise, and</li>
                   5697: 
                   5698:        <li>has the same tag name as the token.</li>
                   5699: 
                   5700:       </ul><p>If there is no such node, or, if that node is also in the
                   5701:       <a href="#stack-of-open-elements">stack of open elements</a> but the element is not <a href="#has-an-element-in-scope" title="has an element in scope">in scope</a>, then this is a
                   5702:       <a href="#parse-error">parse error</a>; ignore the token, and abort these
                   5703:       steps.</p>
                   5704: 
                   5705:       <p>Otherwise, if there is such a node, but that node is not
                   5706:       in the <a href="#stack-of-open-elements">stack of open elements</a>, then this is a
                   5707:       <a href="#parse-error">parse error</a>; remove the element from the list,
                   5708:       and abort these steps.</p>
                   5709: 
                   5710:       <p>Otherwise, there is a <var title="">formatting
                   5711:       element</var> and that element is in <a href="#stack-of-open-elements" title="stack of
                   5712:       open elements">the stack</a> and is <a href="#has-an-element-in-scope" title="has an
                   5713:       element in scope">in scope</a>. If the element is not the
                   5714:       <a href="#current-node">current node</a>, this is a <a href="#parse-error">parse
                   5715:       error</a>. In any case, proceed with the algorithm as
                   5716:       written in the following steps.</p>
                   5717: 
                   5718:      </li>
                   5719: 
                   5720:      <li><p>Let the <var title="">furthest block</var> be the
                   5721:      topmost node in the <a href="#stack-of-open-elements">stack of open elements</a> that
                   5722:      is lower in the stack than the <var title="">formatting
                   5723:      element</var>, and is not an element in the
                   5724:      <a href="#phrasing">phrasing</a> or <a href="#formatting">formatting</a>
                   5725:      categories. There might not be one.</p></li>
                   5726: 
                   5727:      <li><p>If there is no <var title="">furthest block</var>,
                   5728:      then the UA must skip the subsequent steps and instead just
                   5729:      pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of open
                   5730:      elements</a>, from the <a href="#current-node">current node</a> up to and
                   5731:      including the <var title="">formatting element</var>, and
                   5732:      remove the <var title="">formatting element</var> from the
                   5733:      <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</p></li>
                   5734: 
                   5735:      <li><p>Let the <var title="">common ancestor</var> be the element
                   5736:      immediately above the <var title="">formatting element</var> in the
                   5737:      <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
                   5738: 
                   5739:      <li><p>Let a bookmark note the position of the <var title="">formatting element</var> in the <a href="#list-of-active-formatting-elements">list of active
                   5740:      formatting elements</a> relative to the elements on either
                   5741:      side of it in the list.</p></li>
                   5742: 
                   5743:      <li>
                   5744: 
                   5745:       <p>Let <var title="">node</var> and <var title="">last node</var> be the
                   5746:       <var title="">furthest block</var>. Follow these steps:</p>
                   5747: 
                   5748:       <ol><li>Let <var title="">node</var> be the element immediately
                   5749:        above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
1.436     mike     5750:        elements</a>, or if <var title="">node</var> is no longer in
                   5751:        the <a href="#stack-of-open-elements">stack of open elements</a> (e.g. because it got
                   5752:        removed by the next step), the element that was immediately
                   5753:        above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
                   5754:        elements</a> before <var title="">node</var> was
                   5755:        removed.</li>
1.1       mike     5756: 
                   5757:        <li>If <var title="">node</var> is not in the <a href="#list-of-active-formatting-elements">list of
                   5758:        active formatting elements</a>, then remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of open
                   5759:        elements</a> and then go back to step 1.</li>
                   5760: 
                   5761:        <li>Otherwise, if <var title="">node</var> is the <var title="">formatting element</var>, then go to the next step
                   5762:        in the overall algorithm.</li>
                   5763: 
                   5764:        <li>Otherwise, if <var title="">last node</var> is the <var title="">furthest block</var>, then move the aforementioned
                   5765:        bookmark to be immediately after the <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
                   5766:        elements</a>.</li>
                   5767: 
                   5768:        <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
                   5769:        element <var title="">node</var> was created, replace the entry
                   5770:        for <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active
                   5771:        formatting elements</a> with an entry for the new element,
                   5772:        replace the entry for <var title="">node</var> in the
                   5773:        <a href="#stack-of-open-elements">stack of open elements</a> with an entry for the new
                   5774:        element, and let <var title="">node</var> be the new
                   5775:        element.</li>
                   5776: 
                   5777:        <li>Insert <var title="">last node</var> into <var title="">node</var>, first removing it from its previous
                   5778:        parent node if any.</li>
                   5779: 
                   5780:        <li>Let <var title="">last node</var> be <var title="">node</var>.</li>
                   5781: 
                   5782:        <li>Return to step 1 of this inner set of steps.</li>
                   5783: 
                   5784:       </ol></li>
                   5785: 
                   5786:      <li>
                   5787: 
                   5788:       <p>If the <var title="">common ancestor</var> node is a
                   5789:       <code><a href="tabular-data.html#the-table-element">table</a></code>, <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>, <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code>,
                   5790:       <code><a href="tabular-data.html#the-thead-element">thead</a></code>, or <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then,
                   5791:       <a href="#foster-parent">foster parent</a> whatever <var title="">last
                   5792:       node</var> ended up being in the previous step, first removing
                   5793:       it from its previous parent node if any.</p>
                   5794: 
                   5795:       <p>Otherwise, append whatever <var title="">last node</var>
                   5796:       ended up being in the previous step to the <var title="">common
                   5797:       ancestor</var> node, first removing it from its previous parent
                   5798:       node if any.</p>
                   5799: 
                   5800:      </li>
                   5801: 
                   5802:      <li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
                   5803:      <var title="">formatting element</var> was created.</p></li>
                   5804: 
                   5805:      <li><p>Take all of the child nodes of the <var title="">furthest
                   5806:      block</var> and append them to the element created in the last
                   5807:      step.</p></li>
                   5808: 
                   5809:      <li><p>Append that new element to the <var title="">furthest
                   5810:      block</var>.</p></li>
                   5811: 
                   5812:      <li><p>Remove the <var title="">formatting element</var> from the
                   5813:      <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, and insert the
                   5814:      new element into the <a href="#list-of-active-formatting-elements">list of active formatting
                   5815:      elements</a> at the position of the aforementioned
                   5816:      bookmark.</p></li>
                   5817: 
                   5818:      <li><p>Remove the <var title="">formatting element</var> from the
                   5819:      <a href="#stack-of-open-elements">stack of open elements</a>, and insert the new element
                   5820:      into the <a href="#stack-of-open-elements">stack of open elements</a> immediately below
                   5821:      the position of the <var title="">furthest block</var> in that
                   5822:      stack.</p></li>
                   5823: 
                   5824:      <li><p>Jump back to step 1 in this series of steps.</p></li>
                   5825: 
1.334     mike     5826:     </ol><p class="note">Because of the way this algorithm causes elements
1.304     mike     5827:     to change parents, it has been dubbed the "adoption agency
                   5828:     algorithm" (in contrast with other possible algorithms for dealing
                   5829:     with misnested content, which included the "incest algorithm", the
1.1       mike     5830:     "secret affair algorithm", and the "Heisenberg algorithm").</p>
                   5831: 
                   5832:    </dd>
                   5833: 
                   5834:    <dt>A start tag whose tag name is "button"</dt>
                   5835:    <dd>
                   5836: 
                   5837:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5838:     an element in scope">has a <code>button</code> element in
                   5839:     scope</a>, then this is a <a href="#parse-error">parse error</a>;
                   5840:     act as if an end tag with the tag name "button" had been seen,
                   5841:     then reprocess the token.</p>
                   5842: 
                   5843:     <p>Otherwise:</p>
                   5844: 
                   5845:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5846:     any.</p>
                   5847: 
                   5848:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5849: 
                   5850:     <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
                   5851:     formatting elements</a>.</p>
                   5852: 
                   5853:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   5854: 
                   5855:    </dd>
                   5856: 
                   5857:    <dt>A start tag token whose tag name is one of: "applet",
                   5858:    "marquee", "object"</dt>
                   5859:    <dd>
                   5860: 
                   5861:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5862:     any.</p>
                   5863: 
                   5864:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5865: 
                   5866:     <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
                   5867:     formatting elements</a>.</p>
                   5868: 
                   5869:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   5870: 
                   5871:    </dd>
                   5872: 
                   5873:    <dt>An end tag token whose tag name is one of: "applet", "button",
                   5874:    "marquee", "object"</dt>
                   5875:    <dd>
                   5876: 
                   5877:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-scope" title="has an element in scope">have an element in scope</a>
                   5878:     with the same tag name as that of the token, then this is a
                   5879:     <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5880: 
                   5881:     <p>Otherwise, run these steps:</p>
                   5882: 
                   5883:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   5884: 
                   5885:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5886:      the same tag name as that of the token, then this is a
                   5887:      <a href="#parse-error">parse error</a>.</p></li>
                   5888: 
                   5889:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5890:      until an element with the same tag name as the token has been
                   5891:      popped from the stack.</p></li>
                   5892: 
                   5893:      <li><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to the
                   5894:      last marker</a>.</li>
                   5895: 
                   5896:     </ol></dd>
                   5897: 
                   5898:    <dt>A start tag whose tag name is "table"</dt>
                   5899:    <dd>
                   5900: 
                   5901:     <p>If the <code>Document</code> is <em>not</em> set to
                   5902:     <a href="dom.html#quirks-mode">quirks mode</a>, and the <a href="#stack-of-open-elements">stack of open
                   5903:     elements</a> <a href="#has-an-element-in-scope" title="has an element in scope">has a
                   5904:     <code>p</code> element in scope</a>, then act as if an end tag
                   5905:     with the tag name "p" had been seen.</p> <!-- i hate myself (this
                   5906:     quirk was basically caused by acid2; if i'd realised we could
                   5907:     change the specs when i wrote acid2, we could have avoided having
                   5908:     any parsing-mode quirks) -Hixie -->
                   5909: 
                   5910:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5911: 
                   5912:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   5913: 
                   5914:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
                   5915: 
                   5916:    </dd>
                   5917: 
                   5918:    <dt>A start tag whose tag name is one of: "area", "basefont",
                   5919:    "bgsound", "br", "embed", "img", "input", "keygen", "spacer",
                   5920:    "wbr"</dt>
                   5921:    <dd>
                   5922: 
                   5923:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5924:     any.</p>
                   5925: 
                   5926:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   5927:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   5928:     elements</a>.</p>
                   5929: 
                   5930:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   5931:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   5932: 
                   5933:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p> <!--
                   5934:     shouldn't really do it for <area>, <basefont>, <bgsound>, and
                   5935:     <spacer> -->
                   5936: 
                   5937:    </dd>
                   5938: 
                   5939:    <dt>A start tag whose tag name is one of: "param", "source"</dt>
                   5940:    <dd>
                   5941: 
                   5942:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   5943:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   5944:     elements</a>.</p>
                   5945: 
                   5946:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   5947:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   5948: 
                   5949:    </dd>
                   5950: 
                   5951:    <dt>A start tag whose tag name is "hr"</dt>
                   5952:    <dd>
                   5953: 
                   5954:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5955:     an element in scope">has a <code>p</code> element in
                   5956:     scope</a>, then act as if an end tag with the tag name
                   5957:     "p" had been seen.</p>
                   5958: 
                   5959:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   5960:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   5961:     elements</a>.</p>
                   5962: 
                   5963:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   5964:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   5965: 
                   5966:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   5967: 
                   5968:    </dd>
                   5969: 
                   5970:    <dt>A start tag whose tag name is "image"</dt>
                   5971:    <dd>
                   5972:     <p><a href="#parse-error">Parse error</a>. Change the token's tag name
                   5973:     to "img" and reprocess it. (Don't ask.)</p> <!-- As of
                   5974:     2005-12, studies showed that around 0.2% of pages used the
                   5975:     <image> element. -->
                   5976:    </dd>
                   5977: 
                   5978:    <dt id="isindex">A start tag whose tag name is "isindex"</dt>
                   5979:    <dd>
                   5980: 
                   5981:     <p><a href="#parse-error">Parse error</a>.</p>
                   5982: 
                   5983:     <p>If the <a href="#form-element-pointer"><code title="">form</code> element
                   5984:     pointer</a> is not null, then ignore the token.</p>
                   5985: 
                   5986:     <p>Otherwise:</p>
                   5987: 
                   5988:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   5989:     token's <i>self-closing flag</i></a>, if it is set.</p> <!--
                   5990:     purely to reduce the number of errors (we don't care if they
                   5991:     included the /, they're not supposed to be including the tag at
                   5992:     all! -->
                   5993: 
                   5994:     <p>Act as if a start tag token with the tag name "form" had been seen.</p>
                   5995: 
                   5996:     <p>If the token has an attribute called "action", set the
                   5997:     <code title="attr-form-action">action</code> attribute on the
                   5998:     resulting <code><a href="forms.html#the-form-element">form</a></code> element to the value of the
                   5999:     "action" attribute of the token.</p>
                   6000: 
                   6001:     <p>Act as if a start tag token with the tag name "hr" had been
                   6002:     seen.</p>
                   6003: 
                   6004:     <p>Act as if a start tag token with the tag name "label" had been
                   6005:     seen.</p>
                   6006: 
                   6007:     <p>Act as if a stream of character tokens had been seen (see below
                   6008:     for what they should say).</p>
                   6009: 
                   6010:     <p>Act as if a start tag token with the tag name "input" had been
                   6011:     seen, with all the attributes from the "isindex" token except
                   6012:     "name", "action", and "prompt". Set the <code title="attr-fe-name"><a href="forms.html#attr-fe-name">name</a></code> attribute of the resulting
                   6013:     <code><a href="forms.html#the-input-element">input</a></code> element to the value "<code title="">isindex</code>".</p>
                   6014: 
                   6015:     <p>Act as if a stream of character tokens had been seen (see
                   6016:     below for what they should say).</p>
                   6017: 
                   6018:     <p>Act as if an end tag token with the tag name "label" had been
                   6019:     seen.</p>
                   6020: 
                   6021:     <p>Act as if a start tag token with the tag name "hr" had been
                   6022:     seen.</p>
                   6023: 
                   6024:     <p>Act as if an end tag token with the tag name "form" had been
                   6025:     seen.</p>
                   6026: 
                   6027:     <p>If the token has an attribute with the name "prompt", then the
                   6028:     first stream of characters must be the same string as given in
                   6029:     that attribute, and the second stream of characters must be
                   6030:     empty. Otherwise, the two streams of character tokens together
                   6031:     should, together with the <code><a href="forms.html#the-input-element">input</a></code> element, express the
                   6032:     equivalent of "This is a searchable index. Insert your search
                   6033:     keywords here: (input field)" in the user's preferred
                   6034:     language.</p>
                   6035: 
                   6036:    </dd>
                   6037: 
                   6038:    <dt>A start tag whose tag name is "textarea"</dt>
                   6039:    <dd>
                   6040: 
                   6041:     <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
                   6042:      token.</p></li>
                   6043: 
                   6044:      <li><p>If the next token is a U+000A LINE FEED (LF) character
                   6045:      token, then ignore that token and move on to the next
                   6046:      one. (Newlines at the start of <code><a href="forms.html#the-textarea-element">textarea</a></code> elements are
                   6047:      ignored as an authoring convenience.)</p></li>
                   6048: 
1.541     mike     6049:      <li><p>Switch the tokenizer to the the <a href="#rcdata-state">RCDATA
                   6050:      state</a>.</p></li>
1.1       mike     6051: 
                   6052:      <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the
                   6053:      current <a href="#insertion-mode">insertion mode</a>.</p>
                   6054: 
                   6055:      </li><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not
                   6056:      ok".</p></li>
                   6057: 
1.540     mike     6058:      <li><p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incdata" title="insertion mode: text">text</a>".</p></li>
1.1       mike     6059: 
                   6060:     </ol></dd>
                   6061: 
                   6062:    <dt>A start tag whose tag name is "xmp"</dt>
                   6063:    <dd>
                   6064: 
1.233     mike     6065:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   6066:     an element in scope">has a <code>p</code> element in
                   6067:     scope</a>, then act as if an end tag with the tag name
                   6068:     "p" had been seen.</p>
                   6069: 
1.1       mike     6070:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6071:     any.</p>
                   6072: 
                   6073:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6074: 
1.91      mike     6075:     <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1       mike     6076: 
                   6077:    </dd>
                   6078: 
                   6079:    <dt>A start tag whose tag name is "iframe"</dt>
                   6080:    <dd>
                   6081: 
                   6082:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6083: 
1.91      mike     6084:     <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1       mike     6085: 
                   6086:    </dd>
                   6087: 
                   6088:    <dt>A start tag whose tag name is "noembed"</dt>
                   6089:    <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
                   6090:    <dd>
                   6091: 
1.91      mike     6092:     <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1       mike     6093: 
                   6094:    </dd>
                   6095: 
                   6096:    <dt>A start tag whose tag name is "select"</dt>
                   6097:    <dd>
                   6098: 
                   6099:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6100:     any.</p>
                   6101: 
                   6102:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6103: 
                   6104:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6105: 
                   6106:     <p>If the <a href="#insertion-mode">insertion mode</a> is one of <a href="#parsing-main-intable" title="insertion mode: in table">in table</a>", "<a href="#parsing-main-incaption" title="insertion mode: in caption">in caption</a>", "<a href="#parsing-main-incolgroup" title="insertion mode: in column group">in column group</a>",
                   6107:     "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   6108:     body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in
                   6109:     row</a>", or "<a href="#parsing-main-intd" title="insertion mode: in cell">in
                   6110:     cell</a>", then switch the <a href="#insertion-mode">insertion mode</a> to
                   6111:     "<a href="#parsing-main-inselectintable" title="insertion mode: in select in table">in select in
                   6112:     table</a>". Otherwise, switch the <a href="#insertion-mode">insertion mode</a>
                   6113:     to "<a href="#parsing-main-inselect" title="insertion mode: in select">in select</a>".</p>
                   6114: 
                   6115:    </dd>
                   6116: 
                   6117:    <dt>A start tag whose tag name is one of: "optgroup", "option"</dt>
                   6118:    <dd>
                   6119: 
                   6120:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
                   6121:     element in scope">has an <code>option</code> element in
                   6122:     scope</a>, then act as if an end tag with the tag name "option"
                   6123:     had been seen.</p>
                   6124: 
                   6125:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6126:     any.</p>
                   6127: 
                   6128:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6129: 
                   6130:    </dd>
                   6131: 
                   6132:    <dt>A start tag whose tag name is one of: "rp", "rt"</dt>
                   6133:    <dd>
                   6134: 
                   6135:     <!-- the parsing rules for ruby really don't match IE much at all,
                   6136:          but in practice the markup used is very simple and so strict
                   6137:          compatibility with IE isn't required. For example, as defined
                   6138:          here we get very, very different behaviour than IE for
                   6139:          pathological cases like:
                   6140: 
                   6141:            <ruby><ol><li><p>a<rt>b
                   6142:            <ruby>a<rt>b<p>c
                   6143: 
                   6144:          But in practice most ruby markup falls into these cases:
                   6145: 
                   6146:            <ruby>a<rt>b</ruby>
                   6147:            <ruby>a<rp>b<rt>c<rp>d</ruby>
                   6148:            <ruby>a<rt>b</rt></ruby>
                   6149:            <ruby>a<rp>b</rp><rt>c</rt><rp>d</rp></ruby>
                   6150: 
                   6151:     -->
                   6152: 
                   6153:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
                   6154:     element in scope">has a <code>ruby</code> element in scope</a>,
                   6155:     then <a href="#generate-implied-end-tags">generate implied end tags</a>. If the <a href="#current-node">current
                   6156:     node</a> is not then a <code><a href="text-level-semantics.html#the-ruby-element">ruby</a></code> element, this is a
                   6157:     <a href="#parse-error">parse error</a>; pop all the nodes from the <a href="#current-node">current
                   6158:     node</a> up to the node immediately before the bottommost
                   6159:     <code><a href="text-level-semantics.html#the-ruby-element">ruby</a></code> element on the <a href="#stack-of-open-elements">stack of open
                   6160:     elements</a>.</p>
                   6161: 
                   6162:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6163: 
                   6164:    </dd>
                   6165: 
                   6166:    <dt>An end tag whose tag name is "br"</dt>
                   6167:    <dd>
                   6168:     <p><a href="#parse-error">Parse error</a>. Act as if a start tag token with
                   6169:     the tag name "br" had been seen. Ignore the end tag token.</p>
                   6170:    </dd>
                   6171: 
                   6172:    <dt>A start tag whose tag name is "math"</dt>
                   6173:    <dd>
                   6174: 
                   6175:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6176:     any.</p>
                   6177: 
                   6178:     <p><a href="#adjust-mathml-attributes">Adjust MathML attributes</a> for the token. (This
                   6179:     fixes the case of MathML attributes that are not all
                   6180:     lowercase.)</p>
                   6181: 
                   6182:     <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
                   6183:     fixes the use of namespaced attributes, in particular XLink.)</p>
                   6184: 
                   6185:     <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
                   6186:     <a href="#mathml-namespace">MathML namespace</a>.</p>
                   6187: 
                   6188:     <!-- If we ever change the frameset-ok flag to an insertion mode,
                   6189:     the following change would be implied, except we'd have to do it
                   6190:     even in the face of a self-closed tag:
                   6191:     <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
                   6192:     -->
                   6193: 
                   6194:     <p>If the token has its <i>self-closing flag</i> set, pop the
                   6195:     <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6196:     elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
                   6197:     flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
                   6198: 
                   6199:     <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
                   6200:     "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
                   6201:     content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
                   6202:     the current <a href="#insertion-mode">insertion mode</a>, and then switch the
                   6203:     <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
                   6204:     foreign content">in foreign content</a>".</p>
                   6205: 
                   6206:    </dd>
                   6207: 
                   6208:    <dt>A start tag whose tag name is "svg"</dt>
                   6209:    <dd>
                   6210: 
                   6211:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6212:     any.</p>
                   6213: 
                   6214:     <p><a href="#adjust-svg-attributes">Adjust SVG attributes</a> for the token. (This fixes
                   6215:     the case of SVG attributes that are not all lowercase.)</p>
                   6216: 
                   6217:     <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
                   6218:     fixes the use of namespaced attributes, in particular XLink in
                   6219:     SVG.)</p>
                   6220: 
                   6221:     <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
                   6222:     <a href="#svg-namespace">SVG namespace</a>.</p>
                   6223: 
                   6224:     <!-- If we ever change the frameset-ok flag to an insertion mode,
                   6225:     the following change would be implied, except we'd have to do it
                   6226:     even in the face of a self-closed tag:
                   6227:     <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
                   6228:     -->
                   6229: 
                   6230:     <p>If the token has its <i>self-closing flag</i> set, pop the
                   6231:     <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6232:     elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
                   6233:     flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
                   6234: 
                   6235:     <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
                   6236:     "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
                   6237:     content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
                   6238:     the current <a href="#insertion-mode">insertion mode</a>, and then switch the
                   6239:     <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
                   6240:     foreign content">in foreign content</a>".</p>
                   6241: 
                   6242:    </dd>
                   6243: 
                   6244:    <dt>A start <!--or end--> tag whose tag name is one of: "caption",
                   6245:    "col", "colgroup", "frame", "head", "tbody", "td", "tfoot", "th",
                   6246:    "thead", "tr"</dt>
                   6247:    <!--<dt>An end tag whose tag name is one of: "area", "base",
                   6248:    "basefont", "bgsound", "command", "embed", "hr", "iframe", "image",
                   6249:    "img", "input", "isindex", "keygen", "link", "meta", "noembed",
                   6250:    "noframes", "param", "script", "select", "source", "spacer",
                   6251:    "style", "table", "textarea", "title", "wbr"</dt>-->
                   6252:    <!--<dt>An end tag whose tag name is "noscript", if the
                   6253:    <span>scripting flag</span> is enabled</dt>-->
                   6254:    <dd>
                   6255:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6256:     <!-- end tags are commented out because since they can never end
                   6257:     up on the stack anyway, the default end tag clause will
                   6258:     automatically handle them. we don't want to have text in the spec
                   6259:     that is just an optimisation, as that detracts from the spec
                   6260:     itself -->
                   6261:    </dd>
                   6262: 
                   6263:    <dt>Any other start tag</dt>
                   6264:    <dd>
                   6265: 
                   6266:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6267:     any.</p>
                   6268: 
                   6269:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6270: 
                   6271:     <p class="note">This element will be a <a href="#phrasing">phrasing</a>
                   6272:     element.</p>
                   6273: 
                   6274:    </dd>
                   6275: 
                   6276:    <dt>Any other end tag</dt>
                   6277:    <dd>
                   6278: 
                   6279:     <p>Run the following steps:</p>
                   6280: 
                   6281:     <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
                   6282:      node</a> (the bottommost node of the stack).</p></li>
                   6283: 
                   6284:      <li><p>If <var title="">node</var> has the same tag name as
                   6285:      the end tag token, then:</p>
                   6286: 
                   6287:       <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   6288: 
                   6289:        <li><p>If the tag name of the end tag token does not match
                   6290:        the tag name of the <a href="#current-node">current node</a>, this is a
                   6291:        <a href="#parse-error">parse error</a>.</p></li>
                   6292: 
                   6293:        <li><p>Pop all the nodes from the <a href="#current-node">current node</a> up
                   6294:        to <var title="">node</var>, including <var title="">node</var>, then stop these steps.</p></li>
                   6295: 
                   6296:       </ol></li>
                   6297: 
                   6298:      <li><p>Otherwise, if <var title="">node</var> is in neither the
                   6299:      <a href="#formatting">formatting</a> category nor the <a href="#phrasing">phrasing</a>
                   6300:      category, then this is a <a href="#parse-error">parse error</a>; ignore the
                   6301:      token, and abort these steps.</p></li>
                   6302: 
                   6303:      <li><p>Set <var title="">node</var> to the previous entry in the
                   6304:      <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
                   6305: 
                   6306:      <li><p>Return to step 2.</p></li>
                   6307: 
                   6308:     </ol></dd>
                   6309: 
1.540     mike     6310:   </dl><h5 id="parsing-main-incdata"><span class="secno">9.2.5.11 </span>The "<dfn title="insertion mode: text">text</dfn>" insertion mode</h5>
1.1       mike     6311: 
                   6312:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incdata" title="insertion
1.540     mike     6313:   mode: text">text</a>", tokens must be handled as follows:</p>
1.1       mike     6314: 
                   6315:   <dl class="switch"><dt>A character token</dt>
                   6316:    <dd>
                   6317: 
                   6318:     <p><a href="#insert-a-character" title="insert a character">Insert the token's
                   6319:     character</a> into the <a href="#current-node">current node</a>.</p>
                   6320: 
                   6321:    </dd>
                   6322: 
                   6323:    <dt>An end-of-file token</dt>
                   6324:    <dd>
                   6325: 
                   6326:     <!-- can't be the fragment case -->
                   6327:     <p><a href="#parse-error">Parse error</a>.</p>
                   6328: 
                   6329:     <p>If the <a href="#current-node">current node</a> is a <code><a href="semantics.html#script">script</a></code>
1.484     mike     6330:     element, mark the <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
                   6331:     started"</a>.</p>
1.1       mike     6332: 
                   6333:     <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6334:     elements</a>.</p>
                   6335: 
                   6336:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
                   6337:     insertion mode</a> and reprocess the current token.</p>
                   6338: 
                   6339:    </dd>
                   6340: 
                   6341:    <dt>An end tag whose tag name is "script"</dt>
                   6342:    <dd>
                   6343: 
                   6344:     <p>Let <var title="">script</var> be the <a href="#current-node">current node</a>
                   6345:     (which will be a <code><a href="semantics.html#script">script</a></code> element).</p>
                   6346: 
                   6347:     <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6348:     elements</a>.</p>
                   6349: 
                   6350:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
                   6351:     insertion mode</a>.</p>
                   6352: 
                   6353:     <p>Let the <var title="">old insertion point</var> have the
                   6354:     same value as the current <a href="#insertion-point">insertion point</a>. Let
                   6355:     the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
                   6356:     input character</a>.</p>
                   6357: 
                   6358:     <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
                   6359:     one.</p>
                   6360: 
                   6361:     <p><a href="semantics.html#running-a-script" title="running a script">Run</a> the <var title="">script</var>. This might cause some script to execute,
1.159     mike     6362:     which might cause <a href="embedded-content-0.html#dom-document-write" title="dom-document-write">new characters
1.1       mike     6363:     to be inserted into the tokenizer</a>, and might cause the
                   6364:     tokenizer to output more tokens, resulting in a <a href="#nestedParsing">reentrant invocation of the parser</a>.</p>
                   6365: 
                   6366:     <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
                   6367:     one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
                   6368:     then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
                   6369: 
                   6370:     <p>Let the <a href="#insertion-point">insertion point</a> have the value of the <var title="">old insertion point</var>. (In other words, restore the
                   6371:     <a href="#insertion-point">insertion point</a> to its previous value. This value
                   6372:     might be the "undefined" value.)</p>
                   6373: 
                   6374:     <p id="scriptTagParserResumes">At this stage, if there is a
1.484     mike     6375:     <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking script</a>, then:</p>
1.1       mike     6376: 
                   6377:     <dl class="switch"><dt>If the <a href="#script-nesting-level">script nesting level</a> is not zero:</dt>
                   6378: 
                   6379:      <dd>
                   6380: 
                   6381:       <p>Set the <a href="#parser-pause-flag">parser pause flag</a> to true, and abort the
                   6382:       processing of any nested invocations of the tokenizer, yielding
                   6383:       control back to the caller. (Tokenization will resume when the
                   6384:       caller returns to the "outer" tree construction stage.)</p>
                   6385: 
                   6386:       <p class="note">The tree construction stage of this particular
                   6387:       parser is <a href="#nestedParsing">being called reentrantly</a>,
1.159     mike     6388:       say from a call to <code title="dom-document-write"><a href="embedded-content-0.html#dom-document-write">document.write()</a></code>.</p>
1.1       mike     6389: 
                   6390:      </dd>
                   6391: 
                   6392: 
                   6393:      <dt>Otherwise:</dt>
                   6394: 
                   6395:      <dd>
                   6396: 
                   6397:       <p>Follow these steps:</p>
                   6398: 
1.484     mike     6399:       <ol><li><p>Let <var title="">the script</var> be the <a href="semantics.html#pending-parsing-blocking-script">pending
                   6400:        parsing-blocking script</a>. There is no longer a <a href="semantics.html#pending-parsing-blocking-script">pending
                   6401:        parsing-blocking script</a>.</p></li>
                   6402: 
                   6403:        <li><p>Block the <a href="#tokenization" title="tokenization">tokenizer</a>
                   6404:        for this instance of the <a href="#html-parser">HTML parser</a>, such that
                   6405:        the <a href="browsers.html#event-loop">event loop</a> will not run <a href="browsers.html#concept-task" title="concept-task">tasks</a> that invoke the <a href="#tokenization" title="tokenization">tokenizer</a>.</p></li>
                   6406: 
                   6407:        <li><p><a href="browsers.html#spin-the-event-loop">Spin the event loop</a> until there is no <a href="semantics.html#a-style-sheet-blocking-scripts" title="a style sheet blocking scripts">style sheet blocking
                   6408:        scripts</a> and <var title="">the script</var>'s
                   6409:        <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag is set.</p></li>
                   6410: 
                   6411:        <li><p>Unblock the <a href="#tokenization" title="tokenization">tokenizer</a>
                   6412:        for this instance of the <a href="#html-parser">HTML parser</a>, such that
                   6413:        <a href="browsers.html#concept-task" title="concept-task">tasks</a> that invoke the <a href="#tokenization" title="tokenization">tokenizer</a> can again be
                   6414:        run.</p></li>
1.1       mike     6415: 
                   6416:        <li><p>Let the <a href="#insertion-point">insertion point</a> be just before the
                   6417:        <a href="#next-input-character">next input character</a>.</p></li>
                   6418: 
                   6419:        <li><p>Increment the parser's <a href="#script-nesting-level">script nesting level</a>
                   6420:        by one (it should be zero before this step, so this sets it to
                   6421:        one).</p></li>
                   6422: 
1.484     mike     6423:        <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a>
                   6424:        <var title="">the script</var>.</p></li>
1.1       mike     6425: 
                   6426:        <li><p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a>
                   6427:        by one. If the parser's <a href="#script-nesting-level">script nesting level</a> is
                   6428:        zero (which it always should be at this point), then set the
                   6429:        <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
                   6430: 
                   6431:        </li><li><p>Let the <a href="#insertion-point">insertion point</a> be undefined
                   6432:        again.</p></li>
                   6433: 
1.484     mike     6434:        <li><p>If there is once again a <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking
1.1       mike     6435:        script</a>, then repeat these steps from step 1.</p></li>
                   6436: 
                   6437:       </ol></dd>
                   6438: 
                   6439:     </dl></dd>
                   6440: 
                   6441:    <dt>Any other end tag</dt>
                   6442:    <dd>
                   6443: 
                   6444:     <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6445:     elements</a>.</p>
                   6446: 
                   6447:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
                   6448:     insertion mode</a>.</p>
                   6449: 
                   6450:    </dd>
                   6451: 
                   6452:   </dl><h5 id="parsing-main-intable"><span class="secno">9.2.5.12 </span>The "<dfn title="insertion mode: in table">in table</dfn>" insertion mode</h5>
                   6453: 
                   6454:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion
                   6455:   mode: in table">in table</a>", tokens must be handled as follows:</p>
                   6456: 
                   6457:   <dl class="switch"><dt>A character token</dt>
                   6458:    <dd>
                   6459: 
                   6460:      <p>Let the <dfn id="pending-table-character-tokens"><var>pending table character tokens</var></dfn>
                   6461:      be an empty list of tokens.</p>
                   6462: 
                   6463:      <p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
                   6464:      <a href="#insertion-mode">insertion mode</a>.</p>
                   6465: 
                   6466:      <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intabletext" title="insertion mode: in table text">in table text</a>" and
                   6467:      reprocess the token.</p>
                   6468: 
                   6469:    </dd>
                   6470: 
                   6471:    <dt>A comment token</dt>
                   6472:    <dd>
                   6473:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   6474:     node</a> with the <code title="">data</code> attribute set to
                   6475:     the data given in the comment token.</p>
                   6476:    </dd>
                   6477: 
                   6478:    <dt>A DOCTYPE token</dt>
                   6479:    <dd>
                   6480:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6481:    </dd>
                   6482: 
                   6483:    <dt>A start tag whose tag name is "caption"</dt>
                   6484:    <dd>
                   6485: 
                   6486:     <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
                   6487:     below.)</p>
                   6488: 
                   6489:     <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
                   6490:     formatting elements</a>.</p>
                   6491: 
                   6492:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
                   6493:     switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incaption" title="insertion mode: in caption">in caption</a>".</p>
                   6494: 
                   6495:    </dd>
                   6496: 
                   6497:    <dt>A start tag whose tag name is "colgroup"</dt>
                   6498:    <dd>
                   6499: 
                   6500:     <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
                   6501:     below.)</p>
                   6502: 
                   6503:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
                   6504:     switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incolgroup" title="insertion mode: in column group">in column
                   6505:     group</a>".</p>
                   6506: 
                   6507:    </dd>
                   6508: 
                   6509:    <dt>A start tag whose tag name is "col"</dt>
                   6510:    <dd>
                   6511:     <p>Act as if a start tag token with the tag name "colgroup"
                   6512:     had been seen, then reprocess the current token.</p>
                   6513:    </dd>
                   6514: 
                   6515:    <dt>A start tag whose tag name is one of: "tbody", "tfoot", "thead"</dt>
                   6516:    <dd>
                   6517: 
                   6518:     <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
                   6519:     below.)</p>
                   6520: 
                   6521:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
                   6522:     switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   6523:     body</a>".</p>
                   6524: 
                   6525:    </dd>
                   6526: 
                   6527:    <dt>A start tag whose tag name is one of: "td", "th", "tr"</dt>
                   6528:    <dd>
                   6529:     <p>Act as if a start tag token with the tag name "tbody" had
                   6530:     been seen, then reprocess the current token.</p>
                   6531:    </dd>
                   6532: 
                   6533:    <dt>A start tag whose tag name is "table"</dt>
                   6534:    <dd>
                   6535: 
                   6536:     <p><a href="#parse-error">Parse error</a>. Act as if an end tag token with
                   6537:     the tag name "table" had been seen, then, if that token wasn't
                   6538:     ignored, reprocess the current token.</p>
                   6539: 
                   6540:     <p class="note">The fake end tag token here can only be
                   6541:     ignored in the <a href="#fragment-case">fragment case</a>.</p>
                   6542: 
                   6543:    </dd>
                   6544: 
                   6545:    <dt>An end tag whose tag name is "table"</dt>
                   6546:    <dd>
                   6547: 
                   6548:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" title="has an element in table scope">have an element in table
                   6549:     scope</a> with the same tag name as the token, this is a
                   6550:     <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   6551:     case</a>)</p>
                   6552: 
                   6553:     <p>Otherwise:</p>
                   6554: 
                   6555:     <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-table-element">table</a></code>
                   6556:     element has been popped from the stack.</p>
                   6557: 
                   6558:     <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
                   6559: 
                   6560:    </dd>
                   6561: 
                   6562:    <dt>An end tag whose tag name is one of: "body", "caption",
                   6563:    "col", "colgroup", "html", "tbody", "td", "tfoot", "th",
                   6564:    "thead", "tr"</dt>
                   6565:    <dd>
                   6566:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6567:    </dd>
                   6568: 
                   6569:    <dt>A start tag whose tag name is one of: "style", "script"</dt>
                   6570:    <dd>
                   6571: 
                   6572:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inhead" title="insertion mode: in head">in head</a>" <a href="#insertion-mode">insertion
                   6573:     mode</a>.</p>
                   6574: 
                   6575:    </dd>
                   6576: 
                   6577:    <dt>A start tag whose tag name is "input"</dt>
                   6578:    <dd>
                   6579: 
                   6580:     <p>If the token does not have an attribute with the name "type",
                   6581:     or if it does, but that attribute's value is not an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   6582:     case-insensitive</a> match for the string "<code title="">hidden</code>", then: act as described in the "anything
                   6583:     else" entry below.</p>
                   6584: 
                   6585:     <p>Otherwise:</p>
                   6586: 
                   6587:     <p><a href="#parse-error">Parse error</a>.</p>
                   6588: 
                   6589:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6590: 
                   6591:     <p>Pop that <code><a href="forms.html#the-input-element">input</a></code> element off the <a href="#stack-of-open-elements">stack of
                   6592:     open elements</a>.</p>
                   6593: 
                   6594:    </dd>
                   6595: 
                   6596:    <dt>An end-of-file token</dt>
                   6597:    <dd>
                   6598: 
                   6599:     <p>If the <a href="#current-node">current node</a> is not the root
1.159     mike     6600:     <code><a href="semantics.html#the-html-element-0">html</a></code> element, then this is a <a href="#parse-error">parse
1.1       mike     6601:     error</a>.</p>
                   6602: 
                   6603:     <p class="note">It can only be the <a href="#current-node">current node</a> in
                   6604:     the <a href="#fragment-case">fragment case</a>.</p>
                   6605: 
                   6606:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   6607: 
                   6608:    </dd>
                   6609: 
                   6610:    <dt>Anything else</dt>
                   6611:    <dd>
                   6612: 
                   6613:     <p><a href="#parse-error">Parse error</a>. Process the token <a href="#using-the-rules-for">using the
                   6614:     rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
                   6615:     body</a>" <a href="#insertion-mode">insertion mode</a>, except that if the
                   6616:     <a href="#current-node">current node</a> is a <code><a href="tabular-data.html#the-table-element">table</a></code>,
                   6617:     <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>, <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code>, <code><a href="tabular-data.html#the-thead-element">thead</a></code>, or
                   6618:     <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then, whenever a node would be inserted
                   6619:     into the <a href="#current-node">current node</a>, it must instead be <a href="#foster-parent" title="foster parent">foster parented</a>.</p>
                   6620: 
                   6621:    </dd>
                   6622: 
                   6623:   </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-context">clear the stack
                   6624:   back to a table context</dfn>, it means that the UA must, while
                   6625:   the <a href="#current-node">current node</a> is not a <code><a href="tabular-data.html#the-table-element">table</a></code>
1.159     mike     6626:   element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1       mike     6627:   <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   6628: 
                   6629:   <p class="note">The <a href="#current-node">current node</a> being an
1.159     mike     6630:   <code><a href="semantics.html#the-html-element-0">html</a></code> element after this process is a <a href="#fragment-case">fragment
1.1       mike     6631:   case</a>.</p>
                   6632: 
                   6633: 
                   6634: 
                   6635:   <h5 id="parsing-main-intabletext"><span class="secno">9.2.5.13 </span>The "<dfn title="insertion mode: in table text">in table text</dfn>" insertion mode</h5>
                   6636: 
                   6637:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intabletext" title="insertion
                   6638:   mode: in table text">in table text</a>", tokens must be handled
                   6639:   as follows:</p>
                   6640: 
                   6641:   <dl class="switch"><dt>A character token</dt>
                   6642:    <dd>
                   6643: 
                   6644:     <p>Append the character token to the <var><a href="#pending-table-character-tokens">pending table character
                   6645:     tokens</a></var> list.</p>
                   6646: 
                   6647:    </dd>
                   6648: 
                   6649: 
                   6650:    <dt>Anything else</dt>
                   6651:    <dd>
                   6652: 
                   6653:     <p>If any of the tokens in the <var><a href="#pending-table-character-tokens">pending table character
                   6654:     tokens</a></var> list are character tokens that are not one of U+0009
                   6655:     CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED
                   6656:     (FF), <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE, then
                   6657:     reprocess those character tokens using the rules given in the
                   6658:     "anything else" entry in the <a href="#parsing-main-intable" title="insertion mode: in
                   6659:     table">in table</a>" insertion mode.</p>
                   6660: 
                   6661:     <p>Otherwise, <a href="#insert-a-character" title="insert a character">insert the
                   6662:     characters</a> given by the <var><a href="#pending-table-character-tokens">pending table character
                   6663:     tokens</a></var> list into the <a href="#current-node">current node</a>.</p>
                   6664: 
                   6665:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
                   6666:     insertion mode</a> and reprocess the token.</p>
                   6667: 
                   6668:    </dd>
                   6669: 
                   6670:   </dl><h5 id="parsing-main-incaption"><span class="secno">9.2.5.14 </span>The "<dfn title="insertion mode: in caption">in caption</dfn>" insertion mode</h5>
                   6671: 
                   6672:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incaption" title="insertion
                   6673:   mode: in caption">in caption</a>", tokens must be handled as follows:</p>
                   6674: 
                   6675:   <dl class="switch"><dt>An end tag whose tag name is "caption"</dt>
                   6676:    <dd>
                   6677: 
                   6678:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" title="has an element in table scope">have an element in table
                   6679:     scope</a> with the same tag name as the token, this is a
                   6680:     <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   6681:     case</a>)</p>
                   6682: 
                   6683:     <p>Otherwise:</p>
                   6684: 
                   6685:     <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
                   6686: 
                   6687:     <p>Now, if the <a href="#current-node">current node</a> is not a
                   6688:     <code><a href="tabular-data.html#the-caption-element">caption</a></code> element, then this is a <a href="#parse-error">parse
                   6689:     error</a>.</p>
                   6690: 
                   6691:     <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-caption-element">caption</a></code>
                   6692:     element has been popped from the stack.</p>
                   6693: 
                   6694:     <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
                   6695:     the last marker</a>.</p>
                   6696: 
                   6697:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
                   6698: 
                   6699:    </dd>
                   6700: 
                   6701:    <dt>A start tag whose tag name is one of: "caption", "col",
                   6702:    "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
                   6703:    <dt>An end tag whose tag name is "table"</dt>
                   6704:    <dd>
                   6705: 
                   6706:     <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
                   6707:     name "caption" had been seen, then, if that token wasn't
                   6708:     ignored, reprocess the current token.</p>
                   6709: 
                   6710:     <p class="note">The fake end tag token here can only be
                   6711:     ignored in the <a href="#fragment-case">fragment case</a>.</p>
                   6712: 
                   6713:    </dd>
                   6714: 
                   6715:    <dt>An end tag whose tag name is one of: "body", "col",
                   6716:    "colgroup", "html", "tbody", "td", "tfoot", "th", "thead",
                   6717:    "tr"</dt>
                   6718:    <dd>
                   6719:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6720:    </dd>
                   6721: 
                   6722:    <dt>Anything else</dt>
                   6723:    <dd>
                   6724:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" <a href="#insertion-mode">insertion
                   6725:     mode</a>.</p>
                   6726:    </dd>
                   6727: 
                   6728:   </dl><h5 id="parsing-main-incolgroup"><span class="secno">9.2.5.15 </span>The "<dfn title="insertion mode: in column group">in column group</dfn>" insertion mode</h5>
                   6729: 
                   6730:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incolgroup" title="insertion
                   6731:   mode: in column group">in column group</a>", tokens must be handled as follows:</p>
                   6732: 
                   6733:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   6734:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   6735:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   6736:    <dd>
                   6737:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   6738:     the <a href="#current-node">current node</a>.</p>
                   6739:    </dd>
                   6740: 
                   6741:    <dt>A comment token</dt>
                   6742:    <dd>
                   6743:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   6744:     node</a> with the <code title="">data</code> attribute set to
                   6745:     the data given in the comment token.</p>
                   6746:    </dd>
                   6747: 
                   6748:    <dt>A DOCTYPE token</dt>
                   6749:    <dd>
                   6750:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6751:    </dd>
                   6752: 
                   6753:    <dt>A start tag whose tag name is "html"</dt>
                   6754:    <dd>
                   6755:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" <a href="#insertion-mode">insertion
                   6756:     mode</a>.</p>
                   6757:    </dd>
                   6758: 
                   6759:    <dt>A start tag whose tag name is "col"</dt>
                   6760:    <dd>
                   6761: 
                   6762:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   6763:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6764:     elements</a>.</p>
                   6765: 
                   6766:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   6767:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   6768: 
                   6769:    </dd>
                   6770: 
                   6771:    <dt>An end tag whose tag name is "colgroup"</dt>
                   6772:    <dd>
                   6773: 
                   6774:     <p>If the <a href="#current-node">current node</a> is the root
1.159     mike     6775:     <code><a href="semantics.html#the-html-element-0">html</a></code> element, then this is a <a href="#parse-error">parse
1.1       mike     6776:     error</a>; ignore the token. (<a href="#fragment-case">fragment
                   6777:     case</a>)</p>
                   6778: 
                   6779:     <p>Otherwise, pop the <a href="#current-node">current node</a> (which will be
                   6780:     a <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element) from the <a href="#stack-of-open-elements">stack of open
                   6781:     elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
                   6782:     "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
                   6783: 
                   6784:    </dd>
                   6785: 
                   6786:    <dt>An end tag whose tag name is "col"</dt>
                   6787:    <dd>
                   6788:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6789:    </dd>
                   6790: 
                   6791:    <dt>An end-of-file token</dt>
                   6792:    <dd>
                   6793: 
1.159     mike     6794:     <p>If the <a href="#current-node">current node</a> is the root <code><a href="semantics.html#the-html-element-0">html</a></code>
1.1       mike     6795:     element, then <a href="#stop-parsing">stop parsing</a>. (<a href="#fragment-case">fragment
                   6796:     case</a>)</p>
                   6797: 
                   6798:     <p>Otherwise, act as described in the "anything else" entry
                   6799:     below.</p>
                   6800: 
                   6801:    </dd>
                   6802: 
                   6803:    <dt>Anything else</dt>
                   6804:    <dd>
                   6805: 
                   6806:     <p>Act as if an end tag with the tag name "colgroup" had been
                   6807:     seen, and then, if that token wasn't ignored, reprocess the
                   6808:     current token.</p>
                   6809: 
                   6810:     <p class="note">The fake end tag token here can only be
                   6811:     ignored in the <a href="#fragment-case">fragment case</a>.</p>
                   6812: 
                   6813:    </dd>
                   6814: 
                   6815:   </dl><h5 id="parsing-main-intbody"><span class="secno">9.2.5.16 </span>The "<dfn title="insertion mode: in table body">in table body</dfn>" insertion mode</h5>
                   6816: 
                   6817:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion
                   6818:   mode: in table body">in table body</a>", tokens must be handled as follows:</p>
                   6819: 
                   6820:   <dl class="switch"><dt>A start tag whose tag name is "tr"</dt>
                   6821:    <dd>
                   6822: 
                   6823:     <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
                   6824:     context</a>. (See below.)</p>
                   6825: 
                   6826:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
                   6827:     the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion mode:
                   6828:     in row">in row</a>".</p>
                   6829: 
                   6830:    </dd>
                   6831: 
                   6832:    <dt>A start tag whose tag name is one of: "th", "td"</dt>
                   6833:    <dd>
                   6834:     <p><a href="#parse-error">Parse error</a>. Act as if a start tag with
                   6835:     the tag name "tr" had been seen, then reprocess the current
                   6836:     token.</p>
                   6837:    </dd>
                   6838: 
                   6839:    <dt>An end tag whose tag name is one of: "tbody", "tfoot",
                   6840:    "thead"</dt>
                   6841:    <dd>
                   6842: 
                   6843:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" title="has an element in table scope">have an element in table
                   6844:     scope</a> with the same tag name as the token, this is a
                   6845:     <a href="#parse-error">parse error</a>. Ignore the token.</p>
                   6846: 
                   6847:     <p>Otherwise:</p>
                   6848: 
                   6849:     <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
                   6850:     context</a>. (See below.)</p>
                   6851: 
                   6852:     <p>Pop the <a href="#current-node">current node</a> from the <a href="#stack-of-open-elements">stack of
                   6853:     open elements</a>. Switch the <a href="#insertion-mode">insertion mode</a>
                   6854:     to "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
                   6855: 
                   6856:    </dd>
                   6857: 
                   6858:    <dt>A start tag whose tag name is one of: "caption", "col",
                   6859:    "colgroup", "tbody", "tfoot", "thead"</dt>
                   6860:    <dt>An end tag whose tag name is "table"</dt>
                   6861:    <dd>
                   6862: 
                   6863:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" title="has an element in table scope">have a
                   6864:     <code>tbody</code>, <code>thead</code>, or <code>tfoot</code>
                   6865:     element in table scope</a>, this is a <a href="#parse-error">parse
                   6866:     error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   6867:     case</a>)</p>
                   6868: 
                   6869:     <p>Otherwise:</p>
                   6870: 
                   6871:     <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
                   6872:     context</a>. (See below.)</p>
                   6873: 
                   6874:     <p>Act as if an end tag with the same tag name as the
                   6875:     <a href="#current-node">current node</a> ("tbody", "tfoot", or "thead") had
                   6876:     been seen, then reprocess the current token.</p>
                   6877: 
                   6878:    </dd>
                   6879: 
                   6880:    <dt>An end tag whose tag name is one of: "body", "caption",
                   6881:    "col", "colgroup", "html", "td", "th", "tr"</dt>
                   6882:    <dd>
                   6883:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6884:    </dd>
                   6885: 
                   6886:    <dt>Anything else</dt>
                   6887:    <dd>
                   6888:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>" <a href="#insertion-mode">insertion
                   6889:     mode</a>.</p>
                   6890:    </dd>
                   6891: 
                   6892:   </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-body-context">clear the stack
                   6893:   back to a table body context</dfn>, it means that the UA must,
                   6894:   while the <a href="#current-node">current node</a> is not a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>,
1.159     mike     6895:   <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code>, <code><a href="tabular-data.html#the-thead-element">thead</a></code>, or <code><a href="semantics.html#the-html-element-0">html</a></code>
1.1       mike     6896:   element, pop elements from the <a href="#stack-of-open-elements">stack of open
                   6897:   elements</a>.</p>
                   6898: 
                   6899:   <p class="note">The <a href="#current-node">current node</a> being an
1.159     mike     6900:   <code><a href="semantics.html#the-html-element-0">html</a></code> element after this process is a <a href="#fragment-case">fragment
1.1       mike     6901:   case</a>.</p>
                   6902: 
                   6903: 
                   6904:   <h5 id="parsing-main-intr"><span class="secno">9.2.5.17 </span>The "<dfn title="insertion mode: in row">in row</dfn>" insertion mode</h5>
                   6905: 
                   6906:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
                   6907:   mode: in row">in row</a>", tokens must be handled as follows:</p>
                   6908: 
                   6909:   <dl class="switch"><dt>A start tag whose tag name is one of: "th", "td"</dt>
                   6910:    <dd>
                   6911: 
                   6912:     <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
                   6913:     context</a>. (See below.)</p>
                   6914: 
                   6915:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
                   6916:     the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion mode:
                   6917:     in cell">in cell</a>".</p>
                   6918: 
                   6919:     <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
                   6920:     formatting elements</a>.</p>
                   6921: 
                   6922:    </dd>
                   6923: 
                   6924:    <dt>An end tag whose tag name is "tr"</dt>
                   6925:    <dd>
                   6926: 
                   6927:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" title="has an element in table scope">have an element in table
                   6928:     scope</a> with the same tag name as the token, this is a
                   6929:     <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   6930:     case</a>)</p>
                   6931: 
                   6932:     <p>Otherwise:</p>
                   6933: 
                   6934:     <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
                   6935:     context</a>. (See below.)</p>
                   6936: 
                   6937:     <p>Pop the <a href="#current-node">current node</a> (which will be a
                   6938:     <code><a href="tabular-data.html#the-tr-element">tr</a></code> element) from the <a href="#stack-of-open-elements">stack of open
                   6939:     elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
                   6940:     "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   6941:     body</a>".</p>
                   6942: 
                   6943:    </dd>
                   6944: 
                   6945:    <dt>A start tag whose tag name is one of: "caption", "col",
                   6946:    "colgroup", "tbody", "tfoot", "thead", "tr"</dt>
                   6947:    <dt>An end tag whose tag name is "table"</dt>
                   6948:    <dd>
                   6949: 
                   6950:     <p>Act as if an end tag with the tag name "tr" had been seen,
                   6951:     then, if that token wasn't ignored, reprocess the current
                   6952:     token.</p>
                   6953: 
                   6954:     <p class="note">The fake end tag token here can only be
                   6955:     ignored in the <a href="#fragment-case">fragment case</a>.</p>
                   6956: 
                   6957:    </dd>
                   6958: 
                   6959:    <dt>An end tag whose tag name is one of: "tbody", "tfoot",
                   6960:    "thead"</dt>
                   6961:    <dd>
                   6962: 
                   6963:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" title="has an element in table scope">have an element in table
                   6964:     scope</a> with the same tag name as the token, this is a
                   6965:     <a href="#parse-error">parse error</a>. Ignore the token.</p>
                   6966: 
                   6967:     <p>Otherwise, act as if an end tag with the tag name "tr" had
                   6968:     been seen, then reprocess the current token.</p>
                   6969: 
                   6970:    </dd>
                   6971: 
                   6972:    <dt>An end tag whose tag name is one of: "body", "caption",
                   6973:    "col", "colgroup", "html", "td", "th"</dt>
                   6974:    <dd>
                   6975:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6976:    </dd>
                   6977: 
                   6978:    <dt>Anything else</dt>
                   6979:    <dd>
                   6980:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>" <a href="#insertion-mode">insertion
                   6981:     mode</a>.</p>
                   6982:    </dd>
                   6983: 
                   6984:   </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-row-context">clear the stack
                   6985:   back to a table row context</dfn>, it means that the UA must,
                   6986:   while the <a href="#current-node">current node</a> is not a <code><a href="tabular-data.html#the-tr-element">tr</a></code>
1.159     mike     6987:   element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1       mike     6988:   <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   6989: 
                   6990:   <p class="note">The <a href="#current-node">current node</a> being an
1.159     mike     6991:   <code><a href="semantics.html#the-html-element-0">html</a></code> element after this process is a <a href="#fragment-case">fragment
1.1       mike     6992:   case</a>.</p>
                   6993: 
                   6994: 
                   6995:   <h5 id="parsing-main-intd"><span class="secno">9.2.5.18 </span>The "<dfn title="insertion mode: in cell">in cell</dfn>" insertion mode</h5>
                   6996: 
                   6997:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intd" title="insertion
                   6998:   mode: in cell">in cell</a>", tokens must be handled as follows:</p>
                   6999: 
                   7000:   <dl class="switch"><dt>An end tag whose tag name is one of: "td", "th"</dt>
                   7001:    <dd>
                   7002: 
                   7003:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" title="has an element in table scope">have an element in table
                   7004:     scope</a> with the same tag name as that of the token, then
                   7005:     this is a <a href="#parse-error">parse error</a> and the token must be
                   7006:     ignored.</p>
                   7007: 
                   7008:     <p>Otherwise:</p>
                   7009: 
                   7010:     <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
                   7011: 
                   7012:     <p>Now, if the <a href="#current-node">current node</a> is not an element
                   7013:     with the same tag name as the token, then this is a
                   7014:     <a href="#parse-error">parse error</a>.</p>
                   7015: 
                   7016:     <p>Pop elements from this stack until an element with the same
                   7017:     tag name as the token has been popped from the stack.</p>
                   7018: 
                   7019:     <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
                   7020:     the last marker</a>.</p>
                   7021: 
                   7022:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion mode: in row">in row</a>". (The
                   7023:     <a href="#current-node">current node</a> will be a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element at
                   7024:     this point.)</p>
                   7025: 
                   7026:    </dd>
                   7027: 
                   7028:    <dt>A start tag whose tag name is one of: "caption", "col",
                   7029:    "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
                   7030:    <dd>
                   7031: 
                   7032:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does
                   7033:     <em>not</em> <a href="#has-an-element-in-table-scope" title="has an element in table scope">have
                   7034:     a <code>td</code> or <code>th</code> element in table
                   7035:     scope</a>, then this is a <a href="#parse-error">parse error</a>; ignore
                   7036:     the token. (<a href="#fragment-case">fragment case</a>)</p>
                   7037: 
                   7038:     <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
                   7039:     reprocess the current token.</p>
                   7040: 
                   7041:    </dd>
                   7042: 
                   7043:    <dt>An end tag whose tag name is one of: "body", "caption",
                   7044:    "col", "colgroup", "html"</dt>
                   7045:    <dd>
                   7046:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7047:    </dd>
                   7048: 
                   7049:    <dt>An end tag whose tag name is one of: "table", "tbody",
                   7050:    "tfoot", "thead", "tr"</dt>
                   7051:    <dd>
                   7052: 
                   7053:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" title="has an element in table scope">have an element in table
                   7054:     scope</a> with the same tag name as that of the token
                   7055:     (which can only happen for "tbody", "tfoot" and "thead", or,
                   7056:     in the <a href="#fragment-case">fragment case</a>), then this is a <a href="#parse-error">parse
                   7057:     error</a> and the token must be ignored.</p>
                   7058: 
                   7059:     <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
                   7060:     reprocess the current token.</p>
                   7061: 
                   7062:    </dd>
                   7063: 
                   7064:    <dt>Anything else</dt>
                   7065:    <dd>
                   7066:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" <a href="#insertion-mode">insertion
                   7067:     mode</a>.</p>
                   7068:    </dd>
                   7069: 
                   7070:   </dl><p>Where the steps above say to <dfn id="close-the-cell">close the cell</dfn>, they
                   7071:   mean to run the following algorithm:</p>
                   7072: 
                   7073:   <ol><li><p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-table-scope" title="has an element in table scope">has a <code>td</code>
                   7074:    element in table scope</a>, then act as if an end tag token
                   7075:    with the tag name "td" had been seen.</p></li>
                   7076: 
                   7077:    <li><p>Otherwise, the <a href="#stack-of-open-elements">stack of open elements</a> will
                   7078:    <a href="#has-an-element-in-table-scope" title="has an element in table scope">have a
                   7079:    <code>th</code> element in table scope</a>; act as if an end
                   7080:    tag token with the tag name "th" had been seen.</p></li>
                   7081: 
                   7082:   </ol><p class="note">The <a href="#stack-of-open-elements">stack of open elements</a> cannot
                   7083:   have both a <code><a href="tabular-data.html#the-td-element">td</a></code> and a <code><a href="tabular-data.html#the-th-element">th</a></code> element <a href="#has-an-element-in-table-scope" title="has an element in table scope">in table scope</a> at
                   7084:   the same time, nor can it have neither when the <a href="#insertion-mode">insertion
                   7085:   mode</a> is "<a href="#parsing-main-intd" title="insertion mode: in cell">in
                   7086:   cell</a>".</p>
                   7087: 
                   7088: 
                   7089:   <h5 id="parsing-main-inselect"><span class="secno">9.2.5.19 </span>The "<dfn title="insertion mode: in select">in select</dfn>" insertion mode</h5>
                   7090: 
                   7091:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselect" title="insertion
                   7092:   mode: in select">in select</a>", tokens must be handled as follows:</p>
                   7093: 
                   7094:   <dl class="switch"><dt>A character token</dt>
                   7095:    <dd>
                   7096:     <p><a href="#insert-a-character" title="insert a character">Insert the token's
                   7097:     character</a> into the <a href="#current-node">current node</a>.</p>
                   7098:    </dd>
                   7099: 
                   7100:    <dt>A comment token</dt>
                   7101:    <dd>
                   7102:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   7103:     node</a> with the <code title="">data</code> attribute set to
                   7104:     the data given in the comment token.</p>
                   7105:    </dd>
                   7106: 
                   7107:    <dt>A DOCTYPE token</dt>
                   7108:    <dd>
                   7109:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7110:    </dd>
                   7111: 
                   7112:    <dt>A start tag whose tag name is "html"</dt>
                   7113:    <dd>
                   7114:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" <a href="#insertion-mode">insertion
                   7115:     mode</a>.</p>
                   7116:    </dd>
                   7117: 
                   7118:    <dt>A start tag whose tag name is "option"</dt>
                   7119:    <dd>
                   7120: 
                   7121:     <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
                   7122:     element, act as if an end tag with the tag name "option" had
                   7123:     been seen.</p>
                   7124: 
                   7125:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   7126: 
                   7127:    </dd>
                   7128: 
                   7129:    <dt>A start tag whose tag name is "optgroup"</dt>
                   7130:    <dd>
                   7131: 
                   7132:     <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
                   7133:     element, act as if an end tag with the tag name "option" had
                   7134:     been seen.</p>
                   7135: 
                   7136:     <p>If the <a href="#current-node">current node</a> is an
                   7137:     <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, act as if an end tag with the
                   7138:     tag name "optgroup" had been seen.</p>
                   7139: 
                   7140:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   7141: 
                   7142:    </dd>
                   7143: 
                   7144:    <dt>An end tag whose tag name is "optgroup"</dt>
                   7145:    <dd>
                   7146: 
                   7147:     <p>First, if the <a href="#current-node">current node</a> is an
                   7148:     <code><a href="forms.html#the-option-element">option</a></code> element, and the node immediately before
                   7149:     it in the <a href="#stack-of-open-elements">stack of open elements</a> is an
                   7150:     <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then act as if an end tag with
                   7151:     the tag name "option" had been seen.</p>
                   7152: 
                   7153:     <p>If the <a href="#current-node">current node</a> is an
                   7154:     <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then pop that node from the
                   7155:     <a href="#stack-of-open-elements">stack of open elements</a>. Otherwise, this is a
                   7156:     <a href="#parse-error">parse error</a>; ignore the token.</p>
                   7157: 
                   7158:    </dd>
                   7159: 
                   7160:    <dt>An end tag whose tag name is "option"</dt>
                   7161:    <dd>
                   7162: 
                   7163:     <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
                   7164:     element, then pop that node from the <a href="#stack-of-open-elements">stack of open
                   7165:     elements</a>. Otherwise, this is a <a href="#parse-error">parse
                   7166:     error</a>; ignore the token.</p>
                   7167: 
                   7168:    </dd>
                   7169: 
                   7170:    <dt>An end tag whose tag name is "select"</dt>
                   7171:    <dd>
                   7172: 
                   7173:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" title="has an element in table scope">have an element in table
                   7174:     scope</a> with the same tag name as the token, this is a
                   7175:     <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   7176:     case</a>)</p>
                   7177: 
                   7178:     <p>Otherwise:</p>
                   7179: 
                   7180:     <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   7181:     until a <code><a href="forms.html#the-select-element">select</a></code> element has been popped from the
                   7182:     stack.</p>
                   7183: 
                   7184:     <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
                   7185: 
                   7186:    </dd>
                   7187: 
                   7188:    <dt>A start tag whose tag name is "select"</dt>
                   7189:    <dd>
                   7190: 
                   7191:     <p><a href="#parse-error">Parse error</a>. Act as if the token had been
                   7192:     an end tag with the tag name "select" instead.</p>
                   7193: 
                   7194:    </dd>
                   7195: 
                   7196:    <dt>A start tag whose tag name is one of: "input", "keygen", "textarea"</dt>
                   7197:    <dd>
1.73      mike     7198: 
                   7199:     <p><a href="#parse-error">Parse error</a>.</p>
                   7200: 
1.124     mike     7201:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does not <a href="#has-an-element-in-table-scope" title="has an element in table scope">have a <code>select</code>
                   7202:     element in table scope</a>, ignore the token. (<a href="#fragment-case">fragment
                   7203:     case</a>)</p>
1.73      mike     7204: 
                   7205:     <p>Otherwise, act as if an end tag with the tag name "select" had
                   7206:     been seen, and reprocess the token.</p>
                   7207: 
1.1       mike     7208:    </dd>
                   7209: 
                   7210:    <dt>A start tag token whose tag name is "script"</dt>
                   7211:    <dd>
                   7212:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inhead" title="insertion mode: in head">in head</a>" <a href="#insertion-mode">insertion
                   7213:     mode</a>.</p>
                   7214:    </dd>
                   7215: 
                   7216:    <dt>An end-of-file token</dt>
                   7217:    <dd>
                   7218: 
                   7219:     <p>If the <a href="#current-node">current node</a> is not the root
1.159     mike     7220:     <code><a href="semantics.html#the-html-element-0">html</a></code> element, then this is a <a href="#parse-error">parse
1.1       mike     7221:     error</a>.</p>
                   7222: 
                   7223:     <p class="note">It can only be the <a href="#current-node">current node</a> in
                   7224:     the <a href="#fragment-case">fragment case</a>.</p>
                   7225: 
                   7226:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7227: 
                   7228:    </dd>
                   7229: 
                   7230:    <dt>Anything else</dt>
                   7231:    <dd>
                   7232:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7233:    </dd>
                   7234: 
                   7235:   </dl><h5 id="parsing-main-inselectintable"><span class="secno">9.2.5.20 </span>The "<dfn title="insertion mode: in select in table">in select in table</dfn>" insertion mode</h5>
                   7236: 
                   7237:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselectintable" title="insertion
                   7238:   mode: in select in table">in select in table</a>", tokens must be handled as follows:</p>
                   7239: 
                   7240:   <dl class="switch"><dt>A start tag whose tag name is one of: "caption", "table",
                   7241:    "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
                   7242:    <dd>
                   7243:     <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
                   7244:     name "select" had been seen, and reprocess the token.</p>
                   7245:    </dd>
                   7246: 
                   7247:    <dt>An end tag whose tag name is one of: "caption", "table",
                   7248:    "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
                   7249:    <dd>
                   7250: 
                   7251:     <p><a href="#parse-error">Parse error</a>.</p>
                   7252: 
                   7253:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-table-scope">has an
                   7254:     element in table scope</a> with the same tag name as that
                   7255:     of the token, then act as if an end tag with the tag name
                   7256:     "select" had been seen, and reprocess the token. Otherwise,
                   7257:     ignore the token.</p>
                   7258: 
                   7259:    </dd>
                   7260: 
                   7261:    <dt>Anything else</dt>
                   7262:    <dd>
                   7263:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inselect" title="insertion mode: in select">in select</a>" <a href="#insertion-mode">insertion
                   7264:     mode</a>.</p>
                   7265:    </dd>
                   7266: 
1.168     mike     7267:   </dl><h5 id="parsing-main-inforeign"><span class="secno">9.2.5.21 </span>The "<dfn title="insertion mode: in foreign content">in foreign content</dfn>" insertion mode</h5>
1.1       mike     7268: 
                   7269:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inforeign" title="insertion
                   7270:   mode: in foreign content">in foreign content</a>", tokens must be
                   7271:   handled as follows:</p>
                   7272: 
                   7273:   <dl class="switch"><dt>A character token</dt>
                   7274:    <dd>
                   7275: 
                   7276:     <p><a href="#insert-a-character" title="insert a character">Insert the token's
                   7277:     character</a> into the <a href="#current-node">current node</a>.</p>
                   7278: 
                   7279:     <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
                   7280:     LINE FEED (LF), U+000C FORM FEED (FF), <!--U+000D CARRIAGE RETURN
                   7281:     (CR),--> or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
                   7282:     flag</a> to "not ok".</p>
                   7283: 
                   7284:    </dd>
                   7285: 
                   7286:    <dt>A comment token</dt>
                   7287:    <dd>
                   7288:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   7289:     node</a> with the <code title="">data</code> attribute set to
                   7290:     the data given in the comment token.</p>
                   7291:    </dd>
                   7292: 
                   7293:    <dt>A DOCTYPE token</dt>
                   7294:    <dd>
                   7295:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7296:    </dd>
                   7297: 
                   7298:    <dt>An end tag whose tag name is "script", if the <a href="#current-node">current node</a> is a <code title="">script</code> element in the <a href="#svg-namespace">SVG namespace</a>.</dt>
                   7299:    <dd>
                   7300: 
                   7301:     <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   7302:     elements</a>.</p>
                   7303: 
                   7304:     <p>Let the <var title="">old insertion point</var> have the
                   7305:     same value as the current <a href="#insertion-point">insertion point</a>. Let
                   7306:     the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
                   7307:     input character</a>.</p>
                   7308: 
                   7309:     <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
                   7310:     one. Set the <a href="#parser-pause-flag">parser pause flag</a> to true.</p>
                   7311: 
                   7312:     <p><a href="http://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing">Process
                   7313:     the <code title="">script</code> element</a> according to the SVG
1.187     mike     7314:     rules, if the user agent supports SVG. <a href="references.html#refsSVG">[SVG]</a></p>
1.1       mike     7315: 
1.159     mike     7316:     <p class="note">Even if this causes <a href="embedded-content-0.html#dom-document-write" title="dom-document-write">new characters to be inserted into the
1.1       mike     7317:     tokenizer</a>, the parser will not be executed reentrantly,
                   7318:     since the <a href="#parser-pause-flag">parser pause flag</a> is true.</p>
                   7319: 
                   7320:     <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
                   7321:     one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
                   7322:     then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
                   7323: 
                   7324:     <p>Let the <a href="#insertion-point">insertion point</a> have the value of the <var title="">old insertion point</var>. (In other words, restore the
                   7325:     <a href="#insertion-point">insertion point</a> to its previous value. This value
                   7326:     might be the "undefined" value.)</p>
                   7327: 
                   7328:    </dd>
                   7329: 
                   7330:    <dt>A start tag whose tag name is neither "mglyph" nor "malignmark", if the <a href="#current-node">current node</a> is an <code title="">mi</code> element in the <a href="#mathml-namespace">MathML namespace</a>.</dt>
                   7331:    <dt>A start tag whose tag name is neither "mglyph" nor "malignmark", if the <a href="#current-node">current node</a> is an <code title="">mo</code> element in the <a href="#mathml-namespace">MathML namespace</a>.</dt>
                   7332:    <dt>A start tag whose tag name is neither "mglyph" nor "malignmark", if the <a href="#current-node">current node</a> is an <code title="">mn</code> element in the <a href="#mathml-namespace">MathML namespace</a>.</dt>
                   7333:    <dt>A start tag whose tag name is neither "mglyph" nor "malignmark", if the <a href="#current-node">current node</a> is an <code title="">ms</code> element in the <a href="#mathml-namespace">MathML namespace</a>.</dt>
                   7334:    <dt>A start tag whose tag name is neither "mglyph" nor "malignmark", if the <a href="#current-node">current node</a> is an <code title="">mtext</code> element in the <a href="#mathml-namespace">MathML namespace</a>.</dt>
                   7335:    <dt>A start tag whose tag name is "svg", if the <a href="#current-node">current node</a> is an <code title="">annotation-xml</code> element in the <a href="#mathml-namespace">MathML namespace</a>.</dt>
                   7336:    <dt>A start tag, if the <a href="#current-node">current node</a> is a <code title="">foreignObject</code> element in the <a href="#svg-namespace">SVG namespace</a>.</dt>
                   7337:    <dt>A start tag, if the <a href="#current-node">current node</a> is a <code title="">desc</code> element in the <a href="#svg-namespace">SVG namespace</a>.</dt>
                   7338:    <dt>A start tag, if the <a href="#current-node">current node</a> is a <code title="">title</code> element in the <a href="#svg-namespace">SVG namespace</a>.</dt>
                   7339:    <dt>A start tag, if the <a href="#current-node">current node</a> is an element in the <a href="#html-namespace-0">HTML namespace</a>.</dt>
                   7340:    <dt>An end tag</dt>
                   7341:    <dd>
                   7342: 
                   7343:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the
                   7344:     <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
                   7345: 
                   7346:     <p>If, after doing so, the <a href="#insertion-mode">insertion mode</a> is still
                   7347:     "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
1.336     mike     7348:     content</a>", but there is no element <a href="#has-an-element-in-scope" title="has an
                   7349:     element in scope">in scope</a> that has a namespace other than
                   7350:     the <a href="#html-namespace-0">HTML namespace</a>, switch the <a href="#insertion-mode">insertion
1.1       mike     7351:     mode</a> to the <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
                   7352: 
                   7353:    </dd>
                   7354: 
                   7355:    <dt>A start tag whose tag name is one of: <!--"a",--> "b", "big",
                   7356:    "blockquote", "body"<!--by inspection-->, "br", "center", "code",
1.422     mike     7357:    "dd", "div", "dl", "dt"<!-- so that dd and dt can be handled
                   7358:    uniformly throughout the parser -->, "em", "embed", "h1", "h2",
                   7359:    "h3", "h4"<!--for completeness-->, "h5", "h6"<!--for
1.1       mike     7360:    completeness-->, "head"<!--by inspection-->, "hr", "i", "img",
                   7361:    "li", "listing"<!-- so that pre and listing can be handled
                   7362:    uniformly throughout the parser -->, "menu", "meta", "nobr",
                   7363:    "ol"<!-- so that dl, ul, and ol can be handled uniformly throughout
                   7364:    the parser -->, "p", "pre", "ruby", "s", <!--"script",--> "small",
                   7365:    "span", "strong", "strike"<!-- so that s and strike can be handled
                   7366:    uniformly throughout the parser -->, <!--"style",--> "sub", "sup",
1.305     mike     7367:    "table"<!--by inspection-->, "tt", "u", "ul", "var"</dt> <!-- this
                   7368:    list was determined empirically by studying over 6,000,000,000
1.422     mike     7369:    pages that were specifically not XML pages -->
                   7370:    <dt>A start tag whose tag name is "font", if the token has any
                   7371:    attributes named "color", "face", or "size"</dt> <!-- the
                   7372:    attributes here are required so that SVG <font> will go through as
                   7373:    SVG but legacy <font>s won't -->
                   7374:    <dt>An end-of-file token</dt> <dd>
1.1       mike     7375: 
                   7376:     <p><a href="#parse-error">Parse error</a>.</p>
                   7377: 
                   7378:     <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a> until
                   7379:     the <a href="#current-node">current node</a> is in the <a href="#html-namespace-0">HTML
                   7380:     namespace</a>.</p>
                   7381: 
                   7382:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#secondary-insertion-mode">secondary
                   7383:     insertion mode</a>, and reprocess the token.</p>
                   7384: 
                   7385:    </dd>
                   7386: 
                   7387:    <dt>Any other start tag</dt>
                   7388:    <dd>
                   7389: 
                   7390:     <p>If the <a href="#current-node">current node</a> is an element in the
                   7391:     <a href="#mathml-namespace">MathML namespace</a>, <a href="#adjust-mathml-attributes">adjust MathML
                   7392:     attributes</a> for the token. (This fixes the case of MathML
                   7393:     attributes that are not all lowercase.)</p>
                   7394: 
                   7395:     <p>If the <a href="#current-node">current node</a> is an element in the <a href="#svg-namespace">SVG
                   7396:     namespace</a>, and the token's tag name is one of the ones in
                   7397:     the first column of the following table, change the tag name to
                   7398:     the name given in the corresponding cell in the second
                   7399:     column. (This fixes the case of SVG elements that are not all
                   7400:     lowercase.)</p>
                   7401: 
                   7402:     <table><thead><tr><th> Tag name </th><th> Element name
                   7403:      </th></tr></thead><tbody><tr><td> <code title="">altglyph</code> </td><td> <code title="">altGlyph</code>
                   7404:       </td></tr><tr><td> <code title="">altglyphdef</code> </td><td> <code title="">altGlyphDef</code>
                   7405:       </td></tr><tr><td> <code title="">altglyphitem</code> </td><td> <code title="">altGlyphItem</code>
                   7406:       </td></tr><tr><td> <code title="">animatecolor</code> </td><td> <code title="">animateColor</code>
                   7407:       </td></tr><tr><td> <code title="">animatemotion</code> </td><td> <code title="">animateMotion</code>
                   7408:       </td></tr><tr><td> <code title="">animatetransform</code> </td><td> <code title="">animateTransform</code>
                   7409:       </td></tr><tr><td> <code title="">clippath</code> </td><td> <code title="">clipPath</code>
                   7410:       </td></tr><tr><td> <code title="">feblend</code> </td><td> <code title="">feBlend</code>
                   7411:       </td></tr><tr><td> <code title="">fecolormatrix</code> </td><td> <code title="">feColorMatrix</code>
                   7412:       </td></tr><tr><td> <code title="">fecomponenttransfer</code> </td><td> <code title="">feComponentTransfer</code>
                   7413:       </td></tr><tr><td> <code title="">fecomposite</code> </td><td> <code title="">feComposite</code>
                   7414:       </td></tr><tr><td> <code title="">feconvolvematrix</code> </td><td> <code title="">feConvolveMatrix</code>
                   7415:       </td></tr><tr><td> <code title="">fediffuselighting</code> </td><td> <code title="">feDiffuseLighting</code>
                   7416:       </td></tr><tr><td> <code title="">fedisplacementmap</code> </td><td> <code title="">feDisplacementMap</code>
                   7417:       </td></tr><tr><td> <code title="">fedistantlight</code> </td><td> <code title="">feDistantLight</code>
                   7418:       </td></tr><tr><td> <code title="">feflood</code> </td><td> <code title="">feFlood</code>
                   7419:       </td></tr><tr><td> <code title="">fefunca</code> </td><td> <code title="">feFuncA</code>
                   7420:       </td></tr><tr><td> <code title="">fefuncb</code> </td><td> <code title="">feFuncB</code>
                   7421:       </td></tr><tr><td> <code title="">fefuncg</code> </td><td> <code title="">feFuncG</code>
                   7422:       </td></tr><tr><td> <code title="">fefuncr</code> </td><td> <code title="">feFuncR</code>
                   7423:       </td></tr><tr><td> <code title="">fegaussianblur</code> </td><td> <code title="">feGaussianBlur</code>
                   7424:       </td></tr><tr><td> <code title="">feimage</code> </td><td> <code title="">feImage</code>
                   7425:       </td></tr><tr><td> <code title="">femerge</code> </td><td> <code title="">feMerge</code>
                   7426:       </td></tr><tr><td> <code title="">femergenode</code> </td><td> <code title="">feMergeNode</code>
                   7427:       </td></tr><tr><td> <code title="">femorphology</code> </td><td> <code title="">feMorphology</code>
                   7428:       </td></tr><tr><td> <code title="">feoffset</code> </td><td> <code title="">feOffset</code>
                   7429:       </td></tr><tr><td> <code title="">fepointlight</code> </td><td> <code title="">fePointLight</code>
                   7430:       </td></tr><tr><td> <code title="">fespecularlighting</code> </td><td> <code title="">feSpecularLighting</code>
                   7431:       </td></tr><tr><td> <code title="">fespotlight</code> </td><td> <code title="">feSpotLight</code>
                   7432:       </td></tr><tr><td> <code title="">fetile</code> </td><td> <code title="">feTile</code>
                   7433:       </td></tr><tr><td> <code title="">feturbulence</code> </td><td> <code title="">feTurbulence</code>
                   7434:       </td></tr><tr><td> <code title="">foreignobject</code> </td><td> <code title="">foreignObject</code>
                   7435:       </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
                   7436:       </td></tr><tr><td> <code title="">lineargradient</code> </td><td> <code title="">linearGradient</code>
                   7437:       </td></tr><tr><td> <code title="">radialgradient</code> </td><td> <code title="">radialGradient</code>
                   7438:       <!--<tr> <td> <code title="">solidcolor</code> <td> <code title="">solidColor</code> (SVG 1.2)-->
                   7439:       </td></tr><tr><td> <code title="">textpath</code> </td><td> <code title="">textPath</code>
                   7440:     </td></tr></tbody></table><p>If the <a href="#current-node">current node</a> is an element in the <a href="#svg-namespace">SVG
                   7441:     namespace</a>, <a href="#adjust-svg-attributes">adjust SVG attributes</a> for the
                   7442:     token. (This fixes the case of SVG attributes that are not all
                   7443:     lowercase.)</p>
                   7444: 
                   7445:     <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
                   7446:     fixes the use of namespaced attributes, in particular XLink in
                   7447:     SVG.)</p>
                   7448: 
                   7449:     <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
                   7450:     same namespace as the <a href="#current-node">current node</a>.</p>
                   7451: 
                   7452:     <p>If the token has its <i>self-closing flag</i> set, pop the
                   7453:     <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   7454:     elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
                   7455:     flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
                   7456: 
                   7457:    </dd>
                   7458: 
                   7459:   </dl><h5 id="parsing-main-afterbody"><span class="secno">9.2.5.22 </span>The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h5>
                   7460: 
                   7461:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterbody" title="insertion
                   7462:   mode: after body">after body</a>", tokens must be handled as follows:</p>
                   7463: 
                   7464:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   7465:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   7466:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   7467:    <dd>
                   7468:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" <a href="#insertion-mode">insertion
                   7469:     mode</a>.</p>
                   7470:    </dd>
                   7471: 
                   7472:    <dt>A comment token</dt>
                   7473:    <dd>
                   7474:     <p>Append a <code>Comment</code> node to the first element in
1.159     mike     7475:     the <a href="#stack-of-open-elements">stack of open elements</a> (the <code><a href="semantics.html#the-html-element-0">html</a></code>
1.1       mike     7476:     element), with the <code title="">data</code> attribute set to
                   7477:     the data given in the comment token.</p>
                   7478:    </dd>
                   7479: 
                   7480:    <dt>A DOCTYPE token</dt>
                   7481:    <dd>
                   7482:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7483:    </dd>
                   7484: 
                   7485:    <dt>A start tag whose tag name is "html"</dt>
                   7486:    <dd>
                   7487:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" <a href="#insertion-mode">insertion
                   7488:     mode</a>.</p>
                   7489:    </dd>
                   7490: 
                   7491:    <dt>An end tag whose tag name is "html"</dt>
                   7492:    <dd>
                   7493: 
                   7494:     <p>If the parser was originally created as part of the <a href="#html-fragment-parsing-algorithm">HTML
                   7495:     fragment parsing algorithm</a>, this is a <a href="#parse-error">parse
                   7496:     error</a>; ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
                   7497: 
                   7498:     <p>Otherwise, switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#the-after-after-body-insertion-mode" title="insertion mode: after after body">after after
                   7499:     body</a>".</p>
                   7500: 
                   7501:    </dd>
                   7502: 
                   7503:    <dt>An end-of-file token</dt>
                   7504:    <dd>
                   7505:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7506:    </dd>
                   7507: 
                   7508:    <dt>Anything else</dt>
                   7509:    <dd>
                   7510: 
                   7511:     <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion
                   7512:     mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in body">in
                   7513:     body</a>" and reprocess the token.</p>
                   7514: 
                   7515:    </dd>
                   7516: 
                   7517:   </dl><h5 id="parsing-main-inframeset"><span class="secno">9.2.5.23 </span>The "<dfn title="insertion mode: in frameset">in frameset</dfn>" insertion mode</h5>
                   7518: 
                   7519:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inframeset" title="insertion
                   7520:   mode: in frameset">in frameset</a>", tokens must be handled as follows:</p>
                   7521: 
                   7522:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   7523:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   7524:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   7525:    <dd>
                   7526:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   7527:     the <a href="#current-node">current node</a>.</p>
                   7528:    </dd>
                   7529: 
                   7530:    <dt>A comment token</dt>
                   7531:    <dd>
                   7532:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   7533:     node</a> with the <code title="">data</code> attribute set to
                   7534:     the data given in the comment token.</p>
                   7535:    </dd>
                   7536: 
                   7537:    <dt>A DOCTYPE token</dt>
                   7538:    <dd>
                   7539:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7540:    </dd>
                   7541: 
                   7542:    <dt>A start tag whose tag name is "html"</dt>
                   7543:    <dd>
                   7544:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" <a href="#insertion-mode">insertion
                   7545:     mode</a>.</p>
                   7546:    </dd>
                   7547: 
                   7548:    <dt>A start tag whose tag name is "frameset"</dt>
                   7549:    <dd>
                   7550:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   7551:    </dd>
                   7552: 
                   7553:    <dt>An end tag whose tag name is "frameset"</dt>
                   7554:    <dd>
                   7555: 
                   7556:     <p>If the <a href="#current-node">current node</a> is the root
1.159     mike     7557:     <code><a href="semantics.html#the-html-element-0">html</a></code> element, then this is a <a href="#parse-error">parse
1.1       mike     7558:     error</a>; ignore the token. (<a href="#fragment-case">fragment
                   7559:     case</a>)</p>
                   7560: 
                   7561:     <p>Otherwise, pop the <a href="#current-node">current node</a> from the
                   7562:     <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   7563: 
                   7564:     <p>If the parser was <em>not</em> originally created as part
                   7565:     of the <a href="#html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>
                   7566:     (<a href="#fragment-case">fragment case</a>), and the <a href="#current-node">current
1.5       mike     7567:     node</a> is no longer a <code><a href="obsolete.html#frameset">frameset</a></code> element, then
1.1       mike     7568:     switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-afterframeset" title="insertion mode: after frameset">after
                   7569:     frameset</a>".</p>
                   7570: 
                   7571:    </dd>
                   7572: 
                   7573:    <dt>A start tag whose tag name is "frame"</dt>
                   7574:    <dd>
                   7575: 
                   7576:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.
                   7577:     Immediately pop the <a href="#current-node">current node</a> off the
                   7578:     <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   7579: 
                   7580:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   7581:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   7582: 
                   7583:    </dd>
                   7584: 
                   7585:    <dt>A start tag whose tag name is "noframes"</dt>
                   7586:    <dd>
                   7587:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inhead" title="insertion mode: in head">in head</a>" <a href="#insertion-mode">insertion
                   7588:     mode</a>.</p>
                   7589:    </dd>
                   7590: 
                   7591:    <dt>An end-of-file token</dt>
                   7592:    <dd>
                   7593: 
                   7594:     <p>If the <a href="#current-node">current node</a> is not the root
1.159     mike     7595:     <code><a href="semantics.html#the-html-element-0">html</a></code> element, then this is a <a href="#parse-error">parse
1.1       mike     7596:     error</a>.</p>
                   7597: 
                   7598:     <p class="note">It can only be the <a href="#current-node">current node</a> in
                   7599:     the <a href="#fragment-case">fragment case</a>.</p>
                   7600: 
                   7601:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7602: 
                   7603:    </dd>
                   7604: 
                   7605:    <dt>Anything else</dt>
                   7606:    <dd>
                   7607:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7608:    </dd>
                   7609: 
                   7610:   </dl><h5 id="parsing-main-afterframeset"><span class="secno">9.2.5.24 </span>The "<dfn title="insertion mode: after frameset">after frameset</dfn>" insertion mode</h5>
                   7611: 
                   7612:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterframeset" title="insertion
                   7613:   mode: after frameset">after frameset</a>", tokens must be handled as follows:</p>
                   7614: 
                   7615:   <!-- due to rules in the "in frameset" mode, this can't be entered in the fragment case -->
                   7616:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   7617:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   7618:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   7619:    <dd>
                   7620:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   7621:     the <a href="#current-node">current node</a>.</p>
                   7622:    </dd>
                   7623: 
                   7624:    <dt>A comment token</dt>
                   7625:    <dd>
                   7626:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   7627:     node</a> with the <code title="">data</code> attribute set to
                   7628:     the data given in the comment token.</p>
                   7629:    </dd>
                   7630: 
                   7631:    <dt>A DOCTYPE token</dt>
                   7632:    <dd>
                   7633:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7634:    </dd>
                   7635: 
                   7636:    <dt>A start tag whose tag name is "html"</dt>
                   7637:    <dd>
                   7638:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" <a href="#insertion-mode">insertion
                   7639:     mode</a>.</p>
                   7640:    </dd>
                   7641: 
                   7642:    <dt>An end tag whose tag name is "html"</dt>
                   7643:    <dd>
                   7644:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#the-after-after-frameset-insertion-mode" title="insertion mode: after after frameset">after after
                   7645:     frameset</a>".</p>
                   7646:    </dd>
                   7647: 
                   7648:    <dt>A start tag whose tag name is "noframes"</dt>
                   7649:    <dd>
                   7650:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inhead" title="insertion mode: in head">in head</a>" <a href="#insertion-mode">insertion
                   7651:     mode</a>.</p>
                   7652:    </dd>
                   7653: 
                   7654:    <dt>An end-of-file token</dt>
                   7655:    <dd>
                   7656:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7657:    </dd>
                   7658: 
                   7659:    <dt>Anything else</dt>
                   7660:    <dd>
                   7661:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7662:    </dd>
                   7663: 
1.336     mike     7664:   </dl><h5 id="the-after-after-body-insertion-mode"><span class="secno">9.2.5.25 </span>The "<dfn title="insertion mode: after after body">after after body</dfn>" insertion mode</h5>
1.1       mike     7665: 
                   7666:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-body-insertion-mode" title="insertion
                   7667:   mode: after after body">after after body</a>", tokens must be handled as follows:</p>
                   7668: 
                   7669:   <dl class="switch"><dt>A comment token</dt>
                   7670:    <dd>
                   7671:     <p>Append a <code>Comment</code> node to the <code>Document</code>
                   7672:     object with the <code title="">data</code> attribute set to the
                   7673:     data given in the comment token.</p>
                   7674:    </dd>
                   7675: 
                   7676:    <dt>A DOCTYPE token</dt>
                   7677:    <dt>A character token that is one of U+0009 CHARACTER
                   7678:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   7679:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   7680:    <dt>A start tag whose tag name is "html"</dt>
                   7681:    <dd>
                   7682:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" <a href="#insertion-mode">insertion
                   7683:     mode</a>.</p>
                   7684:    </dd>
                   7685: 
                   7686:    <dt>An end-of-file token</dt>
                   7687:    <dd>
                   7688:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7689:    </dd>
                   7690: 
                   7691:    <dt>Anything else</dt>
                   7692:    <dd>
                   7693:     <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion mode</a>
                   7694:     to "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" and
                   7695:     reprocess the token.</p>
                   7696:    </dd>
                   7697: 
                   7698:   </dl><h5 id="the-after-after-frameset-insertion-mode"><span class="secno">9.2.5.26 </span>The "<dfn title="insertion mode: after after frameset">after after frameset</dfn>" insertion mode</h5>
                   7699: 
                   7700:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-frameset-insertion-mode" title="insertion
                   7701:   mode: after after frameset">after after frameset</a>", tokens must be handled as follows:</p>
                   7702: 
                   7703:   <dl class="switch"><dt>A comment token</dt>
                   7704:    <dd>
                   7705:     <p>Append a <code>Comment</code> node to the <code>Document</code>
                   7706:     object with the <code title="">data</code> attribute set to the
                   7707:     data given in the comment token.</p>
                   7708:    </dd>
                   7709: 
                   7710:    <dt>A DOCTYPE token</dt>
                   7711:    <dt>A character token that is one of U+0009 CHARACTER
                   7712:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   7713:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   7714:    <dt>A start tag whose tag name is "html"</dt>
                   7715:    <dd>
                   7716:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" <a href="#insertion-mode">insertion
                   7717:     mode</a>.</p>
                   7718:    </dd>
                   7719: 
                   7720:    <dt>An end-of-file token</dt>
                   7721:    <dd>
                   7722:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7723:    </dd>
                   7724: 
                   7725:    <dt>A start tag whose tag name is "noframes"</dt>
                   7726:    <dd>
                   7727:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the "<a href="#parsing-main-inhead" title="insertion mode: in head">in head</a>" <a href="#insertion-mode">insertion
                   7728:     mode</a>.</p>
                   7729:    </dd>
                   7730: 
                   7731:    <dt>Anything else</dt>
                   7732:    <dd>
                   7733:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7734:    </dd>
                   7735: 
1.266     mike     7736:   </dl></div><div class="impl">
                   7737: 
                   7738:   <h4 id="the-end"><span class="secno">9.2.6 </span>The end</h4>
1.1       mike     7739: 
                   7740:   <p>Once the user agent <dfn id="stop-parsing" title="stop parsing">stops parsing</dfn>
1.484     mike     7741:   the document, the user agent must run the following steps:</p>
1.1       mike     7742: 
1.484     mike     7743:   <ol><!-- this happens as part of one of the tasks that runs the parser --><li><p>Set the <a href="dom.html#current-document-readiness">current document readiness</a> to
                   7744:    "interactive" <!-- this also synchronously fires an event --> and
                   7745:    the <a href="#insertion-point">insertion point</a> to undefined.</p></li>
                   7746: 
                   7747:    <li><p>If the <a href="semantics.html#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of scripts that will execute when the
                   7748:    document has finished parsing</a> is not empty, run these
                   7749:    substeps:</p>
                   7750: 
                   7751:     <ol><li><p><a href="browsers.html#spin-the-event-loop">Spin the event loop</a> until the first
                   7752:      <code><a href="semantics.html#script">script</a></code> in the <a href="semantics.html#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of scripts that will
                   7753:      execute when the document has finished parsing</a> has its
                   7754:      <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag set <em>and</em> there
                   7755:      is no <a href="semantics.html#a-style-sheet-blocking-scripts" title="a style sheet blocking scripts">style sheet
                   7756:      blocking scripts</a>.</p></li>
                   7757: 
                   7758:      <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a> the
                   7759:      first <code><a href="semantics.html#script">script</a></code> in the <a href="semantics.html#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of scripts that will
                   7760:      execute when the document has finished parsing</a>.</p></li>
                   7761: 
                   7762:      <li><p>Remove the first <code><a href="semantics.html#script">script</a></code> element from the
                   7763:      <a href="semantics.html#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of scripts that will execute when the document has
                   7764:      finished parsing</a> (i.e. shift out the first entry in the
                   7765:      list).</p></li>
                   7766:  
                   7767:      <li><p>If the <a href="semantics.html#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of scripts that will execute when the
                   7768:      document has finished parsing</a> is still not empty, repeat
                   7769:      these substeps again from substep 1.</p>
                   7770: 
                   7771:     </li></ol></li>
                   7772: 
                   7773:    <li><p><a href="browsers.html#spin-the-event-loop">Spin the event loop</a> until the the <a href="semantics.html#list-of-scripts-that-will-execute-as-soon-as-possible">list of
                   7774:    scripts that will execute as soon as possible</a> is
                   7775:    empty.</p></li>
                   7776: 
                   7777:    <li><p><a href="browsers.html#queue-a-task">Queue a task</a> to <a href="browsers.html#fire-a-simple-event">fire a simple
                   7778:    event</a> named <code title="event-DOMContentLoaded">DOMContentLoaded</code> at the
                   7779:    <code>Document</code>.</p></li>
                   7780: 
                   7781:    <li><p><a href="browsers.html#spin-the-event-loop">Spin the event loop</a> until there is nothing that
                   7782:    <dfn id="delay-the-load-event" title="delay the load event">delays the load event</dfn> in
                   7783:    the <code>Document</code>.</p></li>
                   7784: 
                   7785:    <li><p><a href="browsers.html#queue-a-task">Queue a task</a> to set the <a href="dom.html#current-document-readiness">current document
                   7786:    readiness</a> to "complete". <!-- this also fires an event
                   7787:    synchronously during the task --></p></li>
1.1       mike     7788: 
1.484     mike     7789:    <li><p>If the <code>Document</code> is in a <a href="browsers.html#browsing-context">browsing
1.1       mike     7790:    context</a>, then <a href="browsers.html#queue-a-task">queue a task</a> to <a href="browsers.html#fire-a-simple-event">fire a
1.460     mike     7791:    simple event</a> named <code title="event-load">load</code> at
1.1       mike     7792:    the <code>Document</code>'s <code><a href="browsers.html#window">Window</a></code> object, but with
                   7793:    its <code title="dom-event-target">target</code> set to the
                   7794:    <code>Document</code> object (and the <code title="dom-event-currentTarget">currentTarget</code> set to the
1.484     mike     7795:    <code><a href="browsers.html#window">Window</a></code> object).</p></li>
1.1       mike     7796: 
1.484     mike     7797:    <li><p>If the <code>Document</code> has a <a href="history.html#pending-state-object">pending state
1.1       mike     7798:    object</a>, then <a href="browsers.html#queue-a-task">queue a task</a> to fire a <code title="event-popstate"><a href="history.html#event-popstate">popstate</a></code> event in no namespace on the
                   7799:    <code>Document</code>'s <code><a href="browsers.html#window">Window</a></code> object using the
                   7800:    <code><a href="history.html#popstateevent">PopStateEvent</a></code> interface, with the <code title="dom-PopStateEvent-state"><a href="history.html#dom-popstateevent-state">state</a></code> attribute set to the
                   7801:    current value of the <a href="history.html#pending-state-object">pending state object</a>. This event
1.484     mike     7802:    must bubble but not be cancelable and has no default
                   7803:    action.</p></li>
1.1       mike     7804: 
1.484     mike     7805:   </ol><p>The <a href="browsers.html#task-source">task source</a> for the <a href="browsers.html#concept-task" title="concept-task">tasks</a> mentioned in this section is the
                   7806:   <a href="browsers.html#dom-manipulation-task-source">DOM manipulation task source</a>.</p>
1.1       mike     7807: 
1.266     mike     7808:   </div><div class="impl">
1.1       mike     7809: 
                   7810:   <h4 id="coercing-an-html-dom-into-an-infoset"><span class="secno">9.2.7 </span>Coercing an HTML DOM into an infoset</h4>
                   7811: 
                   7812:   <p>When an application uses an <a href="#html-parser">HTML parser</a> in
                   7813:   conjunction with an XML pipeline, it is possible that the
                   7814:   constructed DOM is not compatible with the XML tool chain in certain
                   7815:   subtle ways. For example, an XML toolchain might not be able to
                   7816:   represent attributes with the name <code title="">xmlns</code>,
                   7817:   since they conflict with the Namespaces in XML syntax. There is also
                   7818:   some data that the <a href="#html-parser">HTML parser</a> generates that isn't
                   7819:   included in the DOM itself. This section specifies some rules for
                   7820:   handling these issues.</p>
                   7821: 
                   7822:   <p>If the XML API being used doesn't support DOCTYPEs, the tool may
                   7823:   drop DOCTYPEs altogether.</p>
                   7824: 
                   7825:   <p>If the XML API doesn't support attributes in no namespace that
                   7826:   are named "<code title="">xmlns</code>", attributes whose names
                   7827:   start with "<code title="">xmlns:</code>", or attributes in the
                   7828:   <a href="#xmlns-namespace">XMLNS namespace</a>, then the tool may drop such
                   7829:   attributes.</p>
                   7830: 
                   7831:   <p>The tool may annotate the output with any namespace declarations
                   7832:   required for proper operation.</p>
                   7833: 
                   7834:   <p>If the XML API being used restricts the allowable characters in
                   7835:   the local names of elements and attributes, then the tool may map
                   7836:   all element and attribute local names that the API wouldn't support
                   7837:   to a set of names that <em>are</em> allowed, by replacing any
                   7838:   character that isn't supported with the uppercase letter U and the
                   7839:   six digits of the character's Unicode code point when expressed in
                   7840:   hexadecimal, using digits 0-9 and capital letters A-F as the
                   7841:   symbols, in increasing numeric order.</p>
                   7842: 
                   7843:   <p class="example">For example, the element name <code title="">foo&lt;bar</code>, which can be output by the <a href="#html-parser">HTML
                   7844:   parser</a>, though it is neither a legal HTML element name nor a
                   7845:   well-formed XML element name, would be converted into <code title="">fooU00003Cbar</code>, which <em>is</em> a well-formed XML
                   7846:   element name (though it's still not legal in HTML by any means).</p>
                   7847: 
                   7848:   <p class="example">As another example, consider the attribute
                   7849:   <code>xlink:href</code>. Used on a MathML element, it becomes, after
                   7850:   being <a href="#adjust-foreign-attributes" title="adjust foreign attributes">adjusted</a>, an
                   7851:   attribute with a prefix "<code title="">xlink</code>" and a local
                   7852:   name "<code title="">href</code>". However, used on an HTML element,
                   7853:   it becomes an attribute with no prefix and the local name "<code title="">xlink:href</code>", which is not a valid NCName, and thus
                   7854:   might not be accepted by an XML API. It could thus get converted,
                   7855:   becoming "<code title="">xlinkU00003Ahref</code>".</p>
                   7856: 
                   7857:   <p class="note">The resulting names from this conversion
                   7858:   conveniently can't clash with any attribute generated by the
                   7859:   <a href="#html-parser">HTML parser</a>, since those are all either lowercase or
                   7860:   those listed in the <a href="#adjust-foreign-attributes">adjust foreign attributes</a>
                   7861:   algorithm's table.</p>
                   7862: 
                   7863:   <p>If the XML API restricts comments from having two consecutive
                   7864:   U+002D HYPHEN-MINUS characters (--), the tool may insert a single
                   7865:   U+0020 SPACE character between any such offending characters.</p>
                   7866: 
                   7867:   <p>If the XML API restricts comments from ending in a
                   7868:   U+002D HYPHEN-MINUS character (-), the tool may insert a single
                   7869:   U+0020 SPACE character at the end of such comments.</p>
                   7870: 
                   7871:   <p>If the XML API restricts allowed characters in character data,
1.439     mike     7872:   attribute values, or comments, the tool may replace any U+000C FORM
                   7873:   FEED (FF) character with a U+0020 SPACE character, and any other
                   7874:   literal non-XML character with a U+FFFD REPLACEMENT CHARACTER.</p>
1.1       mike     7875: 
                   7876:   <p>If the tool has no way to convey out-of-band information, then
                   7877:   the tool may drop the following information:</p>
                   7878: 
                   7879:   <ul><li>Whether the document is set to <i><a href="dom.html#no-quirks-mode">no quirks mode</a></i>,
                   7880:    <i><a href="dom.html#limited-quirks-mode">limited quirks mode</a></i>, or <i><a href="dom.html#quirks-mode">quirks mode</a></i></li>
                   7881: 
                   7882:    <li>The association between form controls and forms that aren't
                   7883:    their nearest <code><a href="forms.html#the-form-element">form</a></code> element ancestor (use of the
                   7884:    <a href="#form-element-pointer"><code>form</code> element pointer</a> in the parser)</li>
                   7885: 
                   7886:   </ul><p class="note">The mutations allowed by this section apply
                   7887:   <em>after</em> the <a href="#html-parser">HTML parser</a>'s rules have been
                   7888:   applied. For example, a <code title="">&lt;a::&gt;</code> start tag
                   7889:   will be closed by a <code title="">&lt;/a::&gt;</code> end tag, and
                   7890:   never by a <code title="">&lt;/aU00003AU00003A&gt;</code> end tag, even
                   7891:   if the user agent is using the rules above to then generate an
                   7892:   actual element in the DOM with the name <code title="">aU00003AU00003A</code> for that start tag.</p>
                   7893: 
1.266     mike     7894:   </div><div class="impl">
1.1       mike     7895: 
1.35      mike     7896:   <h4 id="an-introduction-to-error-handling-and-strange-cases-in-the-parser"><span class="secno">9.2.8 </span>An introduction to error handling and strange cases in the parser</h4>
1.1       mike     7897: 
                   7898:   <p><i>This section is non-normative.</i></p>
                   7899: 
                   7900:   <p>This section examines some erroneous markup and discusses how
                   7901:   the <a href="#html-parser">HTML parser</a> handles these cases.</p>
                   7902: 
                   7903: 
                   7904:   <h5 id="misnested-tags:-b-i-b-i"><span class="secno">9.2.8.1 </span>Misnested tags: &lt;b&gt;&lt;i&gt;&lt;/b&gt;&lt;/i&gt;</h5>
                   7905: 
                   7906:   <p><i>This section is non-normative.</i></p>
                   7907: 
                   7908:   <p>The most-often discussed example of erroneous markup is as
                   7909:   follows:</p>
                   7910: 
                   7911:   <pre>&lt;p&gt;1&lt;b&gt;2&lt;i&gt;3&lt;/b&gt;4&lt;/i&gt;5&lt;/p&gt;</pre>
                   7912: 
                   7913:   <p>The parsing of this markup is straightforward up to the "3". At
                   7914:   this point, the DOM looks like this:</p>
                   7915: 
1.159     mike     7916:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="semantics.html#the-p-element">p</a></code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li><li class="t1"><code><a href="text-level-semantics.html#the-i-element">i</a></code><ul><li class="t3"><code>#text</code>: <span title="">3</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul><p>Here, the <a href="#stack-of-open-elements">stack of open elements</a> has five elements
                   7917:   on it: <code><a href="semantics.html#the-html-element-0">html</a></code>, <code><a href="semantics.html#the-body-element-0">body</a></code>, <code><a href="semantics.html#the-p-element">p</a></code>,
1.1       mike     7918:   <code><a href="text-level-semantics.html#the-b-element">b</a></code>, and <code><a href="text-level-semantics.html#the-i-element">i</a></code>. The <a href="#list-of-active-formatting-elements">list of active
                   7919:   formatting elements</a> just has two: <code><a href="text-level-semantics.html#the-b-element">b</a></code> and
                   7920:   <code><a href="text-level-semantics.html#the-i-element">i</a></code>. The <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>".</p>
                   7921: 
                   7922:   <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is
                   7923:   invoked. This is a simple case, in that the <var title="">formatting
                   7924:   element</var> is the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element, and there is no
                   7925:   <var title="">furthest block</var>. Thus, the <a href="#stack-of-open-elements">stack of open
1.159     mike     7926:   elements</a> ends up with just three elements: <code><a href="semantics.html#the-html-element-0">html</a></code>,
                   7927:   <code><a href="semantics.html#the-body-element-0">body</a></code>, and <code><a href="semantics.html#the-p-element">p</a></code>, while the <a href="#list-of-active-formatting-elements">list of
1.1       mike     7928:   active formatting elements</a> has just one: <code><a href="text-level-semantics.html#the-i-element">i</a></code>. The
                   7929:   DOM tree is unmodified at this point.</p>
                   7930: 
                   7931:   <p>The next token is a character ("4"), triggers the <a href="#reconstruct-the-active-formatting-elements" title="reconstruct the active formatting elements">reconstruction of
                   7932:   the active formatting elements</a>, in this case just the
                   7933:   <code><a href="text-level-semantics.html#the-i-element">i</a></code> element. A new <code><a href="text-level-semantics.html#the-i-element">i</a></code> element is thus created
                   7934:   for the "4" text node. After the end tag token for the "i" is also
                   7935:   received, and the "5" text node is inserted, the DOM looks as
                   7936:   follows:</p>
                   7937: 
1.159     mike     7938:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="semantics.html#the-p-element">p</a></code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li><li class="t1"><code><a href="text-level-semantics.html#the-i-element">i</a></code><ul><li class="t3"><code>#text</code>: <span title="">3</span></li></ul></li></ul></li><li class="t1"><code><a href="text-level-semantics.html#the-i-element">i</a></code><ul><li class="t3"><code>#text</code>: <span title="">4</span></li></ul></li><li class="t3"><code>#text</code>: <span title="">5</span></li></ul></li></ul></li></ul></li></ul><h5 id="misnested-tags:-b-p-b-p"><span class="secno">9.2.8.2 </span>Misnested tags: &lt;b&gt;&lt;p&gt;&lt;/b&gt;&lt;/p&gt;</h5>
1.1       mike     7939: 
                   7940:   <p><i>This section is non-normative.</i></p>
                   7941: 
                   7942:   <p>A case similar to the previous one is the following:</p>
                   7943: 
                   7944:   <pre>&lt;b&gt;1&lt;p&gt;2&lt;/b&gt;3&lt;/p&gt;</pre>
                   7945: 
                   7946:   <p>Up to the "2" the parsing here is straightforward:</p>
                   7947: 
1.159     mike     7948:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li><li class="t1"><code><a href="semantics.html#the-p-element">p</a></code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li></ul></li></ul></li></ul></li></ul></li></ul><p>The interesting part is when the end tag token with the tag name
1.1       mike     7949:   "b" is parsed.</p>
                   7950: 
                   7951:   <p>Before that token is seen, the <a href="#stack-of-open-elements">stack of open
1.159     mike     7952:   elements</a> has four elements on it: <code><a href="semantics.html#the-html-element-0">html</a></code>,
                   7953:   <code><a href="semantics.html#the-body-element-0">body</a></code>, <code><a href="text-level-semantics.html#the-b-element">b</a></code>, and <code><a href="semantics.html#the-p-element">p</a></code>. The
1.1       mike     7954:   <a href="#list-of-active-formatting-elements">list of active formatting elements</a> just has the one:
                   7955:   <code><a href="text-level-semantics.html#the-b-element">b</a></code>. The <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>".</p>
                   7956: 
                   7957:   <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is invoked, as
                   7958:   in the previous example. However, in this case, there <em>is</em> a
                   7959:   <var title="">furthest block</var>, namely the <code><a href="semantics.html#the-p-element">p</a></code> element. Thus,
                   7960:   this time the adoption agency algorithm isn't skipped over.</p>
                   7961: 
1.159     mike     7962:   <p>The <var title="">common ancestor</var> is the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1       mike     7963:   element. A conceptual "bookmark" marks the position of the
                   7964:   <code><a href="text-level-semantics.html#the-b-element">b</a></code> in the <a href="#list-of-active-formatting-elements">list of active formatting
                   7965:   elements</a>, but since that list has only one element in it,
                   7966:   it won't have much effect.</p>
                   7967: 
                   7968:   <p>As the algorithm progresses, <var title="">node</var> ends up set
                   7969:   to the formatting element (<code><a href="text-level-semantics.html#the-b-element">b</a></code>), and <var title="">last
                   7970:   node</var> ends up set to the <var title="">furthest block</var>
                   7971:   (<code><a href="semantics.html#the-p-element">p</a></code>).</p>
                   7972: 
                   7973:   <p>The <var title="">last node</var> gets appended (moved) to the
                   7974:   <var title="">common ancestor</var>, so that the DOM looks like:</p>
                   7975: 
1.159     mike     7976:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li></ul></li><li class="t1"><code><a href="semantics.html#the-p-element">p</a></code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li></ul></li></ul></li></ul></li></ul><p>A new <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created, and the children of the
1.1       mike     7977:   <code><a href="semantics.html#the-p-element">p</a></code> element are moved to it:</p>
                   7978: 
1.159     mike     7979:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li></ul></li><li class="t1"><code><a href="semantics.html#the-p-element">p</a></code></li></ul></li></ul></li></ul><ul class="domTree"><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li></ul></li></ul><p>Finally, the new <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is appended to the
1.1       mike     7980:   <code><a href="semantics.html#the-p-element">p</a></code> element, so that the DOM looks like:</p>
                   7981: 
1.159     mike     7982:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li></ul></li><li class="t1"><code><a href="semantics.html#the-p-element">p</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li></ul></li></ul></li></ul></li></ul></li></ul><p>The <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is removed from the <a href="#list-of-active-formatting-elements">list of
1.1       mike     7983:   active formatting elements</a> and the <a href="#stack-of-open-elements">stack of open
                   7984:   elements</a>, so that when the "3" is parsed, it is appended to
                   7985:   the <code><a href="semantics.html#the-p-element">p</a></code> element:</p>
                   7986: 
1.159     mike     7987:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">1</span></li></ul></li><li class="t1"><code><a href="semantics.html#the-p-element">p</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">2</span></li></ul></li><li class="t3"><code>#text</code>: <span title="">3</span></li></ul></li></ul></li></ul></li></ul><h5 id="unexpected-markup-in-tables"><span class="secno">9.2.8.3 </span>Unexpected markup in tables</h5>
1.1       mike     7988: 
                   7989:   <p><i>This section is non-normative.</i></p>
                   7990: 
                   7991:   <p>Error handling in tables is, for historical reasons, especially
                   7992:   strange. For example, consider the following markup:</p>
                   7993: 
                   7994:   <pre>&lt;table&gt;<strong>&lt;b&gt;</strong>&lt;tr&gt;&lt;td&gt;aaa&lt;/td&gt;&lt;/tr&gt;<strong>bbb</strong>&lt;/table&gt;ccc</pre>
                   7995: 
                   7996:   <p>The highlighted <code><a href="text-level-semantics.html#the-b-element">b</a></code> element start tag is not allowed
                   7997:   directly inside a table like that, and the parser handles this case
                   7998:   by placing the element <em>before</em> the table. (This is called <i title="foster parent"><a href="#foster-parent">foster parenting</a></i>.) This can be seen by
                   7999:   examining the DOM tree as it stands just after the
                   8000:   <code><a href="tabular-data.html#the-table-element">table</a></code> element's start tag has been seen:</p>
                   8001: 
1.159     mike     8002:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-table-element">table</a></code></li></ul></li></ul></li></ul><p>...and then immediately after the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element start
1.1       mike     8003:   tag has been seen:</p>
                   8004: 
1.159     mike     8005:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code></li><li class="t1"><code><a href="tabular-data.html#the-table-element">table</a></code></li></ul></li></ul></li></ul><p>At this point, the <a href="#stack-of-open-elements">stack of open elements</a> has on it
                   8006:   the elements <code><a href="semantics.html#the-html-element-0">html</a></code>, <code><a href="semantics.html#the-body-element-0">body</a></code>,
1.1       mike     8007:   <code><a href="tabular-data.html#the-table-element">table</a></code>, and <code><a href="text-level-semantics.html#the-b-element">b</a></code> (in that order, despite the
                   8008:   resulting DOM tree); the <a href="#list-of-active-formatting-elements">list of active formatting
                   8009:   elements</a> just has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it; and the
                   8010:   <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion mode: in
                   8011:   table">in table</a>".</p>
                   8012: 
                   8013:   <p>The <code><a href="tabular-data.html#the-tr-element">tr</a></code> start tag causes the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element
                   8014:   to be popped off the stack and a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> start tag to be
                   8015:   implied; the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> and <code><a href="tabular-data.html#the-tr-element">tr</a></code> elements are
                   8016:   then handled in a rather straight-forward manner, taking the parser
                   8017:   through the "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   8018:   body</a>" and "<a href="#parsing-main-intr" title="insertion mode: in row">in
                   8019:   row</a>" insertion modes, after which the DOM looks as
                   8020:   follows:</p>
                   8021: 
1.159     mike     8022:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code></li><li class="t1"><code><a href="tabular-data.html#the-table-element">table</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tbody-element">tbody</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tr-element">tr</a></code></li></ul></li></ul></li></ul></li></ul></li></ul><p>Here, the <a href="#stack-of-open-elements">stack of open elements</a> has on it the
                   8023:   elements <code><a href="semantics.html#the-html-element-0">html</a></code>, <code><a href="semantics.html#the-body-element-0">body</a></code>, <code><a href="tabular-data.html#the-table-element">table</a></code>,
1.1       mike     8024:   <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>, and <code><a href="tabular-data.html#the-tr-element">tr</a></code>; the <a href="#list-of-active-formatting-elements">list of active
                   8025:   formatting elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in
                   8026:   it; and the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
                   8027:   mode: in row">in row</a>".</p>
                   8028: 
                   8029:   <p>The <code><a href="tabular-data.html#the-td-element">td</a></code> element start tag token, after putting a
                   8030:   <code><a href="tabular-data.html#the-td-element">td</a></code> element on the tree, puts a marker on the <a href="#list-of-active-formatting-elements">list
                   8031:   of active formatting elements</a> (it also switches to the "<a href="#parsing-main-intd" title="insertion mode: in cell">in cell</a>" <a href="#insertion-mode">insertion
                   8032:   mode</a>).</p>
                   8033: 
1.159     mike     8034:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code></li><li class="t1"><code><a href="tabular-data.html#the-table-element">table</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tbody-element">tbody</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tr-element">tr</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-td-element">td</a></code></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul><p>The marker means that when the "aaa" character tokens are seen,
1.1       mike     8035:   no <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created to hold the resulting text
                   8036:   node:</p>
                   8037: 
1.159     mike     8038:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code></li><li class="t1"><code><a href="tabular-data.html#the-table-element">table</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tbody-element">tbody</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tr-element">tr</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-td-element">td</a></code><ul><li class="t3"><code>#text</code>: <span title="">aaa</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul><p>The end tags are handled in a straight-forward manner; after
1.1       mike     8039:   handling them, the <a href="#stack-of-open-elements">stack of open elements</a> has on it the
1.159     mike     8040:   elements <code><a href="semantics.html#the-html-element-0">html</a></code>, <code><a href="semantics.html#the-body-element-0">body</a></code>, <code><a href="tabular-data.html#the-table-element">table</a></code>,
1.1       mike     8041:   and <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>; the <a href="#list-of-active-formatting-elements">list of active formatting
                   8042:   elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it (the
                   8043:   marker having been removed by the "td" end tag token); and the
                   8044:   <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion mode: in
                   8045:   table body">in table body</a>".</p>
                   8046: 
                   8047:   <p>Thus it is that the "bbb" character tokens are found. These
                   8048:   trigger the "<a href="#parsing-main-intabletext" title="insertion mode: in table text">in table
                   8049:   text</a>" insertion mode to be used (with the <a href="#original-insertion-mode">original
                   8050:   insertion mode</a> set to "<a href="#parsing-main-intbody" title="insertion mode: in table
                   8051:   body">in table body</a>"). The character tokens are collected,
                   8052:   and when the next token (the <code><a href="tabular-data.html#the-table-element">table</a></code> element end tag) is
                   8053:   seen, they are processed as a group. Since they are not all spaces,
                   8054:   they are handled as per the "anything else" rules in the "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>" insertion mode,
                   8055:   which defer to the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
                   8056:   body</a>" insertion mode but with <a href="#foster-parent" title="foster
                   8057:   parent">foster parenting</a>.</p>
                   8058: 
                   8059:   <p>When <a href="#reconstruct-the-active-formatting-elements" title="reconstruct the active formatting elements">the
                   8060:   active formatting elements are reconstructed</a>, a
                   8061:   <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created and <a href="#foster-parent" title="foster
                   8062:   parent">foster parented</a>, and then the "bbb" text node is
                   8063:   appended to it:</p>
                   8064: 
1.159     mike     8065:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code></li><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">bbb</span></li></ul></li><li class="t1"><code><a href="tabular-data.html#the-table-element">table</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tbody-element">tbody</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tr-element">tr</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-td-element">td</a></code><ul><li class="t3"><code>#text</code>: <span title="">aaa</span></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul><p>The <a href="#stack-of-open-elements">stack of open elements</a> has on it the elements
                   8066:   <code><a href="semantics.html#the-html-element-0">html</a></code>, <code><a href="semantics.html#the-body-element-0">body</a></code>, <code><a href="tabular-data.html#the-table-element">table</a></code>,
1.1       mike     8067:   <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>, and the new <code><a href="text-level-semantics.html#the-b-element">b</a></code> (again, note that
                   8068:   this doesn't match the resulting tree!); the <a href="#list-of-active-formatting-elements">list of active
                   8069:   formatting elements</a> has the new <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it;
                   8070:   and the <a href="#insertion-mode">insertion mode</a> is still "<a href="#parsing-main-intbody" title="insertion
                   8071:   mode: in table body">in table body</a>".</p>
                   8072: 
                   8073:   <p>Had the character tokens been only <a href="infrastructure.html#space-character" title="space
                   8074:   character">space characters</a> instead of "bbb", then those
                   8075:   <a href="infrastructure.html#space-character" title="space character">space characters</a> would just be
                   8076:   appended to the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element.</p>
                   8077: 
                   8078:   <p>Finally, the <code><a href="tabular-data.html#the-table-element">table</a></code> is closed by a "table" end
                   8079:   tag. This pops all the nodes from the <a href="#stack-of-open-elements">stack of open
                   8080:   elements</a> up to and including the <code><a href="tabular-data.html#the-table-element">table</a></code> element,
                   8081:   but it doesn't affect the <a href="#list-of-active-formatting-elements">list of active formatting
                   8082:   elements</a>, so the "ccc" character tokens after the table
                   8083:   result in yet another <code><a href="text-level-semantics.html#the-b-element">b</a></code> element being created, this
                   8084:   time after the table:</p>
                   8085: 
1.159     mike     8086:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code></li><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">bbb</span></li></ul></li><li class="t1"><code><a href="tabular-data.html#the-table-element">table</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tbody-element">tbody</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-tr-element">tr</a></code><ul><li class="t1"><code><a href="tabular-data.html#the-td-element">td</a></code><ul><li class="t3"><code>#text</code>: <span title="">aaa</span></li></ul></li></ul></li></ul></li></ul></li><li class="t1"><code><a href="text-level-semantics.html#the-b-element">b</a></code><ul><li class="t3"><code>#text</code>: <span title="">ccc</span></li></ul></li></ul></li></ul></li></ul><h5 id="scripts-that-modify-the-page-as-it-is-being-parsed"><span class="secno">9.2.8.4 </span>Scripts that modify the page as it is being parsed</h5>
1.1       mike     8087: 
                   8088:   <p><i>This section is non-normative.</i></p>
                   8089: 
                   8090:   <p>Consider the following markup, which for this example we will
                   8091:   assume is the document with <a href="infrastructure.html#url">URL</a> <code title="">http://example.com/inner</code>, being rendered as the
1.159     mike     8092:   content of an <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code> in another document with the
1.1       mike     8093:   <a href="infrastructure.html#url">URL</a> <code title="">http://example.com/outer</code>:</p>
                   8094: 
                   8095:   <pre>&lt;div id=a&gt;
                   8096:  &lt;script&gt;
                   8097:   var div = document.getElementById('a');
                   8098:   parent.document.body.appendChild(div);
                   8099:  &lt;/script&gt;
                   8100:  &lt;script&gt;
                   8101:   alert(document.URL);
                   8102:  &lt;/script&gt;
                   8103: &lt;/div&gt;
                   8104: &lt;script&gt;
                   8105:  alert(document.URL);
                   8106: &lt;/script&gt;</pre>
                   8107: 
                   8108:   <p>Up to the first "script" end tag, before the script is parsed,
                   8109:   the result is relatively straightforward:</p>
                   8110: 
1.306     mike     8111:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="semantics.html#the-div-element">div</a></code> <span class="t2" title=""><code class="attribute name">id</code>="<code class="attribute value"><a href="text-level-semantics.html#the-a-element">a</a></code>"</span><ul><li class="t3"><code>#text</code>: <span title="">
                   8112:  </span></li><li class="t1"><code><a href="semantics.html#script">script</a></code><ul><li class="t3"><code>#text</code>: <span title="">var div = document.getElementById('a'); &#9166; parent.document.body.appendChild(div);</span></li></ul></li></ul></li></ul></li></ul></li></ul><p>After the script is parsed, though, the <code><a href="semantics.html#the-div-element">div</a></code> element
1.1       mike     8113:   and its child <code><a href="semantics.html#script">script</a></code> element are gone:</p>
                   8114: 
1.159     mike     8115:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code></li></ul></li></ul><p>They are, at this point, in the <code>Document</code> of the
1.1       mike     8116:   aforementioned outer <a href="browsers.html#browsing-context">browsing context</a>. However, the
                   8117:   <a href="#stack-of-open-elements">stack of open elements</a> <em>still contains the
1.306     mike     8118:   <code><a href="semantics.html#the-div-element">div</a></code> element</em>.</p>
1.1       mike     8119: 
                   8120:   <p>Thus, when the second <code><a href="semantics.html#script">script</a></code> element is parsed, it
                   8121:   is inserted <em>into the outer <code>Document</code>
                   8122:   object</em>.</p>
                   8123: 
                   8124:   <p>This also means that the <a href="browsers.html#script-s-global-object">script's global object</a> is
                   8125:   the outer <a href="browsers.html#browsing-context">browsing context</a>'s <code><a href="browsers.html#window">Window</a></code>
                   8126:   object, <em>not</em> the <code><a href="browsers.html#window">Window</a></code> object inside the
1.159     mike     8127:   <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code>.</p>
1.1       mike     8128: 
                   8129:   <p class="note">This isn't a security problem since the script that
1.306     mike     8130:   moves the <code><a href="semantics.html#the-div-element">div</a></code> into the outer <code>Document</code> can
1.1       mike     8131:   only do so because they have the two <code>Document</code> object
1.159     mike     8132:   have the same <a href="browsers.html#origin">origin</a>.</p>
1.1       mike     8133: 
                   8134:   <p>Thus, the first alert says "http://example.com/outer".</p>
                   8135: 
1.306     mike     8136:   <p>Once the <code><a href="semantics.html#the-div-element">div</a></code> element's end tag is parsed, the
                   8137:   <code><a href="semantics.html#the-div-element">div</a></code> element is popped off the stack, and so the next
1.1       mike     8138:   <code><a href="semantics.html#script">script</a></code> element is in the inner <code>Document</code>:</p>
                   8139: 
1.159     mike     8140:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="semantics.html#script">script</a></code><ul><li class="t3"><code>#text</code>: <span title="">alert(document.URL);</span></li></ul></li></ul></li></ul></li></ul><p>This second alert will say "http://example.com/inner".</p>
1.1       mike     8141: 
                   8142: 
                   8143: 
1.215     mike     8144:   <h3 id="namespaces"><span class="secno">9.3 </span>Namespaces</h3>
1.1       mike     8145: 
                   8146:   <p>The <dfn id="html-namespace-0">HTML namespace</dfn> is: <code>http://www.w3.org/1999/xhtml</code></p>
                   8147: 
                   8148:   <p>The <dfn id="mathml-namespace">MathML namespace</dfn> is: <code>http://www.w3.org/1998/Math/MathML</code></p>
                   8149: 
                   8150:   <p>The <dfn id="svg-namespace">SVG namespace</dfn> is: <code>http://www.w3.org/2000/svg</code></p>
                   8151: 
                   8152:   <p>The <dfn id="xlink-namespace">XLink namespace</dfn> is: <code>http://www.w3.org/1999/xlink</code></p>
                   8153: 
                   8154:   <p>The <dfn id="xml-namespace">XML namespace</dfn> is: <code>http://www.w3.org/XML/1998/namespace</code></p>
                   8155: 
                   8156:   <p>The <dfn id="xmlns-namespace">XMLNS namespace</dfn> is: <code>http://www.w3.org/2000/xmlns/</code></p>
                   8157: 
                   8158:   <hr><p>Data mining tools and other user agents that perform operations
1.83      mike     8159:   on <code><a href="iana-considerations.html#text-html">text/html</a></code> content without running scripts,
1.1       mike     8160:   evaluating CSS or XPath expressions, or otherwise exposing the
                   8161:   resulting DOM to arbitrary content, may "support namespaces" by just
                   8162:   asserting that their DOM node analogues are in certain namespaces,
                   8163:   without actually exposing the above strings.</p>
                   8164: 
                   8165: 
                   8166: 
                   8167: 
                   8168:   <h3 id="serializing-html-fragments"><span class="secno">9.4 </span>Serializing HTML fragments</h3>
                   8169: 
                   8170:   <p>The following steps form the <dfn id="html-fragment-serialization-algorithm">HTML fragment serialization
                   8171:   algorithm</dfn>. The algorithm takes as input a DOM
                   8172:   <code>Element</code> or <code>Document</code>, referred to as <var title="">the node</var>, and either returns a string or raises an
                   8173:   exception.</p>
                   8174: 
                   8175:   <p class="note">This algorithm serializes the <em>children</em> of
                   8176:   the node being serialized, not the node itself.</p>
                   8177: 
                   8178:   <ol><li><p>Let <var title="">s</var> be a string, and initialize it to
                   8179:    the empty string.</p></li>
                   8180: 
                   8181:    <li>
                   8182: 
                   8183:     <p>For each child node of <var title="">the node</var>, in
                   8184:     <a href="infrastructure.html#tree-order">tree order</a>, run the following steps:
                   8185: 
                   8186:     </p><ol><li><p>Let <var title="">current node</var> be the child node
                   8187:      being processed.</p></li>
                   8188: 
                   8189:      <li>
                   8190: 
                   8191:       <p>Append the appropriate string from the following list to
                   8192:       <var title="">s</var>:</p>
                   8193: 
                   8194:       <dl class="switch"><dt>If <var title="">current node</var> is an <code title="">Element</code></dt>
                   8195: 
                   8196:        <dd>
                   8197: 
                   8198:         <p>Append a U+003C LESS-THAN SIGN (<code title="">&lt;</code>)
                   8199:         character, followed by the element's tag name. (For nodes
                   8200:         created by the <a href="#html-parser">HTML parser</a> or <code title="">Document.createElement()</code>, the tag name will be
                   8201:         lowercase.)</p>
                   8202: 
                   8203:         <p>For each attribute that the element has, append a U+0020
                   8204:         SPACE character, the attribute's name (which, for attributes
                   8205:         set by the <a href="#html-parser">HTML parser</a> or by <code title="">Element.setAttributeNode()</code> or <code title="">Element.setAttribute()</code>, will be lowercase), a
                   8206:         U+003D EQUALS SIGN (<code title="">=</code>) character, a
                   8207:         U+0022 QUOTATION MARK (<code title="">"</code>)
                   8208:         character, the attribute's value, <a href="#escapingString" title="escaping a
                   8209:         string">escaped as described below</a> in <i>attribute
                   8210:         mode</i>, and a second U+0022 QUOTATION MARK (<code title="">"</code>) character.</p>
                   8211: 
                   8212:         <p>While the exact order of attributes is UA-defined, and may
                   8213:         depend on factors such as the order that the attributes were
                   8214:         given in the original markup, the sort order must be stable,
                   8215:         such that consecutive invocations of this algorithm serialize an
                   8216:         element's attributes in the same order.</p>
                   8217: 
                   8218:         <p>Append a U+003E GREATER-THAN SIGN (<code title="">&gt;</code>)
                   8219:         character.</p>
                   8220: 
                   8221:         <p>If <var title="">current node</var> is an
1.5       mike     8222:         <code><a href="the-canvas-element.html#the-area-element">area</a></code>, <code><a href="semantics.html#the-base-element">base</a></code>, <code><a href="obsolete.html#basefont">basefont</a></code>,
1.1       mike     8223:         <code>bgsound</code>, <code><a href="semantics.html#the-br-element">br</a></code>, <code><a href="tabular-data.html#the-col-element">col</a></code>,
1.159     mike     8224:         <code><a href="text-level-semantics.html#the-embed-element">embed</a></code>, <code><a href="obsolete.html#frame">frame</a></code>, <code><a href="semantics.html#the-hr-element">hr</a></code>,
                   8225:         <code><a href="text-level-semantics.html#the-img-element">img</a></code>, <code><a href="forms.html#the-input-element">input</a></code>, <code><a href="forms.html#the-keygen-element">keygen</a></code>,
                   8226:         <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="semantics.html#meta">meta</a></code>, <code><a href="text-level-semantics.html#the-param-element">param</a></code>,
1.5       mike     8227:         <code><a href="obsolete.html#spacer">spacer</a></code>, or <code>wbr</code> element, then
1.1       mike     8228:         continue on to the next child node at this point.</p> <!--
                   8229:         also, i guess: image and isindex, but we don't list those
                   8230:         because we don't consider those "elements", more "macros", and
                   8231:         thus we should never serialize them -->
                   8232: 
                   8233:         <p>If <var title="">current node</var> is a <code><a href="semantics.html#the-pre-element">pre</a></code>,
1.42      mike     8234:         <code><a href="forms.html#the-textarea-element">textarea</a></code>, or <code><a href="obsolete.html#listing">listing</a></code> element, append
1.1       mike     8235:         a U+000A LINE FEED (LF) character.</p>
                   8236: 
                   8237:         <p>Append the value of running the <a href="#html-fragment-serialization-algorithm">HTML fragment
                   8238:         serialization algorithm</a> on the <var title="">current
                   8239:         node</var> element (thus recursing into this algorithm for
                   8240:         that element), followed by a U+003C LESS-THAN SIGN (<code title="">&lt;</code>) character, a U+002F SOLIDUS (<code title="">/</code>) character, the element's tag name again,
                   8241:         and finally a U+003E GREATER-THAN SIGN (<code title="">&gt;</code>) character.</p>
                   8242: 
                   8243:        </dd>
                   8244: 
                   8245: 
                   8246:        <dt>If <var title="">current node</var> is a <code title="">Text</code> or <code title="">CDATASection</code>
                   8247:        node</dt>
                   8248: 
                   8249:        <dd>
                   8250: 
1.19      mike     8251:         <p>If the parent of <var title="">current node</var> is a
1.42      mike     8252:         <code><a href="semantics.html#the-style-element">style</a></code>, <code><a href="semantics.html#script">script</a></code>, <code><a href="obsolete.html#xmp">xmp</a></code>,
1.159     mike     8253:         <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code>, <code><a href="obsolete.html#noembed">noembed</a></code>,
1.222     mike     8254:         <code><a href="obsolete.html#noframes">noframes</a></code>, or <code><a href="obsolete.html#plaintext">plaintext</a></code> element, or
                   8255:         if the parent of <var title="">current node</var> is
                   8256:         <code><a href="semantics.html#the-noscript-element">noscript</a></code> element and <a href="browsers.html#concept-n-script" title="concept-n-script">scripting is enabled</a> for the
                   8257:         node, then append the value of <var title="">current
                   8258:         node</var>'s <code title="">data</code> IDL attribute
                   8259:         literally.</p>
1.1       mike     8260: 
                   8261:         <p>Otherwise, append the value of <var title="">current
1.192     mike     8262:         node</var>'s <code title="">data</code> IDL attribute, <a href="#escapingString" title="escaping a string">escaped as described
1.1       mike     8263:         below</a>.</p>
                   8264: 
                   8265:        </dd>
                   8266: 
                   8267: 
                   8268:        <dt>If <var title="">current node</var> is a <code title="">Comment</code></dt>
                   8269: 
                   8270:        <dd>
                   8271: 
                   8272:         <p>Append the literal string <code>&lt;!--</code> (U+003C
                   8273:         LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS,
1.192     mike     8274:         U+002D HYPHEN-MINUS), followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1       mike     8275:         attribute, followed by the literal string <code>--&gt;</code>
                   8276:         (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN
                   8277:         SIGN).</p>
                   8278: 
                   8279:        </dd>
                   8280: 
                   8281: 
                   8282:        <dt>If <var title="">current node</var> is a <code title="">ProcessingInstruction</code></dt>
                   8283: 
                   8284:        <dd>
                   8285: 
                   8286:         <p>Append the literal string <code>&lt;?</code> (U+003C
                   8287:         LESS-THAN SIGN, U+003F QUESTION MARK), followed by the value
1.192     mike     8288:         of <var title="">current node</var>'s <code title="">target</code> IDL attribute, followed by a single
                   8289:         U+0020 SPACE character, followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1       mike     8290:         attribute, followed by a single U+003E GREATER-THAN SIGN
1.464     mike     8291:         character (&gt;).</p>
1.1       mike     8292: 
                   8293:        </dd>
                   8294: 
                   8295: 
                   8296:        <dt>If <var title="">current node</var> is a <code title="">DocumentType</code></dt>
                   8297: 
                   8298:        <dd>
                   8299: 
                   8300:         <p>Append the literal string <code>&lt;!DOCTYPE</code> (U+003C
                   8301:         LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+0044 LATIN CAPITAL
                   8302:         LETTER D, U+004F LATIN CAPITAL LETTER O, U+0043 LATIN CAPITAL
                   8303:         LETTER C, U+0054 LATIN CAPITAL LETTER T, U+0059 LATIN CAPITAL
                   8304:         LETTER Y, U+0050 LATIN CAPITAL LETTER P, U+0045 LATIN CAPITAL
                   8305:         LETTER E), followed by a space (U+0020 SPACE), followed by the
1.192     mike     8306:         value of <var title="">current node</var>'s <code title="">name</code> IDL attribute, followed by the literal
1.1       mike     8307:         string <code>&gt;</code> (U+003E GREATER-THAN SIGN).</p>
                   8308: 
                   8309:        </dd>
                   8310: 
                   8311: 
                   8312:       </dl><p>Other node types (e.g. <code title="">Attr</code>) cannot
                   8313:       occur as children of elements. If, despite this, they somehow do
                   8314:       occur, this algorithm must raise an
                   8315:       <code><a href="infrastructure.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception.</p>
                   8316: 
                   8317:      </li>
                   8318: 
                   8319:     </ol></li>
                   8320: 
                   8321:    <li><p>The result of the algorithm is the string <var title="">s</var>.</p></li>
                   8322: 
                   8323:   </ol><p><dfn id="escapingString">Escaping a string</dfn> (for the
                   8324:   purposes of the algorithm above) consists of replacing any
                   8325:   occurrences of the "<code title="">&amp;</code>" character by the
                   8326:   string "<code title="">&amp;amp;</code>", any occurrences of the
                   8327:   U+00A0 NO-BREAK SPACE character by the string "<code title="">&amp;nbsp;</code>", and, if the algorithm was invoked in
                   8328:   the <i>attribute mode</i>, any occurrences of the "<code title="">"</code>" character by the string "<code title="">&amp;quot;</code>", or if it was not, any occurrences of
                   8329:   the "<code title="">&lt;</code>" character by the string "<code title="">&amp;lt;</code>", any occurrences of the "<code title="">&gt;</code>" character by the string "<code title="">&amp;gt;</code>".</p>
                   8330: 
                   8331:   <p class="note">Entity reference nodes are <a href="infrastructure.html#entity-references">assumed to be expanded</a> by the user
                   8332:   agent, and are therefore not covered in the algorithm above.</p>
                   8333: 
                   8334:   <p class="note">It is possible that the output of this algorithm, if
                   8335:   parsed with an <a href="#html-parser">HTML parser</a>, will not return the
                   8336:   original tree structure. For instance, if a <code><a href="forms.html#the-textarea-element">textarea</a></code>
                   8337:   element to which a <code title="">Comment</code> node has been
                   8338:   appended is serialized and the output is then reparsed, the comment
                   8339:   will end up being displayed in the text field. Similarly, if, as a
                   8340:   result of DOM manipulation, an element contains a comment that
                   8341:   contains the literal string "<code title="">--&gt;</code>", then
                   8342:   when the result of serializing the element is parsed, the comment
                   8343:   will be truncated at that point and the rest of the comment will be
                   8344:   interpreted as markup. More examples would be making a
                   8345:   <code><a href="semantics.html#script">script</a></code> element contain a text node with the text string
                   8346:   "<code>&lt;/script&gt;</code>", or having a <code><a href="semantics.html#the-p-element">p</a></code> element that
                   8347:   contains a <code><a href="semantics.html#the-ul-element">ul</a></code> element (as the <code><a href="semantics.html#the-ul-element">ul</a></code> element's
                   8348:   <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> would imply the end
                   8349:   tag for the <code><a href="semantics.html#the-p-element">p</a></code>).</p>
                   8350: 
                   8351: 
                   8352:   <h3 id="parsing-html-fragments"><span class="secno">9.5 </span>Parsing HTML fragments</h3>
                   8353: 
                   8354:   <p>The following steps form the <dfn id="html-fragment-parsing-algorithm">HTML fragment parsing
                   8355:   algorithm</dfn>. The algorithm optionally takes as input an
                   8356:   <code>Element</code> node, referred to as the <var title="">context</var> element, which gives the context for the
                   8357:   parser, as well as <var title="">input</var>, a string to parse, and
                   8358:   returns a list of zero or more nodes.</p>
                   8359: 
                   8360:   <p class="note">Parts marked <dfn id="fragment-case">fragment case</dfn> in algorithms
                   8361:   in the parser section are parts that only occur if the parser was
                   8362:   created for the purposes of this algorithm (and with a <var title="">context</var> element). The algorithms have been annotated
                   8363:   with such markings for informational purposes only; such markings
                   8364:   have no normative weight. If it is possible for a condition
                   8365:   described as a <a href="#fragment-case">fragment case</a> to occur even when the
                   8366:   parser wasn't created for the purposes of handling this algorithm,
                   8367:   then that is an error in the specification.</p>
                   8368: 
                   8369:   <ol><li>
                   8370: 
                   8371:     <p>Create a new <code>Document</code> node, and mark it as being
                   8372:     an <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
                   8373: 
                   8374:    </li>
                   8375: 
                   8376:    <li>
                   8377: 
                   8378:     <p>If there is a <var title="">context</var> element, and the
                   8379:     <code>Document</code> of the <var title="">context</var> element
                   8380:     is in <a href="dom.html#quirks-mode">quirks mode</a>, then let the <code>Document</code>
                   8381:     be in <a href="dom.html#quirks-mode">quirks mode</a>. Otherwise, if there is a <var title="">context</var> element, and the <code>Document</code> of
                   8382:     the <var title="">context</var> element is in <a href="dom.html#limited-quirks-mode">limited quirks
                   8383:     mode</a>, then let the <code>Document</code> be in
                   8384:     <a href="dom.html#limited-quirks-mode">limited quirks mode</a>. Otherwise, leave the
                   8385:     <code>Document</code> in <a href="dom.html#no-quirks-mode">no quirks mode</a>.</p>
                   8386: 
                   8387:    </li>
                   8388: 
                   8389:    <li>
                   8390: 
                   8391:     <p>Create a new <a href="#html-parser">HTML parser</a>, and associate it with
                   8392:     the just created <code>Document</code> node.</p>
                   8393: 
                   8394:    </li>
                   8395: 
                   8396:    <li>
                   8397: 
                   8398:     <p>If there is a <var title="">context</var> element, run these
                   8399:     substeps:</p>
                   8400: 
                   8401:     <ol><li>
                   8402: 
1.541     mike     8403:       <p>Set the state of the <a href="#html-parser">HTML parser</a>'s
                   8404:       <a href="#tokenization">tokenization</a> stage as follows:</p>
1.1       mike     8405: 
1.159     mike     8406:       <dl class="switch"><dt>If it is a <code><a href="semantics.html#the-title-element-0">title</a></code> or <code><a href="forms.html#the-textarea-element">textarea</a></code>
1.1       mike     8407:        element</dt>
                   8408: 
1.541     mike     8409:        <dd>Switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1       mike     8410: 
                   8411: 
                   8412:        <dt>If it is a <code><a href="semantics.html#the-style-element">style</a></code>, <code><a href="semantics.html#script">script</a></code>,
1.159     mike     8413:        <code><a href="obsolete.html#xmp">xmp</a></code>, <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code>, <code><a href="obsolete.html#noembed">noembed</a></code>, or
1.5       mike     8414:        <code><a href="obsolete.html#noframes">noframes</a></code> element</dt>
1.1       mike     8415: 
1.541     mike     8416:        <dd>Switch the tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1       mike     8417: 
                   8418: 
                   8419:        <dt>If it is a <code><a href="semantics.html#the-noscript-element">noscript</a></code> element</dt>
                   8420: 
1.541     mike     8421:        <dd>If the <a href="#scripting-flag">scripting flag</a> is enabled, switch the
                   8422:        tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>.  Otherwise,
                   8423:        leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1       mike     8424: 
                   8425: 
1.42      mike     8426:        <dt>If it is a <code><a href="obsolete.html#plaintext">plaintext</a></code> element</dt>
1.1       mike     8427: 
1.541     mike     8428:        <dd>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT
                   8429:        state</a>.</dd>
1.1       mike     8430: 
                   8431: 
                   8432:        <dt>Otherwise</dt>
                   8433: 
1.541     mike     8434:        <dd>Leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1       mike     8435: 
                   8436:       </dl></li>
                   8437: 
                   8438:      <li>
                   8439: 
1.159     mike     8440:       <p>Let <var title="">root</var> be a new <code><a href="semantics.html#the-html-element-0">html</a></code> element
1.1       mike     8441:       with no attributes.</p>
                   8442: 
                   8443:      </li>
                   8444: 
                   8445:      <li>
                   8446: 
                   8447:       <p>Append the element <var title="">root</var> to the
                   8448:       <code>Document</code> node created above.</p>
                   8449: 
                   8450:      </li>
                   8451: 
                   8452:      <li>
                   8453: 
                   8454:       <p>Set up the parser's <a href="#stack-of-open-elements">stack of open elements</a> so that
                   8455:       it contains just the single element <var title="">root</var>.</p>
                   8456: 
                   8457:      </li>
                   8458: 
                   8459:      <li>
                   8460: 
                   8461:       <p><a href="#reset-the-insertion-mode-appropriately" title="reset the insertion mode appropriately">Reset the
                   8462:       parser's insertion mode appropriately</a>.</p>
                   8463: 
                   8464:       <p class="note">The parser will reference the <var title="">context</var> element as part of that algorithm.</p>
                   8465: 
                   8466:      </li>
                   8467: 
                   8468:      <li>
                   8469: 
                   8470:       <p>Set the parser's <a href="#form-element-pointer"><code>form</code> element pointer</a>
                   8471:       to the nearest node to the <var title="">context</var> element
                   8472:       that is a <code><a href="forms.html#the-form-element">form</a></code> element (going straight up the
                   8473:       ancestor chain, and including the element itself, if it is a
                   8474:       <code><a href="forms.html#the-form-element">form</a></code> element), or, if there is no such
                   8475:       <code><a href="forms.html#the-form-element">form</a></code> element, to null.</p>
                   8476: 
                   8477:      </li>
                   8478: 
                   8479:     </ol></li>
                   8480: 
                   8481:    <li>
                   8482: 
                   8483:     <p>Place into the <a href="#the-input-stream">input stream</a> for the <a href="#html-parser">HTML
                   8484:     parser</a> just created the <var title="">input</var>. The
                   8485:     encoding <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
                   8486:     <i>irrelevant</i>.</p>
                   8487: 
                   8488:    </li>
                   8489: 
                   8490:    <li>
                   8491: 
                   8492:     <p>Start the parser and let it run until it has consumed all the
                   8493:     characters just inserted into the input stream.</p>
                   8494: 
                   8495:    </li>
                   8496: 
                   8497:    <li>
                   8498: 
                   8499:     <p>If there is a <var title="">context</var> element, return the
                   8500:     child nodes of <var title="">root</var>, in <a href="infrastructure.html#tree-order">tree
                   8501:     order</a>.</p>
                   8502: 
                   8503:     <p>Otherwise, return the children of the <code>Document</code>
                   8504:     object, in <a href="infrastructure.html#tree-order">tree order</a>.</p>
                   8505: 
                   8506:    </li>
                   8507: 
1.123     mike     8508:   </ol></div></body></html>

Webmaster