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

1.2       mike        1: <!DOCTYPE HTML>
1.724     mike        2: <!-- when publishing, change bits marked ZZZ --><html lang="en-US-x-Hixie"><head><title>7 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; }
1.671     mike       75:    div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }
1.1       mike       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.671     mike      169:    #configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
                    170:    #configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
                    171:    #configUI p label { display: block; }
                    172:    #configUI #updateUI, #configUI .loginUI { text-align: center; }
                    173:    #configUI input[type=button] { display: block; margin: auto; }
1.267     mike      174:   </style><style type="text/css">
                    175: 
1.292     mike      176:    .applies thead th > * { display: block; }
                    177:    .applies thead code { display: block; }
                    178:    .applies tbody th { whitespace: nowrap; }
                    179:    .applies td { text-align: center; }
                    180:    .applies .yes { background: yellow; }
                    181: 
1.267     mike      182:    .matrix, .matrix td { border: none; text-align: right; }
                    183:    .matrix { margin-left: 2em; }
                    184: 
                    185:    .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
                    186:    .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
                    187:    .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
                    188: 
                    189:    #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
                    190:    #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
                    191:    #table-example-1 caption { padding-bottom: 0.5em; }
                    192:    #table-example-1 thead, #table-example-1 tbody { border: none; }
                    193:    #table-example-1 th, #table-example-1 td { border: solid thin; }
                    194:    #table-example-1 th { font-weight: normal; }
                    195:    #table-example-1 td { border-style: none solid; vertical-align: top; }
                    196:    #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
                    197:    #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
                    198:    #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
                    199:    #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
                    200:    #table-example-1 tbody td:first-child::after { content: leader(". "); }
                    201:    #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
                    202:    #table-example-1 tbody td:first-child + td { width: 10em; }
                    203:    #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
                    204:    #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
                    205: 
                    206:    .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
                    207:    .apple-table-examples * { font-family: "Times", serif; }
                    208:    .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
                    209:    .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
                    210:    .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
                    211:    .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
                    212:    .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
                    213:    .apple-table-examples td { text-align: right; vertical-align: top; }
                    214:    .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
                    215:    .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
                    216:    .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
                    217:    .apple-table-examples sup { line-height: 0; }
                    218: 
1.724     mike      219:    .details-example img { vertical-align: top; }
                    220: 
                    221:   </style><link href="data:text/css," id="complete" rel="stylesheet" title="Complete specification"><link href="data:text/css,.impl%20%7B%20display:%20none;%20%7D" id="author" rel="alternate stylesheet" title="Author documentation only"><link href="data:text/css,.impl%20%7B%20background:%20%23FFEEEE;%20%7D" id="highlight" rel="alternate stylesheet" title="Highlight implementation requirements"><script type="text/javascript">
1.671     mike      222:    function getCookie(name) {
                    223:      var params = location.search.substr(1).split("&");
                    224:      for (var index = 0; index < params.length; index++) {
                    225:        if (params[index] == name)
                    226:          return "1";
                    227:        var data = params[index].split("=");
                    228:        if (data[0] == name)
                    229:          return unescape(data[1]);
                    230:      }
                    231:      var cookies = document.cookie.split("; ");
                    232:      for (var index = 0; index < cookies.length; index++) {
                    233:        var data = cookies[index].split("=");
                    234:        if (data[0] == name)
                    235:          return unescape(data[1]);
                    236:      }
                    237:      return null;
                    238:    }
                    239:    function load(script) {
                    240:      var e = document.createElement('script');
                    241:      e.setAttribute('src', 'http://www.whatwg.org/specs/web-apps/current-work/' + script + '?' + encodeURIComponent(location) + '&' + encodeURIComponent(document.referrer));
                    242:      document.body.appendChild(e);
                    243:    }
                    244:    function init() {
                    245:      if (location.search == '?slow-browser')
                    246:        return;
                    247:      var configUI = document.createElement('div');
                    248:      configUI.id = 'configUI';
                    249:      document.body.appendChild(configUI);
                    250:      // load('reviewer.js'); // would need cross-site XHR
                    251:      if (document.getElementById('head'))
                    252:        load('toc.js');
                    253:      load('styler.js');
                    254:      // load('updater.js'); // would need cross-site XHR
1.724     mike      255:      load('dfn.js'); // doesn't support split-out specs, but, oh well.
1.671     mike      256:      // load('status.js'); // would need cross-site XHR
                    257:      if (getCookie('profile') == '1')
                    258:        document.getElementsByTagName('h2')[0].textContent += '; load: ' + (new Date() - loadTimer) + 'ms';
                    259:      fixBrokenLink();
                    260:    }
                    261:   </script><link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel="stylesheet" type="text/css">
1.2       mike      262:   <script src="link-fixup.js"></script>
1.724     mike      263:   <link href="editing.html" title="6 User Interaction" rel="prev">
1.2       mike      264:   <link href="spec.html#contents" title="Table of contents" rel="index">
1.724     mike      265:   <link href="named-character-references.html" title="7.5 Named character references" rel="next">
1.671     mike      266:   </head><body onload="fixBrokenLink(); init()"><div class="head" id="head">
1.1       mike      267:    <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      268:    <h1>HTML5</h1>
1.1       mike      269:    <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.642     mike      270: 
1.123     mike      271:    </div><nav>
1.724     mike      272:    <a href="editing.html">&#8592; 6 User Interaction</a> &#8211;
1.2       mike      273:    <a href="spec.html#contents">Table of contents</a> &#8211;
1.724     mike      274:    <a href="named-character-references.html">7.5 Named character references &#8594;</a>
1.726   ! mike      275:   </nav><p>This is revision 1.3679.</p>
1.659     mike      276: 
1.1       mike      277: 
1.725     mike      278:   <h2 id="syntax"><span class="secno">7 </span><dfn>The HTML syntax</dfn></h2><p class="note">This section only describes the rules for resources
                    279:   labeled with an <a href="infrastructure.html#html-mime-type">HTML MIME type</a>. Rules for XML resources
                    280:   are discussed in the section below entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
1.724     mike      281:   syntax</a>".</p><h3 id="writing"><span class="secno">7.1 </span>Writing HTML documents</h3><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><div class="impl">
1.1       mike      282: 
                    283:   <p><i>This section only applies to documents, authoring tools, and
                    284:   markup generators. In particular, it does not apply to conformance
                    285:   checkers; conformance checkers must use the requirements given in
                    286:   the next section ("parsing HTML documents").</i></p>
                    287: 
1.123     mike      288:   </div><p>Documents must consist of the following parts, in the given
                    289:   order:</p><ol><li>Optionally, a single U+FEFF BYTE ORDER MARK (BOM) character.</li>
1.1       mike      290: 
                    291:    <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
                    292:    <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    293: 
                    294:    <li>A <a href="#syntax-doctype" title="syntax-doctype">DOCTYPE</a>.
                    295: 
                    296:    </li><li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
                    297:    <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    298: 
1.159     mike      299:    <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      300: 
                    301:    <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
                    302:    <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    303: 
                    304:   </ol><p>The various types of content mentioned above are described in the
1.123     mike      305:   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      306:   declarations</a> are to be serialized, as discussed in the
1.123     mike      307:   section on that topic.</p><div class="note">
1.1       mike      308: 
1.159     mike      309:    <p>Space characters before the root <code><a href="semantics.html#the-html-element-0">html</a></code> element, and
                    310:    space characters at the start of the <code><a href="semantics.html#the-html-element-0">html</a></code> element and
                    311:    before the <code><a href="semantics.html#the-head-element-0">head</a></code> element, will be dropped when the
1.1       mike      312:    document is parsed; space characters <em>after</em> the root
1.159     mike      313:    <code><a href="semantics.html#the-html-element-0">html</a></code> element will be parsed as if they were at the end
                    314:    of the <code><a href="semantics.html#the-body-element-0">body</a></code> element. Thus, space characters around the
1.1       mike      315:    root element do not round-trip.</p>
                    316: 
                    317:    <p>It is suggested that newlines be inserted after the DOCTYPE,
                    318:    after any comments that are before the root element, after the
1.159     mike      319:    <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
                    320:    that are inside the <code><a href="semantics.html#the-html-element-0">html</a></code> element but before the
                    321:    <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1       mike      322: 
1.123     mike      323:   </div><p>Many strings in the HTML syntax (e.g. the names of elements and
1.1       mike      324:   their attributes) are case-insensitive, but only for characters in
1.547     mike      325:   the ranges U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL
                    326:   LETTER Z) and U+0061 to U+007A (LATIN SMALL LETTER A to LATIN SMALL
1.1       mike      327:   LETTER Z). For convenience, in this section this is just referred to
1.724     mike      328:   as "case-insensitive".</p><h4 id="the-doctype"><span class="secno">7.1.1 </span>The DOCTYPE</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments. </i><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      329:   but required, header.</p><p class="note">DOCTYPEs are required for legacy reasons. When
1.1       mike      330:   omitted, browsers tend to use a different rendering mode that is
                    331:   incompatible with some specifications. Including the DOCTYPE in a
                    332:   document ensures that the browser makes a best-effort attempt at
1.123     mike      333:   following the relevant specifications.</p><p>A DOCTYPE must consist of the following characters, in this
1.588     mike      334:   order:</p><ol class="brief"><li>A U+003C LESS-THAN SIGN character (&lt;).</li>
                    335:    <li>A U+0021 EXCLAMATION MARK character (!).</li>
1.1       mike      336:    <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>
                    337:    <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    338:    <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>
                    339:    <li>Optionally, a <a href="#doctype-legacy-string">DOCTYPE legacy string</a> (defined below).</li>
                    340:    <li>Zero or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
1.588     mike      341:    <li>A U+003E GREATER-THAN SIGN character (&gt;).</li>
1.1       mike      342:   </ol><p class="note">In other words, <code>&lt;!DOCTYPE HTML&gt;</code>,
1.123     mike      343:   case-insensitively.</p><p>For the purposes of HTML generators that cannot output HTML
1.1       mike      344:   markup with the short DOCTYPE "<code title="">&lt;!DOCTYPE
                    345:   HTML&gt;</code>", a <dfn id="doctype-legacy-string">DOCTYPE legacy string</dfn> may be inserted
                    346:   into the DOCTYPE (in the position defined above). This string must
1.123     mike      347:   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      348:    <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      349:    <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
1.1       mike      350:    <li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>quote mark</i>).</li>
1.465     mike      351:    <li>The literal string "<code><a href="infrastructure.html#about:legacy-compat">about:legacy-compat</a></code>".</li>
1.1       mike      352:    <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>
                    353:   </ol><p class="note">In other words, <code>&lt;!DOCTYPE HTML SYSTEM
                    354:   "about:legacy-compat"&gt;</code> or <code>&lt;!DOCTYPE HTML SYSTEM
                    355:   'about:legacy-compat'&gt;</code>, case-insensitively except for the bit
1.724     mike      356:   in single or double quotes.</p><p>The <a href="#doctype-legacy-string">DOCTYPE legacy string</a> should not be used unless
1.1       mike      357:   the document is generated from a system that cannot output the
1.724     mike      358:   shorter string.</p><h4 id="elements-0"><span class="secno">7.1.2 </span>Elements</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>There are five different kinds of <dfn id="syntax-elements" title="syntax-elements">elements</dfn>: <a href="#void-elements">void elements</a>,
1.373     mike      359:   <a href="#raw-text-elements">raw text elements</a>, <a href="#rcdata-elements">RCDATA elements</a>,
                    360:   <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      361: 
                    362:    <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      363:    <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>,
                    364:    <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      365:    <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      366:    <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      367: 
1.373     mike      368:    <dt><dfn id="raw-text-elements">Raw text elements</dfn></dt>
1.1       mike      369: 
                    370:    <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      371:    noscript don't count as raw text for syntax purposes -->
1.1       mike      372: 
1.373     mike      373:    <dt><dfn id="rcdata-elements">RCDATA elements</dfn></dt>
1.1       mike      374: 
1.159     mike      375:    <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      376: 
1.373     mike      377:    <dt><dfn id="foreign-elements">Foreign elements</dfn></dt>
1.1       mike      378: 
1.724     mike      379:    <dd>Elements from the <a href="infrastructure.html#mathml-namespace">MathML namespace</a>
                    380:    and the <a href="infrastructure.html#svg-namespace">SVG namespace</a>.</dd>
1.1       mike      381: 
1.373     mike      382:    <dt><dfn id="normal-elements">Normal elements</dfn></dt>
1.1       mike      383: 
                    384:    <dd>All other allowed <a href="infrastructure.html#html-elements">HTML elements</a> are normal
                    385:    elements.</dd>
                    386: 
                    387:   </dl><p><dfn id="syntax-tags" title="syntax-tags">Tags</dfn> are used to delimit the start
1.373     mike      388:   and end of elements in the markup. <a href="#raw-text-elements" title="raw text
                    389:   elements">Raw text</a>, <a href="#rcdata-elements" title="RCDATA
                    390:   elements">RCDATA</a>, and <a href="#normal-elements" title="normal
                    391:   elements">normal</a> elements have a <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> to indicate where they
                    392:   begin, and an <a href="#syntax-end-tag" title="syntax-end-tag">end tag</a> to
                    393:   indicate where they end. The start and end tags of certain
                    394:   <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      395:   later. Those that cannot be omitted must not be omitted. <a href="#void-elements">Void
                    396:   elements</a> only have a start tag; end tags must not be
1.373     mike      397:   specified for <a href="#void-elements">void elements</a>. <a href="#foreign-elements">Foreign
                    398:   elements</a> must either have a start tag and an end tag, or a
                    399:   start tag that is marked as self-closing, in which case they must
                    400:   not have an end tag.</p><p>The contents of the element must be placed between just after the
1.1       mike      401:   start tag (which <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied,
                    402:   in certain cases</a>) and just before the end tag (which again,
                    403:   <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied in certain
                    404:   cases</a>). The exact allowed contents of each individual element
                    405:   depends on the content model of that element, as described earlier
                    406:   in this specification. Elements must not contain content that their
                    407:   content model disallows. In addition to the restrictions placed on
                    408:   the contents by those content models, however, the five types of
1.123     mike      409:   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      410:   no end tag, no content can be put between the start tag and the end
1.373     mike      411:   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
                    412:   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
                    413:   must not contain an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.
1.1       mike      414:   There are also <a href="#cdata-rcdata-restrictions">further
1.373     mike      415:   restrictions</a> described below.</p><p><a href="#foreign-elements">Foreign elements</a> whose start tag is marked as
                    416:   self-closing can't have any contents (since, again, as there's no
                    417:   end tag, no content can be put between the start tag and the end
                    418:   tag). <a href="#foreign-elements">Foreign elements</a> whose start tag is <em>not</em>
                    419:   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.588     mike      420:   contain the character U+003C LESS-THAN SIGN (&lt;) or an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.</p><div class="note">
1.374     mike      421: 
                    422:    <p>The HTML syntax does not support namespace
                    423:    declarations, even in <a href="#foreign-elements">foreign elements</a>.</p>
                    424: 
                    425:    <p>For instance, consider the following HTML fragment:</p>
                    426: 
                    427:    <pre>&lt;p&gt;
                    428:  &lt;svg&gt;
                    429:   &lt;metadata&gt;
                    430:    &lt;!-- this is invalid --&gt;
                    431:    &lt;cdr:license xmlns:cdr="http://www.example.com/cdr/metadata" name="MIT"/&gt;
                    432:   &lt;/metadata&gt;
                    433:  &lt;/svg&gt;
                    434: &lt;/p&gt;</pre>
                    435: 
                    436:    <p>The innermost element, <code title="">cdr:license</code>, is
                    437:    actually in the SVG namespace, as the "<code title="">xmlns:cdr</code>" attribute has no effect (unlike in
                    438:    XML). In fact, as the comment in the fragment above says, the
                    439:    fragment is actually non-conforming. This is because the SVG
                    440:    specification does not define any elements called "<code title="">cdr:license</code>" in the SVG namespace.</p>
                    441: 
                    442:   </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.588     mike      443:   contain the character U+003C LESS-THAN SIGN (&lt;) or an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>. Some
                    444:   <a href="#normal-elements">normal elements</a> also have <a href="#element-restrictions">yet more restrictions</a> on what
1.1       mike      445:   content they are allowed to hold, beyond the restrictions imposed by
                    446:   the content model and those described in this paragraph. Those
1.123     mike      447:   restrictions are described below.</p><p>Tags contain a <dfn id="syntax-tag-name" title="syntax-tag-name">tag name</dfn>,
1.1       mike      448:   giving the element's name. HTML elements all have names that only
1.464     mike      449:   use characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
                    450:   NINE (9), U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER
                    451:   Z, and U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER
                    452:   Z. In the HTML syntax, tag names, even those for <a href="#foreign-elements">foreign
1.462     mike      453:   elements</a>, may be written with any mix of lower- and uppercase
                    454:   letters that, when converted to all-lowercase, matches the element's
1.724     mike      455:   tag name; tag names are case-insensitive.</p><h5 id="start-tags"><span class="secno">7.1.2.1 </span>Start tags</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p><dfn id="syntax-start-tag" title="syntax-start-tag">Start tags</dfn> must have the
1.123     mike      456:   following format:</p><ol><li>The first character of a start tag must be a U+003C LESS-THAN
1.588     mike      457:    SIGN character (&lt;).</li>
1.1       mike      458: 
                    459:    <li>The next few characters of a start tag must be the element's
                    460:    <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
                    461: 
                    462:    <li>If there are to be any attributes in the next step, there must
                    463:    first be one or more <a href="infrastructure.html#space-character" title="space character">space
                    464:    characters</a>.</li>
                    465: 
                    466:    <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
                    467:    below. Attributes may be separated from each other by one or more
                    468:    <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    469: 
                    470:    <li>After the attributes, there may be one or more <a href="infrastructure.html#space-character" title="space character">space characters</a>. (Some attributes
                    471:    are required to be followed by a space. See the <a href="#syntax-attributes" title="syntax-attributes">attributes section</a> below.)</li>
                    472: 
                    473:    <li>Then, if the element is one of the <a href="#void-elements">void elements</a>,
1.373     mike      474:    or if the element is a <a href="#foreign-elements" title="foreign elements">foreign
1.588     mike      475:    element</a>, then there may be a single U+002F SOLIDUS character
                    476:    (/). This character has no effect on <a href="#void-elements">void elements</a>,
                    477:    but on <a href="#foreign-elements">foreign elements</a> it marks the start tag as
                    478:    self-closing.</li>
1.1       mike      479: 
                    480:    <li>Finally, start tags must be closed by a U+003E GREATER-THAN
1.588     mike      481:    SIGN character (&gt;).</li>
1.1       mike      482: 
1.724     mike      483:   </ol><h5 id="end-tags"><span class="secno">7.1.2.2 </span>End tags</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p><dfn id="syntax-end-tag" title="syntax-end-tag">End tags</dfn> must have the
1.123     mike      484:   following format:</p><ol><li>The first character of an end tag must be a U+003C LESS-THAN
1.588     mike      485:    SIGN character (&lt;).</li>
1.1       mike      486: 
                    487:    <li>The second character of an end tag must be a U+002F SOLIDUS
1.588     mike      488:    character (/).</li>
1.1       mike      489: 
                    490:    <li>The next few characters of an end tag must be the element's
                    491:    <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
                    492: 
                    493:    <li>After the tag name, there may be one or more <a href="infrastructure.html#space-character" title="space
                    494:    character">space characters</a>.</li>
                    495: 
1.588     mike      496:    <li>Finally, end tags must be closed by a U+003E GREATER-THAN SIGN
                    497:    character (&gt;).</li>
1.1       mike      498: 
1.724     mike      499:   </ol><h5 id="attributes"><span class="secno">7.1.2.3 </span>Attributes</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p><dfn id="syntax-attributes" title="syntax-attributes">Attributes</dfn> for an element
1.123     mike      500:   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      501:   one or more characters other than the <a href="infrastructure.html#space-character" title="space
                    502:   character">space characters</a>, U+0000 NULL, U+0022 QUOTATION
                    503:   MARK ("), U+0027 APOSTROPHE ('), U+003E GREATER-THAN SIGN
                    504:   (&gt;), U+002F SOLIDUS (/), and U+003D EQUALS SIGN (=) characters,
                    505:   the control characters, and any characters that are not defined by
1.462     mike      506:   Unicode. In the HTML syntax, attribute names, even those for
                    507:   <a href="#foreign-elements">foreign elements</a>, may be written with any mix of lower-
                    508:   and uppercase letters that are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.123     mike      509:   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      510:   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      511:   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      512: 
                    513:    <dd>
                    514: 
                    515:     <p>Just the <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute
                    516:     name</a>.</p>
                    517: 
                    518:     <div class="example">
                    519: 
                    520:      <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
                    521:      the empty attribute syntax:</p>
                    522: 
                    523:      <pre>&lt;input <em>disabled</em>&gt;</pre>
                    524: 
                    525:     </div>
                    526: 
                    527:     <p>If an attribute using the empty attribute syntax is to be
                    528:     followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
                    529:     character</a> separating the two.</p>
                    530: 
                    531:    </dd>
                    532: 
1.2       mike      533:    <dt id="unquoted">Unquoted attribute value syntax</dt>
1.1       mike      534: 
                    535:    <dd>
                    536: 
                    537:     <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
                    538:     followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
                    539:     characters</a>, followed by a single U+003D EQUALS SIGN
                    540:     character, followed by zero or more <a href="infrastructure.html#space-character" title="space
                    541:     character">space characters</a>, followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
                    542:     addition to the requirements given above for attribute values,
                    543:     must not contain any literal <a href="infrastructure.html#space-character" title="space character">space
1.588     mike      544:     characters</a>, any U+0022 QUOTATION MARK characters ("),
                    545:     U+0027 APOSTROPHE characters ('), U+003D EQUALS SIGN
                    546:     characters (=), U+003C LESS-THAN SIGN characters (&lt;), U+003E
                    547:     GREATER-THAN SIGN characters (&gt;), or U+0060 GRAVE ACCENT
                    548:     characters (`), and must not be the empty string.</p>
1.463     mike      549: 
                    550:     <!-- The ` character is in this list on a temporary basis, waiting
                    551:          for IE to fix it's parsing bug whereby it treats ` as an
                    552:          attribute value delimiter. Otherwise, escaping software that
                    553:          tries to be clever and not use quotes when it doesn't need to
                    554:          could be tricked by an attacker.
                    555: 
                    556:          Posit a site that allows the user to input text that is used
                    557:          verbatim in two attributes, such that the user can set the
                    558:          first attribute's value to:
                    559: 
                    560:             `
                    561: 
                    562:          ...and the second to:
                    563: 
                    564:             ` onload='...payload...' end=x
                    565: 
                    566:          ...with the assumption that the site is going to not quote
                    567:          the first one, and quote the second one with double quotes:
                    568: 
                    569:             <body title=` class="` onload='...payload...' end=x">
                    570: 
                    571:          In IE, this is treated as:
                    572: 
                    573:             <body title=' class="'
                    574:                   onload='...payload...'
                    575:                   end='x"'>
                    576: 
                    577:     -->
                    578: 
1.1       mike      579: 
                    580:     <div class="example">
                    581: 
                    582:      <p>In the following example, the <code title="attr-input-value"><a href="forms.html#attr-input-value">value</a></code> attribute is given
                    583:      with the unquoted attribute value syntax:</p>
                    584: 
                    585:      <pre>&lt;input <em>value=yes</em>&gt;</pre>
                    586: 
                    587:     </div>
                    588: 
                    589:     <p>If an attribute using the unquoted attribute syntax is to be
1.101     mike      590:     followed by another attribute or by the optional U+002F SOLIDUS
1.464     mike      591:     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      592:     must be a <a href="infrastructure.html#space-character">space character</a> separating the two.</p>
                    593: 
                    594:    </dd>
                    595: 
                    596:    <dt>Single-quoted attribute value syntax</dt>
                    597: 
                    598:    <dd>
                    599: 
                    600:     <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
                    601:     followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
                    602:     characters</a>, followed by a single U+003D EQUALS SIGN
                    603:     character, followed by zero or more <a href="infrastructure.html#space-character" title="space
                    604:     character">space characters</a>, followed by a single U+0027
1.588     mike      605:     APOSTROPHE character ('), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1       mike      606:     addition to the requirements given above for attribute values,
1.588     mike      607:     must not contain any literal U+0027 APOSTROPHE characters ('), and
                    608:     finally followed by a second single U+0027 APOSTROPHE character
                    609:     (').</p>
1.1       mike      610: 
                    611:     <div class="example">
                    612: 
                    613:      <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
                    614:      single-quoted attribute value syntax:</p>
                    615: 
                    616:      <pre>&lt;input <em>type='checkbox'</em>&gt;</pre>
                    617: 
                    618:     </div>
                    619: 
                    620:     <p>If an attribute using the single-quoted attribute syntax is to
                    621:     be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
                    622:     character</a> separating the two.</p>
                    623: 
                    624:    </dd>
                    625: 
                    626:    <dt>Double-quoted attribute value syntax</dt>
                    627: 
                    628:    <dd>
                    629: 
                    630:     <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
                    631:     followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
                    632:     characters</a>, followed by a single U+003D EQUALS SIGN
                    633:     character, followed by zero or more <a href="infrastructure.html#space-character" title="space
                    634:     character">space characters</a>, followed by a single U+0022
1.588     mike      635:     QUOTATION MARK character ("), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1       mike      636:     addition to the requirements given above for attribute values,
1.588     mike      637:     must not contain any literal U+0022 QUOTATION MARK characters ("),
                    638:     and finally followed by a second single U+0022 QUOTATION MARK
                    639:     character (").</p>
1.1       mike      640: 
                    641:     <div class="example">
                    642: 
                    643:      <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
                    644:      double-quoted attribute value syntax:</p>
                    645: 
                    646:      <pre>&lt;input <em>name="be evil"</em>&gt;</pre>
                    647: 
                    648:     </div>
                    649: 
                    650:     <p>If an attribute using the double-quoted attribute syntax is to
                    651:     be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
                    652:     character</a> separating the two.</p>
                    653: 
                    654:    </dd>
                    655: 
                    656:   </dl><p>There must never be two or more attributes on the same start tag
                    657:   whose names are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for
1.462     mike      658:   each other.</p><hr><p>When a <a href="#foreign-elements" title="foreign elements">foreign element</a> has
                    659:   one of the namespaced attributes given by the local name and
                    660:   namespace of the first and second cells of a row from the following
                    661:   table, it must be written using the name given by the third cell
                    662:   from the same row.</p><table><thead><tr><th> Local name </th><th> Namespace </th><th> Attribute name
1.724     mike      663:    </th></tr></thead><tbody><tr><td> <code title="">actuate</code> </td><td> <a href="infrastructure.html#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:actuate</code>
                    664:     </td></tr><tr><td> <code title="">arcrole</code> </td><td> <a href="infrastructure.html#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:arcrole</code>
                    665:     </td></tr><tr><td> <code title="">href</code> </td><td> <a href="infrastructure.html#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:href</code>
                    666:     </td></tr><tr><td> <code title="">role</code> </td><td> <a href="infrastructure.html#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:role</code>
                    667:     </td></tr><tr><td> <code title="">show</code> </td><td> <a href="infrastructure.html#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:show</code>
                    668:     </td></tr><tr><td> <code title="">title</code> </td><td> <a href="infrastructure.html#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:title</code>
                    669:     </td></tr><tr><td> <code title="">type</code> </td><td> <a href="infrastructure.html#xlink-namespace">XLink namespace</a> </td><td> <code title="">xlink:type</code>
                    670:     </td></tr><tr><td> <code title="">base</code> </td><td> <a href="infrastructure.html#xml-namespace">XML namespace</a> <!-- attr-xml-base --> </td><td> <code title="">xml:base</code>
                    671:     </td></tr><tr><td> <code title="">lang</code> </td><td> <a href="infrastructure.html#xml-namespace">XML namespace</a> </td><td> <code title="">xml:lang</code>
                    672:     </td></tr><tr><td> <code title="">space</code> </td><td> <a href="infrastructure.html#xml-namespace">XML namespace</a> </td><td> <code title="">xml:space</code>
                    673:     </td></tr><tr><td> <code title="">xmlns</code> </td><td> <a href="infrastructure.html#xmlns-namespace">XMLNS namespace</a> </td><td> <code title="">xmlns</code>
                    674:     </td></tr><tr><td> <code title="">xlink</code> </td><td> <a href="infrastructure.html#xmlns-namespace">XMLNS namespace</a> </td><td> <code title="">xmlns:xlink</code>
1.671     mike      675:   </td></tr></tbody></table><p>No other namespaced attribute can be expressed in <a href="#syntax">the
1.724     mike      676:   HTML syntax</a>.</p><h5 id="optional-tags"><span class="secno">7.1.2.4 </span>Optional tags</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><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      677:   is not present; it is implied, but it is still there. An HTML
1.159     mike      678:   document always has a root <code><a href="semantics.html#the-html-element-0">html</a></code> element, even if the
1.1       mike      679:   string <code title="">&lt;html&gt;</code> doesn't appear anywhere in
1.159     mike      680:   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
                    681:   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
                    682:   tag</a> may be omitted if the <code><a href="semantics.html#the-html-element-0">html</a></code> element is not
                    683:   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      684:   element is empty, or--> if the first thing inside the
1.159     mike      685:   <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
                    686:   tag</a> may be omitted if the <code><a href="semantics.html#the-head-element-0">head</a></code> element is not
                    687:   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
                    688:   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      689:   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      690:   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      691:   <code><a href="semantics.html#the-style-element">style</a></code> element. <!-- Note that even if the </head> end
1.724     mike      692:   tag is present, the parser makes <style> and <script type="text/javascript"> elements
1.1       mike      693:   between </head> and <body> end up in the <head> instead of implying
1.159     mike      694:   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
                    695:   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      696:   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      697:   tag</a> may be omitted if the <code><a href="semantics.html#the-li-element">li</a></code> element is
                    698:   immediately followed by another <code><a href="semantics.html#the-li-element">li</a></code> element or if there
1.422     mike      699:   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      700:   tag</a> may be omitted if the <code><a href="semantics.html#the-dt-element">dt</a></code> element is
                    701:   immediately followed by another <code><a href="semantics.html#the-dt-element">dt</a></code> element or a
1.123     mike      702:   <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      703:   tag</a> may be omitted if the <code><a href="semantics.html#the-dd-element">dd</a></code> element is
                    704:   immediately followed by another <code><a href="semantics.html#the-dd-element">dd</a></code> element or a
                    705:   <code><a href="semantics.html#the-dt-element">dt</a></code> element, or if there is no more content in the
1.123     mike      706:   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      707:   tag</a> may be omitted if the <code><a href="semantics.html#the-p-element">p</a></code> element is
                    708:   immediately followed by an <code><a href="semantics.html#the-address-element">address</a></code>,
                    709:   <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      710:   <!--v2DATAGRID <code>datagrid</code>,--> <code><a href="obsolete.html#dir">dir</a></code>,
1.306     mike      711:   <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      712:   <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>,
                    713:   <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>,
                    714:   <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>,
                    715:   <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>,
                    716:   <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      717:   <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>,
                    718:   element, or if there is no more content in the parent element and
1.123     mike      719:   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      720:   tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rt-element">rt</a></code> element is
                    721:   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      722:   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      723:   tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rp-element">rp</a></code> element is
                    724:   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      725:   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      726:   <select>; commented out text below can handle the non-<select> case
1.123     mike      727:   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      728:   <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element <!--has an ancestor
                    729:   <code>select</code> element and--> is immediately followed by
                    730:   another <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or if <!--all of the elements
                    731:   that are ancestors of the <code>optgroup</code> element, up to and
                    732:   including the first ancestor element that is not an
                    733:   <code>optgroup</code> element, have no more content--> there is no
1.123     mike      734:   more content in the parent element.</p><!-- so e.g. the max number of </optgroup>s are omitted here:
1.1       mike      735:    <select><optgroup></select>
                    736:    <p id=x><optgroup></optgroup>x</p>
                    737:    <p id=x><optgroup><optgroup></optgroup></optgroup>x</p>
                    738:    <p><optgroup id=x><optgroup></optgroup>x</p>
                    739:    <p><optgroup><optgroup id=x>x</p>
1.123     mike      740:   --><!-- </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      741:   tag</a> may be omitted if the <code><a href="forms.html#the-option-element">option</a></code> element is
                    742:   immediately followed by another <code><a href="forms.html#the-option-element">option</a></code> element, or if
                    743:   it is immediately followed by an <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or
1.123     mike      744:   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      745:   first thing inside the <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is a
                    746:   <code><a href="tabular-data.html#the-col-element">col</a></code> element, and if the element is not immediately
                    747:   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      748:   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      749:   <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is not immediately followed by a
1.123     mike      750:   <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      751:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-thead-element">thead</a></code> element is
                    752:   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      753:   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      754:   first thing inside the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is a
                    755:   <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, and if the element is not immediately
                    756:   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
                    757:   <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element whose <a href="#syntax-end-tag" title="syntax-end-tag">end
                    758:   tag</a> has been omitted. (It can't be omitted if the element is
1.123     mike      759:   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      760:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is
                    761:   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      762:   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      763:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element is
                    764:   immediately followed by a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element, or if there is
1.123     mike      765:   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      766:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
                    767:   immediately followed by another <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, or if there
1.123     mike      768:   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      769:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-td-element">td</a></code> element is
                    770:   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      771:   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      772:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-th-element">th</a></code> element is
                    773:   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      774:   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
1.724     mike      775:   tag</a> must never be omitted if it has any attributes.</p><h5 id="element-restrictions"><span class="secno">7.1.2.5 </span>Restrictions on content models</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>For historical reasons, certain elements have extra restrictions
1.123     mike      776:   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      777:   elements, even though these elements are technically allowed inside
                    778:   <code><a href="tabular-data.html#the-table-element">table</a></code> elements according to the content models
                    779:   described in this specification. (If a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
                    780:   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      781:   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
                    782:   placed immediately after the <a href="#syntax-start-tag" title="syntax-start-tag">start
1.1       mike      783:   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>
                    784:   elements. This does not affect the processing of the element. The
1.304     mike      785:   otherwise optional <a href="#syntax-newlines" title="syntax-newlines">newline</a>
1.381     mike      786:   <em>must</em> be included if the element's contents themselves start
                    787:   with a <a href="#syntax-newlines" title="syntax-newlines">newline</a> (because
                    788:   otherwise the leading newline in the contents would be treated like
                    789:   the optional newline, and ignored).</p><div class="example">
1.1       mike      790:    <p>The following two <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are equivalent:</p>
                    791:    <pre>&lt;pre&gt;Hello&lt;/pre&gt;</pre>
                    792:    <pre>&lt;pre&gt;<br>Hello&lt;/pre&gt;</pre>
1.724     mike      793:   </div><h5 id="cdata-rcdata-restrictions"><span class="secno">7.1.2.6 </span>Restrictions on the contents of raw text and RCDATA elements</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The text in <a href="#raw-text-elements" title="raw text elements">raw text</a> and
1.373     mike      794:   <a href="#rcdata-elements" title="RCDATA elements">RCDATAs</a> element must not
                    795:   contain any occurrences of the string "<code title="">&lt;/</code>"
                    796:   (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that
1.1       mike      797:   case-insensitively match the tag name of the element followed by one
                    798:   of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM
1.304     mike      799:   FEED (FF), U+000D CARRIAGE RETURN (CR), U+0020 SPACE, U+003E
1.724     mike      800:   GREATER-THAN SIGN (&gt;), or U+002F SOLIDUS (/).</p><h4 id="text"><span class="secno">7.1.3 </span>Text</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p><dfn id="syntax-text" title="syntax-text">Text</dfn> is allowed inside elements,
1.1       mike      801:   attributes, and comments. Text must consist of Unicode characters.
                    802:   Text must not contain U+0000 characters. Text must not contain
1.316     mike      803:   permanently undefined Unicode characters (noncharacters). Text must
                    804:   not contain control characters other than <a href="infrastructure.html#space-character" title="space
                    805:   character">space characters</a>. Extra constraints are placed on
                    806:   what is and what is not allowed in text based on where the text is
1.724     mike      807:   to be put, as described in the other sections.</p><h5 id="newlines"><span class="secno">7.1.3.1 </span>Newlines</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p><dfn id="syntax-newlines" title="syntax-newlines">Newlines</dfn> in HTML may be
1.1       mike      808:   represented either as U+000D CARRIAGE RETURN (CR) characters, U+000A
                    809:   LINE FEED (LF) characters, or pairs of U+000D CARRIAGE RETURN (CR),
1.724     mike      810:   U+000A LINE FEED (LF) characters in that order.</p><h4 id="character-references"><span class="secno">7.1.4 </span>Character references</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><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      811:   to escape characters that couldn't otherwise legally be included in
1.588     mike      812:   <a href="#syntax-text" title="syntax-text">text</a>.</p><p>Character references must start with a U+0026 AMPERSAND character
                    813:   (&amp;). Following this, there are three possible kinds of character
                    814:   references:</p><dl><dt>Named character references</dt>
1.1       mike      815: 
                    816:    <dd>The ampersand must be followed by one of the names given in the
                    817:    <a href="named-character-references.html#named-character-references">named character references</a> section, using the same
1.677     mike      818:    case. <span class="impl">The name must be one that is terminated by
                    819:    a U+003B SEMICOLON character (;).</span></dd>
1.1       mike      820: 
                    821: 
                    822:    <dt>Decimal numeric character reference</dt>
                    823: 
                    824:    <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588     mike      825:    character (#), followed by one or more digits in the range U+0030
                    826:    DIGIT ZERO (0) to U+0039 DIGIT NINE (9), representing a base-ten
                    827:    integer that corresponds to a Unicode code point that is allowed
                    828:    according to the definition below. The digits must then be followed
                    829:    by a U+003B SEMICOLON character (;).</dd>
1.1       mike      830: 
                    831: 
                    832:    <dt>Hexadecimal numeric character reference</dt>
                    833: 
                    834:    <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588     mike      835:    character (#), which must be followed by either a U+0078 LATIN
                    836:    SMALL LETTER X character (x) or a U+0058 LATIN CAPITAL LETTER X
                    837:    character (X), which must then be followed by one or more digits in
                    838:    the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061
                    839:    LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041
                    840:    LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F,
1.464     mike      841:    representing a base-sixteen integer that corresponds to a Unicode
                    842:    code point that is allowed according to the definition below. The
                    843:    digits must then be followed by a U+003B SEMICOLON character
                    844:    (;).</dd>
1.378     mike      845: 
                    846:   </dl><p>The numeric character reference forms described above are allowed
                    847:   to reference any Unicode code point other than U+0000, permanently
                    848:   undefined Unicode characters (noncharacters), and control characters
                    849:   other than <a href="infrastructure.html#space-character" title="space character">space
                    850:   characters</a>.</p><p>An <dfn id="syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous
1.464     mike      851:   ampersand</dfn> is a U+0026 AMPERSAND character (&amp;) that is
                    852:   followed by some <a href="#syntax-text" title="syntax-text">text</a> other than a
                    853:   <a href="infrastructure.html#space-character">space character</a>, a U+003C LESS-THAN SIGN character
1.724     mike      854:   (&lt;), or another U+0026 AMPERSAND character (&amp;).</p><h4 id="cdata-sections"><span class="secno">7.1.5 </span>CDATA sections</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p><dfn id="syntax-cdata" title="syntax-cdata">CDATA sections</dfn> must start with
1.1       mike      855:   the character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
                    856:   MARK, U+005B LEFT SQUARE BRACKET, U+0043 LATIN CAPITAL LETTER C,
                    857:   U+0044 LATIN CAPITAL LETTER D, U+0041 LATIN CAPITAL LETTER A, U+0054
                    858:   LATIN CAPITAL LETTER T, U+0041 LATIN CAPITAL LETTER A, U+005B LEFT
                    859:   SQUARE BRACKET (<code title="">&lt;![CDATA[</code>). Following this
                    860:   sequence, the CDATA section may have <a href="#syntax-text" title="syntax-text">text</a>, with the additional restriction
                    861:   that the text must not contain the three character sequence U+005D
                    862:   RIGHT SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E
                    863:   GREATER-THAN SIGN (<code title="">]]&gt;</code>). Finally, the CDATA
                    864:   section must be ended by the three character sequence U+005D RIGHT
                    865:   SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E GREATER-THAN
1.724     mike      866:   SIGN (<code title="">]]&gt;</code>).</p><div class="example">
                    867: 
                    868:    <p>CDATA sections can only be used in foreign content (MathML or
                    869:    SVG). In this example, a CDATA section is used to escape the
                    870:    contents of an <code>ms</code> element:</p>
                    871: 
                    872:    <pre>&lt;p&gt;You can add a string to a number, but this stringifies the number:&lt;/p&gt;
                    873: &lt;math&gt;
                    874:  &lt;ms&gt;&lt;![CDATA[x&lt;y]]&gt;&lt;/ms&gt;
                    875:  &lt;mo&gt;+&lt;/mo&gt;
                    876:  &lt;mn&gt;3&lt;/mn&gt;
                    877:  &lt;mo&gt;=&lt;/mo&gt;
                    878:  &lt;ms&gt;&lt;![CDATA[x&lt;y3]]&gt;&lt;/ms&gt;
                    879: &lt;/math&gt;</pre>
                    880: 
                    881:   </div><h4 id="comments"><span class="secno">7.1.6 </span>Comments</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p><dfn id="syntax-comments" title="syntax-comments">Comments</dfn> must start with the
1.1       mike      882:   four character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
                    883:   MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS (<code title="">&lt;!--</code>). Following this sequence, the comment may
                    884:   have <a href="#syntax-text" title="syntax-text">text</a>, with the additional
                    885:   restriction that the text must not start with a single U+003E
1.588     mike      886:   GREATER-THAN SIGN character (&gt;), nor start with a U+002D
                    887:   HYPHEN-MINUS character (-) followed by a U+003E GREATER-THAN SIGN
                    888:   (&gt;) character, nor contain two consecutive U+002D HYPHEN-MINUS
                    889:   characters (<code title="">--</code>), nor end with a U+002D
                    890:   HYPHEN-MINUS character (-). Finally, the comment must be ended by
1.1       mike      891:   the three character sequence U+002D HYPHEN-MINUS, U+002D
1.123     mike      892:   HYPHEN-MINUS, U+003E GREATER-THAN SIGN (<code title="">--&gt;</code>).</p><div class="impl">
1.1       mike      893: 
1.724     mike      894:   <h3 id="parsing"><span class="secno">7.2 </span>Parsing HTML documents</h3><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike      895: 
                    896:   <p><i>This section only applies to user agents, data mining tools,
                    897:   and conformance checkers.</i></p>
                    898: 
                    899:   <p class="note">The rules for parsing XML documents into DOM trees
                    900:   are covered by the next section, entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
                    901:   syntax</a>".</p>
                    902: 
                    903:   <p>For <a href="dom.html#html-documents">HTML documents</a>, user agents must use the parsing
                    904:   rules described in this section to generate the DOM trees. Together,
                    905:   these rules define what is referred to as the <dfn id="html-parser">HTML
                    906:   parser</dfn>.</p>
                    907: 
                    908:   <div class="note">
                    909: 
                    910:    <p>While the HTML syntax described in this specification bears a
                    911:    close resemblance to SGML and XML, it is a separate language with
                    912:    its own parsing rules.</p>
                    913: 
1.183     mike      914:    <p>Some earlier versions of HTML (in particular from HTML2 to
                    915:    HTML4) were based on SGML and used SGML parsing rules. However, few
1.1       mike      916:    (if any) web browsers ever implemented true SGML parsing for HTML
                    917:    documents; the only user agents to strictly handle HTML as an SGML
                    918:    application have historically been validators. The resulting
                    919:    confusion &#8212; with validators claiming documents to have one
                    920:    representation while widely deployed Web browsers interoperably
                    921:    implemented a different representation &#8212; has wasted decades
                    922:    of productivity. This version of HTML thus returns to a non-SGML
                    923:    basis.</p>
                    924: 
                    925:    <p>Authors interested in using SGML tools in their authoring
                    926:    pipeline are encouraged to use XML tools and the XML serialization
                    927:    of HTML.</p>
                    928: 
                    929:   </div>
                    930: 
                    931:   <p>This specification defines the parsing rules for HTML documents,
                    932:   whether they are syntactically correct or not. Certain points in the
                    933:   parsing algorithm are said to be <dfn id="parse-error" title="parse error">parse
                    934:   errors</dfn>. The error handling for parse errors is well-defined:
                    935:   user agents must either act as described below when encountering
                    936:   such problems, or must abort processing at the first error that they
                    937:   encounter for which they do not wish to apply the rules described
                    938:   below.</p>
                    939: 
                    940:   <p>Conformance checkers must report at least one parse error
                    941:   condition to the user if one or more parse error conditions exist in
                    942:   the document and must not report parse error conditions if none
                    943:   exist in the document. Conformance checkers may report more than one
1.174     mike      944:   parse error condition if more than one parse error condition exists
1.1       mike      945:   in the document. Conformance checkers are not required to recover
                    946:   from parse errors.</p>
                    947: 
                    948:   <p class="note">Parse errors are only errors with the
                    949:   <em>syntax</em> of HTML. In addition to checking for parse errors,
                    950:   conformance checkers will also verify that the document obeys all
                    951:   the other conformance requirements described in this
                    952:   specification.</p>
                    953: 
                    954:   <p>For the purposes of conformance checkers, if a resource is
                    955:   determined to be in <a href="#syntax">the HTML syntax</a>, then it is an
                    956:   <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
                    957: 
1.266     mike      958:   </div><div class="impl">
1.1       mike      959: 
1.724     mike      960:   <h4 id="overview-of-the-parsing-model"><span class="secno">7.2.1 </span>Overview of the parsing model</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike      961: 
                    962:   <p>The input to the HTML parsing process consists of a stream of
                    963:   Unicode characters, which is passed through a
                    964:   <a href="#tokenization">tokenization</a> stage followed by a <a href="#tree-construction">tree
                    965:   construction</a> stage. The output is a <code>Document</code>
                    966:   object.</p>
                    967: 
                    968:   <p class="note">Implementations that <a href="infrastructure.html#non-scripted">do not
                    969:   support scripting</a> do not have to actually create a DOM
                    970:   <code>Document</code> object, but the DOM tree in such cases is
                    971:   still used as the model for the rest of the specification.</p>
                    972: 
                    973:   <p>In the common case, the data handled by the tokenization stage
1.159     mike      974:   comes from the network, but <a href="embedded-content-0.html#dynamic-markup-insertion" title="dynamic markup
                    975:   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      976: 
1.724     mike      977:   <p><img alt="" src="http://dev.w3.org/html5/spec/images/parsing-model-overview.png"></p>
1.1       mike      978: 
                    979:   <p id="nestedParsing">There is only one set of states for the
                    980:   tokenizer stage and the tree construction stage, but the tree
                    981:   construction stage is reentrant, meaning that while the tree
                    982:   construction stage is handling one token, the tokenizer might be
                    983:   resumed, causing further tokens to be emitted and processed before
                    984:   the first token's processing is complete.</p>
                    985: 
                    986:   <div class="example">
                    987: 
                    988:    <p>In the following example, the tree construction stage will be
                    989:    called upon to handle a "p" start tag token while handling the
                    990:    "script" start tag token:</p>
                    991: 
                    992:    <pre>...
                    993: &lt;script&gt;
                    994:  document.write('&lt;p&gt;');
                    995: &lt;/script&gt;
                    996: ...</pre>
                    997: 
                    998:   </div>
                    999: 
                   1000:   <p>To handle these cases, parsers have a <dfn id="script-nesting-level">script nesting
                   1001:   level</dfn>, which must be initially set to zero, and a <dfn id="parser-pause-flag">parser
                   1002:   pause flag</dfn>, which must be initially set to false.</p>
                   1003: 
1.266     mike     1004:   </div><div class="impl">
1.1       mike     1005: 
1.724     mike     1006:   <h4 id="the-input-stream"><span class="secno">7.2.2 </span>The <dfn>input stream</dfn></h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     1007: 
                   1008:   <p>The stream of Unicode characters that comprises the input to the
                   1009:   tokenization stage will be initially seen by the user agent as a
                   1010:   stream of bytes (typically coming over the network or from the local
                   1011:   file system). The bytes encode the actual characters according to a
                   1012:   particular <em>character encoding</em>, which the user agent must
                   1013:   use to decode the bytes into characters.</p>
                   1014: 
                   1015:   <p class="note">For XML documents, the algorithm user agents must
                   1016:   use to determine the character encoding is given by the XML
1.104     mike     1017:   specification. This section does not apply to XML documents. <a href="references.html#refsXML">[XML]</a></p>
1.1       mike     1018: 
                   1019: 
1.724     mike     1020:   <h5 id="determining-the-character-encoding"><span class="secno">7.2.2.1 </span>Determining the character encoding</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     1021: 
                   1022:   <p>In some cases, it might be impractical to unambiguously determine
                   1023:   the encoding before parsing the document. Because of this, this
                   1024:   specification provides for a two-pass mechanism with an optional
                   1025:   pre-scan. Implementations are allowed, as described below, to apply
                   1026:   a simplified parsing algorithm to whatever bytes they have available
                   1027:   before beginning to parse the document. Then, the real parser is
                   1028:   started, using a tentative encoding derived from this pre-parse and
                   1029:   other out-of-band metadata. If, while the document is being loaded,
                   1030:   the user agent discovers an encoding declaration that conflicts with
                   1031:   this information, then the parser can get reinvoked to perform a
                   1032:   parse of the document with the real encoding.</p>
                   1033: 
                   1034:   <p id="documentEncoding">User agents must use the following
                   1035:   algorithm (the <dfn id="encoding-sniffing-algorithm">encoding sniffing algorithm</dfn>) to determine
                   1036:   the character encoding to use when decoding a document in the first
                   1037:   pass. This algorithm takes as input any out-of-band metadata
                   1038:   available to the user agent (e.g. the <a href="infrastructure.html#content-type" title="Content-Type">Content-Type metadata</a> of the document)
                   1039:   and all the bytes available so far, and returns an encoding and a
                   1040:   <dfn id="concept-encoding-confidence" title="concept-encoding-confidence">confidence</dfn>. The
                   1041:   confidence is either <i>tentative</i>, <i>certain</i>, or
                   1042:   <i>irrelevant</i>. The encoding used, and whether the confidence in
                   1043:   that encoding is <i>tentative</i> or <i>certain</i>, is <a href="#meta-charset-during-parse">used during the parsing</a> to
                   1044:   determine whether to <a href="#change-the-encoding">change the encoding</a>. If no
                   1045:   encoding is necessary, e.g. because the parser is operating on a
                   1046:   stream of Unicode characters and doesn't have to use an encoding at
                   1047:   all, then the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
                   1048:   <i>irrelevant</i>.</p>
                   1049: 
                   1050:   <ol><li><p>If the transport layer specifies an encoding, and it is
                   1051:    supported, return that encoding with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1052:    <i>certain</i>, and abort these steps.</p></li>
                   1053: 
                   1054:    <li><p>The user agent may wait for more bytes of the resource to be
                   1055:    available, either in this step or at any later step in this
                   1056:    algorithm. For instance, a user agent might wait 500ms or 512
                   1057:    bytes, whichever came first. In general preparsing the source to
                   1058:    find the encoding improves performance, as it reduces the need to
                   1059:    throw away the data structures used when parsing upon finding the
                   1060:    encoding information. However, if the user agent delays too long to
                   1061:    obtain data to determine the encoding, then the cost of the delay
                   1062:    could outweigh any performance improvements from the
                   1063:    preparse.</p></li>
                   1064: 
                   1065:    <li><p>For each of the rows in the following table, starting with
                   1066:    the first one and going down, if there are as many or more bytes
                   1067:    available than the number of bytes in the first column, and the
                   1068:    first bytes of the file match the bytes given in the first column,
                   1069:    then return the encoding given in the cell in the second column of
                   1070:    that row, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1071:    <i>certain</i>, and abort these steps:</p>
                   1072: 
                   1073:     <!-- this table is present in several forms in this file; keep them in sync -->
                   1074:     <table><thead><tr><th>Bytes in Hexadecimal
                   1075:        </th><th>Encoding
                   1076:      </th></tr></thead><tbody><!-- nobody uses this
                   1077:       <tr>
                   1078:        <td>00 00 FE FF
                   1079:        <td>UTF-32BE
                   1080:       <tr>
                   1081:        <td>FF FE 00 00
                   1082:        <td>UTF-32LE
                   1083: --><tr><td>FE FF
                   1084:        </td><td>UTF-16BE
                   1085:       </td></tr><tr><td>FF FE
                   1086:        </td><td>UTF-16LE
                   1087:       </td></tr><tr><td>EF BB BF
                   1088:        </td><td>UTF-8
                   1089: <!-- nobody uses this
                   1090:       <tr>
                   1091:        <td>DD 73 66 73
                   1092:        <td>UTF-EBCDIC
                   1093: -->
                   1094:     </td></tr></tbody></table><p class="note">This step looks for Unicode Byte Order Marks
                   1095:    (BOMs).</p></li>
                   1096: 
                   1097:    <li><p>Otherwise, the user agent will have to search for explicit
                   1098:    character encoding information in the file itself. This should
                   1099:    proceed as follows:
                   1100: 
                   1101:     </p><p>Let <var title="">position</var> be a pointer to a byte in the
                   1102:     input stream, initially pointing at the first byte. If at any
                   1103:     point during these substeps the user agent either runs out of
                   1104:     bytes or decides that scanning further bytes would not be
                   1105:     efficient, then skip to the next step of the overall character
                   1106:     encoding detection algorithm. User agents may decide that scanning
                   1107:     <em>any</em> bytes is not efficient, in which case these substeps
                   1108:     are entirely skipped.</p>
                   1109: 
                   1110:     <p>Now, repeat the following "two" steps until the algorithm
                   1111:     aborts (either because user agent aborts, as described above, or
                   1112:     because a character encoding is found):</p>
                   1113: 
                   1114:     <ol><li><p>If <var title="">position</var> points to:</p>
                   1115: 
                   1116:       <dl class="switch"><dt>A sequence of bytes starting with: 0x3C 0x21 0x2D 0x2D (ASCII '&lt;!--')</dt>
                   1117:        <dd>
                   1118: 
                   1119:         <p>Advance the <var title="">position</var> pointer so that it
                   1120:         points at the first 0x3E byte which is preceded by two 0x2D
                   1121:         bytes (i.e. at the end of an ASCII '--&gt;' sequence) and comes
                   1122:         after the 0x3C byte that was found. (The two 0x2D bytes can be
                   1123:         the same as the those in the '&lt;!--' sequence.)</p>
                   1124: 
                   1125:        </dd>
                   1126: 
                   1127:        <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>
                   1128:        <dd>
                   1129: 
                   1130:         <ol><li><p>Advance the <var title="">position</var> pointer so
                   1131:          that it points at the next 0x09, 0x0A, 0x0C, 0x0D, 0x20, or
                   1132:          0x2F byte (the one in sequence of characters matched
                   1133:          above).</p></li>
                   1134: 
                   1135:          <li><p><a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">Get
                   1136:          an attribute</a> and its value. If no attribute was
                   1137:          sniffed, then skip this inner set of steps, and jump to the
                   1138:          second step in the overall "two step" algorithm.</p></li>
                   1139: 
                   1140:          <li><p>If the attribute's name is neither "<code title="">charset</code>" nor "<code title="">content</code>",
                   1141:          then return to step 2 in these inner steps.</p></li>
                   1142: 
                   1143:          <li><p>If the attribute's name is "<code title="">charset</code>", let <var title="">charset</var> be
                   1144:          the attribute's value, interpreted as a character
                   1145:          encoding.</p></li>
                   1146: 
                   1147:          <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
                   1148:          extracting an encoding from a Content-Type</a>, giving the
                   1149:          attribute's value as the string to parse. If an encoding is
                   1150:          returned, let <var title="">charset</var> be that
                   1151:          encoding. Otherwise, return to step 2 in these inner
                   1152:          steps.</p></li>
                   1153: 
                   1154:          <li><p>If <var title="">charset</var> is a UTF-16 encoding,
                   1155:          change the value of <var title="">charset</var> to
                   1156:          UTF-8.</p></li>
                   1157: 
                   1158:          <li><p>If <var title="">charset</var> is a supported
                   1159:          character encoding, then return the given encoding, with
                   1160:          <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1161:          <i>tentative</i>, and abort all these steps.</p></li>
                   1162: 
                   1163:          <li><p>Otherwise, return to step 2 in these inner
                   1164:          steps.</p></li>
                   1165: 
                   1166:         </ol></dd>
                   1167: 
1.464     mike     1168:        <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     1169:        <dd>
                   1170: 
                   1171:         <ol><li><p>Advance the <var title="">position</var> pointer so
                   1172:          that it points at the next 0x09 (ASCII TAB), 0x0A (ASCII LF),
                   1173:          0x0C (ASCII FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E
1.464     mike     1174:          (ASCII &gt;) byte.</p></li>
1.1       mike     1175: 
                   1176:          <li><p>Repeatedly <a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">get an
                   1177:          attribute</a> until no further attributes can be found,
                   1178:          then jump to the second step in the overall "two step"
                   1179:          algorithm.</p></li>
                   1180: 
                   1181:         </ol></dd>
                   1182: 
                   1183:        <dt>A sequence of bytes starting with: 0x3C 0x21 (ASCII '&lt;!')</dt>
                   1184:        <dt>A sequence of bytes starting with: 0x3C 0x2F (ASCII '&lt;/')</dt>
                   1185:        <dt>A sequence of bytes starting with: 0x3C 0x3F (ASCII '&lt;?')</dt>
                   1186:        <dd>
                   1187: 
                   1188:         <p>Advance the <var title="">position</var> pointer so that it
1.464     mike     1189:         points at the first 0x3E byte (ASCII &gt;) that comes after the
1.1       mike     1190:         0x3C byte that was found.</p>
                   1191: 
                   1192:        </dd>
                   1193: 
                   1194:        <dt>Any other byte</dt>
                   1195:        <dd>
                   1196: 
                   1197:         <p>Do nothing with that byte.</p>
                   1198: 
                   1199:        </dd>
                   1200: 
                   1201:       </dl></li>
                   1202: 
                   1203:      <li>Move <var title="">position</var> so it points at the next
                   1204:      byte in the input stream, and return to the first step of this
                   1205:      "two step" algorithm.</li>
                   1206: 
                   1207:     </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
                   1208:     attribute</dfn>, it means doing this:</p>
                   1209: 
                   1210:     <ol><li><p>If the byte at <var title="">position</var> is one of 0x09
                   1211:      (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR),
1.464     mike     1212:      0x20 (ASCII space), or 0x2F (ASCII /) then advance <var title="">position</var> to the next byte and redo this
1.1       mike     1213:      substep.</p></li>
                   1214: 
                   1215:      <li><p>If the byte at <var title="">position</var> is 0x3E (ASCII
1.464     mike     1216:      &gt;), then abort the "get an attribute" algorithm. There isn't
1.1       mike     1217:      one.</p></li>
                   1218: 
                   1219:      <li><p>Otherwise, the byte at <var title="">position</var> is the
                   1220:      start of the attribute name. Let <var title="">attribute
                   1221:      name</var> and <var title="">attribute value</var> be the empty
                   1222:      string.</p></li>
                   1223: 
                   1224:      <li><p><i>Attribute name</i>: Process the byte at <var title="">position</var> as follows:</p>
                   1225: 
1.464     mike     1226:       <dl class="switch"><dt>If it is 0x3D (ASCII =), and the <var title="">attribute
1.1       mike     1227:        name</var> is longer than the empty string</dt>
                   1228: 
                   1229:        <dd>Advance <var title="">position</var> to the next byte and
                   1230:        jump to the step below labeled <i>value</i>.</dd>
                   1231: 
                   1232:        <dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
                   1233:        FF), 0x0D (ASCII CR), or 0x20 (ASCII space)</dt>
                   1234: 
                   1235:        <dd>Jump to the step below labeled <i>spaces</i>.</dd>
                   1236: 
1.464     mike     1237:        <dt>If it is 0x2F (ASCII /) or 0x3E (ASCII &gt;)</dt>
1.1       mike     1238: 
                   1239:        <dd>Abort the "get an attribute" algorithm. The attribute's
                   1240:        name is the value of <var title="">attribute name</var>, its
                   1241:        value is the empty string.</dd>
                   1242: 
1.464     mike     1243:        <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
                   1244:        Z)</dt>
1.1       mike     1245: 
                   1246:        <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
                   1247:        name</var> (where <var title="">b</var> is the value of the
                   1248:        byte at <var title="">position</var>).</dd>
                   1249: 
                   1250:        <dt>Anything else</dt>
                   1251: 
                   1252:        <dd>Append the Unicode character with the same code point as the
                   1253:        value of the byte at <var title="">position</var>) to <var title="">attribute name</var>. (It doesn't actually matter how
                   1254:        bytes outside the ASCII range are handled here, since only
                   1255:        ASCII characters can contribute to the detection of a character
                   1256:        encoding.)</dd>
                   1257: 
                   1258:       </dl></li>
                   1259: 
                   1260:      <li><p>Advance <var title="">position</var> to the next byte and
                   1261:      return to the previous step.</p></li>
                   1262: 
                   1263:      <li><p><i>Spaces</i>: If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
                   1264:      LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
                   1265:      advance <var title="">position</var> to the next byte, then,
                   1266:      repeat this step.</p></li>
                   1267: 
                   1268:      <li><p>If the byte at <var title="">position</var> is
1.464     mike     1269:      <em>not</em> 0x3D (ASCII =), abort the "get an attribute"
1.1       mike     1270:      algorithm. The attribute's name is the value of <var title="">attribute name</var>, its value is the empty
                   1271:      string.</p></li>
                   1272: 
                   1273:      <li><p>Advance <var title="">position</var> past the 0x3D (ASCII
1.464     mike     1274:      =) byte.</p></li>
1.1       mike     1275: 
                   1276:      <li><p><i>Value:</i> If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
                   1277:      LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
                   1278:      advance <var title="">position</var> to the next byte, then,
                   1279:      repeat this step.</p></li>
                   1280: 
                   1281:      <li><p>Process the byte at <var title="">position</var> as
                   1282:      follows:</p>
                   1283: 
1.464     mike     1284:       <dl class="switch"><dt>If it is 0x22 (ASCII ") or 0x27 (ASCII ')</dt>
1.1       mike     1285: 
                   1286:        <dd>
                   1287: 
                   1288:         <ol><li>Let <var title="">b</var> be the value of the byte at
                   1289:          <var title="">position</var>.</li>
                   1290: 
                   1291:          <li>Advance <var title="">position</var> to the next
                   1292:          byte.</li>
                   1293: 
                   1294:          <li>If the value of the byte at <var title="">position</var>
                   1295:          is the value of <var title="">b</var>, then advance <var title="">position</var> to the next byte and abort the "get
                   1296:          an attribute" algorithm. The attribute's name is the value of
                   1297:          <var title="">attribute name</var>, and its value is the
                   1298:          value of <var title="">attribute value</var>.</li>
                   1299: 
1.464     mike     1300:          <li>Otherwise, if the value of the byte at <var title="">position</var> is in the range 0x41 (ASCII A) to
                   1301:          0x5A (ASCII Z), then append a Unicode character to <var title="">attribute value</var> whose code point is 0x20 more
1.1       mike     1302:          than the value of the byte at <var title="">position</var>.</li>
                   1303: 
                   1304:          <li>Otherwise, append a Unicode character to <var title="">attribute value</var> whose code point is the same as
                   1305:          the value of the byte at <var title="">position</var>.</li>
                   1306: 
                   1307:          <li>Return to the second step in these substeps.</li>
                   1308: 
                   1309:         </ol></dd>
                   1310: 
1.464     mike     1311:        <dt>If it is 0x3E (ASCII &gt;)</dt>
1.1       mike     1312: 
                   1313:        <dd>Abort the "get an attribute" algorithm. The attribute's
                   1314:        name is the value of <var title="">attribute name</var>, its
                   1315:        value is the empty string.</dd>
                   1316: 
                   1317: 
1.464     mike     1318:        <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
                   1319:        Z)</dt>
1.1       mike     1320: 
                   1321:        <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
                   1322:        value</var> (where <var title="">b</var> is the value of the
                   1323:        byte at <var title="">position</var>). Advance <var title="">position</var> to the next byte.</dd>
                   1324: 
                   1325:        <dt>Anything else</dt>
                   1326: 
                   1327:        <dd>Append the Unicode character with the same code point as the
                   1328:        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>
                   1329: 
                   1330:       </dl></li>
                   1331: 
                   1332:      <li><p>Process the byte at <var title="">position</var> as
                   1333:      follows:</p>
                   1334: 
                   1335:       <dl class="switch"><dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
                   1336:        FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E (ASCII
1.464     mike     1337:        &gt;)</dt>
1.1       mike     1338: 
                   1339:        <dd>Abort the "get an attribute" algorithm. The attribute's
                   1340:        name is the value of <var title="">attribute name</var> and its
                   1341:        value is the value of <var title="">attribute value</var>.</dd>
                   1342: 
1.464     mike     1343:        <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
                   1344:        Z)</dt>
1.1       mike     1345: 
                   1346:        <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
                   1347:        value</var> (where <var title="">b</var> is the value of the
                   1348:        byte at <var title="">position</var>).</dd>
                   1349: 
                   1350:        <dt>Anything else</dt>
                   1351: 
                   1352:        <dd>Append the Unicode character with the same code point as the
                   1353:        value of the byte at <var title="">position</var>) to <var title="">attribute value</var>.</dd>
                   1354: 
                   1355:       </dl></li>
                   1356: 
                   1357:      <li><p>Advance <var title="">position</var> to the next byte and
                   1358:      return to the previous step.</p></li>
                   1359: 
                   1360:     </ol><p>For the sake of interoperability, user agents should not use a
                   1361:     pre-scan algorithm that returns different results than the one
                   1362:     described above. (But, if you do, please at least let us know, so
                   1363:     that we can improve this algorithm and benefit everyone...)</p>
                   1364: 
                   1365:    </li>
                   1366: 
                   1367:    <li><p>If the user agent has information on the likely encoding for
                   1368:    this page, e.g. based on the encoding of the page when it was last
                   1369:    visited, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1370:    <i>tentative</i>, and abort these steps.</p></li>
                   1371: 
1.322     mike     1372:    <li>
                   1373: 
                   1374:     <p>The user agent may attempt to autodetect the character encoding
                   1375:     from applying frequency analysis or other algorithms to the data
1.568     mike     1376:     stream. Such algorithms may use information about the resource
                   1377:     other than the resource's contents, including the address of the
                   1378:     resource. If autodetection succeeds in determining a character
1.322     mike     1379:     encoding, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1380:     <i>tentative</i>, and abort these steps. <a href="references.html#refsUNIVCHARDET">[UNIVCHARDET]</a></p>
                   1381: 
                   1382:     <p class="note">The UTF-8 encoding has a highly detectable bit
                   1383:     pattern. Documents that contain bytes with values greater than
                   1384:     0x7F which match the UTF-8 pattern are very likely to be UTF-8,
                   1385:     while documents with byte sequences that do not match it are very
                   1386:     likely not. User-agents are therefore encouraged to search for
1.485     mike     1387:     this common encoding. <a href="references.html#refsPPUTF8">[PPUTF8]</a> <a href="references.html#refsUTF8DET">[UTF8DET]</a></p>
1.322     mike     1388: 
                   1389:    </li>
1.1       mike     1390: 
1.501     mike     1391:    <li>
                   1392: 
                   1393:     <p>Otherwise, return an implementation-defined or user-specified
                   1394:     default character encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1395:     <i>tentative</i>.</p>
                   1396: 
                   1397:     <p>In controlled environments or in environments where the
                   1398:     encoding of documents can be prescribed (for example, for user
                   1399:     agents intended for dedicated use in new networks), the
                   1400:     comprehensive <code title="">UTF-8</code> encoding is
                   1401:     suggested.</p>
                   1402: 
                   1403:     <p>In other environments, the default encoding is typically
                   1404:     dependent on the user's locale (an approximation of the languages,
                   1405:     and thus typically encodings, of the pages that the user is likely
                   1406:     to frequent). The following table gives suggested defaults based
1.504     mike     1407:     on the user's locale, for compatibility with legacy
                   1408:     content. Locales are identified by BCP 47 language codes. <a href="references.html#refsBCP47">[BCP47]</a></p>
1.501     mike     1409: 
                   1410:     <!-- based on mozilla 1.9.1 localizations: 
                   1411:          http://mxr.mozilla.org/l10n-mozilla1.9.1/find?string=global%2Fintl.properties&tree=l10n-mozilla1.9.1&hint= -->
                   1412: 
1.504     mike     1413:     <table><thead><tr><th>Locale language
1.501     mike     1414:        </th><th>Suggested default encoding
                   1415:      </th></tr></thead><tbody><tr><td>ar
                   1416:        </td><td>UTF-8
                   1417: 
                   1418:       </td></tr><tr><td>be
                   1419:        </td><td>ISO-8859-5
                   1420: 
                   1421:       </td></tr><tr><td>bg
                   1422:        </td><td>windows-1251
                   1423: 
                   1424:       </td></tr><tr><td>cs<!-- -CZ -->
                   1425:        </td><td>ISO-8859-2
                   1426: 
                   1427:       </td></tr><tr><td>cy
                   1428:        </td><td>UTF-8
                   1429: 
                   1430:       </td></tr><tr><td>fa<!-- -IR -->
                   1431:        </td><td>UTF-8
                   1432: 
                   1433:       </td></tr><tr><td>he<!-- -IL -->
                   1434:        </td><td>windows-1255
                   1435: 
                   1436:       </td></tr><tr><td>hr
                   1437:        </td><td>UTF-8
                   1438: 
                   1439:       </td></tr><tr><td>hu<!-- -HU -->
                   1440:        </td><td>ISO-8859-2
                   1441: 
                   1442:       </td></tr><tr><td>ja <!-- and ja-JP-mac -->
                   1443:        </td><td>windows-31J <!-- Shift_JIS -->
                   1444: 
                   1445:       </td></tr><tr><td>kk
                   1446:        </td><td>UTF-8
                   1447: 
                   1448:       </td></tr><tr><td>ko<!-- -KR -->
                   1449:        </td><td>windows-949 <!-- EUC-KR -->
                   1450: 
                   1451:       </td></tr><tr><td>ku
                   1452:        </td><td>windows-1254 <!-- ISO-8859-9 -->
                   1453: 
                   1454:       </td></tr><tr><td>lt
                   1455:        </td><td>windows-1257
                   1456: 
                   1457:       </td></tr><tr><td>lv<!-- -LV -->
                   1458:        </td><td>ISO-8859-13
                   1459: 
                   1460:       </td></tr><tr><td>mk<!-- -MK -->
                   1461:        </td><td>UTF-8
                   1462: 
                   1463:       </td></tr><tr><td>or
                   1464:        </td><td>UTF-8
                   1465: 
                   1466:       </td></tr><tr><td>pl<!-- -PL -->
                   1467:        </td><td>ISO-8859-2
                   1468: 
                   1469:       </td></tr><tr><td>ro
                   1470:        </td><td>UTF-8
                   1471: 
                   1472:       </td></tr><tr><td>ru
                   1473:        </td><td>windows-1251
                   1474: 
                   1475:       </td></tr><tr><td>sk
                   1476:        </td><td>windows-1250
                   1477: 
                   1478:       </td></tr><tr><td>sl
                   1479:        </td><td>ISO-8859-2
                   1480: 
                   1481:       </td></tr><tr><td>sr
                   1482:        </td><td>UTF-8
                   1483: 
                   1484:       </td></tr><tr><td>th
                   1485:        </td><td>windows-874 <!-- TIS-620 -->
                   1486: 
                   1487:       </td></tr><tr><td>tr<!-- -TR -->
                   1488:        </td><td>windows-1254 <!-- ISO-8859-9 -->
                   1489: 
1.503     mike     1490:       </td></tr><tr><td>uk
1.501     mike     1491:        </td><td>windows-1251
                   1492: 
                   1493:       </td></tr><tr><td>vi
                   1494:        </td><td>UTF-8
                   1495: 
                   1496:       </td></tr><tr><td>zh-CN
                   1497:        </td><td>GB18030
                   1498: 
                   1499:       </td></tr><tr><td>zh-TW
                   1500:        </td><td>Big5
                   1501: 
                   1502:       </td></tr><tr><td>All other locales
                   1503:        </td><td>windows-1252
                   1504: 
                   1505:     </td></tr></tbody></table></li>
1.1       mike     1506: 
                   1507:   </ol><p>The <a href="dom.html#document-s-character-encoding">document's character encoding</a> must immediately
                   1508:   be set to the value returned from this algorithm, at the same time
                   1509:   as the user agent uses the returned value to select the decoder to
                   1510:   use for the input stream.</p>
                   1511: 
1.582     mike     1512:   <p class="note">This algorithm is a <a href="introduction.html#willful-violation">willful violation</a>
                   1513:   of the HTTP specification, which requires that the encoding be
                   1514:   assumed to be ISO-8859-1 in the absence of a <a href="semantics.html#character-encoding-declaration">character
1.647     mike     1515:   encoding declaration</a> to the contrary, and of RFC 2046,
1.582     mike     1516:   which requires that the encoding be assumed to be US-ASCII in the
                   1517:   absence of a <a href="semantics.html#character-encoding-declaration">character encoding declaration</a> to the
                   1518:   contrary. This specification's third approach is motivated by a
                   1519:   desire to be maximally compatible with legacy content. <a href="references.html#refsHTTP">[HTTP]</a> <a href="references.html#refsRFC2046">[RFC2046]</a></p>
                   1520: 
1.1       mike     1521: 
1.724     mike     1522:   <h5 id="character-encodings-0"><span class="secno">7.2.2.2 </span>Character encodings</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     1523: 
1.237     mike     1524:   <p>User agents must at a minimum support the UTF-8 and Windows-1252
                   1525:   encodings, but may support more.</p>
                   1526: 
                   1527:   <p class="note">It is not unusual for Web browsers to support dozens
                   1528:   if not upwards of a hundred distinct character encodings.</p>
                   1529: 
1.365     mike     1530:   <p>User agents must support the <a href="infrastructure.html#preferred-mime-name">preferred MIME name</a> of
                   1531:   every character encoding they support, and should support all the
                   1532:   IANA-registered names and aliases of every character encoding they
                   1533:   support. <a href="references.html#refsIANACHARSET">[IANACHARSET]</a></p>
1.237     mike     1534: 
                   1535:   <p>When comparing a string specifying a character encoding with the
                   1536:   name or alias of a character encoding to determine if they are
                   1537:   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
                   1538:   then perform the comparison in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   1539:   case-insensitive</a> manner.</p>
                   1540: 
1.539     mike     1541:   <hr><p>When a user agent would otherwise use an encoding given in the
1.237     mike     1542:   first column of the following table to either convert content to
                   1543:   Unicode characters or convert Unicode characters to bytes, it must
                   1544:   instead use the encoding given in the cell in the second column of
                   1545:   the same row. When a byte or sequence of bytes is treated
                   1546:   differently due to this encoding aliasing, it is said to have been
                   1547:   <dfn id="misinterpreted-for-compatibility">misinterpreted for compatibility</dfn>.</p>
                   1548: 
                   1549:   <table><caption>Character encoding overrides</caption>
                   1550:    <thead><tr><th> Input encoding </th><th> Replacement encoding </th><th> References
                   1551:    </th></tr></thead><tbody><!-- how about EUC-JP? --><tr><td> EUC-KR </td><td> windows-949 </td><td>
                   1552:          <a href="references.html#refsEUCKR">[EUCKR]</a>
                   1553:          <a href="references.html#refsWIN949">[WIN949]</a>
                   1554:     </td></tr><tr><td> GB2312 </td><td> GBK </td><td>
                   1555:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1556:          <a href="references.html#refsGBK">[GBK]</a>
                   1557:     </td></tr><tr><td> GB_2312-80 </td><td> GBK </td><td>
                   1558:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1559:          <a href="references.html#refsGBK">[GBK]</a>
                   1560:     </td></tr><tr><td> ISO-8859-1 </td><td> windows-1252 </td><td>
                   1561:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1562:          <a href="references.html#refsWIN1252">[WIN1252]</a>
                   1563:     </td></tr><tr><td> ISO-8859-9 </td><td> windows-1254 </td><td>
                   1564:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1565:          <a href="references.html#refsWIN1254">[WIN1254]</a>
                   1566:     </td></tr><tr><td> ISO-8859-11 </td><td> windows-874 </td><td>
                   1567:          <a href="references.html#refsISO885911">[ISO885911]</a>
                   1568:          <a href="references.html#refsWIN874">[WIN874]</a>
                   1569:     </td></tr><tr><td> KS_C_5601-1987 </td><td> windows-949 </td><td>
                   1570:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1571:          <a href="references.html#refsWIN949">[WIN949]</a>
                   1572:     </td></tr><tr><td> Shift_JIS </td><td> windows-31J </td><td>
                   1573:          <a href="references.html#refsSHIFTJIS">[SHIFTJIS]</a>
                   1574:          <a href="references.html#refsWIN31J">[WIN31J]</a>
                   1575:     </td></tr><tr><td> TIS-620 </td><td> windows-874 </td><td>
                   1576:          <a href="references.html#refsTIS620">[TIS620]</a>
                   1577:          <a href="references.html#refsWIN874">[WIN874]</a>
                   1578:     </td></tr><tr><td> US-ASCII </td><td> windows-1252 </td><td>
                   1579:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1580:          <a href="references.html#refsWIN1252">[WIN1252]</a>
                   1581:    </td></tr></tbody></table><p class="note">The requirement to treat certain encodings as other
                   1582:   encodings according to the table above is a <a href="introduction.html#willful-violation">willful
                   1583:   violation</a> of the W3C Character Model specification, motivated
                   1584:   by a desire for compatibility with legacy content. <a href="references.html#refsCHARMOD">[CHARMOD]</a></p>
                   1585: 
                   1586:   <p>When a user agent is to use the UTF-16 encoding but no BOM has
                   1587:   been found, user agents must default to UTF-16LE.</p>
                   1588: 
                   1589:   <p class="note">The requirement to default UTF-16 to LE rather than
                   1590:   BE is a <a href="introduction.html#willful-violation">willful violation</a> of RFC 2781, motivated by a
1.581     mike     1591:   desire for compatibility with legacy content. <a href="references.html#refsRFC2781">[RFC2781]</a></p>
1.237     mike     1592: 
                   1593:   <hr><p>User agents must not support the CESU-8, UTF-7, BOCU-1 and SCSU
                   1594:   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>
                   1595: 
                   1596:   <p>Support for encodings based on EBCDIC is not recommended. This
                   1597:   encoding is rarely used for publicly-facing Web content.</p>
                   1598: 
                   1599:   <p>Support for UTF-32 is not recommended. This encoding is rarely
                   1600:   used, and frequently implemented incorrectly.</p>
                   1601: 
                   1602:   <p class="note">This specification does not make any attempt to
                   1603:   support EBCDIC-based encodings and UTF-32 in its algorithms; support
                   1604:   and use of these encodings can thus lead to unexpected behavior in
                   1605:   implementations of this specification.</p>
                   1606: 
                   1607: 
                   1608: 
1.724     mike     1609:   <h5 id="preprocessing-the-input-stream"><span class="secno">7.2.2.3 </span>Preprocessing the input stream</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     1610: 
                   1611:   <p>Given an encoding, the bytes in the input stream must be
                   1612:   converted to Unicode characters for the tokenizer, as described by
                   1613:   the rules for that encoding, except that the leading U+FEFF BYTE
                   1614:   ORDER MARK character, if any, must not be stripped by the encoding
                   1615:   layer (it is stripped by the rule below).</p> <!-- this is to
                   1616:   prevent two leading BOMs from being both stripped, once by the
                   1617:   decoder, and once by the parser -->
                   1618: 
                   1619:   <p>Bytes or sequences of bytes in the original byte stream that
1.393     mike     1620:   could not be converted to Unicode code points must be converted to
                   1621:   U+FFFD REPLACEMENT CHARACTERs.</p>
1.1       mike     1622: 
                   1623:   <p class="note">Bytes or sequences of bytes in the original byte
                   1624:   stream that did not conform to the encoding specification
                   1625:   (e.g. invalid UTF-8 byte sequences in a UTF-8 input stream) are
                   1626:   errors that conformance checkers are expected to report.</p>
                   1627: 
1.438     mike     1628:   <p>Any byte or sequence of bytes in the original byte stream that is
                   1629:   <a href="#misinterpreted-for-compatibility">misinterpreted for compatibility</a> is a <a href="#parse-error">parse
1.1       mike     1630:   error</a>.</p>
                   1631: 
                   1632:   <p>One leading U+FEFF BYTE ORDER MARK character must be ignored if
                   1633:   any are present.</p>
                   1634: 
1.300     mike     1635:   <p class="note">The requirement to strip a U+FEFF BYTE ORDER MARK
                   1636:   character regardless of whether that character was used to determine
                   1637:   the byte order is a <a href="introduction.html#willful-violation">willful violation</a> of Unicode,
                   1638:   motivated by a desire to increase the resilience of user agents in
                   1639:   the face of na&#239;ve transcoders.</p>
                   1640: 
1.316     mike     1641:   <p>All U+0000 NULL characters and code points in the range U+D800 to
1.315     mike     1642:   U+DFFF<!-- surrogates not allowed e.g. in UTF-8, and we don't want
                   1643:   them to suddenly turn into codepoints when they go through a UTF-16
                   1644:   pipe --> in the input must be replaced by U+FFFD REPLACEMENT
1.316     mike     1645:   CHARACTERs. Any occurrences of such characters and code points are
                   1646:   <a href="#parse-error" title="parse error">parse errors</a>.</p>
1.1       mike     1647: 
                   1648:   <p>Any occurrences of any characters in the ranges U+0001 to U+0008,
                   1649:   <!-- HT, LF allowed --> <!-- U+000B is in the next list --> <!-- FF,
                   1650:   CR allowed --> U+000E to U+001F, <!-- ASCII allowed --> U+007F
1.315     mike     1651:   <!--to U+0084, (U+0085 NEL not allowed), U+0086--> to U+009F, U+FDD0
                   1652:   to U+FDEF, and characters U+000B, U+FFFE, U+FFFF, U+1FFFE, U+1FFFF,
                   1653:   U+2FFFE, U+2FFFF, U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE,
                   1654:   U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF,
                   1655:   U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE,
                   1656:   U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF,
                   1657:   U+10FFFE, and U+10FFFF are <a href="#parse-error" title="parse error">parse
1.316     mike     1658:   errors</a>. These are all control characters or permanently
                   1659:   undefined Unicode characters (noncharacters).</p>
1.1       mike     1660: 
                   1661:   <p>U+000D CARRIAGE RETURN (CR) characters and U+000A LINE FEED (LF)
                   1662:   characters are treated specially. Any CR characters that are
                   1663:   followed by LF characters must be removed, and any CR characters not
                   1664:   followed by LF characters must be converted to LF characters. Thus,
                   1665:   newlines in HTML DOMs are represented by LF characters, and there
                   1666:   are never any CR characters in the input to the
                   1667:   <a href="#tokenization">tokenization</a> stage.</p>
                   1668: 
                   1669:   <p>The <dfn id="next-input-character">next input character</dfn> is the first character in the
                   1670:   input stream that has not yet been <dfn id="consumed">consumed</dfn>. Initially,
                   1671:   the <i><a href="#next-input-character">next input character</a></i> is the first character in the
                   1672:   input. The <dfn id="current-input-character">current input character</dfn> is the last character
                   1673:   to have been <i><a href="#consumed">consumed</a></i>.</p>
                   1674: 
                   1675:   <p>The <dfn id="insertion-point">insertion point</dfn> is the position (just before a
                   1676:   character or just before the end of the input stream) where content
1.159     mike     1677:   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     1678:   inserted. The insertion point is relative to the position of the
                   1679:   character immediately after it, it is not an absolute offset into
                   1680:   the input stream. Initially, the insertion point is
1.10      mike     1681:   undefined.</p>
1.1       mike     1682: 
                   1683:   <p>The "EOF" character in the tables below is a conceptual character
                   1684:   representing the end of the <a href="#the-input-stream">input stream</a>. If the parser
1.159     mike     1685:   is a <a href="embedded-content-0.html#script-created-parser">script-created parser</a>, then the end of the
1.1       mike     1686:   <a href="#the-input-stream">input stream</a> is reached when an <dfn id="explicit-eof-character">explicit "EOF"
1.159     mike     1687:   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     1688:   consumed. Otherwise, the "EOF" character is not a real character in
                   1689:   the stream, but rather the lack of any further characters.</p>
                   1690: 
                   1691: 
1.724     mike     1692:   <h5 id="changing-the-encoding-while-parsing"><span class="secno">7.2.2.4 </span>Changing the encoding while parsing</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     1693: 
                   1694:   <p>When the parser requires the user agent to <dfn id="change-the-encoding">change the
                   1695:   encoding</dfn>, it must run the following steps. This might happen
                   1696:   if the <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> described above
                   1697:   failed to find an encoding, or if it found an encoding that was not
                   1698:   the actual encoding of the file.</p>
                   1699: 
                   1700:   <ol><li>If the new encoding is identical or equivalent to the encoding
                   1701:    that is already being used to interpret the input stream, then set
                   1702:    the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1703:    <i>certain</i> and abort these steps. This happens when the
                   1704:    encoding information found in the file matches what the
                   1705:    <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> determined to be the
                   1706:    encoding, and in the second pass through the parser if the first
                   1707:    pass found that the encoding sniffing algorithm described in the
                   1708:    earlier section failed to find the right encoding.</li>
                   1709: 
                   1710:    <li>If the encoding that is already being used to interpret the
                   1711:    input stream is a UTF-16 encoding, then set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1712:    <i>certain</i> and abort these steps. The new encoding is ignored;
                   1713:    if it was anything but the same encoding, then it would be clearly
                   1714:    incorrect.</li>
                   1715: 
                   1716:    <li>If the new encoding is a UTF-16 encoding, change it to
                   1717:    UTF-8.</li>
                   1718: 
                   1719:    <li>If all the bytes up to the last byte converted by the current
                   1720:    decoder have the same Unicode interpretations in both the current
                   1721:    encoding and the new encoding, and if the user agent supports
                   1722:    changing the converter on the fly, then the user agent may change
                   1723:    to the new converter for the encoding on the fly. Set the
                   1724:    <a href="dom.html#document-s-character-encoding">document's character encoding</a> and the encoding used to
                   1725:    convert the input stream to the new encoding, set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1726:    <i>certain</i>, and abort these steps.</li>
                   1727: 
                   1728:    <li>Otherwise, <a href="history.html#navigate">navigate</a> to the document again, with
                   1729:    <a href="history.html#replacement-enabled">replacement enabled</a>, and using the same <a href="history.html#source-browsing-context">source
                   1730:    browsing context</a>, but this time skip the <a href="#encoding-sniffing-algorithm">encoding
                   1731:    sniffing algorithm</a> and instead just set the encoding to the
                   1732:    new encoding and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1733:    <i>certain</i>. Whenever possible, this should be done without
                   1734:    actually contacting the network layer (the bytes should be
                   1735:    re-parsed from memory), even if, e.g., the document is marked as
                   1736:    not being cacheable. If this is not possible and contacting the
                   1737:    network layer would involve repeating a request that uses a method
                   1738:    other than HTTP GET (<a href="infrastructure.html#concept-http-equivalent-get" title="concept-http-equivalent-get">or
                   1739:    equivalent</a> for non-HTTP URLs), then instead set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1740:    <i>certain</i> and ignore the new encoding. The resource will be
                   1741:    misinterpreted. User agents may notify the user of the situation,
                   1742:    to aid in application development.</li>
                   1743: 
1.266     mike     1744:   </ol></div><div class="impl">
                   1745: 
1.724     mike     1746:   <h4 id="parse-state"><span class="secno">7.2.3 </span>Parse state</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     1747: 
1.724     mike     1748:   <h5 id="the-insertion-mode"><span class="secno">7.2.3.1 </span>The insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     1749: 
                   1750:   <p>The <dfn id="insertion-mode">insertion mode</dfn> is a state variable that controls
                   1751:   the primary operation of the tree construction stage.</p>
                   1752: 
                   1753:   <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
                   1754:   "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before html</a>",
                   1755:   "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before head</a>",
                   1756:   "<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     1757:   "<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     1758:   "<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>",
                   1759:   "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table body</a>",
                   1760:   "<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
                   1761:   table</a>", "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in
                   1762:   foreign content</a>", "<a href="#parsing-main-afterbody" title="insertion mode: after
                   1763:   body">after body</a>", "<a href="#parsing-main-inframeset" title="insertion mode: in
                   1764:   frameset">in frameset</a>", "<a href="#parsing-main-afterframeset" title="insertion mode: after
                   1765:   frameset">after frameset</a>", "<a href="#the-after-after-body-insertion-mode" title="insertion mode:
                   1766:   after after body">after after body</a>", and "<a href="#the-after-after-frameset-insertion-mode" title="insertion mode: after after frameset">after after
                   1767:   frameset</a>" during the course of the parsing, as described in
                   1768:   the <a href="#tree-construction">tree construction</a> stage. The insertion mode affects
                   1769:   how tokens are processed and whether CDATA sections are
                   1770:   supported.</p>
                   1771: 
                   1772:   <p>Seven of these modes, namely "<a href="#parsing-main-inhead" title="insertion mode: in
                   1773:   head">in head</a>", "<a href="#parsing-main-inbody" title="insertion mode: in body">in
                   1774:   body</a>", "<a href="#parsing-main-intable" title="insertion mode: in table">in
                   1775:   table</a>", "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   1776:   body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in row</a>",
                   1777:   "<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
                   1778:   that the other modes defer to them at various times. When the
                   1779:   algorithm below says that the user agent is to do something
                   1780:   "<dfn id="using-the-rules-for">using the rules for</dfn> the <var title="">m</var> insertion
                   1781:   mode", where <var title="">m</var> is one of these modes, the user
                   1782:   agent must use the rules described under the <var title="">m</var>
                   1783:   <a href="#insertion-mode">insertion mode</a>'s section, but must leave the
                   1784:   <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>
                   1785:   to a new value.</p>
                   1786: 
                   1787:   <p>When the insertion mode is switched to "<a href="#parsing-main-incdata" title="insertion
1.540     mike     1788:   mode: text">text</a>" or "<a href="#parsing-main-intabletext" title="insertion mode: in table
                   1789:   text">in table text</a>", the <dfn id="original-insertion-mode">original insertion mode</dfn>
                   1790:   is also set. This is the insertion mode to which the tree
                   1791:   construction stage will return.</p>
1.1       mike     1792: 
                   1793:   <p>When the insertion mode is switched to "<a href="#parsing-main-inforeign" title="insertion
                   1794:   mode: in foreign content">in foreign content</a>", the
                   1795:   <dfn id="secondary-insertion-mode">secondary insertion mode</dfn> is also set. This secondary mode
                   1796:   is used within the rules for the "<a href="#parsing-main-inforeign" title="insertion mode: in
                   1797:   foreign content">in foreign content</a>" mode to handle HTML
                   1798:   (i.e. not foreign) content.</p>
                   1799: 
                   1800:   <hr><p>When the steps below require the UA to <dfn id="reset-the-insertion-mode-appropriately">reset the insertion
                   1801:   mode appropriately</dfn>, it means the UA must follow these
                   1802:   steps:</p>
                   1803: 
                   1804:   <ol><li>Let <var title="">last</var> be false.</li>
                   1805: 
1.604     mike     1806:    <li>Let <var title="">foreign</var> be false.</li>
                   1807: 
1.1       mike     1808:    <li>Let <var title="">node</var> be the last node in the
                   1809:    <a href="#stack-of-open-elements">stack of open elements</a>.</li>
                   1810: 
1.604     mike     1811:    <li><i>Loop</i>: If <var title="">node</var> is the first node in
                   1812:    the stack of open elements, then set <var title="">last</var> to
                   1813:    true and set <var title="">node</var> to the <var title="">context</var> element. (<a href="#fragment-case">fragment case</a>)</li>
1.1       mike     1814: 
                   1815:    <li>If <var title="">node</var> is a <code><a href="forms.html#the-select-element">select</a></code> element,
1.604     mike     1816:    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 jump to the
                   1817:    step marked <i title="">end</i>. (<a href="#fragment-case">fragment case</a>)</li>
1.1       mike     1818: 
                   1819:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-td-element">td</a></code> or
                   1820:    <code><a href="tabular-data.html#the-th-element">th</a></code> element and <var title="">last</var> is false, then
                   1821:    switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion
1.604     mike     1822:    mode: in cell">in cell</a>" and jump to the step marked <i title="">end</i>.</li>
1.1       mike     1823: 
                   1824:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then
                   1825:    switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion
1.604     mike     1826:    mode: in row">in row</a>" and jump to the step marked <i title="">end</i>.</li>
1.1       mike     1827: 
                   1828:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>,
                   1829:    <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
                   1830:    <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in
1.604     mike     1831:    table body">in table body</a>" and jump to the step marked <i title="">end</i>.</li>
1.1       mike     1832: 
                   1833:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-caption-element">caption</a></code> element,
1.604     mike     1834:    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 jump to
                   1835:    the step marked <i title="">end</i>.</li>
1.1       mike     1836: 
                   1837:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element,
                   1838:    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
1.604     mike     1839:    jump to the step marked <i title="">end</i>. (<a href="#fragment-case">fragment
                   1840:    case</a>)</li>
1.1       mike     1841: 
                   1842:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-table-element">table</a></code> element,
1.604     mike     1843:    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 jump to the
                   1844:    step marked <i title="">end</i>.</li>
1.1       mike     1845: 
1.159     mike     1846:    <li>If <var title="">node</var> is a <code><a href="semantics.html#the-head-element-0">head</a></code> element,
1.604     mike     1847:    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 jump to
                   1848:    the step marked <i title="">end</i>. (<a href="#fragment-case">fragment
                   1849:    case</a>)</li> <!-- This is only here for now in case people
                   1850:    think that the spec accidentally omitted it and try to "fix"
                   1851:    it. Note that noscript-in-head is also handled this way. This is
                   1852:    all intentional. The only thing it doesn't handle is the
                   1853:    scripting-disabled fragment parsing case for a <head> element
                   1854:    containing a <noscript> which itself contains something other than
                   1855:    a <link> or a <style> element; you'd expect that to break out of
                   1856:    the <noscript> but it doesn't. This is an edge case that doesn't
                   1857:    affect the spec, since the algorithm for fragment parsing is only
                   1858:    used for innerHTML/outerHTML/insertAdjacentHTML(), where we know
                   1859:    scripting is enabled. -->
1.1       mike     1860: 
1.159     mike     1861:    <li>If <var title="">node</var> is a <code><a href="semantics.html#the-body-element-0">body</a></code> element,
1.604     mike     1862:    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 jump to the
                   1863:    step marked <i title="">end</i>.</li>
1.1       mike     1864: 
1.5       mike     1865:    <li>If <var title="">node</var> is a <code><a href="obsolete.html#frameset">frameset</a></code> element,
1.604     mike     1866:    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 jump to
                   1867:    the step marked <i title="">end</i>. (<a href="#fragment-case">fragment
                   1868:    case</a>)</li>
1.1       mike     1869: 
1.159     mike     1870:    <li>If <var title="">node</var> is an <code><a href="semantics.html#the-html-element-0">html</a></code> element,
1.333     mike     1871:    then <!--: if the <span><code title="">head</code> element
                   1872:    pointer</span> is null,--> switch the <a href="#insertion-mode">insertion mode</a>
                   1873:    to "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before
                   1874:    head</a>"<!--, otherwise, switch the <span>insertion mode</span>
                   1875:    to "<span title="insertion mode: after head">after head</span>".-->
1.604     mike     1876:    Then, <!-- in either case, --> jump to the step marked <i title="">end</i>. (<a href="#fragment-case">fragment case</a>)</li> <!-- if the
                   1877:    head element pointer can ever be non-null when we're going through
                   1878:    these steps, we'll need to uncomment out the commented-out bits -->
                   1879: 
1.724     mike     1880:    <li>If <var title="">node</var> is an element from the <a href="infrastructure.html#mathml-namespace">MathML
                   1881:    namespace</a> or the <a href="infrastructure.html#svg-namespace">SVG namespace</a>, then set the
1.604     mike     1882:    <var title="">foreign</var> flag to true.</li>
1.1       mike     1883: 
                   1884:    <li>If <var title="">last</var> is true, then switch the
                   1885:    <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in
1.604     mike     1886:    body">in body</a>" and jump to the step marked <i title="">end</i>. (<a href="#fragment-case">fragment case</a>)</li>
1.1       mike     1887: 
                   1888:    <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
                   1889:    elements</a>.</li>
                   1890: 
1.604     mike     1891:    <li>Return to the step marked <i>loop</i>.</li>
                   1892: 
                   1893:    <li><i>End</i>: If <var title="">foreign</var> is true, switch the
                   1894:    <a href="#secondary-insertion-mode">secondary insertion mode</a> to whatever the
                   1895:    <a href="#insertion-mode">insertion mode</a> is set to, and switch the
                   1896:    <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
                   1897:    foreign content">in foreign content</a>".</li>
1.1       mike     1898: 
1.724     mike     1899:   </ol><h5 id="the-stack-of-open-elements"><span class="secno">7.2.3.2 </span>The stack of open elements</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     1900: 
                   1901:   <p>Initially, the <dfn id="stack-of-open-elements">stack of open elements</dfn> is empty. The
                   1902:   stack grows downwards; the topmost node on the stack is the first
                   1903:   one added to the stack, and the bottommost node of the stack is the
                   1904:   most recently added node in the stack (notwithstanding when the
                   1905:   stack is manipulated in a random access fashion as part of <a href="#adoptionAgency">the handling for misnested tags</a>).</p>
                   1906: 
                   1907:   <p>The "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before
                   1908:   html</a>" <a href="#insertion-mode">insertion mode</a> creates the
1.159     mike     1909:   <code><a href="semantics.html#the-html-element-0">html</a></code> root element node, which is then added to the
1.1       mike     1910:   stack.</p>
                   1911: 
                   1912:   <p>In the <a href="#fragment-case">fragment case</a>, the <a href="#stack-of-open-elements">stack of open
1.159     mike     1913:   elements</a> is initialized to contain an <code><a href="semantics.html#the-html-element-0">html</a></code>
1.1       mike     1914:   element that is created as part of <a href="#html-fragment-parsing-algorithm" title="html fragment
                   1915:   parsing algorithm">that algorithm</a>. (The <a href="#fragment-case">fragment
                   1916:   case</a> skips the "<a href="#the-before-html-insertion-mode" title="insertion mode: before
                   1917:   html">before html</a>" <a href="#insertion-mode">insertion mode</a>.)</p>
                   1918: 
1.159     mike     1919:   <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     1920:   node of the stack. It never gets popped off the stack.</p>
                   1921: 
                   1922:   <p>The <dfn id="current-node">current node</dfn> is the bottommost node in this
                   1923:   stack.</p>
                   1924: 
                   1925:   <p>The <dfn id="current-table">current table</dfn> is the last <code><a href="tabular-data.html#the-table-element">table</a></code>
                   1926:   element in the <a href="#stack-of-open-elements">stack of open elements</a>, if there is
                   1927:   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
                   1928:   open elements</a> (<a href="#fragment-case">fragment case</a>), then the
                   1929:   <a href="#current-table">current table</a> is the first element in the <a href="#stack-of-open-elements">stack
1.159     mike     1930:   of open elements</a> (the <code><a href="semantics.html#the-html-element-0">html</a></code> element).</p>
1.1       mike     1931: 
                   1932:   <p>Elements in the stack fall into the following categories:</p>
                   1933: 
                   1934:   <dl><dt><dfn id="special">Special</dfn></dt>
                   1935: 
                   1936:    <dd><p>The following HTML elements have varying levels of special
                   1937:    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>,
                   1938:    <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.724     mike     1939:    <code><a href="obsolete.html#basefont">basefont</a></code>, <code><a href="obsolete.html#bgsound">bgsound</a></code>,
1.159     mike     1940:    <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     1941:    <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     1942:    <code><a href="interactive-elements.html#the-command">command</a></code>, <!--v2DDATAGRID--><code>datagrid</code>,
1.422     mike     1943:    <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>,
                   1944:    <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>,
                   1945:    <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>,
                   1946:    <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>,
                   1947:    <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>,
                   1948:    <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>,
                   1949:    <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>,
                   1950:    <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>,
                   1951:    (commented out because this isn't an element that can end up on the
                   1952:    stack, so it doesn't matter) --> <code><a href="text-level-semantics.html#the-img-element">img</a></code>,
                   1953:    <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>,
                   1954:    <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>,
                   1955:    <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>,
                   1956:    <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>,
                   1957:    <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>,
                   1958:    <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>,
1.589     mike     1959:    <code><a href="forms.html#the-select-element">select</a></code>, <code><a href="semantics.html#the-style-element">style</a></code>, <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>,
                   1960:    <code><a href="forms.html#the-textarea-element">textarea</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>,
                   1961:    <code><a href="semantics.html#the-title-element-0">title</a></code>, <code><a href="tabular-data.html#the-tr-element">tr</a></code>, <code><a href="semantics.html#the-ul-element">ul</a></code>,
1.724     mike     1962:    <code><a href="obsolete.html#wbr">wbr</a></code>, and <code><a href="obsolete.html#xmp">xmp</a></code>.</p></dd>
1.1       mike     1963: 
                   1964:    <dt><dfn id="scoping">Scoping</dfn></dt>
                   1965:    <dd><p>The following HTML elements introduce new <a href="#has-an-element-in-scope" title="has
                   1966:    an element in scope">scopes</a> for various parts of the
1.5       mike     1967:    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     1968:    <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>,
                   1969:    <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     1970:    <code><a href="tabular-data.html#the-th-element">th</a></code>, and SVG's <code>foreignObject</code>.</p></dd>
                   1971: 
                   1972:    <dt><dfn id="formatting">Formatting</dfn></dt>
                   1973:    <dd><p>The following HTML elements are those that end up in the
                   1974:    <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     1975:    <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>,
                   1976:    <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>,
1.724     mike     1977:    <code><a href="obsolete.html#nobr">nobr</a></code>, <code><a href="obsolete.html#s">s</a></code>, <code><a href="text-level-semantics.html#the-small-element">small</a></code>,
1.5       mike     1978:    <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
                   1979:    <code><a href="obsolete.html#u">u</a></code>.</p></dd>
1.1       mike     1980: 
                   1981:    <dt><dfn id="phrasing">Phrasing</dfn></dt>
                   1982:    <dd><p>All other elements found while parsing an HTML
                   1983:    document.</p></dd>
                   1984: 
1.234     mike     1985:   </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
                   1986:   specific scope</dfn> consisting of a list of element types <var title="">list</var> when the following algorithm terminates in a
                   1987:   match state:</p>
1.1       mike     1988: 
                   1989:   <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
                   1990:    node</a> (the bottommost node of the stack).</p></li>
                   1991: 
                   1992:    <li><p>If <var title="">node</var> is the target node, terminate in
                   1993:    a match state.</p></li>
                   1994: 
1.234     mike     1995:    <li><p>Otherwise, if <var title="">node</var> is one of the element
                   1996:    types in <var title="">list</var>, terminate in a failure
                   1997:    state.</p></li>
1.1       mike     1998: 
                   1999:    <li><p>Otherwise, set <var title="">node</var> to the previous
                   2000:    entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to step
                   2001:    2. (This will never fail, since the loop will always terminate in
                   2002:    the previous step if the top of the stack &#8212; an
1.159     mike     2003:    <code><a href="semantics.html#the-html-element-0">html</a></code> element &#8212; is reached.)</p></li>
1.1       mike     2004: 
1.234     mike     2005:   </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
                   2006:   it <a href="#has-an-element-in-the-specific-scope">has an element in the specific scope</a> consisting
                   2007:   of the following element types:</p>
                   2008: 
                   2009:   <ul class="brief"><li><code><a href="obsolete.html#the-applet-element">applet</a></code> in the HTML namespace</li>
                   2010:    <li><code><a href="tabular-data.html#the-caption-element">caption</a></code> in the HTML namespace</li>
                   2011:    <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.) -->
                   2012:    <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
                   2013:    <li><code><a href="tabular-data.html#the-td-element">td</a></code> in the HTML namespace</li>
                   2014:    <li><code><a href="tabular-data.html#the-th-element">th</a></code> in the HTML namespace</li>
                   2015:    <li><code><a href="forms.html#the-button-element">button</a></code> in the HTML namespace</li>
                   2016:    <li><code><a href="obsolete.html#the-marquee-element">marquee</a></code> in the HTML namespace</li>
                   2017:    <li><code><a href="text-level-semantics.html#the-object-element">object</a></code> in the HTML namespace</li>
                   2018:    <li><code title="">foreignObject</code> in the SVG namespace</li>
                   2019:   </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
                   2020:   item scope</dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
                   2021:   scope</a> consisting of the following element types:</p>
                   2022: 
                   2023:   <ul class="brief"><li>All the element types listed above for the <i><a href="#has-an-element-in-scope">has an element
                   2024:    in scope</a></i> algorithm.</li>
                   2025:    <li><code><a href="semantics.html#the-ol-element">ol</a></code> in the HTML namespace</li>
                   2026:    <li><code><a href="semantics.html#the-ul-element">ul</a></code> in the HTML namespace</li>
                   2027:   </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
                   2028:   scope</em></dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
                   2029:   scope</a> consisting of the following element types:</p>
                   2030: 
                   2031:   <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.) -->
                   2032:    <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
                   2033:   </ul><p>Nothing happens if at any time any of the elements in the
1.1       mike     2034:   <a href="#stack-of-open-elements">stack of open elements</a> are moved to a new location in,
                   2035:   or removed from, the <code>Document</code> tree. In particular, the
                   2036:   stack is not changed in this situation. This can cause, amongst
                   2037:   other strange effects, content to be appended to nodes that are no
                   2038:   longer in the DOM.</p>
                   2039: 
                   2040:   <p class="note">In some cases (namely, when <a href="#adoptionAgency">closing misnested formatting elements</a>),
                   2041:   the stack is manipulated in a random-access fashion.</p>
                   2042: 
                   2043: 
1.724     mike     2044:   <h5 id="the-list-of-active-formatting-elements"><span class="secno">7.2.3.3 </span>The list of active formatting elements</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     2045: 
                   2046:   <p>Initially, the <dfn id="list-of-active-formatting-elements">list of active formatting elements</dfn> is
                   2047:   empty. It is used to handle mis-nested <a href="#formatting" title="formatting">formatting element tags</a>.</p>
                   2048: 
                   2049:   <p>The list contains elements in the <a href="#formatting">formatting</a>
                   2050:   category, and scope markers. The scope markers are inserted when
1.159     mike     2051:   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     2052:   elements, marquees, table cells, and table captions, and are used to
1.5       mike     2053:   prevent formatting from "leaking" <em>into</em> <code><a href="obsolete.html#the-applet-element">applet</a></code>
1.159     mike     2054:   elements, buttons, <code><a href="text-level-semantics.html#the-object-element">object</a></code> elements, marquees, and
1.1       mike     2055:   tables.</p>
                   2056: 
                   2057:   <p class="note">The scope markers are unrelated to the concept of an
                   2058:   element being <a href="#has-an-element-in-scope" title="has an element in scope">in
                   2059:   scope</a>.</p>
                   2060: 
                   2061:   <p>In addition, each element in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2062:   elements</a> is associated with the token for which it was
                   2063:   created, so that further elements can be created for that token if
                   2064:   necessary.</p>
                   2065: 
                   2066:   <p>When the steps below require the UA to <dfn id="reconstruct-the-active-formatting-elements">reconstruct the
                   2067:   active formatting elements</dfn>, the UA must perform the following
                   2068:   steps:</p>
                   2069: 
                   2070:   <ol><li>If there are no entries in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2071:    elements</a>, then there is nothing to reconstruct; stop this
                   2072:    algorithm.</li>
                   2073: 
                   2074:    <li>If the last (most recently added) entry in the <a href="#list-of-active-formatting-elements">list of
                   2075:    active formatting elements</a> is a marker, or if it is an
                   2076:    element that is in the <a href="#stack-of-open-elements">stack of open elements</a>, then
                   2077:    there is nothing to reconstruct; stop this algorithm.</li>
                   2078: 
                   2079:    <li>Let <var title="">entry</var> be the last (most recently added)
                   2080:    element in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2081:    elements</a>.</li>
                   2082: 
                   2083:    <li>If there are no entries before <var title="">entry</var> in the
                   2084:    <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, then jump to step
                   2085:    8.</li>
                   2086: 
                   2087:    <li>Let <var title="">entry</var> be the entry one earlier than
                   2088:    <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2089:    elements</a>.</li>
                   2090: 
                   2091:    <li>If <var title="">entry</var> is neither a marker nor an element
                   2092:    that is also in the <a href="#stack-of-open-elements">stack of open elements</a>, go to step
                   2093:    4.</li>
                   2094: 
                   2095:    <li>Let <var title="">entry</var> be the element one later than
                   2096:    <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2097:    elements</a>.</li>
                   2098: 
                   2099:    <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
                   2100:    element <var title="">entry</var> was created, to obtain <var title="">new element</var>.</li>
                   2101: 
                   2102:    <li>Append <var title="">new element</var> to the <a href="#current-node">current
                   2103:    node</a> and push it onto the <a href="#stack-of-open-elements">stack of open
                   2104:    elements</a> so that it is the new <a href="#current-node">current
                   2105:    node</a>.</li>
                   2106: 
                   2107:    <li>Replace the entry for <var title="">entry</var> in the list
                   2108:    with an entry for <var title="">new element</var>.</li>
                   2109: 
                   2110:    <li>If the entry for <var title="">new element</var> in the
                   2111:    <a href="#list-of-active-formatting-elements">list of active formatting elements</a> is not the last
                   2112:    entry in the list, return to step 7.</li>
                   2113: 
                   2114:   </ol><p>This has the effect of reopening all the formatting elements that
                   2115:   were opened in the current body, cell, or caption (whichever is
                   2116:   youngest) that haven't been explicitly closed.</p>
                   2117: 
                   2118:   <p class="note">The way this specification is written, the
                   2119:   <a href="#list-of-active-formatting-elements">list of active formatting elements</a> always consists of
                   2120:   elements in chronological order with the least recently added
                   2121:   element first and the most recently added element last (except for
                   2122:   while steps 8 to 11 of the above algorithm are being executed, of
                   2123:   course).</p>
                   2124: 
                   2125:   <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
                   2126:   active formatting elements up to the last marker</dfn>, the UA must
                   2127:   perform the following steps:</p>
                   2128: 
                   2129:   <ol><li>Let <var title="">entry</var> be the last (most recently added)
                   2130:    entry in the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</li>
                   2131: 
                   2132:    <li>Remove <var title="">entry</var> from the <a href="#list-of-active-formatting-elements">list of active
                   2133:    formatting elements</a>.</li>
                   2134: 
                   2135:    <li>If <var title="">entry</var> was a marker, then stop the
                   2136:    algorithm at this point. The list has been cleared up to the last
                   2137:    marker.</li>
                   2138: 
                   2139:    <li>Go to step 1.</li>
                   2140: 
1.724     mike     2141:   </ol><h5 id="the-element-pointers"><span class="secno">7.2.3.4 </span>The element pointers</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     2142: 
                   2143:   <p>Initially, the <dfn id="head-element-pointer"><code title="">head</code> element
                   2144:   pointer</dfn> and the <dfn id="form-element-pointer"><code title="">form</code> element
                   2145:   pointer</dfn> are both null.</p>
                   2146: 
1.159     mike     2147:   <p>Once a <code><a href="semantics.html#the-head-element-0">head</a></code> element has been parsed (whether
1.1       mike     2148:   implicitly or explicitly) the <a href="#head-element-pointer"><code title="">head</code>
                   2149:   element pointer</a> gets set to point to this node.</p>
                   2150: 
                   2151:   <p>The <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
                   2152:   points to the last <code><a href="forms.html#the-form-element">form</a></code> element that was opened and
                   2153:   whose end tag has not yet been seen. It is used to make form
                   2154:   controls associate with forms in the face of dramatically bad
                   2155:   markup, for historical reasons.</p>
                   2156: 
                   2157: 
1.724     mike     2158:   <h5 id="other-parsing-state-flags"><span class="secno">7.2.3.5 </span>Other parsing state flags</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     2159: 
                   2160:   <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
                   2161:   <code>Document</code> with which the parser is associated when the
                   2162:   parser was created, and "disabled" otherwise.</p>
                   2163: 
                   2164:   <p class="note">The <a href="#scripting-flag">scripting flag</a> can be enabled even
                   2165:   when the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML fragment
                   2166:   parsing algorithm</a>, even though <code><a href="semantics.html#script">script</a></code> elements
                   2167:   don't execute in that case.</p>
                   2168: 
                   2169:   <p>The <dfn id="frameset-ok-flag">frameset-ok flag</dfn> is set to "ok" when the parser is
                   2170:   created. It is set to "not ok" after certain tokens are seen.</p>
                   2171: 
1.266     mike     2172:   </div><div class="impl">
1.1       mike     2173: 
1.724     mike     2174:   <h4 id="tokenization"><span class="secno">7.2.4 </span><dfn>Tokenization</dfn></h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     2175: 
                   2176:   <p>Implementations must act as if they used the following state
                   2177:   machine to tokenize HTML. The state machine must start in the
                   2178:   <a href="#data-state">data state</a>. Most states consume a single character,
                   2179:   which may have various side-effects, and either switches the state
                   2180:   machine to a new state to <em>reconsume</em> the same character, or
                   2181:   switches it to a new state (to consume the next character), or
                   2182:   repeats the same state (to consume the next character). Some states
                   2183:   have more complicated behavior and can consume several characters
1.541     mike     2184:   before switching to another state. In some cases, the tokenizer
                   2185:   state is also changed by the tree construction stage.</p>
1.1       mike     2186: 
1.541     mike     2187:   <p>The exact behavior of certain states depends on the
                   2188:   <a href="#insertion-mode">insertion mode</a> and the <a href="#stack-of-open-elements">stack of open
                   2189:   elements</a>. Certain states also use a <dfn id="temporary-buffer"><var>temporary
                   2190:   buffer</var></dfn> to track progress.</p>
1.1       mike     2191: 
                   2192:   <p>The output of the tokenization step is a series of zero or more
                   2193:   of the following tokens: DOCTYPE, start tag, end tag, comment,
                   2194:   character, end-of-file. DOCTYPE tokens have a name, a public
                   2195:   identifier, a system identifier, and a <i>force-quirks
                   2196:   flag</i>. When a DOCTYPE token is created, its name, public
                   2197:   identifier, and system identifier must be marked as missing (which
                   2198:   is a distinct state from the empty string), and the <i>force-quirks
                   2199:   flag</i> must be set to <i>off</i> (its other state is
                   2200:   <i>on</i>). Start and end tag tokens have a tag name, a
                   2201:   <i>self-closing flag</i>, and a list of attributes, each of which
                   2202:   has a name and a value. When a start or end tag token is created,
                   2203:   its <i>self-closing flag</i> must be unset (its other state is that
                   2204:   it be set), and its attributes list must be empty. Comment and
                   2205:   character tokens have data.</p>
                   2206: 
                   2207:   <p>When a token is emitted, it must immediately be handled by the
                   2208:   <a href="#tree-construction">tree construction</a> stage. The tree construction stage
1.541     mike     2209:   can affect the state of the tokenization stage, and can insert
                   2210:   additional characters into the stream. (For example, the
1.1       mike     2211:   <code><a href="semantics.html#script">script</a></code> element can result in scripts executing and
1.159     mike     2212:   using the <a href="embedded-content-0.html#dynamic-markup-insertion">dynamic markup insertion</a> APIs to insert
1.1       mike     2213:   characters into the stream being tokenized.)</p>
                   2214: 
                   2215:   <p>When a start tag token is emitted with its <i>self-closing
                   2216:   flag</i> set, if the flag is not <dfn id="acknowledge-self-closing-flag" title="acknowledge
                   2217:   self-closing flag">acknowledged</dfn> when it is processed by the
                   2218:   tree construction stage, that is a <a href="#parse-error">parse error</a>.</p>
                   2219: 
                   2220:   <p>When an end tag token is emitted with attributes, that is a
                   2221:   <a href="#parse-error">parse error</a>.</p>
                   2222: 
                   2223:   <p>When an end tag token is emitted with its <i>self-closing
                   2224:   flag</i> set, that is a <a href="#parse-error">parse error</a>.</p>
                   2225: 
1.541     mike     2226:   <p>An <dfn id="appropriate-end-tag-token">appropriate end tag token</dfn> is an end tag token whose
                   2227:   tag name matches the tag name of the last start tag to have been
                   2228:   emitted from this tokenizer, if any. If no start tag has been
                   2229:   emitted from this tokenizer, then no end tag token is
                   2230:   appropriate.</p>
                   2231: 
1.1       mike     2232:   <p>Before each step of the tokenizer, the user agent must first
                   2233:   check the <a href="#parser-pause-flag">parser pause flag</a>. If it is true, then the
                   2234:   tokenizer must abort the processing of any nested invocations of the
1.479     mike     2235:   tokenizer, yielding control back to the caller.</p>
1.1       mike     2236: 
                   2237:   <p>The tokenizer state machine consists of the states defined in the
                   2238:   following subsections.</p>
                   2239: 
1.541     mike     2240: 
1.333     mike     2241:   <!-- Order of the lists below is supposed to be non-error then
                   2242:   error, by unicode, then EOF, ending with "anything else" -->
1.1       mike     2243: 
1.541     mike     2244: 
1.724     mike     2245:   <h5 id="data-state"><span class="secno">7.2.4.1 </span><dfn>Data state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     2246: 
                   2247:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2248: 
                   2249:   <dl class="switch"><dt>U+0026 AMPERSAND (&amp;)</dt>
1.541     mike     2250:    <dd>Switch to the <a href="#character-reference-in-data-state">character reference in data
1.56      mike     2251:    state</a>.</dd>
1.1       mike     2252: 
1.541     mike     2253:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2254:    <dd>Switch to the <a href="#tag-open-state">tag open state</a>.</dd>
                   2255: 
                   2256:    <dt>EOF</dt>
                   2257:    <dd>Emit an end-of-file token.</dd>
                   2258: 
                   2259:    <dt>Anything else</dt>
                   2260:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2261:    token. Stay in the <a href="#data-state">data state</a>.</dd>
1.1       mike     2262: 
1.724     mike     2263:   </dl><h5 id="character-reference-in-data-state"><span class="secno">7.2.4.2 </span><dfn>Character reference in data state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.618     mike     2264: 
                   2265:   <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>, with no
                   2266:   <a href="#additional-allowed-character">additional allowed character</a>.</p>
                   2267: 
                   2268:   <p>If nothing is returned, emit a U+0026 AMPERSAND character
                   2269:   token.</p>
                   2270: 
                   2271:   <p>Otherwise, emit the character token that was returned.</p>
                   2272: 
                   2273:   <p>Finally, switch to the <a href="#data-state">data state</a>.</p>
                   2274: 
                   2275: 
1.724     mike     2276:   <h5 id="rcdata-state"><span class="secno">7.2.4.3 </span><dfn>RCDATA state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     2277: 
1.541     mike     2278:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2279: 
1.541     mike     2280:   <dl class="switch"><dt>U+0026 AMPERSAND (&amp;)</dt>
1.618     mike     2281:    <dd>Switch to the <a href="#character-reference-in-rcdata-state">character reference in RCDATA
1.541     mike     2282:    state</a>.</dd>
1.1       mike     2283: 
                   2284:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
1.541     mike     2285:    <dd>Switch to the <a href="#rcdata-less-than-sign-state">RCDATA less-than sign state</a>.</dd>
                   2286: 
                   2287:    <dt>EOF</dt>
                   2288:    <dd>Emit an end-of-file token.</dd>
1.1       mike     2289: 
1.541     mike     2290:    <dt>Anything else</dt>
                   2291:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2292:    token. Stay in the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1       mike     2293: 
1.724     mike     2294:   </dl><h5 id="character-reference-in-rcdata-state"><span class="secno">7.2.4.4 </span><dfn>Character reference in RCDATA state</dfn></h5>
1.618     mike     2295: 
                   2296:   <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>, with no
                   2297:   <a href="#additional-allowed-character">additional allowed character</a>.</p>
                   2298: 
                   2299:   <p>If nothing is returned, emit a U+0026 AMPERSAND character
                   2300:   token.</p>
                   2301: 
                   2302:   <p>Otherwise, emit the character token that was returned.</p>
                   2303: 
                   2304:   <p>Finally, switch to the <a href="#rcdata-state">RCDATA state</a>.</p>
                   2305: 
                   2306: 
1.724     mike     2307:   <h5 id="rawtext-state"><span class="secno">7.2.4.5 </span><dfn>RAWTEXT state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     2308: 
1.541     mike     2309:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2310: 
1.541     mike     2311:   <dl class="switch"><dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2312:    <dd>Switch to the <a href="#rawtext-less-than-sign-state">RAWTEXT less-than sign state</a>.</dd>
1.1       mike     2313: 
                   2314:    <dt>EOF</dt>
                   2315:    <dd>Emit an end-of-file token.</dd>
                   2316: 
                   2317:    <dt>Anything else</dt>
1.541     mike     2318:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2319:    token. Stay in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1       mike     2320: 
1.724     mike     2321:   </dl><h5 id="script-data-state"><span class="secno">7.2.4.6 </span><dfn>Script data state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     2322: 
1.541     mike     2323:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2324: 
1.541     mike     2325:   <dl class="switch"><dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2326:    <dd>Switch to the <a href="#script-data-less-than-sign-state">script data less-than sign state</a>.</dd>
1.1       mike     2327: 
1.541     mike     2328:    <dt>EOF</dt>
                   2329:    <dd>Emit an end-of-file token.</dd>
1.1       mike     2330: 
1.541     mike     2331:    <dt>Anything else</dt>
                   2332:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2333:    token. Stay in the <a href="#script-data-state">script data state</a>.</dd>
1.1       mike     2334: 
1.724     mike     2335:   </dl><h5 id="plaintext-state"><span class="secno">7.2.4.7 </span><dfn>PLAINTEXT state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     2336: 
1.541     mike     2337:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2338: 
1.541     mike     2339:   <dl class="switch"><dt>EOF</dt>
                   2340:    <dd>Emit an end-of-file token.</dd>
1.1       mike     2341: 
1.541     mike     2342:    <dt>Anything else</dt>
                   2343:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2344:    token. Stay in the <a href="#plaintext-state">PLAINTEXT state</a>.</dd>
1.1       mike     2345: 
1.724     mike     2346:   </dl><h5 id="tag-open-state"><span class="secno">7.2.4.8 </span><dfn>Tag open state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     2347: 
1.541     mike     2348:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2349: 
1.541     mike     2350:   <dl class="switch"><dt>U+0021 EXCLAMATION MARK (!)</dt>
                   2351:    <dd>Switch to the <a href="#markup-declaration-open-state">markup declaration open state</a>.</dd>
1.1       mike     2352: 
1.541     mike     2353:    <dt>U+002F SOLIDUS (/)</dt>
                   2354:    <dd>Switch to the <a href="#close-tag-open-state">close tag open state</a>.</dd>
1.1       mike     2355: 
1.541     mike     2356:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2357:    <dd>Create a new start tag token, set its tag name to the
                   2358:    lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
                   2359:    character's code point), then switch to the <a href="#tag-name-state">tag name
                   2360:    state</a>. (Don't emit the token yet; further details will
                   2361:    be filled in before it is emitted.)</dd>
1.1       mike     2362: 
1.541     mike     2363:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2364:    <dd>Create a new start tag token, set its tag name to the
                   2365:    <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
                   2366:    name state</a>. (Don't emit the token yet; further details will
                   2367:    be filled in before it is emitted.)</dd>
1.1       mike     2368: 
1.541     mike     2369:    <dt>U+003F QUESTION MARK (?)</dt>
                   2370:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
                   2371:    comment state</a>.</dd>
1.1       mike     2372: 
1.541     mike     2373:    <dt>Anything else</dt>
                   2374:    <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
                   2375:    character token and reconsume the <a href="#current-input-character">current input
                   2376:    character</a> in the <a href="#data-state">data state</a>.</dd>
1.1       mike     2377: 
1.724     mike     2378:   </dl><h5 id="close-tag-open-state"><span class="secno">7.2.4.9 </span><dfn>Close tag open state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     2379: 
1.541     mike     2380:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2381: 
                   2382:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2383:    <dd>Create a new end tag token, set its tag name to the lowercase
1.541     mike     2384:    version of the <a href="#current-input-character">current input character</a> (add 0x0020 to
                   2385:    the character's code point), then switch to the <a href="#tag-name-state">tag name
1.1       mike     2386:    state</a>. (Don't emit the token yet; further details will be
                   2387:    filled in before it is emitted.)</dd>
                   2388: 
                   2389:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
1.541     mike     2390:    <dd>Create a new end tag token, set its tag name to the
                   2391:    <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
                   2392:    name state</a>. (Don't emit the token yet; further details will
                   2393:    be filled in before it is emitted.)</dd>
1.1       mike     2394: 
                   2395:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2396:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#data-state">data
                   2397:    state</a>.</dd>
                   2398: 
                   2399:    <dt>EOF</dt>
                   2400:    <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
                   2401:    character token and a U+002F SOLIDUS character token. Reconsume
                   2402:    the EOF character in the <a href="#data-state">data state</a>.</dd>
                   2403: 
                   2404:    <dt>Anything else</dt>
                   2405:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
                   2406:    comment state</a>.</dd>
                   2407: 
1.724     mike     2408:   </dl><h5 id="tag-name-state"><span class="secno">7.2.4.10 </span><dfn>Tag name state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     2409: 
                   2410:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2411: 
                   2412:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2413:    <dt>U+000A LINE FEED (LF)</dt>
                   2414:    <dt>U+000C FORM FEED (FF)</dt>
                   2415:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2416:    <dt>U+0020 SPACE</dt>
                   2417:    <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   2418: 
                   2419:    <dt>U+002F SOLIDUS (/)</dt>
                   2420:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   2421: 
                   2422:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2423:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   2424:    state</a>.</dd>
                   2425: 
                   2426:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541     mike     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. Stay in the <a href="#tag-name-state">tag name
                   2430:    state</a>.</dd>
                   2431: 
                   2432:    <dt>EOF</dt>
                   2433:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2434:    <a href="#data-state">data state</a>.</dd>
                   2435: 
                   2436:    <dt>Anything else</dt>
                   2437:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2438:    tag token's tag name. Stay in the <a href="#tag-name-state">tag name state</a>.</dd>
                   2439: 
1.724     mike     2440:   </dl><h5 id="rcdata-less-than-sign-state"><span class="secno">7.2.4.11 </span><dfn>RCDATA less-than sign state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.541     mike     2441:   <!-- identical to the RAWTEXT less-than sign state, except s/RAWTEXT/RCDATA/g -->
                   2442: 
                   2443:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2444: 
                   2445:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   2446:    <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
                   2447:    to the <a href="#rcdata-end-tag-open-state">RCDATA end tag open state</a>.</dd>
                   2448: 
                   2449:    <dt>Anything else</dt>
                   2450:    <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
                   2451:    <a href="#current-input-character">current input character</a> in the <a href="#rcdata-state">RCDATA
                   2452:    state</a>.</dd>
                   2453: 
1.724     mike     2454:   </dl><h5 id="rcdata-end-tag-open-state"><span class="secno">7.2.4.12 </span><dfn>RCDATA end tag open state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.541     mike     2455:   <!-- identical to the RAWTEXT (and Script data) end tag open state, except s/RAWTEXT/RCDATA/g -->
                   2456: 
                   2457:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2458: 
                   2459:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2460:    <dd>Create a new end tag token, and set its tag name to the
                   2461:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2462:    0x0020 to the character's code point). Append the <a href="#current-input-character">current
                   2463:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2464:    switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
                   2465:    the token yet; further details will be filled in before it is
                   2466:    emitted.)</dd>
                   2467: 
                   2468:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2469:    <dd>Create a new end tag token, and set its tag name to the
                   2470:    <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
                   2471:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2472:    switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
                   2473:    the token yet; further details will be filled in before it is
                   2474:    emitted.)</dd>
                   2475: 
                   2476:    <dt>Anything else</dt>
                   2477:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2478:    character token, and reconsume the <a href="#current-input-character">current input
                   2479:    character</a> in the <a href="#rcdata-state">RCDATA state</a>.</dd>
                   2480: 
1.724     mike     2481:   </dl><h5 id="rcdata-end-tag-name-state"><span class="secno">7.2.4.13 </span><dfn>RCDATA end tag name state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.541     mike     2482:   <!-- identical to the RAWTEXT (and Script data) end tag name state, except s/RAWTEXT/RCDATA/g -->
                   2483: 
                   2484:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2485: 
                   2486:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2487:    <dt>U+000A LINE FEED (LF)</dt>
                   2488:    <dt>U+000C FORM FEED (FF)</dt>
                   2489:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2490:    <dt>U+0020 SPACE</dt>
                   2491:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2492:    token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
                   2493:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2494:    below.</dd>
                   2495: 
                   2496:    <dt>U+002F SOLIDUS (/)</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="#self-closing-start-tag-state">self-closing start tag
                   2499:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2500:    below.</dd>
                   2501: 
                   2502:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2503:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2504:    token</a>, then emit the current tag token and switch to the
                   2505:    <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
                   2506:    else" entry below.</dd>
                   2507: 
                   2508:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2509:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2510:    character</a> (add 0x0020 to the character's code point) to the
                   2511:    current tag token's tag name. Append the <a href="#current-input-character">current input
                   2512:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2513:    <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
                   2514: 
                   2515:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2516:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2517:    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="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
                   2520: 
                   2521:    <dt>Anything else</dt>
                   2522:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2523:    character token, a character token for each of the characters in
                   2524:    the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
                   2525:    the buffer), and reconsume the <a href="#current-input-character">current input character</a>
                   2526:    in the <a href="#rcdata-state">RCDATA state</a>.</dd>
                   2527: 
1.724     mike     2528:   </dl><h5 id="rawtext-less-than-sign-state"><span class="secno">7.2.4.14 </span><dfn>RAWTEXT less-than sign state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.541     mike     2529:   <!-- identical to the RCDATA less-than sign state, except s/RCDATA/RAWTEXT/g -->
                   2530: 
                   2531:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2532: 
                   2533:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   2534:    <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
                   2535:    to the <a href="#rawtext-end-tag-open-state">RAWTEXT end tag open state</a>.</dd>
                   2536: 
                   2537:    <dt>Anything else</dt>
                   2538:    <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
                   2539:    <a href="#current-input-character">current input character</a> in the <a href="#rawtext-state">RAWTEXT
                   2540:    state</a>.</dd>
                   2541: 
1.724     mike     2542:   </dl><h5 id="rawtext-end-tag-open-state"><span class="secno">7.2.4.15 </span><dfn>RAWTEXT end tag open state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.541     mike     2543:   <!-- identical to the RCDATA (and Script data) end tag open state, except s/RCDATA/RAWTEXT/g -->
                   2544: 
                   2545:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2546: 
                   2547:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2548:    <dd>Create a new end tag token, and set its tag name to the
                   2549:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2550:    0x0020 to the character's code point). Append the <a href="#current-input-character">current
                   2551:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2552:    switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
                   2553:    the token yet; further details will be filled in before it is
                   2554:    emitted.)</dd>
                   2555: 
                   2556:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2557:    <dd>Create a new end tag token, and set its tag name to the
                   2558:    <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
                   2559:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2560:    switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
                   2561:    the token yet; further details will be filled in before it is
                   2562:    emitted.)</dd>
                   2563: 
                   2564:    <dt>Anything else</dt>
                   2565:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2566:    character token, and reconsume the <a href="#current-input-character">current input
                   2567:    character</a> in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
                   2568: 
1.724     mike     2569:   </dl><h5 id="rawtext-end-tag-name-state"><span class="secno">7.2.4.16 </span><dfn>RAWTEXT end tag name state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.541     mike     2570:   <!-- identical to the RCDATA (and Script data) end tag name state, except s/RCDATA/RAWTEXT/g -->
                   2571: 
                   2572:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2573: 
                   2574:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2575:    <dt>U+000A LINE FEED (LF)</dt>
                   2576:    <dt>U+000C FORM FEED (FF)</dt>
                   2577:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2578:    <dt>U+0020 SPACE</dt>
                   2579:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2580:    token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
                   2581:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2582:    below.</dd>
                   2583: 
                   2584:    <dt>U+002F SOLIDUS (/)</dt>
                   2585:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2586:    token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
                   2587:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2588:    below.</dd>
                   2589: 
                   2590:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2591:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2592:    token</a>, then emit the current tag token and switch to the
                   2593:    <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
                   2594:    else" entry below.</dd>
                   2595: 
                   2596:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2597:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2598:    character</a> (add 0x0020 to the character's code point) to the
                   2599:    current tag token's tag name. Append the <a href="#current-input-character">current input
                   2600:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2601:    <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
                   2602: 
                   2603:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2604:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2605:    tag token's tag name. Append the <a href="#current-input-character">current input
                   2606:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2607:    <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
                   2608: 
                   2609:    <dt>Anything else</dt>
                   2610:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2611:    character token, a character token for each of the characters in
                   2612:    the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
                   2613:    the buffer), and reconsume the <a href="#current-input-character">current input character</a>
                   2614:    in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
                   2615: 
1.724     mike     2616:   </dl><h5 id="script-data-less-than-sign-state"><span class="secno">7.2.4.17 </span><dfn>Script data less-than sign state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.541     mike     2617: 
                   2618:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2619: 
                   2620:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   2621:    <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
                   2622:    to the <a href="#script-data-end-tag-open-state">script data end tag open state</a>.</dd>
                   2623: 
                   2624:    <dt>U+0021 EXCLAMATION MARK (!)</dt>
                   2625:    <dd>Emit a U+003C LESS-THAN SIGN character token and a U+0021
                   2626:    EXCLAMATION MARK character token. Switch to the <a href="#script-data-escape-start-state">script data
                   2627:    escape start state</a>.</dd>
                   2628: 
                   2629:    <dt>Anything else</dt>
                   2630:    <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
                   2631:    <a href="#current-input-character">current input character</a> in the <a href="#script-data-state">script data
                   2632:    state</a>.</dd>
                   2633: 
1.724     mike     2634:   </dl><h5 id="script-data-end-tag-open-state"><span class="secno">7.2.4.18 </span><dfn>Script data end tag open state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.541     mike     2635:   <!-- identical to the RCDATA (and RAWTEXT) end tag open state, except s/RCDATA/Script data/g -->
                   2636: 
                   2637:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2638: 
                   2639:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2640:    <dd>Create a new end tag token, and set its tag name to the
                   2641:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2642:    0x0020 to the character's code point). Append the <a href="#current-input-character">current
                   2643:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2644:    switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
                   2645:    the token yet; further details will be filled in before it is
                   2646:    emitted.)</dd>
                   2647: 
                   2648:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2649:    <dd>Create a new end tag token, and set its tag name to the
                   2650:    <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
                   2651:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2652:    switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
                   2653:    the token yet; further details will be filled in before it is
                   2654:    emitted.)</dd>
                   2655: 
                   2656:    <dt>Anything else</dt>
                   2657:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2658:    character token, and reconsume the <a href="#current-input-character">current input
                   2659:    character</a> in the <a href="#script-data-state">script data state</a>.</dd>
                   2660: 
1.724     mike     2661:   </dl><h5 id="script-data-end-tag-name-state"><span class="secno">7.2.4.19 </span><dfn>Script data end tag name state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.541     mike     2662:   <!-- identical to the RCDATA (and RAWTEXT) end tag name state, except s/RCDATA/Script data/g -->
                   2663: 
                   2664:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2665: 
                   2666:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2667:    <dt>U+000A LINE FEED (LF)</dt>
                   2668:    <dt>U+000C FORM FEED (FF)</dt>
                   2669:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2670:    <dt>U+0020 SPACE</dt>
                   2671:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2672:    token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
                   2673:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2674:    below.</dd>
                   2675: 
                   2676:    <dt>U+002F SOLIDUS (/)</dt>
                   2677:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2678:    token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
                   2679:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2680:    below.</dd>
                   2681: 
                   2682:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2683:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2684:    token</a>, then emit the current tag token and switch to the
                   2685:    <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
                   2686:    else" entry below.</dd>
                   2687: 
                   2688:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2689:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2690:    character</a> (add 0x0020 to the character's code point) to the
                   2691:    current tag token's tag name. Append the <a href="#current-input-character">current input
                   2692:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542     mike     2693:    <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541     mike     2694: 
                   2695:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2696:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2697:    tag token's tag name. Append the <a href="#current-input-character">current input
                   2698:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542     mike     2699:    <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541     mike     2700: 
                   2701:    <dt>Anything else</dt>
                   2702:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2703:    character token, a character token for each of the characters in
                   2704:    the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
                   2705:    the buffer), and reconsume the <a href="#current-input-character">current input character</a>
                   2706:    in the <a href="#script-data-state">script data state</a>.</dd>
                   2707: 
1.724     mike     2708:   </dl><h5 id="script-data-escape-start-state"><span class="secno">7.2.4.20 </span><dfn>Script data escape start state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.541     mike     2709: 
                   2710:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2711: 
                   2712:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2713:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2714:    <a href="#script-data-escape-start-dash-state">script data escape start dash state</a>.</dd>
                   2715: 
                   2716:    <dt>Anything else</dt>
                   2717:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   2718:    <a href="#script-data-state">script data state</a>.</dd>
                   2719: 
1.724     mike     2720:   </dl><h5 id="script-data-escape-start-dash-state"><span class="secno">7.2.4.21 </span><dfn>Script data escape start dash state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.541     mike     2721: 
                   2722:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2723: 
                   2724:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2725:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2726:    <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
                   2727: 
                   2728:    <dt>Anything else</dt>
                   2729:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   2730:    <a href="#script-data-state">script data state</a>.</dd>
                   2731: 
1.724     mike     2732:   </dl><h5 id="script-data-escaped-state"><span class="secno">7.2.4.22 </span><dfn>Script data escaped state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.541     mike     2733: 
                   2734:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2735: 
                   2736:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2737:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2738:    <a href="#script-data-escaped-dash-state">script data escaped dash state</a>.</dd>
                   2739: 
1.542     mike     2740:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2741:    <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
                   2742:    state</a>.</p></dd>
                   2743: 
1.541     mike     2744:    <dt>EOF</dt>
                   2745:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2746:    <a href="#data-state">data state</a>.</dd>
                   2747: 
                   2748:    <dt>Anything else</dt>
1.542     mike     2749:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2750:    token. Stay in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541     mike     2751: 
1.724     mike     2752:   </dl><h5 id="script-data-escaped-dash-state"><span class="secno">7.2.4.23 </span><dfn>Script data escaped dash state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.541     mike     2753: 
                   2754:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2755: 
                   2756:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2757:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2758:    <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
                   2759: 
1.542     mike     2760:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2761:    <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
                   2762:    state</a>.</p></dd>
                   2763: 
1.541     mike     2764:    <dt>EOF</dt>
                   2765:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2766:    <a href="#data-state">data state</a>.</dd>
                   2767: 
                   2768:    <dt>Anything else</dt>
1.542     mike     2769:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2770:    token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541     mike     2771: 
1.724     mike     2772:   </dl><h5 id="script-data-escaped-dash-dash-state"><span class="secno">7.2.4.24 </span><dfn>Script data escaped dash dash state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.541     mike     2773: 
                   2774:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2775: 
                   2776:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2777:    <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
                   2778:    <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
                   2779: 
1.542     mike     2780:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2781:    <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
                   2782:    state</a>.</p></dd>
                   2783: 
1.541     mike     2784:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2785:    <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
                   2786:    <a href="#script-data-state">script data state</a>.</dd>
1.1       mike     2787: 
                   2788:    <dt>EOF</dt>
                   2789:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2790:    <a href="#data-state">data state</a>.</dd>
                   2791: 
                   2792:    <dt>Anything else</dt>
1.542     mike     2793:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2794:    token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
                   2795: 
1.724     mike     2796:   </dl><h5 id="script-data-escaped-less-than-sign-state"><span class="secno">7.2.4.25 </span><dfn>Script data escaped less-than sign state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.542     mike     2797: 
                   2798:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2799: 
                   2800:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   2801:    <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
                   2802:    to the <a href="#script-data-escaped-end-tag-open-state">script data escaped end tag open state</a>.</dd>
                   2803: 
                   2804:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2805:    <dd>Emit a U+003C LESS-THAN SIGN character token and the
                   2806:    <a href="#current-input-character">current input character</a> as a character token. Set the
                   2807:    <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
                   2808:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2809:    0x0020 to the character's code point) to the <var><a href="#temporary-buffer">temporary
                   2810:    buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
                   2811:    state</a>.</dd>
                   2812: 
                   2813:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2814:    <dd>Emit a U+003C LESS-THAN SIGN character token and the
                   2815:    <a href="#current-input-character">current input character</a> as a character token. Set the
                   2816:    <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
                   2817:    <a href="#current-input-character">current input character</a> to the <var><a href="#temporary-buffer">temporary
                   2818:    buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
                   2819:    state</a>.</dd>
                   2820: 
                   2821:    <dt>Anything else</dt>
                   2822:    <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
                   2823:    <a href="#current-input-character">current input character</a> in the <a href="#script-data-escaped-state">script data
                   2824:    escaped state</a>.</dd>
                   2825: 
1.724     mike     2826:   </dl><h5 id="script-data-escaped-end-tag-open-state"><span class="secno">7.2.4.26 </span><dfn>Script data escaped end tag open state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.542     mike     2827: 
                   2828:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2829: 
                   2830:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2831:    <dd>Create a new end tag token, and set its tag name to the
                   2832:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2833:    0x0020 to the character's code point). Append the <a href="#current-input-character">current
                   2834:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2835:    switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
                   2836:    state</a>. (Don't emit the token yet; further details will be
                   2837:    filled in before it is emitted.)</dd>
                   2838: 
                   2839:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2840:    <dd>Create a new end tag token, and set its tag name to the
                   2841:    <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
                   2842:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2843:    switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
                   2844:    state</a>. (Don't emit the token yet; further details will be
                   2845:    filled in before it is emitted.)</dd>
                   2846: 
                   2847:    <dt>Anything else</dt>
                   2848:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2849:    character token, and reconsume the <a href="#current-input-character">current input
                   2850:    character</a> in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
                   2851: 
1.724     mike     2852:   </dl><h5 id="script-data-escaped-end-tag-name-state"><span class="secno">7.2.4.27 </span><dfn>Script data escaped end tag name state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.542     mike     2853: 
                   2854:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2855: 
                   2856:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2857:    <dt>U+000A LINE FEED (LF)</dt>
                   2858:    <dt>U+000C FORM FEED (FF)</dt>
                   2859:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2860:    <dt>U+0020 SPACE</dt>
                   2861:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2862:    token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
                   2863:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2864:    below.</dd>
                   2865: 
                   2866:    <dt>U+002F SOLIDUS (/)</dt>
                   2867:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2868:    token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
                   2869:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2870:    below.</dd>
                   2871: 
                   2872:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2873:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2874:    token</a>, then emit the current tag token and switch to the
                   2875:    <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
                   2876:    else" entry below.</dd>
                   2877: 
                   2878:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2879:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2880:    character</a> (add 0x0020 to the character's code point) to the
                   2881:    current tag token's tag name. Append the <a href="#current-input-character">current input
                   2882:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2883:    <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
                   2884: 
                   2885:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2886:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2887:    tag token's tag name. Append the <a href="#current-input-character">current input
                   2888:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2889:    <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
                   2890: 
                   2891:    <dt>Anything else</dt>
                   2892:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2893:    character token, a character token for each of the characters in
                   2894:    the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
                   2895:    the buffer), and reconsume the <a href="#current-input-character">current input character</a>
                   2896:    in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
                   2897: 
1.724     mike     2898:   </dl><h5 id="script-data-double-escape-start-state"><span class="secno">7.2.4.28 </span><dfn>Script data double escape start state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.542     mike     2899: 
                   2900:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2901: 
                   2902:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2903:    <dt>U+000A LINE FEED (LF)</dt>
                   2904:    <dt>U+000C FORM FEED (FF)</dt>
                   2905:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2906:    <dt>U+0020 SPACE</dt>
                   2907:    <dt>U+002F SOLIDUS (/)</dt>
                   2908:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2909:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2910:    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
                   2911:    double escaped state</a>. Otherwise, switch to the <a href="#script-data-escaped-state">script
                   2912:    data escaped state</a>.</dd>
                   2913: 
                   2914:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2915:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2916:    token. Append the lowercase version of the <a href="#current-input-character">current input
                   2917:    character</a> (add 0x0020 to the character's code point) to the
                   2918:    <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
                   2919:    escape start state</a>.</dd>
                   2920: 
                   2921:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2922:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2923:    token. Append the <a href="#current-input-character">current input character</a> to the
                   2924:    <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
                   2925:    escape start state</a>.</dd>
                   2926: 
                   2927:    <dt>Anything else</dt>
                   2928:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   2929:    <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
                   2930: 
1.724     mike     2931:   </dl><h5 id="script-data-double-escaped-state"><span class="secno">7.2.4.29 </span><dfn>Script data double escaped state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.542     mike     2932: 
                   2933:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2934: 
                   2935:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2936:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2937:    <a href="#script-data-double-escaped-dash-state">script data double escaped dash state</a>.</dd>
                   2938: 
                   2939:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2940:    <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
                   2941:    <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
                   2942:    state</a>.</p></dd>
                   2943: 
                   2944:    <dt>EOF</dt>
                   2945:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2946:    <a href="#data-state">data state</a>.</dd>
                   2947: 
                   2948:    <dt>Anything else</dt>
                   2949:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2950:    token. Stay in the <a href="#script-data-double-escaped-state">script data double escaped
                   2951:    state</a>.</dd>
                   2952: 
1.724     mike     2953:   </dl><h5 id="script-data-double-escaped-dash-state"><span class="secno">7.2.4.30 </span><dfn>Script data double escaped dash state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.542     mike     2954: 
                   2955:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2956: 
                   2957:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2958:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2959:    <a href="#script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>.</dd>
                   2960: 
                   2961:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2962:    <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
                   2963:    <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
                   2964:    state</a>.</p></dd>
                   2965: 
                   2966:    <dt>EOF</dt>
                   2967:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2968:    <a href="#data-state">data state</a>.</dd>
                   2969: 
                   2970:    <dt>Anything else</dt>
                   2971:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2972:    token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
                   2973:    state</a>.</dd>
                   2974: 
1.724     mike     2975:   </dl><h5 id="script-data-double-escaped-dash-dash-state"><span class="secno">7.2.4.31 </span><dfn>Script data double escaped dash dash state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.542     mike     2976: 
                   2977:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2978: 
                   2979:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2980:    <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
                   2981:    <a href="#script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>.</dd>
                   2982: 
                   2983:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2984:    <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
                   2985:    <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
                   2986:    state</a>.</p></dd>
                   2987: 
                   2988:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2989:    <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
                   2990:    <a href="#script-data-state">script data state</a>.</dd>
                   2991: 
                   2992:    <dt>EOF</dt>
                   2993:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2994:    <a href="#data-state">data state</a>.</dd>
                   2995: 
                   2996:    <dt>Anything else</dt>
                   2997:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2998:    token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
                   2999:    state</a>.</dd>
                   3000: 
1.724     mike     3001:   </dl><h5 id="script-data-double-escaped-less-than-sign-state"><span class="secno">7.2.4.32 </span><dfn>Script data double escaped less-than sign state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.542     mike     3002: 
                   3003:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3004: 
                   3005:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   3006:    <dd>Emit a U+002F SOLIDUS character token. Set the <var><a href="#temporary-buffer">temporary
                   3007:    buffer</a></var> to the empty string. Switch to the <a href="#script-data-double-escape-end-state">script data
                   3008:    double escape end state</a>.</dd>
                   3009: 
                   3010:    <dt>Anything else</dt>
                   3011:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   3012:    <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
                   3013: 
1.724     mike     3014:   </dl><h5 id="script-data-double-escape-end-state"><span class="secno">7.2.4.33 </span><dfn>Script data double escape end state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.542     mike     3015: 
                   3016:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3017: 
                   3018:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3019:    <dt>U+000A LINE FEED (LF)</dt>
                   3020:    <dt>U+000C FORM FEED (FF)</dt>
                   3021:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3022:    <dt>U+0020 SPACE</dt>
                   3023:    <dt>U+002F SOLIDUS (/)</dt>
                   3024:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3025:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   3026:    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
                   3027:    escaped state</a>. Otherwise, switch to the <a href="#script-data-double-escaped-state">script data
                   3028:    double escaped state</a>.</dd>
                   3029: 
                   3030:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   3031:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   3032:    token. Append the lowercase version of the <a href="#current-input-character">current input
                   3033:    character</a> (add 0x0020 to the character's code point) to the
                   3034:    <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
                   3035:    escape end state</a>.</dd>
                   3036: 
                   3037:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   3038:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   3039:    token. Append the <a href="#current-input-character">current input character</a> to the
                   3040:    <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
                   3041:    escape end state</a>.</dd>
                   3042: 
                   3043:    <dt>Anything else</dt>
                   3044:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   3045:    <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
1.1       mike     3046: 
1.724     mike     3047:   </dl><h5 id="before-attribute-name-state"><span class="secno">7.2.4.34 </span><dfn>Before attribute name state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3048: 
                   3049:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3050: 
                   3051:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3052:    <dt>U+000A LINE FEED (LF)</dt>
                   3053:    <dt>U+000C FORM FEED (FF)</dt>
                   3054:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3055:    <dt>U+0020 SPACE</dt>
                   3056:    <dd>Stay in the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3057: 
                   3058:    <dt>U+002F SOLIDUS (/)</dt>
                   3059:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   3060: 
                   3061:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3062:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3063:    state</a>.</dd>
                   3064: 
                   3065:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   3066:    <dd>Start a new attribute in the current tag token. Set that
                   3067:    attribute's name to the lowercase version of the <a href="#current-input-character">current input
                   3068:    character</a> (add 0x0020 to the character's code point), and its
                   3069:    value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
                   3070:    state</a>.</dd>
                   3071: 
                   3072:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3073:    <dt>U+0027 APOSTROPHE (')</dt>
                   3074:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3075:    <dt>U+003D EQUALS SIGN (=)</dt>
                   3076:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3077:    entry below.</dd>
                   3078: 
                   3079:    <dt>EOF</dt>
                   3080:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3081:    <a href="#data-state">data state</a>.</dd>
                   3082: 
                   3083:    <dt>Anything else</dt>
                   3084:    <dd>Start a new attribute in the current tag token. Set that
                   3085:    attribute's name to the <a href="#current-input-character">current input character</a>, and its value to
                   3086:    the empty string. Switch to the <a href="#attribute-name-state">attribute name
                   3087:    state</a>.</dd>
                   3088: 
1.724     mike     3089:   </dl><h5 id="attribute-name-state"><span class="secno">7.2.4.35 </span><dfn>Attribute name state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3090: 
                   3091:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3092: 
                   3093:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3094:    <dt>U+000A LINE FEED (LF)</dt>
                   3095:    <dt>U+000C FORM FEED (FF)</dt>
                   3096:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3097:    <dt>U+0020 SPACE</dt>
                   3098:    <dd>Switch to the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
                   3099: 
                   3100:    <dt>U+002F SOLIDUS (/)</dt>
                   3101:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   3102: 
                   3103:    <dt>U+003D EQUALS SIGN (=)</dt>
                   3104:    <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
                   3105: 
                   3106:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3107:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3108:    state</a>.</dd>
                   3109: 
                   3110:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541     mike     3111:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   3112:    character</a> (add 0x0020 to the character's code point) to the
                   3113:    current attribute's name. Stay in the <a href="#attribute-name-state">attribute name
1.1       mike     3114:    state</a>.</dd>
                   3115: 
                   3116:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3117:    <dt>U+0027 APOSTROPHE (')</dt>
                   3118:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3119:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3120:    entry below.</dd>
                   3121: 
                   3122:    <dt>EOF</dt>
                   3123:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3124:    <a href="#data-state">data state</a>.</dd>
                   3125: 
                   3126:    <dt>Anything else</dt>
1.541     mike     3127:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3128:    attribute's name. Stay in the <a href="#attribute-name-state">attribute name
                   3129:    state</a>.</dd>
1.1       mike     3130: 
                   3131:   </dl><p>When the user agent leaves the attribute name state (and before
                   3132:   emitting the tag token, if appropriate), the complete attribute's
                   3133:   name must be compared to the other attributes on the same token;
                   3134:   if there is already an attribute on the token with the exact same
                   3135:   name, then this is a <a href="#parse-error">parse error</a> and the new
                   3136:   attribute must be dropped, along with the value that gets
                   3137:   associated with it (if any).</p>
                   3138: 
                   3139: 
1.724     mike     3140:   <h5 id="after-attribute-name-state"><span class="secno">7.2.4.36 </span><dfn>After attribute name state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3141: 
                   3142:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3143: 
                   3144:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3145:    <dt>U+000A LINE FEED (LF)</dt>
                   3146:    <dt>U+000C FORM FEED (FF)</dt>
                   3147:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3148:    <dt>U+0020 SPACE</dt>
                   3149:    <dd>Stay in the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
                   3150: 
                   3151:    <dt>U+002F SOLIDUS (/)</dt>
                   3152:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   3153: 
                   3154:    <dt>U+003D EQUALS SIGN (=)</dt>
                   3155:    <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
                   3156: 
                   3157:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3158:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3159:    state</a>.</dd>
                   3160: 
                   3161:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   3162:    <dd>Start a new attribute in the current tag token. Set that
1.541     mike     3163:    attribute's name to the lowercase version of the <a href="#current-input-character">current
                   3164:    input character</a> (add 0x0020 to the character's code point),
                   3165:    and its value to the empty string. Switch to the <a href="#attribute-name-state">attribute
                   3166:    name state</a>.</dd>
1.1       mike     3167: 
                   3168:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3169:    <dt>U+0027 APOSTROPHE (')</dt>
                   3170:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3171:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3172:    entry below.</dd>
                   3173: 
                   3174:    <dt>EOF</dt>
                   3175:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3176:    <a href="#data-state">data state</a>.</dd>
                   3177: 
                   3178:    <dt>Anything else</dt>
                   3179:    <dd>Start a new attribute in the current tag token. Set that
1.541     mike     3180:    attribute's name to the <a href="#current-input-character">current input character</a>, and
                   3181:    its value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
1.1       mike     3182:    state</a>.</dd>
                   3183: 
1.724     mike     3184:   </dl><h5 id="before-attribute-value-state"><span class="secno">7.2.4.37 </span><dfn>Before attribute value state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3185: 
                   3186:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3187: 
                   3188:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3189:    <dt>U+000A LINE FEED (LF)</dt>
                   3190:    <dt>U+000C FORM FEED (FF)</dt>
                   3191:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3192:    <dt>U+0020 SPACE</dt>
                   3193:    <dd>Stay in the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
                   3194: 
                   3195:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3196:    <dd>Switch to the <a href="#attribute-value-double-quoted-state">attribute value (double-quoted) state</a>.</dd>
                   3197: 
                   3198:    <dt>U+0026 AMPERSAND (&amp;)</dt>
                   3199:    <dd>Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted) state</a>
1.541     mike     3200:    and reconsume this <a href="#current-input-character">current input character</a>.</dd>
1.1       mike     3201: 
                   3202:    <dt>U+0027 APOSTROPHE (')</dt>
                   3203:    <dd>Switch to the <a href="#attribute-value-single-quoted-state">attribute value (single-quoted) state</a>.</dd>
                   3204: 
                   3205:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3206:    <dd><a href="#parse-error">Parse error</a>. Emit the current tag token. Switch to
                   3207:    the <a href="#data-state">data state</a>.</dd>
                   3208: 
                   3209:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3210:    <dt>U+003D EQUALS SIGN (=)</dt>
1.463     mike     3211:    <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1       mike     3212:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3213:    entry below.</dd>
                   3214: 
                   3215:    <dt>EOF</dt>
                   3216:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3217:    <a href="#data-state">data state</a>.</dd>
                   3218: 
                   3219:    <dt>Anything else</dt>
                   3220:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3221:    attribute's value. Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
                   3222:    state</a>.</dd>
                   3223: 
1.724     mike     3224:   </dl><h5 id="attribute-value-double-quoted-state"><span class="secno">7.2.4.38 </span><dfn>Attribute value (double-quoted) state</dfn></h5>
1.1       mike     3225: 
                   3226:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3227: 
                   3228:   <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
                   3229:    <dd>Switch to the <a href="#after-attribute-value-quoted-state">after attribute value (quoted)
                   3230:    state</a>.</dd>
                   3231: 
                   3232:    <dt>U+0026 AMPERSAND (&amp;)</dt>
                   3233:    <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
                   3234:    state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
                   3235:    being U+0022 QUOTATION MARK (").</dd>
                   3236: 
                   3237:    <dt>EOF</dt>
                   3238:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3239:    <a href="#data-state">data state</a>.</dd>
                   3240: 
                   3241:    <dt>Anything else</dt>
1.541     mike     3242:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3243:    attribute's value. Stay in the <a href="#attribute-value-double-quoted-state">attribute value
                   3244:    (double-quoted) state</a>.</dd>
1.1       mike     3245: 
1.724     mike     3246:   </dl><h5 id="attribute-value-single-quoted-state"><span class="secno">7.2.4.39 </span><dfn>Attribute value (single-quoted) state</dfn></h5>
1.1       mike     3247: 
                   3248:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3249: 
                   3250:   <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
                   3251:    <dd>Switch to the <a href="#after-attribute-value-quoted-state">after attribute value (quoted)
                   3252:    state</a>.</dd>
                   3253: 
                   3254:    <dt>U+0026 AMPERSAND (&amp;)</dt>
                   3255:    <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
                   3256:    state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
                   3257:    being U+0027 APOSTROPHE (').</dd>
                   3258: 
                   3259:    <dt>EOF</dt>
                   3260:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3261:    <a href="#data-state">data state</a>.</dd>
                   3262: 
                   3263:    <dt>Anything else</dt>
1.541     mike     3264:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3265:    attribute's value. Stay in the <a href="#attribute-value-single-quoted-state">attribute value
                   3266:    (single-quoted) state</a>.</dd>
1.1       mike     3267: 
1.724     mike     3268:   </dl><h5 id="attribute-value-unquoted-state"><span class="secno">7.2.4.40 </span><dfn>Attribute value (unquoted) state</dfn></h5>
1.1       mike     3269: 
                   3270:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3271: 
                   3272:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3273:    <dt>U+000A LINE FEED (LF)</dt>
                   3274:    <dt>U+000C FORM FEED (FF)</dt>
                   3275:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3276:    <dt>U+0020 SPACE</dt>
                   3277:    <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3278: 
                   3279:    <dt>U+0026 AMPERSAND (&amp;)</dt>
                   3280:    <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
1.299     mike     3281:    state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
                   3282:    being U+003E GREATER-THAN SIGN (&gt;).</dd>
1.1       mike     3283: 
                   3284:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3285:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3286:    state</a>.</dd>
                   3287: 
                   3288:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3289:    <dt>U+0027 APOSTROPHE (')</dt>
                   3290:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3291:    <dt>U+003D EQUALS SIGN (=)</dt>
1.463     mike     3292:    <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1       mike     3293:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3294:    entry below.</dd>
                   3295: 
                   3296:    <dt>EOF</dt>
                   3297:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3298:    <a href="#data-state">data state</a>.</dd>
                   3299: 
                   3300:    <dt>Anything else</dt>
1.541     mike     3301:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3302:    attribute's value. Stay in the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
1.1       mike     3303:    state</a>.</dd>
                   3304: 
1.724     mike     3305:   </dl><h5 id="character-reference-in-attribute-value-state"><span class="secno">7.2.4.41 </span><dfn>Character reference in attribute value state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3306: 
                   3307:   <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>.</p>
                   3308: 
                   3309:   <p>If nothing is returned, append a U+0026 AMPERSAND character to
                   3310:   the current attribute's value.</p>
                   3311: 
                   3312:   <p>Otherwise, append the returned character token to the current
                   3313:   attribute's value.</p>
                   3314: 
                   3315:   <p>Finally, switch back to the attribute value state that you were
                   3316:   in when were switched into this state.</p>
                   3317: 
                   3318: 
1.724     mike     3319:   <h5 id="after-attribute-value-quoted-state"><span class="secno">7.2.4.42 </span><dfn>After attribute value (quoted) state</dfn></h5>
1.1       mike     3320: 
                   3321:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3322: 
                   3323:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3324:    <dt>U+000A LINE FEED (LF)</dt>
                   3325:    <dt>U+000C FORM FEED (FF)</dt>
                   3326:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3327:    <dt>U+0020 SPACE</dt>
                   3328:    <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3329: 
                   3330:    <dt>U+002F SOLIDUS (/)</dt>
                   3331:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   3332: 
                   3333:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3334:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3335:    state</a>.</dd>
                   3336: 
                   3337:    <dt>EOF</dt>
                   3338:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3339:    <a href="#data-state">data state</a>.</dd>
                   3340: 
                   3341:    <dt>Anything else</dt>
                   3342:    <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
                   3343:    the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3344: 
1.724     mike     3345:   </dl><h5 id="self-closing-start-tag-state"><span class="secno">7.2.4.43 </span><dfn>Self-closing start tag state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3346: 
                   3347:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3348: 
                   3349:   <dl class="switch"><dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3350:    <dd>Set the <i>self-closing flag</i> of the current tag
                   3351:    token. Emit the current tag token. Switch to the <a href="#data-state">data
                   3352:    state</a>.</dd>
                   3353: 
                   3354:    <dt>EOF</dt>
                   3355:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3356:    <a href="#data-state">data state</a>.</dd>
                   3357: 
                   3358:    <dt>Anything else</dt>
                   3359:    <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
                   3360:    the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3361: 
1.724     mike     3362:   </dl><h5 id="bogus-comment-state"><span class="secno">7.2.4.44 </span><dfn>Bogus comment state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3363: 
                   3364:   <p>Consume every character up to and including the first U+003E
                   3365:   GREATER-THAN SIGN character (&gt;) or the end of the file (EOF),
                   3366:   whichever comes first. Emit a comment token whose data is the
                   3367:   concatenation of all the characters starting from and including
                   3368:   the character that caused the state machine to switch into the
                   3369:   bogus comment state, up to and including the character immediately
                   3370:   before the last consumed character (i.e. up to the character just
                   3371:   before the U+003E or EOF character). (If the comment was started
                   3372:   by the end of the file (EOF), the token is empty.)</p>
                   3373: 
                   3374:   <p>Switch to the <a href="#data-state">data state</a>.</p>
                   3375: 
                   3376:   <p>If the end of the file was reached, reconsume the EOF
                   3377:   character.</p>
                   3378: 
                   3379: 
1.724     mike     3380:   <h5 id="markup-declaration-open-state"><span class="secno">7.2.4.45 </span><dfn>Markup declaration open state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3381: 
1.588     mike     3382:   <p>If the next two characters are both U+002D HYPHEN-MINUS
                   3383:   characters (-), consume those two characters, create a comment token
1.1       mike     3384:   whose data is the empty string, and switch to the <a href="#comment-start-state">comment
                   3385:   start state</a>.</p>
                   3386: 
                   3387:   <p>Otherwise, if the next seven characters are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   3388:   case-insensitive</a> match for the word "DOCTYPE", then consume
                   3389:   those characters and switch to the <a href="#doctype-state">DOCTYPE state</a>.</p>
                   3390: 
                   3391:   <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
                   3392:   content</a>" and the <a href="#current-node">current node</a> is not an element
1.724     mike     3393:   in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a> and the next seven characters are
1.585     mike     3394:   an <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string "[CDATA[" (the
                   3395:   five uppercase letters "CDATA" with a U+005B LEFT SQUARE BRACKET
                   3396:   character before and after), then consume those characters and
                   3397:   switch to the <a href="#cdata-section-state">CDATA section state</a>.</p>
1.1       mike     3398: 
                   3399:   <p>Otherwise, this is a <a href="#parse-error">parse error</a>. Switch to the
                   3400:   <a href="#bogus-comment-state">bogus comment state</a>. The next character that is
                   3401:   consumed, if any, is the first character that will be in the
                   3402:   comment.</p>
                   3403: 
                   3404: 
1.724     mike     3405:   <h5 id="comment-start-state"><span class="secno">7.2.4.46 </span><dfn>Comment start state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3406: 
                   3407:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3408: 
                   3409:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3410:    <dd>Switch to the <a href="#comment-start-dash-state">comment start dash state</a>.</dd>
                   3411: 
                   3412:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3413:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to the
                   3414:    <a href="#data-state">data state</a>.</dd> <!-- see comment in comment end state
                   3415:    -->
                   3416: 
                   3417:    <dt>EOF</dt>
                   3418:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
                   3419:    the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3420: 
                   3421:    <dt>Anything else</dt>
1.541     mike     3422:    <dd>Append the <a href="#current-input-character">current input character</a> to the comment
                   3423:    token's data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3424: 
1.724     mike     3425:   </dl><h5 id="comment-start-dash-state"><span class="secno">7.2.4.47 </span><dfn>Comment start dash state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3426: 
                   3427:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3428: 
                   3429:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3430:    <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
                   3431: 
                   3432:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3433:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to
                   3434:    the <a href="#data-state">data state</a>.</dd>
                   3435: 
                   3436:    <dt>EOF</dt>
                   3437:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
                   3438:    EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
                   3439:    in comment end state -->
                   3440: 
                   3441:    <dt>Anything else</dt>
1.541     mike     3442:    <dd>Append a U+002D HYPHEN-MINUS character (-) and the
                   3443:    <a href="#current-input-character">current input character</a> to the comment token's
                   3444:    data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3445: 
1.724     mike     3446:   </dl><h5 id="comment-state"><span class="secno">7.2.4.48 </span><dfn id="comment">Comment state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3447: 
                   3448:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3449: 
                   3450:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3451:    <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a></dd>
                   3452: 
                   3453:    <dt>EOF</dt>
                   3454:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
                   3455:    EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
                   3456:    in comment end state -->
                   3457: 
                   3458:    <dt>Anything else</dt>
1.541     mike     3459:    <dd>Append the <a href="#current-input-character">current input character</a> to the comment
                   3460:    token's data. Stay in the <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3461: 
1.724     mike     3462:   </dl><h5 id="comment-end-dash-state"><span class="secno">7.2.4.49 </span><dfn>Comment end dash state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3463: 
                   3464:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3465: 
                   3466:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3467:    <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
                   3468: 
                   3469:    <dt>EOF</dt>
                   3470:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
                   3471:    EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
                   3472:    in comment end state -->
                   3473: 
                   3474:    <dt>Anything else</dt>
1.541     mike     3475:    <dd>Append a U+002D HYPHEN-MINUS character (-) and the
                   3476:    <a href="#current-input-character">current input character</a> to the comment token's
                   3477:    data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3478: 
1.724     mike     3479:   </dl><h5 id="comment-end-state"><span class="secno">7.2.4.50 </span><dfn>Comment end state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3480: 
                   3481:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3482: 
                   3483:   <dl class="switch"><dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3484:    <dd>Emit the comment token. Switch to the <a href="#data-state">data
                   3485:    state</a>.</dd>
                   3486: 
                   3487:    <dt>U+0009 CHARACTER TABULATION</dt>
                   3488:    <dt>U+000A LINE FEED (LF)</dt>
                   3489:    <dt>U+000C FORM FEED (FF)</dt>
                   3490:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3491:    <dt>U+0020 SPACE</dt>
1.588     mike     3492:    <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS
                   3493:    characters (-) and the <a href="#current-input-character">current input character</a> to the
1.541     mike     3494:    comment token's data. Switch to the <a href="#comment-end-space-state">comment end space
                   3495:    state</a>.</dd>
1.1       mike     3496: 
                   3497:    <dt>U+0021 EXCLAMATION MARK (!)</dt>
                   3498:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#comment-end-bang-state">comment end bang
                   3499:    state</a>.</dd>
                   3500: 
1.333     mike     3501:    <dt>U+002D HYPHEN-MINUS (-)</dt>
                   3502:    <dd><a href="#parse-error">Parse error</a>. Append a U+002D HYPHEN-MINUS
1.464     mike     3503:    character (-) to the comment token's data. Stay in the
1.333     mike     3504:    <a href="#comment-end-state">comment end state</a>.</dd>
                   3505: 
1.1       mike     3506:    <dt>EOF</dt>
                   3507:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
                   3508:    the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- For
1.724     mike     3509:    security reasons: otherwise, hostile user could put a <script type="text/javascript"> in
1.1       mike     3510:    a comment e.g. in a blog comment and then DOS the server so that
1.724     mike     3511:    the end tag isn't read, and then the commented <script type="text/javascript"> tag would
1.1       mike     3512:    be treated as live code -->
                   3513: 
                   3514:    <dt>Anything else</dt>
1.588     mike     3515:    <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS
                   3516:    characters (-) and the <a href="#current-input-character">current input character</a> to the
1.541     mike     3517:    comment token's data. Switch to the <a href="#comment-state">comment
                   3518:    state</a>.</dd>
1.1       mike     3519: 
1.724     mike     3520:   </dl><h5 id="comment-end-bang-state"><span class="secno">7.2.4.51 </span><dfn>Comment end bang state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3521: 
                   3522:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3523: 
1.333     mike     3524:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
1.588     mike     3525:    <dd>Append two U+002D HYPHEN-MINUS characters (-) and a U+0021
1.464     mike     3526:    EXCLAMATION MARK character (!) to the comment token's data. Switch
1.1       mike     3527:    to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
                   3528: 
1.333     mike     3529:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3530:    <dd>Emit the comment token. Switch to the <a href="#data-state">data
                   3531:    state</a>.</dd>
                   3532: 
1.1       mike     3533:    <dt>EOF</dt>
                   3534:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
                   3535:    the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
                   3536:    comment in comment end state -->
                   3537: 
                   3538:    <dt>Anything else</dt>
1.588     mike     3539:    <dd>Append two U+002D HYPHEN-MINUS characters (-), a U+0021
1.541     mike     3540:    EXCLAMATION MARK character (!), and the <a href="#current-input-character">current input
                   3541:    character</a> to the comment token's data. Switch to the
                   3542:    <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3543: 
1.724     mike     3544:   </dl><h5 id="comment-end-space-state"><span class="secno">7.2.4.52 </span><dfn>Comment end space state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3545: 
                   3546:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3547: 
1.333     mike     3548:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
1.1       mike     3549:    <dt>U+000A LINE FEED (LF)</dt>
                   3550:    <dt>U+000C FORM FEED (FF)</dt>
                   3551:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3552:    <dt>U+0020 SPACE</dt>
1.541     mike     3553:    <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Stay in
1.1       mike     3554:    the <a href="#comment-end-space-state">comment end space state</a>.</dd>
                   3555: 
1.333     mike     3556:    <dt>U+002D HYPHEN-MINUS (-)</dt>
                   3557:    <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
                   3558: 
                   3559:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3560:    <dd>Emit the comment token. Switch to the <a href="#data-state">data
                   3561:    state</a>.</dd>
                   3562: 
1.1       mike     3563:    <dt>EOF</dt>
                   3564:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
                   3565:    the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
                   3566:    comment in comment end state -->
                   3567: 
                   3568:    <dt>Anything else</dt>
1.541     mike     3569:    <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Switch
1.1       mike     3570:    to the <a href="#comment-state">comment state</a>.</dd>
                   3571: 
1.724     mike     3572:   </dl><h5 id="doctype-state"><span class="secno">7.2.4.53 </span><dfn>DOCTYPE state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3573: 
                   3574:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3575: 
                   3576:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3577:    <dt>U+000A LINE FEED (LF)</dt>
                   3578:    <dt>U+000C FORM FEED (FF)</dt>
                   3579:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3580:    <dt>U+0020 SPACE</dt>
                   3581:    <dd>Switch to the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
                   3582: 
                   3583:    <dt>EOF</dt>
                   3584:    <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
                   3585:    <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
                   3586:    the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3587: 
                   3588:    <dt>Anything else</dt>
1.608     mike     3589:    <dd><a href="#parse-error">Parse error</a>. Reconsume the character in the
                   3590:    <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
1.1       mike     3591: 
1.724     mike     3592:   </dl><h5 id="before-doctype-name-state"><span class="secno">7.2.4.54 </span><dfn>Before DOCTYPE name state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3593: 
                   3594:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3595: 
                   3596:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3597:    <dt>U+000A LINE FEED (LF)</dt>
                   3598:    <dt>U+000C FORM FEED (FF)</dt>
                   3599:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3600:    <dt>U+0020 SPACE</dt>
                   3601:    <dd>Stay in the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
                   3602: 
                   3603:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   3604:    <dd>Create a new DOCTYPE token. Set the token's name to the
1.541     mike     3605:    lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
1.1       mike     3606:    character's code point). Switch to the <a href="#doctype-name-state">DOCTYPE name
                   3607:    state</a>.</dd>
                   3608: 
1.333     mike     3609:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3610:    <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
                   3611:    <i>force-quirks flag</i> to <i>on</i>. Emit the token. Switch to
                   3612:    the <a href="#data-state">data state</a>.</dd>
                   3613: 
1.1       mike     3614:    <dt>EOF</dt>
                   3615:    <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
                   3616:    <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
                   3617:    the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3618: 
                   3619:    <dt>Anything else</dt>
                   3620:    <dd>Create a new DOCTYPE token. Set the token's name to the
                   3621:    <a href="#current-input-character">current input character</a>. Switch to the <a href="#doctype-name-state">DOCTYPE name
                   3622:    state</a>.</dd>
                   3623: 
1.724     mike     3624:   </dl><h5 id="doctype-name-state"><span class="secno">7.2.4.55 </span><dfn>DOCTYPE name state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3625: 
                   3626:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3627: 
                   3628:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3629:    <dt>U+000A LINE FEED (LF)</dt>
                   3630:    <dt>U+000C FORM FEED (FF)</dt>
                   3631:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3632:    <dt>U+0020 SPACE</dt>
                   3633:    <dd>Switch to the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
                   3634: 
                   3635:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3636:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   3637:    state</a>.</dd>
                   3638: 
                   3639:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541     mike     3640:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   3641:    character</a> (add 0x0020 to the character's code point) to the
                   3642:    current DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
                   3643:    state</a>.</dd>
1.1       mike     3644: 
                   3645:    <dt>EOF</dt>
                   3646:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3647:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3648:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3649: 
                   3650:    <dt>Anything else</dt>
1.541     mike     3651:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3652:    DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
                   3653:    state</a>.</dd>
1.1       mike     3654: 
1.724     mike     3655:   </dl><h5 id="after-doctype-name-state"><span class="secno">7.2.4.56 </span><dfn>After DOCTYPE name state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3656: 
                   3657:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3658: 
                   3659:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3660:    <dt>U+000A LINE FEED (LF)</dt>
                   3661:    <dt>U+000C FORM FEED (FF)</dt>
                   3662:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3663:    <dt>U+0020 SPACE</dt>
                   3664:    <dd>Stay in the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
                   3665: 
                   3666:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3667:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   3668:    state</a>.</dd>
                   3669: 
                   3670:    <dt>EOF</dt>
                   3671:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3672:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3673:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3674: 
                   3675:    <dt>Anything else</dt>
                   3676:    <dd>
                   3677: 
                   3678:     <p>If the six characters starting from the <a href="#current-input-character">current input
                   3679:     character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match
                   3680:     for the word "PUBLIC", then consume those characters and switch to
1.444     mike     3681:     the <a href="#after-doctype-public-keyword-state">after DOCTYPE public keyword state</a>.</p>
1.1       mike     3682: 
                   3683:     <p>Otherwise, if the six characters starting from the
                   3684:     <a href="#current-input-character">current input character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   3685:     case-insensitive</a> match for the word "SYSTEM", then consume
1.444     mike     3686:     those characters and switch to the <a href="#after-doctype-system-keyword-state">after DOCTYPE system
                   3687:     keyword state</a>.</p>
1.1       mike     3688: 
                   3689:     <p>Otherwise, this is the <a href="#parse-error">parse error</a>. Set the
                   3690:     DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to
                   3691:     the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</p>
                   3692: 
                   3693:    </dd>
                   3694: 
1.724     mike     3695:   </dl><h5 id="after-doctype-public-keyword-state"><span class="secno">7.2.4.57 </span><dfn>After DOCTYPE public keyword state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.444     mike     3696: 
                   3697:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3698: 
                   3699:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3700:    <dt>U+000A LINE FEED (LF)</dt>
                   3701:    <dt>U+000C FORM FEED (FF)</dt>
                   3702:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3703:    <dt>U+0020 SPACE</dt>
                   3704:    <dd>Switch to the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier
                   3705:    state</a>.</dd>
                   3706: 
1.620     mike     3707:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3708:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's public
                   3709:    identifier to the empty string (not missing), then switch to the
                   3710:    <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public identifier (double-quoted) state</a>.</dd>
                   3711: 
                   3712:    <dt>U+0027 APOSTROPHE (')</dt>
                   3713:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's public
                   3714:    identifier to the empty string (not missing), then switch to the
                   3715:    <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public identifier (single-quoted) state</a>.</dd>
                   3716: 
                   3717:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3718:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3719:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3720:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3721: 
1.444     mike     3722:    <dt>EOF</dt>
                   3723:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3724:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3725:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3726: 
                   3727:    <dt>Anything else</dt>
1.620     mike     3728:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3729:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3730:    DOCTYPE state</a>.</dd>
1.444     mike     3731: 
1.724     mike     3732:   </dl><h5 id="before-doctype-public-identifier-state"><span class="secno">7.2.4.58 </span><dfn>Before DOCTYPE public identifier state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3733: 
                   3734:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3735: 
                   3736:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3737:    <dt>U+000A LINE FEED (LF)</dt>
                   3738:    <dt>U+000C FORM FEED (FF)</dt>
                   3739:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3740:    <dt>U+0020 SPACE</dt>
                   3741:    <dd>Stay in the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier state</a>.</dd>
                   3742: 
                   3743:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3744:    <dd>Set the DOCTYPE token's public identifier to the empty string
                   3745:    (not missing), then switch to the <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public identifier
                   3746:    (double-quoted) state</a>.</dd>
                   3747: 
                   3748:    <dt>U+0027 APOSTROPHE (')</dt>
                   3749:    <dd>Set the DOCTYPE token's public identifier to the empty string
                   3750:    (not missing), then switch to the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public identifier
                   3751:    (single-quoted) state</a>.</dd>
                   3752: 
                   3753:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3754:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3755:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3756:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3757: 
                   3758:    <dt>EOF</dt>
                   3759:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3760:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3761:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3762: 
                   3763:    <dt>Anything else</dt>
                   3764:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3765:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3766:    DOCTYPE state</a>.</dd>
                   3767: 
1.724     mike     3768:   </dl><h5 id="doctype-public-identifier-double-quoted-state"><span class="secno">7.2.4.59 </span><dfn>DOCTYPE public identifier (double-quoted) state</dfn></h5>
1.1       mike     3769: 
                   3770:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3771: 
                   3772:   <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
                   3773:    <dd>Switch to the <a href="#after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd>
                   3774: 
                   3775:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3776:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3777:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3778:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3779: 
                   3780:    <dt>EOF</dt>
                   3781:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3782:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3783:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3784: 
                   3785:    <dt>Anything else</dt>
                   3786:    <dd>Append the <a href="#current-input-character">current input character</a> to the current DOCTYPE
                   3787:    token's public identifier. Stay in the <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public
                   3788:    identifier (double-quoted) state</a>.</dd>
                   3789: 
1.724     mike     3790:   </dl><h5 id="doctype-public-identifier-single-quoted-state"><span class="secno">7.2.4.60 </span><dfn>DOCTYPE public identifier (single-quoted) state</dfn></h5>
1.1       mike     3791: 
                   3792:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3793: 
                   3794:   <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
                   3795:    <dd>Switch to the <a href="#after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd>
                   3796: 
                   3797:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3798:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3799:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3800:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3801: 
                   3802:    <dt>EOF</dt>
                   3803:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3804:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3805:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3806: 
                   3807:    <dt>Anything else</dt>
                   3808:    <dd>Append the <a href="#current-input-character">current input character</a> to the current DOCTYPE
                   3809:    token's public identifier. Stay in the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public
                   3810:    identifier (single-quoted) state</a>.</dd>
                   3811: 
1.724     mike     3812:   </dl><h5 id="after-doctype-public-identifier-state"><span class="secno">7.2.4.61 </span><dfn>After DOCTYPE public identifier state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3813: 
                   3814:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3815: 
                   3816:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3817:    <dt>U+000A LINE FEED (LF)</dt>
                   3818:    <dt>U+000C FORM FEED (FF)</dt>
                   3819:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3820:    <dt>U+0020 SPACE</dt>
1.541     mike     3821:    <dd>Switch to the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system
                   3822:    identifiers state</a>.</dd>
1.444     mike     3823: 
                   3824:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3825:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   3826:    state</a>.</dd>
                   3827: 
                   3828:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3829:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
                   3830:    identifier to the empty string (not missing), then switch to the
                   3831:    <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier (double-quoted) state</a>.</dd>
                   3832: 
                   3833:    <dt>U+0027 APOSTROPHE (')</dt>
                   3834:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
                   3835:    identifier to the empty string (not missing), then switch to the
                   3836:    <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier (single-quoted) state</a>.</dd>
                   3837: 
                   3838:    <dt>EOF</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>. Emit that DOCTYPE token.
                   3841:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3842: 
                   3843:    <dt>Anything else</dt>
                   3844:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3845:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3846:    DOCTYPE state</a>.</dd>
                   3847: 
1.724     mike     3848:   </dl><h5 id="between-doctype-public-and-system-identifiers-state"><span class="secno">7.2.4.62 </span><dfn>Between DOCTYPE public and system identifiers state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.444     mike     3849: 
                   3850:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3851: 
                   3852:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3853:    <dt>U+000A LINE FEED (LF)</dt>
                   3854:    <dt>U+000C FORM FEED (FF)</dt>
                   3855:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3856:    <dt>U+0020 SPACE</dt>
1.541     mike     3857:    <dd>Stay in the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system identifiers
                   3858:    state</a>.</dd>
1.444     mike     3859: 
                   3860:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3861:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   3862:    state</a>.</dd>
1.1       mike     3863: 
                   3864:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3865:    <dd>Set the DOCTYPE token's system identifier to the empty string
                   3866:    (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
                   3867:    (double-quoted) state</a>.</dd>
                   3868: 
                   3869:    <dt>U+0027 APOSTROPHE (')</dt>
                   3870:    <dd>Set the DOCTYPE token's system identifier to the empty string
                   3871:    (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
                   3872:    (single-quoted) state</a>.</dd>
                   3873: 
                   3874:    <dt>EOF</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 token.
                   3877:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3878: 
                   3879:    <dt>Anything else</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>. Switch to the <a href="#bogus-doctype-state">bogus
                   3882:    DOCTYPE state</a>.</dd>
                   3883: 
1.724     mike     3884:   </dl><h5 id="after-doctype-system-keyword-state"><span class="secno">7.2.4.63 </span><dfn>After DOCTYPE system keyword state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.444     mike     3885: 
                   3886:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3887: 
                   3888:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3889:    <dt>U+000A LINE FEED (LF)</dt>
                   3890:    <dt>U+000C FORM FEED (FF)</dt>
                   3891:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3892:    <dt>U+0020 SPACE</dt>
                   3893:    <dd>Switch to the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier
                   3894:    state</a>.</dd>
                   3895: 
1.620     mike     3896:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3897:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
                   3898:    identifier to the empty string (not missing), then switch to the
                   3899:    <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier (double-quoted) state</a>.</dd>
                   3900: 
                   3901:    <dt>U+0027 APOSTROPHE (')</dt>
                   3902:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
                   3903:    identifier to the empty string (not missing), then switch to the
                   3904:    <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier (single-quoted) state</a>.</dd>
                   3905: 
                   3906:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3907:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3908:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3909:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3910: 
1.444     mike     3911:    <dt>EOF</dt>
                   3912:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3913:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3914:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3915: 
                   3916:    <dt>Anything else</dt>
1.620     mike     3917:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3918:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3919:    DOCTYPE state</a>.</dd>
1.444     mike     3920: 
1.724     mike     3921:   </dl><h5 id="before-doctype-system-identifier-state"><span class="secno">7.2.4.64 </span><dfn>Before DOCTYPE system identifier state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     3922: 
                   3923:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3924: 
                   3925:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3926:    <dt>U+000A LINE FEED (LF)</dt>
                   3927:    <dt>U+000C FORM FEED (FF)</dt>
                   3928:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3929:    <dt>U+0020 SPACE</dt>
                   3930:    <dd>Stay in the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier state</a>.</dd>
                   3931: 
                   3932:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3933:    <dd>Set the DOCTYPE token's system identifier to the empty string
                   3934:    (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
                   3935:    (double-quoted) state</a>.</dd>
                   3936: 
                   3937:    <dt>U+0027 APOSTROPHE (')</dt>
                   3938:    <dd>Set the DOCTYPE token's system identifier to the empty string
                   3939:    (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
                   3940:    (single-quoted) state</a>.</dd>
                   3941: 
                   3942:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3943:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3944:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3945:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3946: 
                   3947:    <dt>EOF</dt>
                   3948:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3949:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3950:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3951: 
                   3952:    <dt>Anything else</dt>
                   3953:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3954:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3955:    DOCTYPE state</a>.</dd>
                   3956: 
1.724     mike     3957:   </dl><h5 id="doctype-system-identifier-double-quoted-state"><span class="secno">7.2.4.65 </span><dfn>DOCTYPE system identifier (double-quoted) state</dfn></h5>
1.1       mike     3958: 
                   3959:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3960: 
                   3961:   <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
1.541     mike     3962:    <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
                   3963:    state</a>.</dd>
1.1       mike     3964: 
                   3965:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3966:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3967:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3968:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3969: 
                   3970:    <dt>EOF</dt>
                   3971:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3972:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3973:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3974: 
                   3975:    <dt>Anything else</dt>
1.541     mike     3976:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3977:    DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system
1.1       mike     3978:    identifier (double-quoted) state</a>.</dd>
                   3979: 
1.724     mike     3980:   </dl><h5 id="doctype-system-identifier-single-quoted-state"><span class="secno">7.2.4.66 </span><dfn>DOCTYPE system identifier (single-quoted) state</dfn></h5>
1.1       mike     3981: 
                   3982:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3983: 
                   3984:   <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
1.541     mike     3985:    <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
                   3986:    state</a>.</dd>
1.1       mike     3987: 
                   3988:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3989:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3990:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3991:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3992: 
                   3993:    <dt>EOF</dt>
                   3994:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3995:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3996:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3997: 
                   3998:    <dt>Anything else</dt>
1.541     mike     3999:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   4000:    DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system
1.1       mike     4001:    identifier (single-quoted) state</a>.</dd>
                   4002: 
1.724     mike     4003:   </dl><h5 id="after-doctype-system-identifier-state"><span class="secno">7.2.4.67 </span><dfn>After DOCTYPE system identifier state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     4004: 
                   4005:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   4006: 
                   4007:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   4008:    <dt>U+000A LINE FEED (LF)</dt>
                   4009:    <dt>U+000C FORM FEED (FF)</dt>
                   4010:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   4011:    <dt>U+0020 SPACE</dt>
1.541     mike     4012:    <dd>Stay in the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
                   4013:    state</a>.</dd>
1.1       mike     4014: 
                   4015:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   4016:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   4017:    state</a>.</dd>
                   4018: 
                   4019:    <dt>EOF</dt>
                   4020:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   4021:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   4022:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   4023: 
                   4024:    <dt>Anything else</dt>
                   4025:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-doctype-state">bogus DOCTYPE
                   4026:    state</a>. (This does <em>not</em> set the DOCTYPE token's
                   4027:    <i>force-quirks flag</i> to <i>on</i>.)</dd>
                   4028: 
1.724     mike     4029:   </dl><h5 id="bogus-doctype-state"><span class="secno">7.2.4.68 </span><dfn>Bogus DOCTYPE state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     4030: 
                   4031:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   4032: 
                   4033:   <dl class="switch"><dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   4034:    <dd>Emit the DOCTYPE token. Switch to the <a href="#data-state">data
                   4035:    state</a>.</dd>
                   4036: 
                   4037:    <dt>EOF</dt>
                   4038:    <dd>Emit the DOCTYPE token. Reconsume the EOF character in the
                   4039:    <a href="#data-state">data state</a>.</dd>
                   4040: 
                   4041:    <dt>Anything else</dt>
                   4042:    <dd>Stay in the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</dd>
                   4043: 
1.724     mike     4044:   </dl><h5 id="cdata-section-state"><span class="secno">7.2.4.69 </span><dfn>CDATA section state</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     4045: 
                   4046:   <p>Consume every character up to the next occurrence of the three
                   4047:   character sequence U+005D RIGHT SQUARE BRACKET U+005D RIGHT SQUARE
                   4048:   BRACKET U+003E GREATER-THAN SIGN (<code title="">]]&gt;</code>), or the
                   4049:   end of the file (EOF), whichever comes first. Emit a series of
                   4050:   character tokens consisting of all the characters consumed except
                   4051:   the matching three character sequence at the end (if one was found
                   4052:   before the end of the file).</p>
                   4053: 
                   4054:   <p>Switch to the <a href="#data-state">data state</a>.</p>
                   4055: 
                   4056:   <p>If the end of the file was reached, reconsume the EOF
                   4057:   character.</p>
                   4058: 
                   4059: 
                   4060: 
1.724     mike     4061:   <h5 id="tokenizing-character-references"><span class="secno">7.2.4.70 </span>Tokenizing character references</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     4062: 
                   4063:   <p>This section defines how to <dfn id="consume-a-character-reference">consume a character
                   4064:   reference</dfn>. This definition is used when parsing character
1.299     mike     4065:   references <a href="#character-reference-in-data-state" title="character reference in data state">in
1.1       mike     4066:   text</a> and <a href="#character-reference-in-attribute-value-state" title="character reference in attribute value
                   4067:   state">in attributes</a>.</p>
                   4068: 
                   4069:   <p>The behavior depends on the identity of the next character (the
                   4070:   one immediately after the U+0026 AMPERSAND character):</p>
                   4071: 
                   4072:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   4073:    <dt>U+000A LINE FEED (LF)</dt>
                   4074:    <dt>U+000C FORM FEED (FF)</dt>
                   4075:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   4076:    <dt>U+0020 SPACE</dt>
                   4077:    <dt>U+003C LESS-THAN SIGN</dt>
                   4078:    <dt>U+0026 AMPERSAND</dt>
                   4079:    <dt>EOF</dt>
                   4080:    <dt>The <dfn id="additional-allowed-character">additional allowed character</dfn>, if there is one</dt>
                   4081: 
                   4082:    <dd>Not a character reference. No characters are consumed, and
                   4083:    nothing is returned. (This is not an error, either.)</dd>
                   4084: 
                   4085: 
                   4086:    <dt>U+0023 NUMBER SIGN (#)</dt>
                   4087: 
                   4088:    <dd>
                   4089: 
                   4090:     <p>Consume the U+0023 NUMBER SIGN.</p>
                   4091: 
                   4092:     <p>The behavior further depends on the character after the U+0023
                   4093:     NUMBER SIGN:</p>
                   4094: 
                   4095:     <dl class="switch"><dt>U+0078 LATIN SMALL LETTER X</dt>
                   4096:      <dt>U+0058 LATIN CAPITAL LETTER X</dt>
                   4097: 
                   4098:      <dd>
                   4099: 
                   4100:       <p>Consume the X.</p>
                   4101: 
                   4102:       <p>Follow the steps below, but using the range of characters
1.464     mike     4103:       U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061 LATIN
                   4104:       SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041 LATIN
                   4105:       CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F (in other
                   4106:       words, 0-9, A-F, a-f).</p>
1.1       mike     4107: 
                   4108:       <p>When it comes to interpreting the number, interpret it as a
                   4109:       hexadecimal number.</p>
                   4110: 
                   4111:      </dd>
                   4112: 
                   4113: 
                   4114:      <dt>Anything else</dt>
                   4115: 
                   4116:      <dd>
                   4117: 
                   4118:       <p>Follow the steps below, but using the range of characters
1.464     mike     4119:       U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</p>
1.1       mike     4120: 
                   4121:       <p>When it comes to interpreting the number, interpret it as a
                   4122:       decimal number.</p>
                   4123: 
                   4124:      </dd>
                   4125: 
                   4126:     </dl><p>Consume as many characters as match the range of characters
                   4127:     given above.</p>
                   4128: 
                   4129:     <p>If no characters match the range, then don't consume any
                   4130:     characters (and unconsume the U+0023 NUMBER SIGN character and, if
                   4131:     appropriate, the X character). This is a <a href="#parse-error">parse
                   4132:     error</a>; nothing is returned.</p>
                   4133: 
                   4134:     <p>Otherwise, if the next character is a U+003B SEMICOLON, consume
                   4135:     that too. If it isn't, there is a <a href="#parse-error">parse
                   4136:     error</a>.</p>
                   4137: 
                   4138:     <p>If one or more characters match the range, then take them all
                   4139:     and interpret the string of characters as a number (either
                   4140:     hexadecimal or decimal as appropriate).</p>
                   4141: 
                   4142:     <p>If that number is one of the numbers in the first column of the
                   4143:     following table, then this is a <a href="#parse-error">parse error</a>. Find the
                   4144:     row with that number in the first column, and return a character
                   4145:     token for the Unicode character given in the second column of that
                   4146:     row.</p>
                   4147: 
                   4148:     <table><thead><tr><th>Number </th><th colspan="2">Unicode character
                   4149:      </th></tr></thead><tbody><tr><td>0x00 </td><td>U+FFFD </td><td>REPLACEMENT CHARACTER
                   4150:       </td></tr><tr><td>0x0D </td><td>U+000A </td><td>LINE FEED (LF)
1.464     mike     4151:       </td></tr><tr><td>0x80 </td><td>U+20AC </td><td>EURO SIGN (&#8364;)
1.1       mike     4152:       </td></tr><tr><td>0x81 </td><td>U+0081 </td><td>&lt;control&gt;
1.464     mike     4153:       </td></tr><tr><td>0x82 </td><td>U+201A </td><td>SINGLE LOW-9 QUOTATION MARK (&#8218;)
                   4154:       </td></tr><tr><td>0x83 </td><td>U+0192 </td><td>LATIN SMALL LETTER F WITH HOOK (&#402;)
                   4155:       </td></tr><tr><td>0x84 </td><td>U+201E </td><td>DOUBLE LOW-9 QUOTATION MARK (&#8222;)
                   4156:       </td></tr><tr><td>0x85 </td><td>U+2026 </td><td>HORIZONTAL ELLIPSIS (&#8230;)
                   4157:       </td></tr><tr><td>0x86 </td><td>U+2020 </td><td>DAGGER (&#8224;)
                   4158:       </td></tr><tr><td>0x87 </td><td>U+2021 </td><td>DOUBLE DAGGER (&#8225;)
                   4159:       </td></tr><tr><td>0x88 </td><td>U+02C6 </td><td>MODIFIER LETTER CIRCUMFLEX ACCENT (&#710;)
                   4160:       </td></tr><tr><td>0x89 </td><td>U+2030 </td><td>PER MILLE SIGN (&#8240;)
                   4161:       </td></tr><tr><td>0x8A </td><td>U+0160 </td><td>LATIN CAPITAL LETTER S WITH CARON (&#352;)
                   4162:       </td></tr><tr><td>0x8B </td><td>U+2039 </td><td>SINGLE LEFT-POINTING ANGLE QUOTATION MARK (&#8249;)
                   4163:       </td></tr><tr><td>0x8C </td><td>U+0152 </td><td>LATIN CAPITAL LIGATURE OE (&#338;)
1.1       mike     4164:       </td></tr><tr><td>0x8D </td><td>U+008D </td><td>&lt;control&gt;
1.464     mike     4165:       </td></tr><tr><td>0x8E </td><td>U+017D </td><td>LATIN CAPITAL LETTER Z WITH CARON (&#381;)
1.1       mike     4166:       </td></tr><tr><td>0x8F </td><td>U+008F </td><td>&lt;control&gt;
                   4167:       </td></tr><tr><td>0x90 </td><td>U+0090 </td><td>&lt;control&gt;
1.464     mike     4168:       </td></tr><tr><td>0x91 </td><td>U+2018 </td><td>LEFT SINGLE QUOTATION MARK (&#8216;)
                   4169:       </td></tr><tr><td>0x92 </td><td>U+2019 </td><td>RIGHT SINGLE QUOTATION MARK (&#8217;)
                   4170:       </td></tr><tr><td>0x93 </td><td>U+201C </td><td>LEFT DOUBLE QUOTATION MARK (&#8220;)
                   4171:       </td></tr><tr><td>0x94 </td><td>U+201D </td><td>RIGHT DOUBLE QUOTATION MARK (&#8221;)
                   4172:       </td></tr><tr><td>0x95 </td><td>U+2022 </td><td>BULLET (&#8226;)
                   4173:       </td></tr><tr><td>0x96 </td><td>U+2013 </td><td>EN DASH (&#8211;)
                   4174:       </td></tr><tr><td>0x97 </td><td>U+2014 </td><td>EM DASH (&#8212;)
                   4175:       </td></tr><tr><td>0x98 </td><td>U+02DC </td><td>SMALL TILDE (&#732;)
                   4176:       </td></tr><tr><td>0x99 </td><td>U+2122 </td><td>TRADE MARK SIGN (&#8482;)
                   4177:       </td></tr><tr><td>0x9A </td><td>U+0161 </td><td>LATIN SMALL LETTER S WITH CARON (&#353;)
                   4178:       </td></tr><tr><td>0x9B </td><td>U+203A </td><td>SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (&#8250;)
                   4179:       </td></tr><tr><td>0x9C </td><td>U+0153 </td><td>LATIN SMALL LIGATURE OE (&#339;)
1.1       mike     4180:       </td></tr><tr><td>0x9D </td><td>U+009D </td><td>&lt;control&gt;
1.464     mike     4181:       </td></tr><tr><td>0x9E </td><td>U+017E </td><td>LATIN SMALL LETTER Z WITH CARON (&#382;)
                   4182:       </td></tr><tr><td>0x9F </td><td>U+0178 </td><td>LATIN CAPITAL LETTER Y WITH DIAERESIS (&#376;)
1.315     mike     4183:     </td></tr></tbody></table><p>Otherwise, if the number is in the range 0xD800 to 0xDFFF<!--
                   4184:     surrogates not allowed; see the comment in the "preprocessing the
                   4185:     input stream" section for details --> or is greater than 0x10FFFF,
                   4186:     then this is a <a href="#parse-error">parse error</a>. Return a U+FFFD
                   4187:     REPLACEMENT CHARACTER.</p>
1.18      mike     4188: 
                   4189:     <p>Otherwise, return a character token for the Unicode character
1.1       mike     4190:     whose code point is that number.
                   4191: 
                   4192:     <!-- this is the same as the equivalent list in the input stream
                   4193:     section -->
                   4194:     If the number is in the range 0x0001 to 0x0008, <!-- HT, LF
                   4195:     allowed --> <!-- U+000B is in the next list --> <!-- FF, CR
                   4196:     allowed --> 0x000E to 0x001F, <!-- ASCII allowed --> 0x007F <!--to
1.315     mike     4197:     0x0084, (0x0085 NEL not allowed), 0x0086--> to 0x009F, 0xFDD0 to
                   4198:     0xFDEF, or is one of 0x000B, 0xFFFE, 0xFFFF, 0x1FFFE, 0x1FFFF,
                   4199:     0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE,
                   4200:     0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF,
                   4201:     0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF, 0xCFFFE,
                   4202:     0xCFFFF, 0xDFFFE, 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF,
                   4203:     0x10FFFE, or 0x10FFFF, then this is a <a href="#parse-error">parse
                   4204:     error</a>.</p>
1.1       mike     4205: 
                   4206:    </dd>
                   4207: 
                   4208: 
                   4209:    <dt>Anything else</dt>
                   4210: 
                   4211:    <dd>
                   4212: 
                   4213:     <p>Consume the maximum number of characters possible, with the
                   4214:     consumed characters matching one of the identifiers in the first
                   4215:     column of the <a href="named-character-references.html#named-character-references">named character references</a> table (in a
                   4216:     <a href="infrastructure.html#case-sensitive">case-sensitive</a> manner).</p>
                   4217: 
                   4218:     <p>If no match can be made, then this is a <a href="#parse-error">parse
                   4219:     error</a>. No characters are consumed, and nothing is
                   4220:     returned.</p>
                   4221: 
1.588     mike     4222:     <p>If the last character matched is not a U+003B SEMICOLON
                   4223:     character (;), there is a <a href="#parse-error">parse error</a>.</p>
1.1       mike     4224: 
                   4225:     <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
                   4226:     attribute</a>, and the last character matched is not a U+003B
1.588     mike     4227:     SEMICOLON character (;), and the next character is in the range
                   4228:     U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN
                   4229:     CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z, or U+0061 LATIN
                   4230:     SMALL LETTER A to U+007A LATIN SMALL LETTER Z, then, for
                   4231:     historical reasons, all the characters that were matched after the
                   4232:     U+0026 AMPERSAND character (&amp;) must be unconsumed, and nothing
                   4233:     is returned.</p>
1.1       mike     4234: 
                   4235:     <p>Otherwise, return a character token for the character
                   4236:     corresponding to the character reference name (as given by the
                   4237:     second column of the <a href="named-character-references.html#named-character-references">named character references</a>
                   4238:     table).</p>
                   4239: 
                   4240:     <div class="example">
                   4241: 
                   4242:      <p>If the markup contains <code title="">I'm &amp;notit; I tell
                   4243:      you</code>, the character reference is parsed as "not", as in,
                   4244:      <code title="">I'm &#172;it; I tell you</code>. But if the markup
                   4245:      was <code title="">I'm &amp;notin; I tell you</code>, the
                   4246:      character reference would be parsed as "notin;", resulting in
                   4247:      <code title="">I'm &#8713; I tell you</code>.</p>
                   4248: 
                   4249:     </div>
                   4250: 
                   4251:    </dd>
                   4252: 
1.266     mike     4253:   </dl></div><div class="impl">
                   4254: 
1.363     mike     4255:   <!-- v2: One thing that this doesn't define is handling deeply
                   4256:   nested documents. There are compatibility requirements around that:
                   4257:   you can't throw away the elements altogether, consider Tux made only
                   4258:   with opening <font> elements, one per character. Seems that the best
                   4259:   thing to do is to close some formatting elements from the middle of
                   4260:   the stack when you hit a limit, or something. -->
                   4261: 
1.724     mike     4262:   <h4 id="tree-construction"><span class="secno">7.2.5 </span><dfn>Tree construction</dfn></h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     4263: 
                   4264:   <p>The input to the tree construction stage is a sequence of tokens
                   4265:   from the <a href="#tokenization">tokenization</a> stage. The tree construction
                   4266:   stage is associated with a DOM <code>Document</code> object when a
                   4267:   parser is created. The "output" of this stage consists of
                   4268:   dynamically modifying or extending that document's DOM tree.</p>
                   4269: 
                   4270:   <p>This specification does not define when an interactive user agent
                   4271:   has to render the <code>Document</code> so that it is available to
                   4272:   the user, or when it has to begin accepting user input.</p>
                   4273: 
                   4274:   <p>As each token is emitted from the tokenizer, the user agent must
                   4275:   process the token according to the rules given in the section
                   4276:   corresponding to the current <a href="#insertion-mode">insertion mode</a>.</p>
                   4277: 
                   4278:   <p>When the steps below require the UA to <dfn id="insert-a-character">insert a
                   4279:   character</dfn> into a node, if that node has a child immediately
                   4280:   before where the character is to be inserted, and that child is a
                   4281:   <code>Text</code> node, and that <code>Text</code> node was the last
                   4282:   node that the parser inserted into the document, then the character
                   4283:   must be appended to that <code>Text</code> node; otherwise, a new
                   4284:   <code>Text</code> node whose data is just that character must be
                   4285:   inserted in the appropriate place.</p>
                   4286: 
                   4287:   <div class="example">
                   4288: 
                   4289:    <p>Here are some sample inputs to the parser and the corresponding
                   4290:    number of text nodes that they result in, assuming a user agent
                   4291:    that executes scripts.</p>
                   4292: 
                   4293:    <table><thead><tr><th>Input </th><th>Number of text nodes
                   4294:     </th></tr></thead><tbody><tr><td><pre>A&lt;script&gt;
                   4295: var&#160;script&#160;=&#160;document.getElementsByTagName('script')[0];
                   4296: document.body.removeChild(script);
                   4297: &lt;/script&gt;B</pre>
                   4298:       </td><td>Two adjacent text nodes in the document, containing "A" and "B".
                   4299:      </td></tr><tr><td><pre>A&lt;script&gt;
                   4300: var&#160;text&#160;=&#160;document.createTextNode('B');
                   4301: document.body.appendChild(text);
                   4302: &lt;/script&gt;C</pre>
                   4303:       </td><td>Four text nodes; "A" before the script, the script's contents, "B" after the script, and then, immediately after that, "C".
                   4304:      </td></tr><tr><td><pre>A&lt;script&gt;
                   4305: var&#160;text&#160;=&#160;document.getElementsByTagName('script')[0].firstChild;
                   4306: text.data&#160;=&#160;'B';
                   4307: document.body.appendChild(text);
                   4308: &lt;/script&gt;B</pre>
                   4309:       </td><td>Two adjacent text nodes in the document, containing "A" and "BB".
                   4310:      </td></tr><tr><td><pre>A&lt;table&gt;B&lt;tr&gt;C&lt;/tr&gt;C&lt;/table&gt;</pre>
                   4311:       </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>.)
                   4312:      </td></tr><tr><td><pre>A&lt;table&gt;&lt;tr&gt;&#160;B&lt;/tr&gt;&#160;B&lt;/table&gt;</pre>
                   4313:       </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>.)
                   4314:      </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>
                   4315:       </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.)
                   4316:    </td></tr></tbody></table></div>
                   4317: 
                   4318:   <p id="mutation-during-parsing">DOM mutation events must not fire
                   4319:   for changes caused by the UA parsing the document. (Conceptually,
                   4320:   the parser is not mutating the DOM, it is constructing it.) This
1.159     mike     4321:   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     4322: 
                   4323:   <p class="note">Not all of the tag names mentioned below are
                   4324:   conformant tag names in this specification; many are included to
                   4325:   handle legacy content. They still form part of the algorithm that
                   4326:   implementations are required to implement to claim conformance.</p>
                   4327: 
                   4328:   <p class="note">The algorithm described below places no limit on the
                   4329:   depth of the DOM tree generated, or on the length of tag names,
                   4330:   attribute names, attribute values, text nodes, etc. While
                   4331:   implementors are encouraged to avoid arbitrary limits, it is
                   4332:   recognized that <a href="infrastructure.html#hardwareLimitations">practical
1.445     mike     4333:   concerns</a> will likely force user agents to impose nesting depth
                   4334:   constraints.</p>
1.1       mike     4335: 
                   4336: 
1.724     mike     4337:   <h5 id="creating-and-inserting-elements"><span class="secno">7.2.5.1 </span>Creating and inserting elements</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     4338: 
                   4339:   <p>When the steps below require the UA to <dfn id="create-an-element-for-the-token" title="create an
                   4340:   element for the token">create an element for a token</dfn> in a
                   4341:   particular namespace, the UA must create a node implementing the
                   4342:   interface appropriate for the element type corresponding to the tag
                   4343:   name of the token in the given namespace (as given in the
                   4344:   specification that defines that element, e.g. for an <code><a href="text-level-semantics.html#the-a-element">a</a></code>
1.724     mike     4345:   element in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, this specification
1.1       mike     4346:   defines it to be the <code><a href="text-level-semantics.html#htmlanchorelement">HTMLAnchorElement</a></code> interface), with
                   4347:   the tag name being the name of that element, with the node being in
                   4348:   the given namespace, and with the attributes on the node being those
                   4349:   given in the given token.</p>
                   4350: 
1.724     mike     4351:   <p>The interface appropriate for an element in the <a href="infrastructure.html#html-namespace-0">HTML
1.426     mike     4352:   namespace</a> that is not defined in this specification (or
                   4353:   <a href="infrastructure.html#other-applicable-specifications">other applicable specifications</a>) is
1.44      mike     4354:   <code><a href="dom.html#htmlunknownelement">HTMLUnknownElement</a></code>. Element in other namespaces whose
1.1       mike     4355:   interface is not defined by that namespace's specification must use
                   4356:   the interface <code>Element</code>.</p>
                   4357: 
                   4358:   <p>When a <a href="forms.html#category-reset" title="category-reset">resettable</a> element is
                   4359:   created in this manner, its <a href="forms.html#concept-form-reset-control" title="concept-form-reset-control">reset algorithm</a> must be
                   4360:   invoked once the attributes are set. (This initializes the element's
                   4361:   <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
                   4362:   attributes.)</p>
                   4363: 
                   4364:   <hr><p>When the steps below require the UA to <dfn id="insert-an-html-element">insert an HTML
                   4365:   element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
1.724     mike     4366:   for the token</a> in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, and then
1.1       mike     4367:   append this node to the <a href="#current-node">current node</a>, and push it onto
                   4368:   the <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
                   4369:   <a href="#current-node">current node</a>.</p>
                   4370: 
                   4371:   <p>The steps below may also require that the UA insert an HTML
                   4372:   element in a particular place, in which case the UA must follow the
                   4373:   same steps except that it must insert or append the new node in the
                   4374:   location specified instead of appending it to the <a href="#current-node">current
                   4375:   node</a>. (This happens in particular during the parsing of
                   4376:   tables with invalid content.)</p>
                   4377: 
                   4378:   <p>If an element created by the <a href="#insert-an-html-element">insert an HTML element</a>
                   4379:   algorithm is a <a href="forms.html#form-associated-element">form-associated element</a>, and the
                   4380:   <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is not null,
                   4381:   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
                   4382:   <a href="forms.html#concept-form-association" title="concept-form-association">associate</a> the newly
                   4383:   created element with the <code><a href="forms.html#the-form-element">form</a></code> element pointed to by the
                   4384:   <a href="#form-element-pointer"><code title="">form</code> element pointer</a> before
                   4385:   inserting it wherever it is to be inserted.</p>
                   4386: 
                   4387:   <hr><p>When the steps below require the UA to <dfn id="insert-a-foreign-element">insert a foreign
                   4388:   element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
                   4389:   for the token</a> in the given namespace, and then append this
                   4390:   node to the <a href="#current-node">current node</a>, and push it onto the
                   4391:   <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
1.724     mike     4392:   <a href="#current-node">current node</a>. If the newly created element has an <code title="">xmlns</code> attribute in the <a href="infrastructure.html#xmlns-namespace">XMLNS namespace</a>
1.1       mike     4393:   whose value is not exactly the same as the element's namespace, that
                   4394:   is a <a href="#parse-error">parse error</a>. Similarly, if the newly created
                   4395:   element has an <code title="">xmlns:xlink</code> attribute in the
1.724     mike     4396:   <a href="infrastructure.html#xmlns-namespace">XMLNS namespace</a> whose value is not the <a href="infrastructure.html#xlink-namespace">XLink
1.1       mike     4397:   Namespace</a>, that is a <a href="#parse-error">parse error</a>.</p>
                   4398: 
                   4399:   <p>When the steps below require the user agent to <dfn id="adjust-mathml-attributes">adjust MathML
                   4400:   attributes</dfn> for a token, then, if the token has an attribute
                   4401:   named <code title="">definitionurl</code>, change its name to <code title="">definitionURL</code> (note the case difference).</p>
                   4402: 
                   4403:   <p>When the steps below require the user agent to <dfn id="adjust-svg-attributes">adjust SVG
                   4404:   attributes</dfn> for a token, then, for each attribute on the token
                   4405:   whose attribute name is one of the ones in the first column of the
                   4406:   following table, change the attribute's name to the name given in
                   4407:   the corresponding cell in the second column. (This fixes the case of
                   4408:   SVG attributes that are not all lowercase.)</p>
                   4409: 
                   4410:   <table><thead><tr><th> Attribute name on token </th><th> Attribute name on element
                   4411:    </th></tr></thead><tbody><tr><td> <code title="">attributename</code> </td><td> <code title="">attributeName</code>
                   4412:     </td></tr><tr><td> <code title="">attributetype</code> </td><td> <code title="">attributeType</code>
                   4413:     </td></tr><tr><td> <code title="">basefrequency</code> </td><td> <code title="">baseFrequency</code>
                   4414:     </td></tr><tr><td> <code title="">baseprofile</code> </td><td> <code title="">baseProfile</code>
                   4415:     </td></tr><tr><td> <code title="">calcmode</code> </td><td> <code title="">calcMode</code>
                   4416:     </td></tr><tr><td> <code title="">clippathunits</code> </td><td> <code title="">clipPathUnits</code>
                   4417:     </td></tr><tr><td> <code title="">contentscripttype</code> </td><td> <code title="">contentScriptType</code>
                   4418:     </td></tr><tr><td> <code title="">contentstyletype</code> </td><td> <code title="">contentStyleType</code>
                   4419:     </td></tr><tr><td> <code title="">diffuseconstant</code> </td><td> <code title="">diffuseConstant</code>
                   4420:     </td></tr><tr><td> <code title="">edgemode</code> </td><td> <code title="">edgeMode</code>
                   4421:     </td></tr><tr><td> <code title="">externalresourcesrequired</code> </td><td> <code title="">externalResourcesRequired</code>
                   4422:     </td></tr><tr><td> <code title="">filterres</code> </td><td> <code title="">filterRes</code>
                   4423:     </td></tr><tr><td> <code title="">filterunits</code> </td><td> <code title="">filterUnits</code>
                   4424:     </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
                   4425:     </td></tr><tr><td> <code title="">gradienttransform</code> </td><td> <code title="">gradientTransform</code>
                   4426:     </td></tr><tr><td> <code title="">gradientunits</code> </td><td> <code title="">gradientUnits</code>
                   4427:     </td></tr><tr><td> <code title="">kernelmatrix</code> </td><td> <code title="">kernelMatrix</code>
                   4428:     </td></tr><tr><td> <code title="">kernelunitlength</code> </td><td> <code title="">kernelUnitLength</code>
                   4429:     </td></tr><tr><td> <code title="">keypoints</code> </td><td> <code title="">keyPoints</code>
                   4430:     </td></tr><tr><td> <code title="">keysplines</code> </td><td> <code title="">keySplines</code>
                   4431:     </td></tr><tr><td> <code title="">keytimes</code> </td><td> <code title="">keyTimes</code>
                   4432:     </td></tr><tr><td> <code title="">lengthadjust</code> </td><td> <code title="">lengthAdjust</code>
                   4433:     </td></tr><tr><td> <code title="">limitingconeangle</code> </td><td> <code title="">limitingConeAngle</code>
                   4434:     </td></tr><tr><td> <code title="">markerheight</code> </td><td> <code title="">markerHeight</code>
                   4435:     </td></tr><tr><td> <code title="">markerunits</code> </td><td> <code title="">markerUnits</code>
                   4436:     </td></tr><tr><td> <code title="">markerwidth</code> </td><td> <code title="">markerWidth</code>
                   4437:     </td></tr><tr><td> <code title="">maskcontentunits</code> </td><td> <code title="">maskContentUnits</code>
                   4438:     </td></tr><tr><td> <code title="">maskunits</code> </td><td> <code title="">maskUnits</code>
                   4439:     </td></tr><tr><td> <code title="">numoctaves</code> </td><td> <code title="">numOctaves</code>
                   4440:     </td></tr><tr><td> <code title="">pathlength</code> </td><td> <code title="">pathLength</code>
                   4441:     </td></tr><tr><td> <code title="">patterncontentunits</code> </td><td> <code title="">patternContentUnits</code>
                   4442:     </td></tr><tr><td> <code title="">patterntransform</code> </td><td> <code title="">patternTransform</code>
                   4443:     </td></tr><tr><td> <code title="">patternunits</code> </td><td> <code title="">patternUnits</code>
                   4444:     </td></tr><tr><td> <code title="">pointsatx</code> </td><td> <code title="">pointsAtX</code>
                   4445:     </td></tr><tr><td> <code title="">pointsaty</code> </td><td> <code title="">pointsAtY</code>
                   4446:     </td></tr><tr><td> <code title="">pointsatz</code> </td><td> <code title="">pointsAtZ</code>
                   4447:     </td></tr><tr><td> <code title="">preservealpha</code> </td><td> <code title="">preserveAlpha</code>
                   4448:     </td></tr><tr><td> <code title="">preserveaspectratio</code> </td><td> <code title="">preserveAspectRatio</code>
                   4449:     </td></tr><tr><td> <code title="">primitiveunits</code> </td><td> <code title="">primitiveUnits</code>
                   4450:     </td></tr><tr><td> <code title="">refx</code> </td><td> <code title="">refX</code>
                   4451:     </td></tr><tr><td> <code title="">refy</code> </td><td> <code title="">refY</code>
                   4452:     </td></tr><tr><td> <code title="">repeatcount</code> </td><td> <code title="">repeatCount</code>
                   4453:     </td></tr><tr><td> <code title="">repeatdur</code> </td><td> <code title="">repeatDur</code>
                   4454:     </td></tr><tr><td> <code title="">requiredextensions</code> </td><td> <code title="">requiredExtensions</code>
                   4455:     </td></tr><tr><td> <code title="">requiredfeatures</code> </td><td> <code title="">requiredFeatures</code>
                   4456:     </td></tr><tr><td> <code title="">specularconstant</code> </td><td> <code title="">specularConstant</code>
                   4457:     </td></tr><tr><td> <code title="">specularexponent</code> </td><td> <code title="">specularExponent</code>
                   4458:     </td></tr><tr><td> <code title="">spreadmethod</code> </td><td> <code title="">spreadMethod</code>
                   4459:     </td></tr><tr><td> <code title="">startoffset</code> </td><td> <code title="">startOffset</code>
                   4460:     </td></tr><tr><td> <code title="">stddeviation</code> </td><td> <code title="">stdDeviation</code>
                   4461:     </td></tr><tr><td> <code title="">stitchtiles</code> </td><td> <code title="">stitchTiles</code>
                   4462:     </td></tr><tr><td> <code title="">surfacescale</code> </td><td> <code title="">surfaceScale</code>
                   4463:     </td></tr><tr><td> <code title="">systemlanguage</code> </td><td> <code title="">systemLanguage</code>
                   4464:     </td></tr><tr><td> <code title="">tablevalues</code> </td><td> <code title="">tableValues</code>
                   4465:     </td></tr><tr><td> <code title="">targetx</code> </td><td> <code title="">targetX</code>
                   4466:     </td></tr><tr><td> <code title="">targety</code> </td><td> <code title="">targetY</code>
                   4467:     </td></tr><tr><td> <code title="">textlength</code> </td><td> <code title="">textLength</code>
                   4468:     </td></tr><tr><td> <code title="">viewbox</code> </td><td> <code title="">viewBox</code>
                   4469:     </td></tr><tr><td> <code title="">viewtarget</code> </td><td> <code title="">viewTarget</code>
                   4470:     </td></tr><tr><td> <code title="">xchannelselector</code> </td><td> <code title="">xChannelSelector</code>
                   4471:     </td></tr><tr><td> <code title="">ychannelselector</code> </td><td> <code title="">yChannelSelector</code>
                   4472:     </td></tr><tr><td> <code title="">zoomandpan</code> </td><td> <code title="">zoomAndPan</code>
                   4473:   </td></tr></tbody></table><p>When the steps below require the user agent to <dfn id="adjust-foreign-attributes">adjust
                   4474:   foreign attributes</dfn> for a token, then, if any of the attributes
                   4475:   on the token match the strings given in the first column of the
                   4476:   following table, let the attribute be a namespaced attribute, with
                   4477:   the prefix being the string given in the corresponding cell in the
                   4478:   second column, the local name being the string given in the
                   4479:   corresponding cell in the third column, and the namespace being the
                   4480:   namespace given in the corresponding cell in the fourth
                   4481:   column. (This fixes the use of namespaced attributes, in particular
                   4482:   <a href="dom.html#attr-xml-lang" title="attr-xml-lang"><code title="">lang</code> attributes in
                   4483:   the <span>XML namespace</span></a>.)</p>
                   4484: 
                   4485:   <table><thead><tr><th> Attribute name </th><th> Prefix </th><th> Local name </th><th> Namespace
1.724     mike     4486:    </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="infrastructure.html#xlink-namespace">XLink namespace</a>
                   4487:     </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="infrastructure.html#xlink-namespace">XLink namespace</a>
                   4488:     </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="infrastructure.html#xlink-namespace">XLink namespace</a>
                   4489:     </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="infrastructure.html#xlink-namespace">XLink namespace</a>
                   4490:     </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="infrastructure.html#xlink-namespace">XLink namespace</a>
                   4491:     </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="infrastructure.html#xlink-namespace">XLink namespace</a>
                   4492:     </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="infrastructure.html#xlink-namespace">XLink namespace</a>
                   4493:     </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="infrastructure.html#xml-namespace">XML namespace</a> <!-- attr-xml-base -->
                   4494:     </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="infrastructure.html#xml-namespace">XML namespace</a>
                   4495:     </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="infrastructure.html#xml-namespace">XML namespace</a>
                   4496:     </td></tr><tr><td> <code title="">xmlns</code> </td><td> (none) </td><td> <code title="">xmlns</code> </td><td> <a href="infrastructure.html#xmlns-namespace">XMLNS namespace</a>
                   4497:     </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="infrastructure.html#xmlns-namespace">XMLNS namespace</a>
1.91      mike     4498:   </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     4499:   <dfn id="generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</dfn> consist of the
                   4500:   following steps. These algorithms are always invoked in response to
                   4501:   a start tag token.</p>
                   4502: 
                   4503:   <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p></li>
                   4504: 
1.91      mike     4505:    <li><p>If the algorithm that was invoked is the <a href="#generic-raw-text-element-parsing-algorithm">generic raw
1.541     mike     4506:    text element parsing algorithm</a>, switch the tokenizer to the
                   4507:    <a href="#rawtext-state">RAWTEXT state</a>; otherwise the algorithm invoked
                   4508:    was the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>,
                   4509:    switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</p></li>
1.1       mike     4510: 
                   4511:    <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
                   4512:    <a href="#insertion-mode">insertion mode</a>.</p>
                   4513: 
1.540     mike     4514:    </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     4515: 
1.724     mike     4516:   </ol><h5 id="closing-elements-that-have-implied-end-tags"><span class="secno">7.2.5.2 </span>Closing elements that have implied end tags</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     4517: 
                   4518:   <p>When the steps below require the UA to <dfn id="generate-implied-end-tags">generate implied end
                   4519:   tags</dfn>, then, while the <a href="#current-node">current node</a> is a
1.422     mike     4520:   <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     4521:   <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
                   4522:   <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
                   4523:   <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
                   4524:   pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   4525:   elements</a>.</p>
                   4526: 
                   4527:   <p>If a step requires the UA to generate implied end tags but lists
                   4528:   an element to exclude from the process, then the UA must perform the
                   4529:   above steps as if that element was not in the above list.</p>
                   4530: 
                   4531: 
1.724     mike     4532:   <h5 id="foster-parenting"><span class="secno">7.2.5.3 </span>Foster parenting</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     4533: 
                   4534:   <p>Foster parenting happens when content is misnested in tables.</p>
                   4535: 
                   4536:   <p>When a node <var title="">node</var> is to be <dfn id="foster-parent" title="foster
                   4537:   parent">foster parented</dfn>, the node <var title="">node</var>
                   4538:   must be inserted into the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
                   4539: 
                   4540:   <p>The <dfn id="foster-parent-element">foster parent element</dfn> is the parent element of the
                   4541:   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
                   4542:   elements</a>, if there is a <code><a href="tabular-data.html#the-table-element">table</a></code> element and it has
                   4543:   such a parent element. If there is no <code><a href="tabular-data.html#the-table-element">table</a></code> element in
                   4544:   the <a href="#stack-of-open-elements">stack of open elements</a> (<a href="#fragment-case">fragment
                   4545:   case</a>), then the <i><a href="#foster-parent-element">foster parent element</a></i> is the first
                   4546:   element in the <a href="#stack-of-open-elements">stack of open elements</a> (the
1.159     mike     4547:   <code><a href="semantics.html#the-html-element-0">html</a></code> element). Otherwise, if there is a
1.1       mike     4548:   <code><a href="tabular-data.html#the-table-element">table</a></code> element in the <a href="#stack-of-open-elements">stack of open
                   4549:   elements</a>, but the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
                   4550:   <a href="#stack-of-open-elements">stack of open elements</a> has no parent, or its parent
                   4551:   node is not an element, then the <i><a href="#foster-parent-element">foster parent element</a></i> is
                   4552:   the element before the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
                   4553:   <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   4554: 
                   4555:   <p>If the <i><a href="#foster-parent-element">foster parent element</a></i> is the parent element of the
                   4556:   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
                   4557:   elements</a>, then <var title="">node</var> must be inserted
                   4558:   immediately <em>before</em> the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in
                   4559:   the <a href="#stack-of-open-elements">stack of open elements</a> in the <i><a href="#foster-parent-element">foster parent
                   4560:   element</a></i>; otherwise, <var title="">node</var> must be
                   4561:   <em>appended</em> to the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
                   4562: 
                   4563: 
                   4564: 
1.724     mike     4565:   <h5 id="the-initial-insertion-mode"><span class="secno">7.2.5.4 </span>The "<dfn title="insertion mode: initial">initial</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     4566: 
                   4567:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-initial-insertion-mode" title="insertion
                   4568:   mode: initial">initial</a>", tokens must be handled as follows:</p>
                   4569: 
                   4570:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   4571:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   4572:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   4573:    <dd>
                   4574:     <p>Ignore the token.</p>
                   4575:    </dd>
                   4576: 
                   4577:    <dt>A comment token</dt>
                   4578:    <dd>
                   4579:     <p>Append a <code>Comment</code> node to the <code>Document</code>
                   4580:     object with the <code title="">data</code> attribute set to the
                   4581:     data given in the comment token.</p>
                   4582:    </dd>
                   4583: 
                   4584:    <dt>A DOCTYPE token</dt>
                   4585:    <dd>
                   4586: 
                   4587:     <p>If the DOCTYPE token's name is not a
                   4588:     <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
                   4589:     missing, or the token's system identifier is neither missing nor a
                   4590:     <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string
1.465     mike     4591:     "<code><a href="infrastructure.html#about:legacy-compat">about:legacy-compat</a></code>", and none of the sets of
1.1       mike     4592:     conditions in the following list are matched, then there is a
                   4593:     <a href="#parse-error">parse error</a>. If one of the sets of conditions in the
                   4594:     following list is matched, then there is an <dfn id="obsolete-permitted-doctype">obsolete
                   4595:     permitted DOCTYPE</dfn>.</p>
                   4596: 
                   4597:     <ul><!-- only things that trigger no-quirks mode and were valid in
1.688     mike     4598:      some other spec are allowed in this list --><li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
                   4599:      match for the string "<code title="">html</code>", the token's
                   4600:      public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
                   4601:      "<code title="">-//W3C//DTD&#160;HTML&#160;4.0//EN</code>", and
                   4602:      the token's system identifier is either missing or the
1.1       mike     4603:      <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/REC-html40/strict.dtd</code>".</li>
                   4604: 
1.688     mike     4605:      <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
                   4606:      match for the string "<code title="">html</code>", the token's
                   4607:      public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
                   4608:      "<code title="">-//W3C//DTD&#160;HTML&#160;4.01//EN</code>", and
                   4609:      the token's system identifier is either missing or the
1.1       mike     4610:      <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/html4/strict.dtd</code>".</li>
                   4611: 
1.688     mike     4612:      <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
                   4613:      match for the string "<code title="">html</code>", the token's
                   4614:      public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
                   4615:      "<code title="">-//W3C//DTD&#160;XHTML&#160;1.0&#160;Strict//EN</code>",
1.1       mike     4616:      and the token's system identifier is the
                   4617:      <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</code>".</li>
                   4618: 
1.688     mike     4619:      <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
                   4620:      match for the string "<code title="">html</code>", the token's
                   4621:      public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
                   4622:      "<code title="">-//W3C//DTD&#160;XHTML&#160;1.1//EN</code>", and
                   4623:      the token's system identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a>
1.1       mike     4624:      string "<code title="">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</code>".</li>
                   4625: 
                   4626:     </ul><p>Conformance checkers may, based on the values (including
                   4627:     presence or lack thereof) of the DOCTYPE token's name, public
                   4628:     identifier, or system identifier, switch to a conformance checking
                   4629:     mode for another language (e.g. based on the DOCTYPE token a
                   4630:     conformance checker could recognize that the document is an
1.183     mike     4631:     HTML4-era document, and defer to an HTML4 conformance
1.1       mike     4632:     checker.)</p>
                   4633: 
                   4634:     <p>Append a <code>DocumentType</code> node to the
                   4635:     <code>Document</code> node, with the <code title="">name</code>
                   4636:     attribute set to the name given in the DOCTYPE token, or the empty
                   4637:     string if the name was missing; the <code title="">publicId</code>
                   4638:     attribute set to the public identifier given in the DOCTYPE token,
                   4639:     or the empty string if the public identifier was missing; the
                   4640:     <code title="">systemId</code> attribute set to the system
                   4641:     identifier given in the DOCTYPE token, or the empty string if the
                   4642:     system identifier was missing; and the other attributes specific
                   4643:     to <code>DocumentType</code> objects set to null and empty lists
                   4644:     as appropriate. Associate the <code>DocumentType</code> node with
                   4645:     the <code>Document</code> object so that it is returned as the
                   4646:     value of the <code title="">doctype</code> attribute of the
                   4647:     <code>Document</code> object.</p>
                   4648: 
                   4649:     <p id="quirks-mode-doctypes">Then, if the DOCTYPE token matches
                   4650:     one of the conditions in the following list, then set the
                   4651:     <code>Document</code> to <a href="dom.html#quirks-mode">quirks mode</a>:</p>
                   4652: 
                   4653:     <ul class="brief"><li> The <i>force-quirks flag</i> is set to <i>on</i>. </li>
1.688     mike     4654:      <li> The name is set to anything other than "<code title="">html</code>" (compared <a href="infrastructure.html#case-sensitive" title="case-sensitive">case-sensitively</a>). </li>
1.1       mike     4655:      <li> The public identifier starts with: "<code title="">+//Silmaril//dtd html Pro v0r11 19970101//<!--EN--></code>" </li>
                   4656:      <li> The public identifier starts with: "<code title="">-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
                   4657:      <li> The public identifier starts with: "<code title="">-//AS//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
                   4658:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 1//<!--EN--></code>" </li>
                   4659:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 2//<!--EN--></code>" </li>
                   4660:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 1//<!--EN--></code>" </li>
                   4661:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 2//<!--EN--></code>" </li>
                   4662:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict//<!--EN--></code>" </li>
                   4663:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0//<!--EN--></code>" </li>
                   4664:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.1E//<!--EN--></code>" </li>
                   4665:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.0//<!--EN--></code>" </li>
                   4666:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML 3.0//EN//</code>" </li>-->
                   4667:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2 Final//<!--EN--></code>" </li>
                   4668:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2//<!--EN--></code>" </li>
                   4669:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3//<!--EN--></code>" </li>
                   4670:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 0//<!--EN--></code>" </li>
                   4671:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 0//EN//2.0</code>" </li>-->
                   4672:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 1//<!--EN--></code>" </li>
                   4673:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 1//EN//2.0</code>" </li>-->
                   4674:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 2//<!--EN--></code>" </li>
                   4675:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 2//EN//2.0</code>" </li>-->
                   4676:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 3//<!--EN--></code>" </li>
                   4677:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 3//EN//3.0</code>" </li>-->
                   4678:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 0//<!--EN--></code>" </li>
                   4679:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 0//EN//2.0</code>" </li>-->
                   4680:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 1//<!--EN--></code>" </li>
                   4681:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 1//EN//2.0</code>" </li>-->
                   4682:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 2//<!--EN--></code>" </li>
                   4683:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 2//EN//2.0</code>" </li>-->
                   4684:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 3//<!--EN--></code>" </li>
                   4685:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 3//EN//3.0</code>" </li>-->
                   4686:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict//<!--EN--></code>" </li>
                   4687:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//2.0</code>" </li>-->
                   4688:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//3.0</code>" </li>-->
                   4689:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML//<!--EN--></code>" </li>
                   4690:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//2.0</code>" </li>-->
                   4691:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//3.0</code>" </li>-->
                   4692:      <li> The public identifier starts with: "<code title="">-//Metrius//DTD Metrius Presentational//<!--EN--></code>" </li>
                   4693:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//<!--EN--></code>" </li>
                   4694:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML//<!--EN--></code>" </li>
                   4695:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 Tables//<!--EN--></code>" </li>
                   4696:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//<!--EN--></code>" </li>
                   4697:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML//<!--EN--></code>" </li>
                   4698:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 Tables//<!--EN--></code>" </li>
                   4699:      <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD HTML//<!--EN--></code>" </li>
                   4700:      <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD Strict HTML//<!--EN--></code>" </li>
                   4701:      <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML 2.0//<!--EN--></code>" </li>
                   4702:      <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended 1.0//<!--EN--></code>" </li>
                   4703:      <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//<!--EN--></code>" </li>
                   4704:      <li> The public identifier starts with: "<code title="">-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//<!--EN--></code>" </li>
                   4705:      <li> The public identifier starts with: "<code title="">-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//<!--EN--></code>" </li>
                   4706:      <li> The public identifier starts with: "<code title="">-//Spyglass//DTD HTML 2.0 Extended//<!--EN--></code>" </li>
                   4707:      <li> The public identifier starts with: "<code title="">-//SQ//DTD HTML 2.0 HoTMetaL + extensions//<!--EN--></code>" </li>
                   4708:      <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava HTML//<!--EN--></code>" </li>
                   4709:      <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava Strict HTML//<!--EN--></code>" </li>
                   4710:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3 1995-03-24//<!--EN--></code>" </li>
                   4711:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Draft//<!--EN--></code>" </li>
                   4712:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Final//<!--EN--></code>" </li>
                   4713:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2//<!--EN--></code>" </li>
                   4714:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2S Draft//<!--EN--></code>" </li>
                   4715:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Frameset//<!--EN--></code>" </li>
                   4716:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Transitional//<!--EN--></code>" </li>
                   4717:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 19960712//<!--EN--></code>" </li>
                   4718:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 970421//<!--EN--></code>" </li>
                   4719:      <li> The public identifier starts with: "<code title="">-//W3C//DTD W3 HTML//<!--EN--></code>" </li>
                   4720:      <li> The public identifier starts with: "<code title="">-//W3O//DTD W3 HTML 3.0//<!--EN--></code>" </li>
                   4721:    <!--<li> The public identifier is set to: "<code title="">-//W3O//DTD W3 HTML 3.0//EN//</code>" </li>-->
                   4722:      <li> The public identifier is set to: "<code title="">-//W3O//DTD W3 HTML Strict 3.0//EN//</code>" </li>
                   4723:      <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML 2.0//<!--EN--></code>" </li>
                   4724:      <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML//<!--EN--></code>" </li>
                   4725:      <li> The public identifier is set to: "<code title="">-/W3C/DTD HTML 4.0 Transitional/EN</code>" </li>
                   4726:      <li> The public identifier is set to: "<code title="">HTML</code>" </li>
                   4727:      <li> The system identifier is set to: "<code title="">http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd</code>" </li>
                   4728:      <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
                   4729:      <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Transitional//<!--EN--></code>" </li>
                   4730:     </ul><p>Otherwise, if the DOCTYPE token matches one of the conditions
                   4731:     in the following list, then set the <code>Document</code> to
                   4732:     <a href="dom.html#limited-quirks-mode">limited quirks mode</a>:</p>
                   4733: 
                   4734:     <ul class="brief"><li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Frameset//<!--EN--></code>" </li>
                   4735:      <li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Transitional//<!--EN--></code>" </li>
                   4736:      <li> The system identifier is not missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
                   4737:      <li> The system identifier is not missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Transitional//<!--EN--></code>" </li>
1.688     mike     4738:     </ul><p>The system identifier and public identifier strings must be
                   4739:     compared to the values given in the lists above in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   4740:     case-insensitive</a> manner. A system identifier whose value is
                   4741:     the empty string is not considered missing for the purposes of the
                   4742:     conditions above.</p>
1.1       mike     4743: 
                   4744:     <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>
                   4745: 
                   4746:    </dd>
                   4747: 
                   4748:    <dt>Anything else</dt>
                   4749:    <dd>
                   4750: 
                   4751:     <p><a href="#parse-error">Parse error</a>.</p>
                   4752: 
                   4753:     <p>Set the <code>Document</code> to <a href="dom.html#quirks-mode">quirks mode</a>.</p>
                   4754: 
                   4755:     <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
                   4756:     reprocess the current token.</p>
                   4757: 
                   4758:    </dd>
                   4759: 
1.724     mike     4760:   </dl><h5 id="the-before-html-insertion-mode"><span class="secno">7.2.5.5 </span>The "<dfn title="insertion mode: before html">before html</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     4761: 
                   4762:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-html-insertion-mode" title="insertion
                   4763:   mode: before html">before html</a>", tokens must be handled as follows:</p>
                   4764: 
                   4765:   <dl class="switch"><dt>A DOCTYPE token</dt>
                   4766:    <dd>
                   4767:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4768:    </dd>
                   4769: 
                   4770:    <dt>A comment token</dt>
                   4771:    <dd>
                   4772:     <p>Append a <code>Comment</code> node to the <code>Document</code>
                   4773:     object with the <code title="">data</code> attribute set to the
                   4774:     data given in the comment token.</p>
                   4775:    </dd>
                   4776: 
                   4777:    <dt>A character token that is one of U+0009 CHARACTER
                   4778:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   4779:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   4780:    <dd>
                   4781:     <p>Ignore the token.</p>
                   4782:    </dd>
                   4783: 
                   4784:    <dt>A start tag whose tag name is "html"</dt>
                   4785:    <dd>
                   4786: 
1.724     mike     4787:     <p><a href="#create-an-element-for-the-token">Create an element for the token</a> in the <a href="infrastructure.html#html-namespace-0">HTML
1.1       mike     4788:     namespace</a>. Append it to the <code>Document</code>
                   4789:     object. Put this element in the <a href="#stack-of-open-elements">stack of open
                   4790:     elements</a>.</p>
                   4791: 
                   4792:     <p id="parser-appcache">If the <code>Document</code> is being
                   4793:     loaded as part of <a href="history.html#navigate" title="navigate">navigation</a> of a
                   4794:     <a href="browsers.html#browsing-context">browsing context</a>, then: if the newly created element
                   4795:     has a <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code> attribute,
                   4796:     then <a href="infrastructure.html#resolve-a-url" title="resolve a url">resolve</a> the value of that
                   4797:     attribute to an <a href="infrastructure.html#absolute-url">absolute URL</a>, relative to the newly
                   4798:     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     4799:     algorithm</a> with the resulting <a href="infrastructure.html#absolute-url">absolute URL</a> with
                   4800:     any <a href="infrastructure.html#url-fragment" title="url-fragment">&lt;fragment&gt;</a> component
                   4801:     removed; otherwise, if there is no such attribute or resolving it
                   4802:     fails, run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application
                   4803:     cache selection algorithm</a> with no manifest. The algorithm
                   4804:     must be passed the <code>Document</code> object.</p>
1.1       mike     4805: 
                   4806:     <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>
                   4807: 
                   4808:    </dd>
                   4809: 
1.334     mike     4810:    <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
                   4811:    <dd>
                   4812:     <p>Act as described in the "anything else" entry below.</p>
                   4813:    </dd>
                   4814: 
                   4815:    <dt>Any other end tag</dt>
                   4816:    <dd>
                   4817:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4818:    </dd>
                   4819: 
1.1       mike     4820:    <dt>Anything else</dt>
                   4821:    <dd>
                   4822: 
1.159     mike     4823:     <p>Create an <code><a href="semantics.html#the-html-element-0">html</a></code> element. Append it to the
1.1       mike     4824:     <code>Document</code> object. Put this element in the <a href="#stack-of-open-elements">stack
                   4825:     of open elements</a>.</p>
                   4826: 
                   4827:     <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
                   4828:     context</a>, then: run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application cache selection
                   4829:     algorithm</a> with no manifest, passing it the
                   4830:     <code>Document</code> object.</p>
                   4831: 
                   4832:     <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
                   4833:     reprocess the current token.</p>
                   4834: 
                   4835:    </dd>
                   4836: 
                   4837:   </dl><p>The root element can end up being removed from the
                   4838:   <code>Document</code> object, e.g. by scripts; nothing in particular
                   4839:   happens in such cases, content continues being appended to the nodes
                   4840:   as described in the next section.</p>
                   4841: 
                   4842: 
1.724     mike     4843:   <h5 id="the-before-head-insertion-mode"><span class="secno">7.2.5.6 </span>The "<dfn title="insertion mode: before head">before head</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     4844: 
                   4845:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-head-insertion-mode" title="insertion
                   4846:   mode: before head">before head</a>", tokens must be handled as follows:</p>
                   4847: 
                   4848:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   4849:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   4850:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   4851:    <dd>
                   4852:     <p>Ignore the token.</p> <!-- :-( -->
                   4853:    </dd>
                   4854: 
                   4855:    <dt>A comment token</dt>
                   4856:    <dd>
                   4857:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   4858:     node</a> with the <code title="">data</code> attribute set to
                   4859:     the data given in the comment token.</p>
                   4860:    </dd>
                   4861: 
                   4862:    <dt>A DOCTYPE token</dt>
                   4863:    <dd>
                   4864:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4865:    </dd>
                   4866: 
                   4867:    <dt>A start tag whose tag name is "html"</dt>
                   4868:    <dd>
                   4869:     <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
                   4870:     mode</a>.</p>
                   4871:    </dd>
                   4872: 
                   4873:    <dt>A start tag whose tag name is "head"</dt>
                   4874:    <dd>
                   4875: 
                   4876:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   4877: 
                   4878:     <p>Set the <a href="#head-element-pointer"><code title="">head</code> element pointer</a>
1.159     mike     4879:     to the newly created <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1       mike     4880: 
                   4881:     <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>
                   4882: 
                   4883:    </dd>
                   4884: 
                   4885:    <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
                   4886:    <dd>
                   4887: 
                   4888:     <p>Act as if a start tag token with the tag name "head" and no
                   4889:     attributes had been seen, then reprocess the current token.</p>
                   4890: 
                   4891:    </dd>
                   4892: 
                   4893:    <dt>Any other end tag</dt>
                   4894:    <dd>
                   4895: 
                   4896:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4897: 
                   4898:    </dd>
                   4899: 
                   4900:    <dt>Anything else</dt>
                   4901:    <dd>
                   4902: 
                   4903:     <p>Act as if a start tag token with the tag name "head" and no
                   4904:     attributes had been seen, then reprocess the current
                   4905:     token.</p>
                   4906: 
                   4907:    </dd>
                   4908: 
1.724     mike     4909:   </dl><h5 id="parsing-main-inhead"><span class="secno">7.2.5.7 </span>The "<dfn title="insertion mode: in head">in head</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     4910: 
                   4911:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inhead" title="insertion
                   4912:   mode: in head">in head</a>", tokens must be handled as follows:</p>
                   4913: 
                   4914:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   4915:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   4916:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   4917:    <dd>
                   4918:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   4919:     the <a href="#current-node">current node</a>.</p>
                   4920:    </dd>
                   4921: 
                   4922:    <dt>A comment token</dt>
                   4923:    <dd>
                   4924:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   4925:     node</a> with the <code title="">data</code> attribute set to
                   4926:     the data given in the comment token.</p>
                   4927:    </dd>
                   4928: 
                   4929:    <dt>A DOCTYPE token</dt>
                   4930:    <dd>
                   4931:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4932:    </dd>
                   4933: 
                   4934:    <dt>A start tag whose tag name is "html"</dt>
                   4935:    <dd>
                   4936:     <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
                   4937:     mode</a>.</p>
                   4938:    </dd>
                   4939: 
                   4940:    <dt>A start tag whose tag name is one of: "base", "command",
                   4941:    "link"</dt>
                   4942:    <dd>
                   4943: 
                   4944:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   4945:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   4946:     elements</a>.</p>
                   4947: 
                   4948:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   4949:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   4950: 
                   4951:    </dd>
                   4952: 
                   4953:    <dt>A start tag whose tag name is "meta"</dt>
                   4954:    <dd>
                   4955: 
                   4956:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   4957:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   4958:     elements</a>.</p>
                   4959: 
                   4960:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   4961:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   4962: 
                   4963:     <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
                   4964:     value is a supported encoding, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
                   4965:     currently <i>tentative</i>, then <a href="#change-the-encoding">change the
                   4966:     encoding</a> to the encoding given by the value of the
                   4967:     <code title="attr-meta-charset"><a href="semantics.html#attr-meta-charset">charset</a></code> attribute.</p>
                   4968: 
                   4969:     <p>Otherwise, if the element has a <code title="attr-meta-charset"><a href="semantics.html#attr-meta-charset">content</a></code> attribute, and
                   4970:     applying the <a href="infrastructure.html#algorithm-for-extracting-an-encoding-from-a-content-type">algorithm for extracting an encoding from a
                   4971:     Content-Type</a> to its value returns a supported encoding
                   4972:     <var title="">encoding</var>, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
                   4973:     currently <i>tentative</i>, then <a href="#change-the-encoding">change the
                   4974:     encoding</a> to the encoding <var title="">encoding</var>.</p>
                   4975: 
                   4976:    </dd>
                   4977: 
                   4978:    <dt>A start tag whose tag name is "title"</dt>
                   4979:    <dd>
                   4980:     <p>Follow the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>.</p>
                   4981:    </dd>
                   4982: 
                   4983:    <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
                   4984:    <dt>A start tag whose tag name is one of: "noframes", "style"</dt>
                   4985:    <dd>
1.91      mike     4986:     <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1       mike     4987:    </dd>
                   4988: 
                   4989:    <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is disabled</dt>
                   4990:    <dd>
                   4991: 
                   4992:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   4993: 
                   4994:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inheadnoscript" title="insertion mode: in head noscript">in head
                   4995:     noscript</a>".</p>
                   4996: 
                   4997:    </dd>
                   4998: 
                   4999:    <dt id="scriptTag">A start tag whose tag name is "script"</dt>
                   5000:    <dd>
                   5001: 
                   5002:     <ol><li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> in the
1.724     mike     5003:      <a href="infrastructure.html#html-namespace-0">HTML namespace</a>.</p></li>
1.1       mike     5004: 
                   5005:      <li>
                   5006: 
                   5007:       <p>Mark the element as being <a href="semantics.html#parser-inserted">"parser-inserted"</a>.</p>
                   5008: 
                   5009:       <p class="note">This ensures that, if the script is external,
1.159     mike     5010:       any <code title="dom-document-write"><a href="embedded-content-0.html#dom-document-write">document.write()</a></code>
1.1       mike     5011:       calls in the script will execute in-line, instead of blowing the
                   5012:       document away, as would happen in most other cases. It also
                   5013:       prevents the script from executing until the end tag is
                   5014:       seen.</p>
                   5015: 
                   5016:      </li>
                   5017: 
                   5018:      <li><p>If the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML
                   5019:      fragment parsing algorithm</a>, then mark the
1.484     mike     5020:      <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
                   5021:      started"</a>. (<a href="#fragment-case">fragment case</a>)</p></li>
1.1       mike     5022: 
                   5023:      <li><p>Append the new element to the <a href="#current-node">current node</a>
                   5024:      and push it onto the <a href="#stack-of-open-elements">stack of open
                   5025:      elements</a>.</p></li>
                   5026: 
1.541     mike     5027:      <li><p>Switch the tokenizer to the <a href="#script-data-state">script data
                   5028:      state</a>.</p></li>
1.1       mike     5029: 
                   5030:      <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
                   5031:      <a href="#insertion-mode">insertion mode</a>.</p>
                   5032: 
1.540     mike     5033:      </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     5034: 
                   5035:     </ol></dd>
                   5036: 
                   5037:    <dt>An end tag whose tag name is "head"</dt>
                   5038:    <dd>
                   5039: 
                   5040:     <p>Pop the <a href="#current-node">current node</a> (which will be the
1.159     mike     5041:     <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     5042:     elements</a>.</p>
                   5043: 
                   5044:     <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>
                   5045: 
                   5046:    </dd>
                   5047: 
                   5048:    <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
                   5049:    <dd>
                   5050:     <p>Act as described in the "anything else" entry below.</p>
                   5051:    </dd>
                   5052: 
                   5053:    <dt>A start tag whose tag name is "head"</dt>
                   5054:    <dt>Any other end tag</dt>
                   5055:    <dd>
                   5056:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5057:    </dd>
                   5058: 
                   5059:    <dt>Anything else</dt>
                   5060:    <dd>
                   5061: 
                   5062:     <!-- can't get here with an EOF and a fragment case -->
                   5063: 
                   5064:     <p>Act as if an end tag token with the tag name "head" had
                   5065:     been seen, and reprocess the current token.</p>
                   5066: 
                   5067:    </dd>
                   5068: 
1.724     mike     5069:   </dl><h5 id="parsing-main-inheadnoscript"><span class="secno">7.2.5.8 </span>The "<dfn title="insertion mode: in head noscript">in head noscript</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     5070: 
                   5071:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inheadnoscript" title="insertion
                   5072:   mode: in head noscript">in head noscript</a>", tokens must be handled as follows:</p>
                   5073: 
                   5074:   <dl class="switch"><dt>A DOCTYPE token</dt>
                   5075:    <dd>
                   5076:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5077:    </dd>
                   5078: 
                   5079:    <dt>A start tag whose tag name is "html"</dt>
                   5080:    <dd>
                   5081:     <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
                   5082:     mode</a>.</p>
                   5083:    </dd>
                   5084: 
                   5085:    <dt>An end tag whose tag name is "noscript"</dt>
                   5086:    <dd>
                   5087: 
                   5088:     <p>Pop the <a href="#current-node">current node</a> (which will be a
                   5089:     <code><a href="semantics.html#the-noscript-element">noscript</a></code> element) from the <a href="#stack-of-open-elements">stack of open
                   5090:     elements</a>; the new <a href="#current-node">current node</a> will be a
1.159     mike     5091:     <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1       mike     5092: 
                   5093:     <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>
                   5094: 
                   5095:    </dd>
                   5096: 
                   5097:    <dt>A character token that is one of U+0009 CHARACTER
                   5098:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   5099:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   5100:    <dt>A comment token</dt>
                   5101:    <dt>A start tag whose tag name is one of: "link", "meta", "noframes", "style"</dt>
                   5102:    <dd>
                   5103:     <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
                   5104:     mode</a>.</p>
                   5105:    </dd>
                   5106: 
                   5107:    <dt>An end tag whose tag name is "br"</dt>
                   5108:    <dd>
                   5109:     <p>Act as described in the "anything else" entry below.</p>
                   5110:    </dd>
                   5111: 
                   5112:    <dt>A start tag whose tag name is one of: "head", "noscript"</dt>
                   5113:    <dt>Any other end tag</dt>
                   5114:    <dd>
                   5115:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5116:    </dd>
                   5117: 
                   5118:    <dt>Anything else</dt>
                   5119:    <dd>
                   5120: 
                   5121:     <!-- can't get here with an EOF and a fragment case -->
                   5122: 
                   5123:     <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
                   5124:     name "noscript" had been seen and reprocess the current
                   5125:     token.</p>
                   5126: 
                   5127:    </dd>
                   5128: 
1.724     mike     5129:   </dl><h5 id="the-after-head-insertion-mode"><span class="secno">7.2.5.9 </span>The "<dfn title="insertion mode: after head">after head</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     5130: 
                   5131:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-head-insertion-mode" title="insertion
                   5132:   mode: after head">after head</a>", tokens must be handled as follows:</p>
                   5133: 
                   5134:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   5135:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   5136:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   5137:    <dd>
                   5138:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   5139:     the <a href="#current-node">current node</a>.</p>
                   5140:    </dd>
                   5141: 
                   5142:    <dt>A comment token</dt>
                   5143:    <dd>
                   5144:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   5145:     node</a> with the <code title="">data</code> attribute set to
                   5146:     the data given in the comment token.</p>
                   5147:    </dd>
                   5148: 
                   5149:    <dt>A DOCTYPE token</dt>
                   5150:    <dd>
                   5151:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5152:    </dd>
                   5153: 
                   5154:    <dt>A start tag whose tag name is "html"</dt>
                   5155:    <dd>
                   5156:     <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
                   5157:     mode</a>.</p>
                   5158:    </dd>
                   5159: 
                   5160:    <dt>A start tag whose tag name is "body"</dt>
                   5161:    <dd>
                   5162: 
                   5163:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5164: 
                   5165:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   5166: 
                   5167:     <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>
                   5168: 
                   5169:    </dd>
                   5170: 
                   5171:    <dt>A start tag whose tag name is "frameset"</dt>
                   5172:    <dd>
                   5173: 
                   5174:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5175: 
                   5176:     <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>
                   5177: 
                   5178:    </dd>
                   5179: 
                   5180:    <dt>A start tag token whose tag name is one of: "base", "link",
                   5181:    "meta", "noframes", "script", "style", "title"</dt>
                   5182:    <dd>
                   5183: 
                   5184:     <p><a href="#parse-error">Parse error</a>.</p>
                   5185: 
                   5186:     <p>Push the node pointed to by the <a href="#head-element-pointer"><code title="">head</code> element pointer</a> onto the
                   5187:     <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   5188: 
                   5189:     <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
                   5190:     mode</a>.</p>
                   5191: 
                   5192:     <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
                   5193:     of open elements</a>.</p>
                   5194: 
                   5195:     <p class="note">The <a href="#head-element-pointer"><code title="">head</code> element
                   5196:     pointer</a> cannot be null at this point.</p>
                   5197: 
                   5198:    </dd>
                   5199: 
                   5200:    <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
                   5201:    <dd>
                   5202:     <p>Act as described in the "anything else" entry below.</p>
                   5203:    </dd>
                   5204: 
                   5205:    <dt>A start tag whose tag name is "head"</dt>
                   5206:    <dt>Any other end tag</dt>
                   5207:    <dd>
                   5208:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5209:    </dd>
                   5210: 
                   5211:    <dt>Anything else</dt>
                   5212:    <dd>
                   5213:     <p>Act as if a start tag token with the tag name "body" and no
                   5214:     attributes had been seen, then set the <a href="#frameset-ok-flag">frameset-ok
                   5215:     flag</a> back to "ok", and then reprocess the current
                   5216:     token.</p>
                   5217:    </dd>
                   5218: 
1.724     mike     5219:   </dl><h5 id="parsing-main-inbody"><span class="secno">7.2.5.10 </span>The "<dfn title="insertion mode: in body">in body</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     5220: 
                   5221:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inbody" title="insertion
                   5222:   mode: in body">in body</a>", tokens must be handled as follows:</p>
                   5223: 
                   5224:   <dl class="switch"><dt>A character token</dt>
                   5225:    <dd>
                   5226: 
                   5227:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5228:     any.</p>
                   5229: 
                   5230:     <p><a href="#insert-a-character" title="insert a character">Insert the token's
                   5231:     character</a> into the <a href="#current-node">current node</a>.</p>
                   5232: 
                   5233:     <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
                   5234:     LINE FEED (LF), U+000C FORM FEED (FF), <!--U+000D CARRIAGE RETURN
                   5235:     (CR),--> or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
                   5236:     flag</a> to "not ok".</p>
                   5237: 
                   5238:    </dd>
                   5239: 
                   5240:    <dt>A comment token</dt>
                   5241:    <dd>
                   5242:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   5243:     node</a> with the <code title="">data</code> attribute set to
                   5244:     the data given in the comment token.</p>
                   5245:    </dd>
                   5246: 
                   5247:    <dt>A DOCTYPE token</dt>
                   5248:    <dd>
                   5249:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5250:    </dd>
                   5251: 
                   5252:    <dt>A start tag whose tag name is "html"</dt>
                   5253:    <dd>
                   5254:     <p><a href="#parse-error">Parse error</a>. For each attribute on the token,
                   5255:     check to see if the attribute is already present on the top
                   5256:     element of the <a href="#stack-of-open-elements">stack of open elements</a>. If it is not,
                   5257:     add the attribute and its corresponding value to that element.</p>
                   5258:    </dd>
                   5259: 
                   5260:    <dt>A start tag token whose tag name is one of: "base", "command",
                   5261:    "link", "meta", "noframes", "script", "style", "title"</dt>
                   5262:    <dd>
                   5263:     <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
                   5264:     mode</a>.</p>
                   5265:    </dd>
                   5266: 
                   5267:    <dt>A start tag whose tag name is "body"</dt>
                   5268:    <dd>
                   5269: 
                   5270:     <p><a href="#parse-error">Parse error</a>.</p>
                   5271: 
                   5272:     <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159     mike     5273:     elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1       mike     5274:     <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
                   5275:     then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
                   5276: 
                   5277:     <p>Otherwise, for each attribute on the token, check to see if
1.159     mike     5278:     the attribute is already present on the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1       mike     5279:     element (the second element) on the <a href="#stack-of-open-elements">stack of open
                   5280:     elements</a>. If it is not, add the attribute and its
                   5281:     corresponding value to that element.</p>
                   5282: 
                   5283:    </dd>
                   5284: 
                   5285:    <dt>A start tag whose tag name is "frameset"</dt>
                   5286:    <dd>
                   5287: 
                   5288:     <p><a href="#parse-error">Parse error</a>.</p>
                   5289: 
                   5290:     <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159     mike     5291:     elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1       mike     5292:     <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
                   5293:     then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
                   5294: 
                   5295:     <p>If the <a href="#frameset-ok-flag">frameset-ok flag</a> is set to "not ok", ignore
                   5296:     the token.</p>
                   5297: 
                   5298:     <p>Otherwise, run the following steps:</p>
                   5299: 
                   5300:     <ol><li><p>Remove the second element on the <a href="#stack-of-open-elements">stack of open
                   5301:      elements</a> from its parent node, if it has one.</p></li>
                   5302: 
                   5303:      <li><p>Pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of
                   5304:      open elements</a>, from the <a href="#current-node">current node</a> up to,
1.159     mike     5305:      but not including, the root <code><a href="semantics.html#the-html-element-0">html</a></code> element.</p>
1.1       mike     5306: 
                   5307:      </li><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
                   5308:      token.</p></li>
                   5309: 
                   5310:      <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>
                   5311: 
                   5312:     </li></ol></dd>
                   5313: 
                   5314:    <dt>An end-of-file token</dt>
                   5315:    <dd>
                   5316: 
                   5317:     <p>If there is a node in the <a href="#stack-of-open-elements">stack of open elements</a>
1.422     mike     5318:     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>
                   5319:     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     5320:     <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
                   5321:     <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
                   5322:     <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     5323:     <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     5324:     this is a <a href="#parse-error">parse error</a>.</p> <!-- (some of those are
1.422     mike     5325:     fragment cases) -->
1.1       mike     5326: 
                   5327:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   5328: 
                   5329:    </dd>
                   5330: 
                   5331:    <dt>An end tag whose tag name is "body"</dt>
                   5332:    <dd>
                   5333: 
                   5334:     <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
                   5335:     in scope</a>, this is a <a href="#parse-error">parse error</a>; ignore the
                   5336:     token.</p>
                   5337: 
                   5338:     <!-- if we get here, the insertion mode here is forcibly "in
                   5339:     body". -->
                   5340: 
                   5341:     <p>Otherwise, if there is a node in the <a href="#stack-of-open-elements">stack of open
1.422     mike     5342:     elements</a> that is not either a <code><a href="semantics.html#the-dd-element">dd</a></code> element, a
1.1       mike     5343:     <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
                   5344:     <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
                   5345:     <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
                   5346:     <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
                   5347:     <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
                   5348:     <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     5349:     <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
                   5350:     <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     5351:     error</a>.</p> <!-- (some of those are fragment cases, e.g. for
                   5352:     <tbody> you'd have hit the first paragraph since the <body>
1.422     mike     5353:     wouldn't be in scope, unless it was a fragment case) -->
1.1       mike     5354: 
                   5355:     <!-- If we ever change the frameset-ok flag to an insertion mode,
                   5356:     then we'd have to somehow keep track of its state when we switch
                   5357:     to after-body. -->
                   5358: 
                   5359:     <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>
                   5360: 
                   5361:    </dd>
                   5362: 
                   5363:    <dt>An end tag whose tag name is "html"</dt>
                   5364:    <dd>
                   5365: 
                   5366:     <p>Act as if an end tag with tag name "body" had been seen,
                   5367:     then, if that token wasn't ignored, reprocess the current
                   5368:     token.</p>
                   5369: 
                   5370:    </dd>
                   5371: 
                   5372:    <!-- start tags for non-phrasing flow content elements -->
                   5373: 
                   5374:    <!-- the normal ones -->
                   5375:    <dt>A start tag whose tag name is one of: "address", "article",
1.683     mike     5376:    "aside", "blockquote", "center", <!--v2DATAGRID"datagrid",-->
1.305     mike     5377:    "details", "dir", "div", "dl", "fieldset", "figure", "footer",
                   5378:    "header", "hgroup", "menu", "nav", "ol", "p", "section", "ul"</dt>
1.1       mike     5379:    <dd>
                   5380: 
                   5381:     <!-- As of May 2008 this doesn't match any browser exactly, but is
                   5382:     as close to what IE does as I can get without doing the non-tree
                   5383:     DOM nonsense, and thus should actually afford better compatibility
                   5384:     when implemented by the other browsers. -->
                   5385: 
                   5386:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5387:     an element in scope">has a <code>p</code> element in
                   5388:     scope</a>, then act as if an end tag with the tag name
                   5389:     "p" had been seen.</p>
                   5390: 
                   5391:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5392: 
                   5393:    </dd>
                   5394: 
                   5395:    <!-- as normal, but close h1-h6 if it's the current node -->
                   5396:    <dt>A start tag whose tag name is one of: "h1", "h2", "h3", "h4",
                   5397:    "h5", "h6"</dt>
                   5398:    <dd>
                   5399: 
                   5400:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5401:     an element in scope">has a <code>p</code> element in
                   5402:     scope</a>, then act as if an end tag with the tag name
                   5403:     "p" had been seen.</p>
                   5404: 
                   5405:     <p>If the <a href="#current-node">current node</a> is an element whose tag name
                   5406:     is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is a
                   5407:     <a href="#parse-error">parse error</a>; pop the <a href="#current-node">current node</a> off
                   5408:     the <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   5409:     <!-- See https://bugs.webkit.org/show_bug.cgi?id=12646 -->
                   5410: 
                   5411:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5412: 
                   5413:    </dd>
                   5414: 
                   5415:    <!-- as normal, but drops leading newline -->
                   5416:    <dt>A start tag whose tag name is one of: "pre", "listing"</dt>
                   5417:    <dd>
                   5418: 
                   5419:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5420:     an element in scope">has a <code>p</code> element in
                   5421:     scope</a>, then act as if an end tag with the tag name
                   5422:     "p" had been seen.</p>
                   5423: 
                   5424:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5425: 
                   5426:     <p>If the next token is a U+000A LINE FEED (LF) character
                   5427:     token, then ignore that token and move on to the next
                   5428:     one. (Newlines at the start of <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are
                   5429:     ignored as an authoring convenience.)</p>
                   5430: 
                   5431:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   5432: 
                   5433:    </dd>
                   5434: 
                   5435:    <!-- as normal, but interacts with the form element pointer -->
                   5436:    <dt>A start tag whose tag name is "form"</dt>
                   5437:    <dd>
                   5438: 
                   5439:     <p>If the <a href="#form-element-pointer"><code title="form">form</code> element
                   5440:     pointer</a> is not null, then this is a <a href="#parse-error">parse
                   5441:     error</a>; ignore the token.</p>
                   5442: 
                   5443:     <p>Otherwise:</p>
                   5444: 
                   5445:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5446:     an element in scope">has a <code>p</code> element in
                   5447:     scope</a>, then act as if an end tag with the tag name
                   5448:     "p" had been seen.</p>
                   5449: 
                   5450:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, and set the
                   5451:     <a href="#form-element-pointer"><code title="form">form</code> element pointer</a> to
                   5452:     point to the element created.</p>
                   5453: 
                   5454:    </dd>
                   5455: 
                   5456:    <!-- as normal, but imply </li> when there's another <li> open in weird cases -->
                   5457:    <dt>A start tag whose tag name is "li"</dt>
                   5458:    <dd>
                   5459: 
                   5460:     <p>Run the following algorithm:</p>
                   5461: 
                   5462:     <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
                   5463: 
                   5464:      <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
                   5465:      node</a> (the bottommost node of the stack).</p></li>
                   5466: 
1.578     mike     5467:      <li><p><i>Loop</i>: If <var title="">node</var> is an
                   5468:      <code><a href="semantics.html#the-li-element">li</a></code> element, then act as if an end tag with the tag
                   5469:      name "li" had been seen, then jump to the last step.</p></li>
1.1       mike     5470: 
1.578     mike     5471:      <li><p>If <var title="">node</var> is not in the
1.1       mike     5472:      <a href="#formatting">formatting</a> category, and is not in the
                   5473:      <a href="#phrasing">phrasing</a> category, and is not an
1.306     mike     5474:      <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     5475:      element, then jump to the last step.</p></li> <!-- an element
                   5476:      <foo> is in this list if the following markup:
                   5477: 
                   5478:          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><ol><li><foo><li>
                   5479: 
                   5480:      ...results in the second <li> not being (in any way) a descendant
                   5481:      of the first <li>, or if <foo> is a formatting element that gets
                   5482:      reopened later. -->
                   5483: 
                   5484:      <li><p>Otherwise, set <var title="">node</var> to the previous
                   5485:      entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
                   5486:      the step labeled <i>loop</i>.</p></li>
                   5487: 
                   5488:      <li>
                   5489: 
                   5490:       <p>This is the last step.</p>
                   5491: 
                   5492:       <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5493:       an element in scope">has a <code>p</code> element in
                   5494:       scope</a>, then act as if an end tag with the tag name
                   5495:       "p" had been seen.</p>
                   5496: 
                   5497:       <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
                   5498:       token.</p>
                   5499: 
                   5500:      </li>
                   5501: 
                   5502:     </ol></dd>
                   5503: 
                   5504:    <!-- as normal, but imply </dt> or </dd> when there's another <dt> or <dd> open in weird cases  -->
1.422     mike     5505:    <dt>A start tag whose tag name is one of: "dd", "dt"</dt>
1.1       mike     5506:    <dd>
                   5507: 
                   5508:     <p>Run the following algorithm:</p>
                   5509: 
                   5510:     <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
                   5511: 
                   5512:      <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
                   5513:      node</a> (the bottommost node of the stack).</p></li>
                   5514: 
                   5515:      <li><p><i>Loop</i>: If <var title="">node</var> is a
1.422     mike     5516:      <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
                   5517:      tag with the same tag name as <var title="">node</var> had been
                   5518:      seen, then jump to the last step.</p></li>
1.1       mike     5519: 
                   5520:      <li><p>If <var title="">node</var> is not in the
                   5521:      <a href="#formatting">formatting</a> category, and is not in the
                   5522:      <a href="#phrasing">phrasing</a> category, and is not an
1.306     mike     5523:      <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     5524:      element, then jump to the last step.</p></li> <!-- an element
                   5525:      <foo> is in this list if the following markup:
                   5526: 
                   5527:          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><dl><dt><foo><dt>
                   5528: 
                   5529:      ...results in the second <dt> not being (in any way) a descendant
                   5530:      of the first <dt>, or if <foo> is a formatting element that gets
                   5531:      reopened later. -->
                   5532: 
                   5533:      <li><p>Otherwise, set <var title="">node</var> to the previous
                   5534:      entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
                   5535:      the step labeled <i>loop</i>.</p></li>
                   5536: 
                   5537:      <li>
                   5538: 
                   5539:       <p>This is the last step.</p>
                   5540: 
                   5541:       <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5542:       an element in scope">has a <code>p</code> element in
                   5543:       scope</a>, then act as if an end tag with the tag name
                   5544:       "p" had been seen.</p>
                   5545: 
                   5546:       <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
                   5547:       token.</p>
                   5548: 
                   5549:      </li>
                   5550: 
                   5551:     </ol></dd>
                   5552: 
                   5553:    <!-- same as normal, but effectively ends parsing -->
                   5554:    <dt>A start tag whose tag name is "plaintext"</dt>
                   5555:    <dd>
                   5556: 
                   5557:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5558:     an element in scope">has a <code>p</code> element in
                   5559:     scope</a>, then act as if an end tag with the tag name
                   5560:     "p" had been seen.</p>
                   5561: 
                   5562:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5563: 
1.541     mike     5564:     <p>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1       mike     5565: 
1.541     mike     5566:     <p class="note">Once a start tag with the tag name "plaintext" has
                   5567:     been seen, that will be the last token ever seen other than
                   5568:     character tokens (and the end-of-file token), because there is no
                   5569:     way to switch out of the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1       mike     5570: 
                   5571:    </dd>
                   5572: 
                   5573:    <!-- end tags for non-phrasing flow content elements -->
                   5574: 
                   5575:    <!-- the normal ones -->
                   5576:    <dt>An end tag whose tag name is one of: "address", "article",
1.683     mike     5577:    "aside", "blockquote", "center", <!--v2DATAGRID"datagrid",-->
1.305     mike     5578:    "details", "dir", "div", "dl", "fieldset", "figure", "footer",
                   5579:    "header", "hgroup", "listing", "menu", "nav", "ol", "pre",
                   5580:    "section", "ul"</dt>
1.1       mike     5581:    <dd>
                   5582: 
                   5583:     <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>
                   5584:     with the same tag name as that of the token, then this is a
                   5585:     <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5586: 
                   5587:     <p>Otherwise, run these steps:</p>
                   5588: 
                   5589:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   5590: 
                   5591:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5592:      the same tag name as that of the token, then this is a
                   5593:      <a href="#parse-error">parse error</a>.</p></li>
                   5594: 
                   5595:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5596:      until an element with the same tag name as the token has been
                   5597:      popped from the stack.</p></li>
                   5598: 
                   5599:     </ol></dd>
                   5600: 
                   5601:    <!-- removes the form element pointer instead of the matching node -->
                   5602:    <dt>An end tag whose tag name is "form"</dt>
                   5603:    <dd>
                   5604: 
                   5605:     <p>Let <var title="">node</var> be the element that the
                   5606:     <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is set
                   5607:     to.</p>
                   5608: 
                   5609:     <p>Set the <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
                   5610:     to null.</p>
                   5611: 
                   5612:     <p>If <var title="">node</var> is null or the <a href="#stack-of-open-elements">stack of open
                   5613:     elements</a> does not <a href="#has-an-element-in-scope" title="has an element in
                   5614:     scope">have <var title="">node</var> in scope</a>, then this is
                   5615:     a <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5616: 
                   5617:     <p>Otherwise, run these steps:</p>
                   5618: 
                   5619:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   5620: 
                   5621:      <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
                   5622:      error</a>.</p></li>
                   5623: 
                   5624:      <li><p>Remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of
                   5625:      open elements</a>.</p></li>
                   5626: 
                   5627:     </ol></dd>
                   5628: 
                   5629:    <!-- as normal, except </p> implies <p> if there's no <p> in scope, and needs care as the elements have optional tags -->
                   5630:    <dt>An end tag whose tag name is "p"</dt>
                   5631:    <dd>
                   5632: 
                   5633:     <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>
                   5634:     with the same tag name as that of the token, then this is a
                   5635:     <a href="#parse-error">parse error</a>; act as if a start tag with the tag name
                   5636:     "p" had been seen, then reprocess the current token.</p>
                   5637: 
                   5638:     <p>Otherwise, run these steps:</p>
                   5639: 
                   5640:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
                   5641:      for elements with the same tag name as the token.</p></li>
                   5642: 
                   5643:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5644:      the same tag name as that of the token, then this is a
                   5645:      <a href="#parse-error">parse error</a>.</p></li>
                   5646: 
                   5647:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5648:      until an element with the same tag name as the token has been
                   5649:      popped from the stack.</p></li>
                   5650: 
                   5651:     </ol></dd>
                   5652: 
1.234     mike     5653:    <!-- as normal, but needs care as the elements have optional tags, and are further scoped by <ol>/<ul> -->
                   5654:    <dt>An end tag whose tag name is "li"</dt>
                   5655:    <dd>
                   5656: 
                   5657:     <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
                   5658:     item scope</a> with the same tag name as that of the token,
                   5659:     then this is a <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5660: 
                   5661:     <p>Otherwise, run these steps:</p>
                   5662: 
                   5663:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
                   5664:      for elements with the same tag name as the token.</p></li>
                   5665: 
                   5666:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5667:      the same tag name as that of the token, then this is a
                   5668:      <a href="#parse-error">parse error</a>.</p></li>
                   5669: 
                   5670:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5671:      until an element with the same tag name as the token has been
                   5672:      popped from the stack.</p></li>
                   5673: 
                   5674:     </ol></dd>
                   5675: 
1.1       mike     5676:    <!-- as normal, but needs care as the elements have optional tags -->
1.422     mike     5677:    <dt>An end tag whose tag name is one of: "dd", "dt"</dt>
1.1       mike     5678:    <dd>
                   5679: 
                   5680:     <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>
                   5681:     with the same tag name as that of the token, then this is a
                   5682:     <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5683: 
                   5684:     <p>Otherwise, run these steps:</p>
                   5685: 
                   5686:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
                   5687:      for elements with the same tag name as the token.</p></li>
                   5688: 
                   5689:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5690:      the same tag name as that of the token, then this is a
                   5691:      <a href="#parse-error">parse error</a>.</p></li>
                   5692: 
                   5693:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5694:      until an element with the same tag name as the token has been
                   5695:      popped from the stack.</p></li>
                   5696: 
                   5697:     </ol></dd>
                   5698: 
                   5699:    <!-- as normal, except acts as a closer for any of the h1-h6 elements -->
                   5700:    <dt>An end tag whose tag name is one of: "h1", "h2", "h3", "h4", "h5", "h6"</dt>
                   5701:    <dd>
                   5702: 
                   5703:     <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>
                   5704:     whose tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6",
                   5705:     then this is a <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5706: 
                   5707:     <p>Otherwise, run these steps:</p>
                   5708: 
                   5709:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   5710: 
                   5711:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5712:      the same tag name as that of the token, then this is a
                   5713:      <a href="#parse-error">parse error</a>.</p></li>
                   5714: 
                   5715:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5716:      until an element whose tag name is one of "h1", "h2", "h3", "h4",
                   5717:      "h5", or "h6" has been popped from the stack.</p></li>
                   5718: 
                   5719:     </ol></dd>
                   5720: 
                   5721:    <dt>An end tag whose tag name is "sarcasm"</dt>
                   5722:    <dd>
                   5723:     <p>Take a deep breath, then act as described in the "any other end
                   5724:     tag" entry below.</p>
                   5725:    </dd>
                   5726: 
                   5727:    <!-- ADOPTION AGENCY ELEMENTS
                   5728:         Mozilla-only: bdo blink del ins sub sup q
                   5729:         Safari-only: code dfn kbd nobr samp var wbr
                   5730:         Both: a b big em font i s small strike strong tt u -->
                   5731: 
                   5732:    <dt>A start tag whose tag name is "a"</dt>
                   5733:    <dd>
                   5734: 
                   5735:     <p>If the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>
                   5736:     contains an element whose tag name is "a" between the end of
                   5737:     the list and the last marker on the list (or the start of the
                   5738:     list if there is no marker on the list), then this is a
                   5739:     <a href="#parse-error">parse error</a>; act as if an end tag with the tag
                   5740:     name "a" had been seen, then remove that element from the
                   5741:     <a href="#list-of-active-formatting-elements">list of active formatting elements</a> and the
                   5742:     <a href="#stack-of-open-elements">stack of open elements</a> if the end tag didn't
                   5743:     already remove it (it might not have if the element is not
                   5744:     <a href="#has-an-element-in-table-scope" title="has an element in table scope">in table
                   5745:     scope</a>).</p>
                   5746: 
                   5747:     <p class="example">In the non-conforming stream
                   5748:     <code>&lt;a&#160;href="a"&gt;a&lt;table&gt;&lt;a&#160;href="b"&gt;b&lt;/table&gt;x</code>,
                   5749:     the first <code><a href="text-level-semantics.html#the-a-element">a</a></code> element would be closed upon seeing
                   5750:     the second one, and the "x" character would be inside a link
                   5751:     to "b", not to "a". This is despite the fact that the outer
                   5752:     <code><a href="text-level-semantics.html#the-a-element">a</a></code> element is not in table scope (meaning that a
                   5753:     regular <code>&lt;/a&gt;</code> end tag at the start of the table
                   5754:     wouldn't close the outer <code><a href="text-level-semantics.html#the-a-element">a</a></code> element).</p>
                   5755: 
                   5756:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5757:     any.</p>
                   5758: 
                   5759:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
                   5760:     element to the <a href="#list-of-active-formatting-elements">list of active formatting
                   5761:     elements</a>.</p>
                   5762: 
                   5763:    </dd>
                   5764: 
                   5765:    <dt>A start tag whose tag name is one of: "b", "big", "code", "em",
                   5766:    "font", "i", "s", "small", "strike", "strong", "tt", "u"</dt>
                   5767:    <dd>
                   5768: 
                   5769:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5770:     any.</p>
                   5771: 
                   5772:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
                   5773:     element to the <a href="#list-of-active-formatting-elements">list of active formatting
                   5774:     elements</a>.</p>
                   5775: 
                   5776:    </dd>
                   5777: 
                   5778:    <dt>A start tag whose tag name is "nobr"</dt>
                   5779:    <dd>
                   5780: 
                   5781:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5782:     any.</p>
                   5783: 
                   5784:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
                   5785:     element in scope">has a <code>nobr</code> element in scope</a>,
                   5786:     then this is a <a href="#parse-error">parse error</a>; act as if an end tag with
                   5787:     the tag name "nobr" had been seen, then once again
                   5788:     <a href="#reconstruct-the-active-formatting-elements">reconstruct the active formatting elements</a>, if
                   5789:     any.</p>
                   5790: 
                   5791:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
                   5792:     element to the <a href="#list-of-active-formatting-elements">list of active formatting
                   5793:     elements</a>.</p>
                   5794: 
                   5795:    </dd>
                   5796: 
                   5797:    <dt id="adoptionAgency">An end tag whose tag name is one of: "a",
                   5798:    "b", "big", "code", "em", "font", "i", "nobr", "s", "small",
                   5799:    "strike", "strong", "tt", "u"</dt>
                   5800:    <dd>
                   5801: 
                   5802:     <p>Follow these steps:</p>
                   5803: 
                   5804:     <ol><li>
                   5805: 
                   5806:       <p>Let the <var title="">formatting element</var> be the
                   5807:       last element in the <a href="#list-of-active-formatting-elements">list of active formatting
                   5808:       elements</a> that:</p>
                   5809: 
                   5810:       <ul><li>is between the end of the list and the last scope
                   5811:        marker in the list, if any, or the start of the list
                   5812:        otherwise, and</li>
                   5813: 
                   5814:        <li>has the same tag name as the token.</li>
                   5815: 
                   5816:       </ul><p>If there is no such node, or, if that node is also in the
                   5817:       <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
                   5818:       <a href="#parse-error">parse error</a>; ignore the token, and abort these
                   5819:       steps.</p>
                   5820: 
                   5821:       <p>Otherwise, if there is such a node, but that node is not
                   5822:       in the <a href="#stack-of-open-elements">stack of open elements</a>, then this is a
                   5823:       <a href="#parse-error">parse error</a>; remove the element from the list,
                   5824:       and abort these steps.</p>
                   5825: 
                   5826:       <p>Otherwise, there is a <var title="">formatting
                   5827:       element</var> and that element is in <a href="#stack-of-open-elements" title="stack of
                   5828:       open elements">the stack</a> and is <a href="#has-an-element-in-scope" title="has an
                   5829:       element in scope">in scope</a>. If the element is not the
                   5830:       <a href="#current-node">current node</a>, this is a <a href="#parse-error">parse
                   5831:       error</a>. In any case, proceed with the algorithm as
                   5832:       written in the following steps.</p>
                   5833: 
                   5834:      </li>
                   5835: 
                   5836:      <li><p>Let the <var title="">furthest block</var> be the
                   5837:      topmost node in the <a href="#stack-of-open-elements">stack of open elements</a> that
                   5838:      is lower in the stack than the <var title="">formatting
                   5839:      element</var>, and is not an element in the
                   5840:      <a href="#phrasing">phrasing</a> or <a href="#formatting">formatting</a>
                   5841:      categories. There might not be one.</p></li>
                   5842: 
                   5843:      <li><p>If there is no <var title="">furthest block</var>,
                   5844:      then the UA must skip the subsequent steps and instead just
                   5845:      pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of open
                   5846:      elements</a>, from the <a href="#current-node">current node</a> up to and
                   5847:      including the <var title="">formatting element</var>, and
                   5848:      remove the <var title="">formatting element</var> from the
                   5849:      <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</p></li>
                   5850: 
                   5851:      <li><p>Let the <var title="">common ancestor</var> be the element
                   5852:      immediately above the <var title="">formatting element</var> in the
                   5853:      <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
                   5854: 
                   5855:      <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
                   5856:      formatting elements</a> relative to the elements on either
                   5857:      side of it in the list.</p></li>
                   5858: 
                   5859:      <li>
                   5860: 
                   5861:       <p>Let <var title="">node</var> and <var title="">last node</var> be the
                   5862:       <var title="">furthest block</var>. Follow these steps:</p>
                   5863: 
                   5864:       <ol><li>Let <var title="">node</var> be the element immediately
                   5865:        above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
1.436     mike     5866:        elements</a>, or if <var title="">node</var> is no longer in
                   5867:        the <a href="#stack-of-open-elements">stack of open elements</a> (e.g. because it got
                   5868:        removed by the next step), the element that was immediately
                   5869:        above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
                   5870:        elements</a> before <var title="">node</var> was
                   5871:        removed.</li>
1.1       mike     5872: 
                   5873:        <li>If <var title="">node</var> is not in the <a href="#list-of-active-formatting-elements">list of
                   5874:        active formatting elements</a>, then remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of open
                   5875:        elements</a> and then go back to step 1.</li>
                   5876: 
                   5877:        <li>Otherwise, if <var title="">node</var> is the <var title="">formatting element</var>, then go to the next step
                   5878:        in the overall algorithm.</li>
                   5879: 
                   5880:        <li>Otherwise, if <var title="">last node</var> is the <var title="">furthest block</var>, then move the aforementioned
                   5881:        bookmark to be immediately after the <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
                   5882:        elements</a>.</li>
                   5883: 
                   5884:        <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
                   5885:        element <var title="">node</var> was created, replace the entry
                   5886:        for <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active
                   5887:        formatting elements</a> with an entry for the new element,
                   5888:        replace the entry for <var title="">node</var> in the
                   5889:        <a href="#stack-of-open-elements">stack of open elements</a> with an entry for the new
                   5890:        element, and let <var title="">node</var> be the new
                   5891:        element.</li>
                   5892: 
                   5893:        <li>Insert <var title="">last node</var> into <var title="">node</var>, first removing it from its previous
                   5894:        parent node if any.</li>
                   5895: 
                   5896:        <li>Let <var title="">last node</var> be <var title="">node</var>.</li>
                   5897: 
                   5898:        <li>Return to step 1 of this inner set of steps.</li>
                   5899: 
                   5900:       </ol></li>
                   5901: 
                   5902:      <li>
                   5903: 
                   5904:       <p>If the <var title="">common ancestor</var> node is a
                   5905:       <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>,
                   5906:       <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,
                   5907:       <a href="#foster-parent">foster parent</a> whatever <var title="">last
                   5908:       node</var> ended up being in the previous step, first removing
                   5909:       it from its previous parent node if any.</p>
                   5910: 
                   5911:       <p>Otherwise, append whatever <var title="">last node</var>
                   5912:       ended up being in the previous step to the <var title="">common
                   5913:       ancestor</var> node, first removing it from its previous parent
                   5914:       node if any.</p>
                   5915: 
                   5916:      </li>
                   5917: 
                   5918:      <li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
                   5919:      <var title="">formatting element</var> was created.</p></li>
                   5920: 
                   5921:      <li><p>Take all of the child nodes of the <var title="">furthest
                   5922:      block</var> and append them to the element created in the last
                   5923:      step.</p></li>
                   5924: 
                   5925:      <li><p>Append that new element to the <var title="">furthest
                   5926:      block</var>.</p></li>
                   5927: 
                   5928:      <li><p>Remove the <var title="">formatting element</var> from the
                   5929:      <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, and insert the
                   5930:      new element into the <a href="#list-of-active-formatting-elements">list of active formatting
                   5931:      elements</a> at the position of the aforementioned
                   5932:      bookmark.</p></li>
                   5933: 
                   5934:      <li><p>Remove the <var title="">formatting element</var> from the
                   5935:      <a href="#stack-of-open-elements">stack of open elements</a>, and insert the new element
                   5936:      into the <a href="#stack-of-open-elements">stack of open elements</a> immediately below
                   5937:      the position of the <var title="">furthest block</var> in that
                   5938:      stack.</p></li>
                   5939: 
                   5940:      <li><p>Jump back to step 1 in this series of steps.</p></li>
                   5941: 
1.334     mike     5942:     </ol><p class="note">Because of the way this algorithm causes elements
1.304     mike     5943:     to change parents, it has been dubbed the "adoption agency
                   5944:     algorithm" (in contrast with other possible algorithms for dealing
                   5945:     with misnested content, which included the "incest algorithm", the
1.1       mike     5946:     "secret affair algorithm", and the "Heisenberg algorithm").</p>
                   5947: 
                   5948:    </dd>
                   5949: 
                   5950:    <dt>A start tag whose tag name is "button"</dt>
                   5951:    <dd>
                   5952: 
                   5953:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5954:     an element in scope">has a <code>button</code> element in
                   5955:     scope</a>, then this is a <a href="#parse-error">parse error</a>;
                   5956:     act as if an end tag with the tag name "button" had been seen,
                   5957:     then reprocess the token.</p>
                   5958: 
                   5959:     <p>Otherwise:</p>
                   5960: 
                   5961:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5962:     any.</p>
                   5963: 
                   5964:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5965: 
                   5966:     <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
                   5967:     formatting elements</a>.</p>
                   5968: 
                   5969:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   5970: 
                   5971:    </dd>
                   5972: 
                   5973:    <dt>A start tag token whose tag name is one of: "applet",
                   5974:    "marquee", "object"</dt>
                   5975:    <dd>
                   5976: 
                   5977:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5978:     any.</p>
                   5979: 
                   5980:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5981: 
                   5982:     <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
                   5983:     formatting elements</a>.</p>
                   5984: 
                   5985:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   5986: 
                   5987:    </dd>
                   5988: 
                   5989:    <dt>An end tag token whose tag name is one of: "applet", "button",
                   5990:    "marquee", "object"</dt>
                   5991:    <dd>
                   5992: 
                   5993:     <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>
                   5994:     with the same tag name as that of the token, then this is a
                   5995:     <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5996: 
                   5997:     <p>Otherwise, run these steps:</p>
                   5998: 
                   5999:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   6000: 
                   6001:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   6002:      the same tag name as that of the token, then this is a
                   6003:      <a href="#parse-error">parse error</a>.</p></li>
                   6004: 
                   6005:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   6006:      until an element with the same tag name as the token has been
                   6007:      popped from the stack.</p></li>
                   6008: 
                   6009:      <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
                   6010:      last marker</a>.</li>
                   6011: 
                   6012:     </ol></dd>
                   6013: 
                   6014:    <dt>A start tag whose tag name is "table"</dt>
                   6015:    <dd>
                   6016: 
                   6017:     <p>If the <code>Document</code> is <em>not</em> set to
                   6018:     <a href="dom.html#quirks-mode">quirks mode</a>, and the <a href="#stack-of-open-elements">stack of open
                   6019:     elements</a> <a href="#has-an-element-in-scope" title="has an element in scope">has a
                   6020:     <code>p</code> element in scope</a>, then act as if an end tag
                   6021:     with the tag name "p" had been seen.</p> <!-- i hate myself (this
                   6022:     quirk was basically caused by acid2; if i'd realised we could
                   6023:     change the specs when i wrote acid2, we could have avoided having
                   6024:     any parsing-mode quirks) -Hixie -->
                   6025: 
                   6026:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6027: 
                   6028:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6029: 
                   6030:     <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>
                   6031: 
                   6032:    </dd>
                   6033: 
                   6034:    <dt>A start tag whose tag name is one of: "area", "basefont",
1.589     mike     6035:    "bgsound", "br", "embed", "img", "input", "keygen", "wbr"</dt>
1.1       mike     6036:    <dd>
                   6037: 
                   6038:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6039:     any.</p>
                   6040: 
                   6041:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   6042:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6043:     elements</a>.</p>
                   6044: 
                   6045:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   6046:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   6047: 
                   6048:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p> <!--
1.589     mike     6049:     shouldn't really do it for <area>, <basefont>, and <bgsound> -->
1.1       mike     6050: 
                   6051:    </dd>
                   6052: 
                   6053:    <dt>A start tag whose tag name is one of: "param", "source"</dt>
                   6054:    <dd>
                   6055: 
                   6056:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   6057:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6058:     elements</a>.</p>
                   6059: 
                   6060:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   6061:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   6062: 
                   6063:    </dd>
                   6064: 
                   6065:    <dt>A start tag whose tag name is "hr"</dt>
                   6066:    <dd>
                   6067: 
                   6068:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   6069:     an element in scope">has a <code>p</code> element in
                   6070:     scope</a>, then act as if an end tag with the tag name
                   6071:     "p" had been seen.</p>
                   6072: 
                   6073:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   6074:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6075:     elements</a>.</p>
                   6076: 
                   6077:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   6078:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   6079: 
                   6080:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6081: 
                   6082:    </dd>
                   6083: 
                   6084:    <dt>A start tag whose tag name is "image"</dt>
                   6085:    <dd>
                   6086:     <p><a href="#parse-error">Parse error</a>. Change the token's tag name
                   6087:     to "img" and reprocess it. (Don't ask.)</p> <!-- As of
                   6088:     2005-12, studies showed that around 0.2% of pages used the
                   6089:     <image> element. -->
                   6090:    </dd>
                   6091: 
                   6092:    <dt id="isindex">A start tag whose tag name is "isindex"</dt>
                   6093:    <dd>
                   6094: 
                   6095:     <p><a href="#parse-error">Parse error</a>.</p>
                   6096: 
                   6097:     <p>If the <a href="#form-element-pointer"><code title="">form</code> element
                   6098:     pointer</a> is not null, then ignore the token.</p>
                   6099: 
                   6100:     <p>Otherwise:</p>
                   6101: 
                   6102:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   6103:     token's <i>self-closing flag</i></a>, if it is set.</p> <!--
                   6104:     purely to reduce the number of errors (we don't care if they
                   6105:     included the /, they're not supposed to be including the tag at
                   6106:     all! -->
                   6107: 
                   6108:     <p>Act as if a start tag token with the tag name "form" had been seen.</p>
                   6109: 
                   6110:     <p>If the token has an attribute called "action", set the
                   6111:     <code title="attr-form-action">action</code> attribute on the
                   6112:     resulting <code><a href="forms.html#the-form-element">form</a></code> element to the value of the
                   6113:     "action" attribute of the token.</p>
                   6114: 
                   6115:     <p>Act as if a start tag token with the tag name "hr" had been
                   6116:     seen.</p>
                   6117: 
                   6118:     <p>Act as if a start tag token with the tag name "label" had been
                   6119:     seen.</p>
                   6120: 
                   6121:     <p>Act as if a stream of character tokens had been seen (see below
                   6122:     for what they should say).</p>
                   6123: 
                   6124:     <p>Act as if a start tag token with the tag name "input" had been
                   6125:     seen, with all the attributes from the "isindex" token except
                   6126:     "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
                   6127:     <code><a href="forms.html#the-input-element">input</a></code> element to the value "<code title="">isindex</code>".</p>
                   6128: 
                   6129:     <p>Act as if a stream of character tokens had been seen (see
                   6130:     below for what they should say).</p>
                   6131: 
                   6132:     <p>Act as if an end tag token with the tag name "label" had been
                   6133:     seen.</p>
                   6134: 
                   6135:     <p>Act as if a start tag token with the tag name "hr" had been
                   6136:     seen.</p>
                   6137: 
                   6138:     <p>Act as if an end tag token with the tag name "form" had been
                   6139:     seen.</p>
                   6140: 
                   6141:     <p>If the token has an attribute with the name "prompt", then the
                   6142:     first stream of characters must be the same string as given in
                   6143:     that attribute, and the second stream of characters must be
                   6144:     empty. Otherwise, the two streams of character tokens together
                   6145:     should, together with the <code><a href="forms.html#the-input-element">input</a></code> element, express the
                   6146:     equivalent of "This is a searchable index. Insert your search
                   6147:     keywords here: (input field)" in the user's preferred
                   6148:     language.</p>
                   6149: 
                   6150:    </dd>
                   6151: 
                   6152:    <dt>A start tag whose tag name is "textarea"</dt>
                   6153:    <dd>
                   6154: 
                   6155:     <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
                   6156:      token.</p></li>
                   6157: 
                   6158:      <li><p>If the next token is a U+000A LINE FEED (LF) character
                   6159:      token, then ignore that token and move on to the next
                   6160:      one. (Newlines at the start of <code><a href="forms.html#the-textarea-element">textarea</a></code> elements are
                   6161:      ignored as an authoring convenience.)</p></li>
                   6162: 
1.671     mike     6163:      <li><p>Switch the tokenizer to the <a href="#rcdata-state">RCDATA
1.541     mike     6164:      state</a>.</p></li>
1.1       mike     6165: 
                   6166:      <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the
                   6167:      current <a href="#insertion-mode">insertion mode</a>.</p>
                   6168: 
                   6169:      </li><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not
                   6170:      ok".</p></li>
                   6171: 
1.540     mike     6172:      <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     6173: 
                   6174:     </ol></dd>
                   6175: 
                   6176:    <dt>A start tag whose tag name is "xmp"</dt>
                   6177:    <dd>
                   6178: 
1.233     mike     6179:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   6180:     an element in scope">has a <code>p</code> element in
                   6181:     scope</a>, then act as if an end tag with the tag name
                   6182:     "p" had been seen.</p>
                   6183: 
1.1       mike     6184:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6185:     any.</p>
                   6186: 
                   6187:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6188: 
1.91      mike     6189:     <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1       mike     6190: 
                   6191:    </dd>
                   6192: 
                   6193:    <dt>A start tag whose tag name is "iframe"</dt>
                   6194:    <dd>
                   6195: 
                   6196:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6197: 
1.91      mike     6198:     <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1       mike     6199: 
                   6200:    </dd>
                   6201: 
                   6202:    <dt>A start tag whose tag name is "noembed"</dt>
                   6203:    <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
                   6204:    <dd>
                   6205: 
1.91      mike     6206:     <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1       mike     6207: 
                   6208:    </dd>
                   6209: 
                   6210:    <dt>A start tag whose tag name is "select"</dt>
                   6211:    <dd>
                   6212: 
                   6213:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6214:     any.</p>
                   6215: 
                   6216:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6217: 
                   6218:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6219: 
                   6220:     <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>",
                   6221:     "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   6222:     body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in
                   6223:     row</a>", or "<a href="#parsing-main-intd" title="insertion mode: in cell">in
                   6224:     cell</a>", then switch the <a href="#insertion-mode">insertion mode</a> to
                   6225:     "<a href="#parsing-main-inselectintable" title="insertion mode: in select in table">in select in
                   6226:     table</a>". Otherwise, switch the <a href="#insertion-mode">insertion mode</a>
                   6227:     to "<a href="#parsing-main-inselect" title="insertion mode: in select">in select</a>".</p>
                   6228: 
                   6229:    </dd>
                   6230: 
                   6231:    <dt>A start tag whose tag name is one of: "optgroup", "option"</dt>
                   6232:    <dd>
                   6233: 
                   6234:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
                   6235:     element in scope">has an <code>option</code> element in
                   6236:     scope</a>, then act as if an end tag with the tag name "option"
                   6237:     had been seen.</p>
                   6238: 
                   6239:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6240:     any.</p>
                   6241: 
                   6242:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6243: 
                   6244:    </dd>
                   6245: 
                   6246:    <dt>A start tag whose tag name is one of: "rp", "rt"</dt>
                   6247:    <dd>
                   6248: 
                   6249:     <!-- the parsing rules for ruby really don't match IE much at all,
                   6250:          but in practice the markup used is very simple and so strict
                   6251:          compatibility with IE isn't required. For example, as defined
                   6252:          here we get very, very different behaviour than IE for
                   6253:          pathological cases like:
                   6254: 
                   6255:            <ruby><ol><li><p>a<rt>b
                   6256:            <ruby>a<rt>b<p>c
                   6257: 
                   6258:          But in practice most ruby markup falls into these cases:
                   6259: 
                   6260:            <ruby>a<rt>b</ruby>
                   6261:            <ruby>a<rp>b<rt>c<rp>d</ruby>
                   6262:            <ruby>a<rt>b</rt></ruby>
                   6263:            <ruby>a<rp>b</rp><rt>c</rt><rp>d</rp></ruby>
                   6264: 
                   6265:     -->
                   6266: 
                   6267:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
                   6268:     element in scope">has a <code>ruby</code> element in scope</a>,
                   6269:     then <a href="#generate-implied-end-tags">generate implied end tags</a>. If the <a href="#current-node">current
                   6270:     node</a> is not then a <code><a href="text-level-semantics.html#the-ruby-element">ruby</a></code> element, this is a
                   6271:     <a href="#parse-error">parse error</a>; pop all the nodes from the <a href="#current-node">current
                   6272:     node</a> up to the node immediately before the bottommost
                   6273:     <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
                   6274:     elements</a>.</p>
                   6275: 
                   6276:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6277: 
                   6278:    </dd>
                   6279: 
                   6280:    <dt>An end tag whose tag name is "br"</dt>
                   6281:    <dd>
                   6282:     <p><a href="#parse-error">Parse error</a>. Act as if a start tag token with
                   6283:     the tag name "br" had been seen. Ignore the end tag token.</p>
                   6284:    </dd>
                   6285: 
                   6286:    <dt>A start tag whose tag name is "math"</dt>
                   6287:    <dd>
                   6288: 
                   6289:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6290:     any.</p>
                   6291: 
                   6292:     <p><a href="#adjust-mathml-attributes">Adjust MathML attributes</a> for the token. (This
                   6293:     fixes the case of MathML attributes that are not all
                   6294:     lowercase.)</p>
                   6295: 
                   6296:     <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
                   6297:     fixes the use of namespaced attributes, in particular XLink.)</p>
                   6298: 
                   6299:     <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
1.724     mike     6300:     <a href="infrastructure.html#mathml-namespace">MathML namespace</a>.</p>
1.1       mike     6301: 
                   6302:     <!-- If we ever change the frameset-ok flag to an insertion mode,
                   6303:     the following change would be implied, except we'd have to do it
                   6304:     even in the face of a self-closed tag:
                   6305:     <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
                   6306:     -->
                   6307: 
                   6308:     <p>If the token has its <i>self-closing flag</i> set, pop the
                   6309:     <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6310:     elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
                   6311:     flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
                   6312: 
                   6313:     <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
                   6314:     "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
                   6315:     content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
                   6316:     the current <a href="#insertion-mode">insertion mode</a>, and then switch the
                   6317:     <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
                   6318:     foreign content">in foreign content</a>".</p>
                   6319: 
                   6320:    </dd>
                   6321: 
                   6322:    <dt>A start tag whose tag name is "svg"</dt>
                   6323:    <dd>
                   6324: 
                   6325:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6326:     any.</p>
                   6327: 
                   6328:     <p><a href="#adjust-svg-attributes">Adjust SVG attributes</a> for the token. (This fixes
                   6329:     the case of SVG attributes that are not all lowercase.)</p>
                   6330: 
                   6331:     <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
                   6332:     fixes the use of namespaced attributes, in particular XLink in
                   6333:     SVG.)</p>
                   6334: 
                   6335:     <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
1.724     mike     6336:     <a href="infrastructure.html#svg-namespace">SVG namespace</a>.</p>
1.1       mike     6337: 
                   6338:     <!-- If we ever change the frameset-ok flag to an insertion mode,
                   6339:     the following change would be implied, except we'd have to do it
                   6340:     even in the face of a self-closed tag:
                   6341:     <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
                   6342:     -->
                   6343: 
                   6344:     <p>If the token has its <i>self-closing flag</i> set, pop the
                   6345:     <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6346:     elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
                   6347:     flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
                   6348: 
                   6349:     <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
                   6350:     "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
                   6351:     content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
                   6352:     the current <a href="#insertion-mode">insertion mode</a>, and then switch the
                   6353:     <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
                   6354:     foreign content">in foreign content</a>".</p>
                   6355: 
                   6356:    </dd>
                   6357: 
                   6358:    <dt>A start <!--or end--> tag whose tag name is one of: "caption",
                   6359:    "col", "colgroup", "frame", "head", "tbody", "td", "tfoot", "th",
                   6360:    "thead", "tr"</dt>
                   6361:    <!--<dt>An end tag whose tag name is one of: "area", "base",
                   6362:    "basefont", "bgsound", "command", "embed", "hr", "iframe", "image",
                   6363:    "img", "input", "isindex", "keygen", "link", "meta", "noembed",
1.589     mike     6364:    "noframes", "param", "script", "select", "source", "style",
                   6365:    "table", "textarea", "title", "wbr"</dt>-->
1.1       mike     6366:    <!--<dt>An end tag whose tag name is "noscript", if the
                   6367:    <span>scripting flag</span> is enabled</dt>-->
                   6368:    <dd>
                   6369:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6370:     <!-- end tags are commented out because since they can never end
                   6371:     up on the stack anyway, the default end tag clause will
                   6372:     automatically handle them. we don't want to have text in the spec
                   6373:     that is just an optimisation, as that detracts from the spec
                   6374:     itself -->
                   6375:    </dd>
                   6376: 
                   6377:    <dt>Any other start tag</dt>
                   6378:    <dd>
                   6379: 
                   6380:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6381:     any.</p>
                   6382: 
                   6383:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6384: 
                   6385:     <p class="note">This element will be a <a href="#phrasing">phrasing</a>
                   6386:     element.</p>
                   6387: 
                   6388:    </dd>
                   6389: 
                   6390:    <dt>Any other end tag</dt>
                   6391:    <dd>
                   6392: 
                   6393:     <p>Run the following steps:</p>
                   6394: 
                   6395:     <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
                   6396:      node</a> (the bottommost node of the stack).</p></li>
                   6397: 
                   6398:      <li><p>If <var title="">node</var> has the same tag name as
                   6399:      the end tag token, then:</p>
                   6400: 
                   6401:       <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   6402: 
                   6403:        <li><p>If the tag name of the end tag token does not match
                   6404:        the tag name of the <a href="#current-node">current node</a>, this is a
                   6405:        <a href="#parse-error">parse error</a>.</p></li>
                   6406: 
                   6407:        <li><p>Pop all the nodes from the <a href="#current-node">current node</a> up
                   6408:        to <var title="">node</var>, including <var title="">node</var>, then stop these steps.</p></li>
                   6409: 
                   6410:       </ol></li>
                   6411: 
                   6412:      <li><p>Otherwise, if <var title="">node</var> is in neither the
                   6413:      <a href="#formatting">formatting</a> category nor the <a href="#phrasing">phrasing</a>
                   6414:      category, then this is a <a href="#parse-error">parse error</a>; ignore the
                   6415:      token, and abort these steps.</p></li>
                   6416: 
                   6417:      <li><p>Set <var title="">node</var> to the previous entry in the
                   6418:      <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
                   6419: 
                   6420:      <li><p>Return to step 2.</p></li>
                   6421: 
                   6422:     </ol></dd>
                   6423: 
1.724     mike     6424:   </dl><h5 id="parsing-main-incdata"><span class="secno">7.2.5.11 </span>The "<dfn title="insertion mode: text">text</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     6425: 
                   6426:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incdata" title="insertion
1.540     mike     6427:   mode: text">text</a>", tokens must be handled as follows:</p>
1.1       mike     6428: 
                   6429:   <dl class="switch"><dt>A character token</dt>
                   6430:    <dd>
                   6431: 
                   6432:     <p><a href="#insert-a-character" title="insert a character">Insert the token's
                   6433:     character</a> into the <a href="#current-node">current node</a>.</p>
                   6434: 
                   6435:    </dd>
                   6436: 
                   6437:    <dt>An end-of-file token</dt>
                   6438:    <dd>
                   6439: 
                   6440:     <!-- can't be the fragment case -->
                   6441:     <p><a href="#parse-error">Parse error</a>.</p>
                   6442: 
                   6443:     <p>If the <a href="#current-node">current node</a> is a <code><a href="semantics.html#script">script</a></code>
1.484     mike     6444:     element, mark the <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
                   6445:     started"</a>.</p>
1.1       mike     6446: 
                   6447:     <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6448:     elements</a>.</p>
                   6449: 
                   6450:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
                   6451:     insertion mode</a> and reprocess the current token.</p>
                   6452: 
                   6453:    </dd>
                   6454: 
                   6455:    <dt>An end tag whose tag name is "script"</dt>
                   6456:    <dd>
                   6457: 
                   6458:     <p>Let <var title="">script</var> be the <a href="#current-node">current node</a>
                   6459:     (which will be a <code><a href="semantics.html#script">script</a></code> element).</p>
                   6460: 
                   6461:     <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6462:     elements</a>.</p>
                   6463: 
                   6464:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
                   6465:     insertion mode</a>.</p>
                   6466: 
                   6467:     <p>Let the <var title="">old insertion point</var> have the
                   6468:     same value as the current <a href="#insertion-point">insertion point</a>. Let
                   6469:     the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
                   6470:     input character</a>.</p>
                   6471: 
                   6472:     <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
                   6473:     one.</p>
                   6474: 
                   6475:     <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     6476:     which might cause <a href="embedded-content-0.html#dom-document-write" title="dom-document-write">new characters
1.1       mike     6477:     to be inserted into the tokenizer</a>, and might cause the
                   6478:     tokenizer to output more tokens, resulting in a <a href="#nestedParsing">reentrant invocation of the parser</a>.</p>
                   6479: 
                   6480:     <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
                   6481:     one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
                   6482:     then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
                   6483: 
                   6484:     <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
                   6485:     <a href="#insertion-point">insertion point</a> to its previous value. This value
                   6486:     might be the "undefined" value.)</p>
                   6487: 
                   6488:     <p id="scriptTagParserResumes">At this stage, if there is a
1.484     mike     6489:     <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking script</a>, then:</p>
1.1       mike     6490: 
                   6491:     <dl class="switch"><dt>If the <a href="#script-nesting-level">script nesting level</a> is not zero:</dt>
                   6492: 
                   6493:      <dd>
                   6494: 
                   6495:       <p>Set the <a href="#parser-pause-flag">parser pause flag</a> to true, and abort the
                   6496:       processing of any nested invocations of the tokenizer, yielding
                   6497:       control back to the caller. (Tokenization will resume when the
                   6498:       caller returns to the "outer" tree construction stage.)</p>
                   6499: 
                   6500:       <p class="note">The tree construction stage of this particular
                   6501:       parser is <a href="#nestedParsing">being called reentrantly</a>,
1.159     mike     6502:       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     6503: 
                   6504:      </dd>
                   6505: 
                   6506: 
                   6507:      <dt>Otherwise:</dt>
                   6508: 
                   6509:      <dd>
                   6510: 
                   6511:       <p>Follow these steps:</p>
                   6512: 
1.484     mike     6513:       <ol><li><p>Let <var title="">the script</var> be the <a href="semantics.html#pending-parsing-blocking-script">pending
                   6514:        parsing-blocking script</a>. There is no longer a <a href="semantics.html#pending-parsing-blocking-script">pending
                   6515:        parsing-blocking script</a>.</p></li>
                   6516: 
                   6517:        <li><p>Block the <a href="#tokenization" title="tokenization">tokenizer</a>
                   6518:        for this instance of the <a href="#html-parser">HTML parser</a>, such that
                   6519:        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>
                   6520: 
                   6521:        <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
                   6522:        scripts</a> and <var title="">the script</var>'s
                   6523:        <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag is set.</p></li>
                   6524: 
                   6525:        <li><p>Unblock the <a href="#tokenization" title="tokenization">tokenizer</a>
                   6526:        for this instance of the <a href="#html-parser">HTML parser</a>, such that
                   6527:        <a href="browsers.html#concept-task" title="concept-task">tasks</a> that invoke the <a href="#tokenization" title="tokenization">tokenizer</a> can again be
                   6528:        run.</p></li>
1.1       mike     6529: 
                   6530:        <li><p>Let the <a href="#insertion-point">insertion point</a> be just before the
                   6531:        <a href="#next-input-character">next input character</a>.</p></li>
                   6532: 
                   6533:        <li><p>Increment the parser's <a href="#script-nesting-level">script nesting level</a>
                   6534:        by one (it should be zero before this step, so this sets it to
                   6535:        one).</p></li>
                   6536: 
1.484     mike     6537:        <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a>
                   6538:        <var title="">the script</var>.</p></li>
1.1       mike     6539: 
                   6540:        <li><p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a>
                   6541:        by one. If the parser's <a href="#script-nesting-level">script nesting level</a> is
                   6542:        zero (which it always should be at this point), then set the
                   6543:        <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
                   6544: 
                   6545:        </li><li><p>Let the <a href="#insertion-point">insertion point</a> be undefined
                   6546:        again.</p></li>
                   6547: 
1.484     mike     6548:        <li><p>If there is once again a <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking
1.1       mike     6549:        script</a>, then repeat these steps from step 1.</p></li>
                   6550: 
                   6551:       </ol></dd>
                   6552: 
                   6553:     </dl></dd>
                   6554: 
                   6555:    <dt>Any other end tag</dt>
                   6556:    <dd>
                   6557: 
                   6558:     <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6559:     elements</a>.</p>
                   6560: 
                   6561:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
                   6562:     insertion mode</a>.</p>
                   6563: 
                   6564:    </dd>
                   6565: 
1.724     mike     6566:   </dl><h5 id="parsing-main-intable"><span class="secno">7.2.5.12 </span>The "<dfn title="insertion mode: in table">in table</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     6567: 
                   6568:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion
                   6569:   mode: in table">in table</a>", tokens must be handled as follows:</p>
                   6570: 
                   6571:   <dl class="switch"><dt>A character token</dt>
                   6572:    <dd>
                   6573: 
                   6574:      <p>Let the <dfn id="pending-table-character-tokens"><var>pending table character tokens</var></dfn>
                   6575:      be an empty list of tokens.</p>
                   6576: 
                   6577:      <p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
                   6578:      <a href="#insertion-mode">insertion mode</a>.</p>
                   6579: 
                   6580:      <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
                   6581:      reprocess the token.</p>
                   6582: 
                   6583:    </dd>
                   6584: 
                   6585:    <dt>A comment token</dt>
                   6586:    <dd>
                   6587:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   6588:     node</a> with the <code title="">data</code> attribute set to
                   6589:     the data given in the comment token.</p>
                   6590:    </dd>
                   6591: 
                   6592:    <dt>A DOCTYPE token</dt>
                   6593:    <dd>
                   6594:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6595:    </dd>
                   6596: 
                   6597:    <dt>A start tag whose tag name is "caption"</dt>
                   6598:    <dd>
                   6599: 
                   6600:     <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
                   6601:     below.)</p>
                   6602: 
                   6603:     <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
                   6604:     formatting elements</a>.</p>
                   6605: 
                   6606:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
                   6607:     switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incaption" title="insertion mode: in caption">in caption</a>".</p>
                   6608: 
                   6609:    </dd>
                   6610: 
                   6611:    <dt>A start tag whose tag name is "colgroup"</dt>
                   6612:    <dd>
                   6613: 
                   6614:     <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
                   6615:     below.)</p>
                   6616: 
                   6617:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
                   6618:     switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incolgroup" title="insertion mode: in column group">in column
                   6619:     group</a>".</p>
                   6620: 
                   6621:    </dd>
                   6622: 
                   6623:    <dt>A start tag whose tag name is "col"</dt>
                   6624:    <dd>
                   6625:     <p>Act as if a start tag token with the tag name "colgroup"
                   6626:     had been seen, then reprocess the current token.</p>
                   6627:    </dd>
                   6628: 
                   6629:    <dt>A start tag whose tag name is one of: "tbody", "tfoot", "thead"</dt>
                   6630:    <dd>
                   6631: 
                   6632:     <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
                   6633:     below.)</p>
                   6634: 
                   6635:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
                   6636:     switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   6637:     body</a>".</p>
                   6638: 
                   6639:    </dd>
                   6640: 
                   6641:    <dt>A start tag whose tag name is one of: "td", "th", "tr"</dt>
                   6642:    <dd>
                   6643:     <p>Act as if a start tag token with the tag name "tbody" had
                   6644:     been seen, then reprocess the current token.</p>
                   6645:    </dd>
                   6646: 
                   6647:    <dt>A start tag whose tag name is "table"</dt>
                   6648:    <dd>
                   6649: 
                   6650:     <p><a href="#parse-error">Parse error</a>. Act as if an end tag token with
                   6651:     the tag name "table" had been seen, then, if that token wasn't
                   6652:     ignored, reprocess the current token.</p>
                   6653: 
                   6654:     <p class="note">The fake end tag token here can only be
                   6655:     ignored in the <a href="#fragment-case">fragment case</a>.</p>
                   6656: 
                   6657:    </dd>
                   6658: 
                   6659:    <dt>An end tag whose tag name is "table"</dt>
                   6660:    <dd>
                   6661: 
                   6662:     <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
                   6663:     scope</a> with the same tag name as the token, this is a
                   6664:     <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   6665:     case</a>)</p>
                   6666: 
                   6667:     <p>Otherwise:</p>
                   6668: 
                   6669:     <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-table-element">table</a></code>
                   6670:     element has been popped from the stack.</p>
                   6671: 
                   6672:     <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
                   6673: 
                   6674:    </dd>
                   6675: 
                   6676:    <dt>An end tag whose tag name is one of: "body", "caption",
                   6677:    "col", "colgroup", "html", "tbody", "td", "tfoot", "th",
                   6678:    "thead", "tr"</dt>
                   6679:    <dd>
                   6680:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6681:    </dd>
                   6682: 
                   6683:    <dt>A start tag whose tag name is one of: "style", "script"</dt>
                   6684:    <dd>
                   6685: 
                   6686:     <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
                   6687:     mode</a>.</p>
                   6688: 
                   6689:    </dd>
                   6690: 
                   6691:    <dt>A start tag whose tag name is "input"</dt>
                   6692:    <dd>
                   6693: 
                   6694:     <p>If the token does not have an attribute with the name "type",
                   6695:     or if it does, but that attribute's value is not an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   6696:     case-insensitive</a> match for the string "<code title="">hidden</code>", then: act as described in the "anything
                   6697:     else" entry below.</p>
                   6698: 
                   6699:     <p>Otherwise:</p>
                   6700: 
                   6701:     <p><a href="#parse-error">Parse error</a>.</p>
                   6702: 
                   6703:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6704: 
                   6705:     <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
                   6706:     open elements</a>.</p>
                   6707: 
                   6708:    </dd>
                   6709: 
1.603     mike     6710:    <dt>A start tag whose tag name is "form"</dt>
                   6711:    <dd>
                   6712: 
                   6713:     <p><a href="#parse-error">Parse error</a>.</p>
                   6714: 
1.717     mike     6715:     <p>If the <a href="#form-element-pointer"><code title="form">form</code> element
                   6716:     pointer</a> is not null, ignore the token.</p>
                   6717: 
                   6718:     <p>Otherwise:</p>
                   6719: 
1.603     mike     6720:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6721: 
1.637     mike     6722:     <p>Pop that <code><a href="forms.html#the-form-element">form</a></code> element off the <a href="#stack-of-open-elements">stack of
1.603     mike     6723:     open elements</a>.</p>
                   6724: 
                   6725:    </dd>
                   6726: 
1.721     mike     6727:    <!-- "form" end tag falls through to in-body, which does the right thing -->
1.717     mike     6728: 
1.1       mike     6729:    <dt>An end-of-file token</dt>
                   6730:    <dd>
                   6731: 
                   6732:     <p>If the <a href="#current-node">current node</a> is not the root
1.159     mike     6733:     <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     6734:     error</a>.</p>
                   6735: 
                   6736:     <p class="note">It can only be the <a href="#current-node">current node</a> in
                   6737:     the <a href="#fragment-case">fragment case</a>.</p>
                   6738: 
                   6739:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   6740: 
                   6741:    </dd>
                   6742: 
                   6743:    <dt>Anything else</dt>
                   6744:    <dd>
                   6745: 
                   6746:     <p><a href="#parse-error">Parse error</a>. Process the token <a href="#using-the-rules-for">using the
                   6747:     rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
                   6748:     body</a>" <a href="#insertion-mode">insertion mode</a>, except that if the
                   6749:     <a href="#current-node">current node</a> is a <code><a href="tabular-data.html#the-table-element">table</a></code>,
                   6750:     <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
                   6751:     <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then, whenever a node would be inserted
                   6752:     into the <a href="#current-node">current node</a>, it must instead be <a href="#foster-parent" title="foster parent">foster parented</a>.</p>
                   6753: 
                   6754:    </dd>
                   6755: 
                   6756:   </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-context">clear the stack
                   6757:   back to a table context</dfn>, it means that the UA must, while
                   6758:   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     6759:   element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1       mike     6760:   <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   6761: 
                   6762:   <p class="note">The <a href="#current-node">current node</a> being an
1.159     mike     6763:   <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     6764:   case</a>.</p>
                   6765: 
                   6766: 
                   6767: 
1.724     mike     6768:   <h5 id="parsing-main-intabletext"><span class="secno">7.2.5.13 </span>The "<dfn title="insertion mode: in table text">in table text</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     6769: 
                   6770:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intabletext" title="insertion
                   6771:   mode: in table text">in table text</a>", tokens must be handled
                   6772:   as follows:</p>
                   6773: 
                   6774:   <dl class="switch"><dt>A character token</dt>
                   6775:    <dd>
                   6776: 
                   6777:     <p>Append the character token to the <var><a href="#pending-table-character-tokens">pending table character
                   6778:     tokens</a></var> list.</p>
                   6779: 
                   6780:    </dd>
                   6781: 
                   6782: 
                   6783:    <dt>Anything else</dt>
                   6784:    <dd>
                   6785: 
                   6786:     <p>If any of the tokens in the <var><a href="#pending-table-character-tokens">pending table character
                   6787:     tokens</a></var> list are character tokens that are not one of U+0009
                   6788:     CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED
                   6789:     (FF), <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE, then
                   6790:     reprocess those character tokens using the rules given in the
                   6791:     "anything else" entry in the <a href="#parsing-main-intable" title="insertion mode: in
                   6792:     table">in table</a>" insertion mode.</p>
                   6793: 
                   6794:     <p>Otherwise, <a href="#insert-a-character" title="insert a character">insert the
                   6795:     characters</a> given by the <var><a href="#pending-table-character-tokens">pending table character
                   6796:     tokens</a></var> list into the <a href="#current-node">current node</a>.</p>
                   6797: 
                   6798:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
                   6799:     insertion mode</a> and reprocess the token.</p>
                   6800: 
                   6801:    </dd>
                   6802: 
1.724     mike     6803:   </dl><h5 id="parsing-main-incaption"><span class="secno">7.2.5.14 </span>The "<dfn title="insertion mode: in caption">in caption</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     6804: 
                   6805:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incaption" title="insertion
                   6806:   mode: in caption">in caption</a>", tokens must be handled as follows:</p>
                   6807: 
                   6808:   <dl class="switch"><dt>An end tag whose tag name is "caption"</dt>
                   6809:    <dd>
                   6810: 
                   6811:     <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
                   6812:     scope</a> with the same tag name as the token, this is a
                   6813:     <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   6814:     case</a>)</p>
                   6815: 
                   6816:     <p>Otherwise:</p>
                   6817: 
                   6818:     <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
                   6819: 
                   6820:     <p>Now, if the <a href="#current-node">current node</a> is not a
                   6821:     <code><a href="tabular-data.html#the-caption-element">caption</a></code> element, then this is a <a href="#parse-error">parse
                   6822:     error</a>.</p>
                   6823: 
                   6824:     <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-caption-element">caption</a></code>
                   6825:     element has been popped from the stack.</p>
                   6826: 
                   6827:     <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
                   6828:     the last marker</a>.</p>
                   6829: 
                   6830:     <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>
                   6831: 
                   6832:    </dd>
                   6833: 
                   6834:    <dt>A start tag whose tag name is one of: "caption", "col",
                   6835:    "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
                   6836:    <dt>An end tag whose tag name is "table"</dt>
                   6837:    <dd>
                   6838: 
                   6839:     <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
                   6840:     name "caption" had been seen, then, if that token wasn't
                   6841:     ignored, reprocess the current token.</p>
                   6842: 
                   6843:     <p class="note">The fake end tag token here can only be
                   6844:     ignored in the <a href="#fragment-case">fragment case</a>.</p>
                   6845: 
                   6846:    </dd>
                   6847: 
                   6848:    <dt>An end tag whose tag name is one of: "body", "col",
                   6849:    "colgroup", "html", "tbody", "td", "tfoot", "th", "thead",
                   6850:    "tr"</dt>
                   6851:    <dd>
                   6852:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6853:    </dd>
                   6854: 
                   6855:    <dt>Anything else</dt>
                   6856:    <dd>
                   6857:     <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
                   6858:     mode</a>.</p>
                   6859:    </dd>
                   6860: 
1.724     mike     6861:   </dl><h5 id="parsing-main-incolgroup"><span class="secno">7.2.5.15 </span>The "<dfn title="insertion mode: in column group">in column group</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     6862: 
                   6863:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incolgroup" title="insertion
                   6864:   mode: in column group">in column group</a>", tokens must be handled as follows:</p>
                   6865: 
                   6866:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   6867:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   6868:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   6869:    <dd>
                   6870:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   6871:     the <a href="#current-node">current node</a>.</p>
                   6872:    </dd>
                   6873: 
                   6874:    <dt>A comment token</dt>
                   6875:    <dd>
                   6876:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   6877:     node</a> with the <code title="">data</code> attribute set to
                   6878:     the data given in the comment token.</p>
                   6879:    </dd>
                   6880: 
                   6881:    <dt>A DOCTYPE token</dt>
                   6882:    <dd>
                   6883:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6884:    </dd>
                   6885: 
                   6886:    <dt>A start tag whose tag name is "html"</dt>
                   6887:    <dd>
                   6888:     <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
                   6889:     mode</a>.</p>
                   6890:    </dd>
                   6891: 
                   6892:    <dt>A start tag whose tag name is "col"</dt>
                   6893:    <dd>
                   6894: 
                   6895:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   6896:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6897:     elements</a>.</p>
                   6898: 
                   6899:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   6900:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   6901: 
                   6902:    </dd>
                   6903: 
                   6904:    <dt>An end tag whose tag name is "colgroup"</dt>
                   6905:    <dd>
                   6906: 
                   6907:     <p>If the <a href="#current-node">current node</a> is the root
1.159     mike     6908:     <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     6909:     error</a>; ignore the token. (<a href="#fragment-case">fragment
                   6910:     case</a>)</p>
                   6911: 
                   6912:     <p>Otherwise, pop the <a href="#current-node">current node</a> (which will be
                   6913:     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
                   6914:     elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
                   6915:     "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
                   6916: 
                   6917:    </dd>
                   6918: 
                   6919:    <dt>An end tag whose tag name is "col"</dt>
                   6920:    <dd>
                   6921:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6922:    </dd>
                   6923: 
                   6924:    <dt>An end-of-file token</dt>
                   6925:    <dd>
                   6926: 
1.159     mike     6927:     <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     6928:     element, then <a href="#stop-parsing">stop parsing</a>. (<a href="#fragment-case">fragment
                   6929:     case</a>)</p>
                   6930: 
                   6931:     <p>Otherwise, act as described in the "anything else" entry
                   6932:     below.</p>
                   6933: 
                   6934:    </dd>
                   6935: 
                   6936:    <dt>Anything else</dt>
                   6937:    <dd>
                   6938: 
                   6939:     <p>Act as if an end tag with the tag name "colgroup" had been
                   6940:     seen, and then, if that token wasn't ignored, reprocess the
                   6941:     current token.</p>
                   6942: 
                   6943:     <p class="note">The fake end tag token here can only be
                   6944:     ignored in the <a href="#fragment-case">fragment case</a>.</p>
                   6945: 
                   6946:    </dd>
                   6947: 
1.724     mike     6948:   </dl><h5 id="parsing-main-intbody"><span class="secno">7.2.5.16 </span>The "<dfn title="insertion mode: in table body">in table body</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     6949: 
                   6950:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion
                   6951:   mode: in table body">in table body</a>", tokens must be handled as follows:</p>
                   6952: 
                   6953:   <dl class="switch"><dt>A start tag whose tag name is "tr"</dt>
                   6954:    <dd>
                   6955: 
                   6956:     <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
                   6957:     context</a>. (See below.)</p>
                   6958: 
                   6959:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
                   6960:     the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion mode:
                   6961:     in row">in row</a>".</p>
                   6962: 
                   6963:    </dd>
                   6964: 
                   6965:    <dt>A start tag whose tag name is one of: "th", "td"</dt>
                   6966:    <dd>
                   6967:     <p><a href="#parse-error">Parse error</a>. Act as if a start tag with
                   6968:     the tag name "tr" had been seen, then reprocess the current
                   6969:     token.</p>
                   6970:    </dd>
                   6971: 
                   6972:    <dt>An end tag whose tag name is one of: "tbody", "tfoot",
                   6973:    "thead"</dt>
                   6974:    <dd>
                   6975: 
                   6976:     <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
                   6977:     scope</a> with the same tag name as the token, this is a
                   6978:     <a href="#parse-error">parse error</a>. Ignore the token.</p>
                   6979: 
                   6980:     <p>Otherwise:</p>
                   6981: 
                   6982:     <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
                   6983:     context</a>. (See below.)</p>
                   6984: 
                   6985:     <p>Pop the <a href="#current-node">current node</a> from the <a href="#stack-of-open-elements">stack of
                   6986:     open elements</a>. Switch the <a href="#insertion-mode">insertion mode</a>
                   6987:     to "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
                   6988: 
                   6989:    </dd>
                   6990: 
                   6991:    <dt>A start tag whose tag name is one of: "caption", "col",
                   6992:    "colgroup", "tbody", "tfoot", "thead"</dt>
                   6993:    <dt>An end tag whose tag name is "table"</dt>
                   6994:    <dd>
                   6995: 
                   6996:     <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
                   6997:     <code>tbody</code>, <code>thead</code>, or <code>tfoot</code>
                   6998:     element in table scope</a>, this is a <a href="#parse-error">parse
                   6999:     error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   7000:     case</a>)</p>
                   7001: 
                   7002:     <p>Otherwise:</p>
                   7003: 
                   7004:     <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
                   7005:     context</a>. (See below.)</p>
                   7006: 
                   7007:     <p>Act as if an end tag with the same tag name as the
                   7008:     <a href="#current-node">current node</a> ("tbody", "tfoot", or "thead") had
                   7009:     been seen, then reprocess the current token.</p>
                   7010: 
                   7011:    </dd>
                   7012: 
                   7013:    <dt>An end tag whose tag name is one of: "body", "caption",
                   7014:    "col", "colgroup", "html", "td", "th", "tr"</dt>
                   7015:    <dd>
                   7016:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7017:    </dd>
                   7018: 
                   7019:    <dt>Anything else</dt>
                   7020:    <dd>
                   7021:     <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
                   7022:     mode</a>.</p>
                   7023:    </dd>
                   7024: 
                   7025:   </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-body-context">clear the stack
                   7026:   back to a table body context</dfn>, it means that the UA must,
                   7027:   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     7028:   <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     7029:   element, pop elements from the <a href="#stack-of-open-elements">stack of open
                   7030:   elements</a>.</p>
                   7031: 
                   7032:   <p class="note">The <a href="#current-node">current node</a> being an
1.159     mike     7033:   <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     7034:   case</a>.</p>
                   7035: 
                   7036: 
1.724     mike     7037:   <h5 id="parsing-main-intr"><span class="secno">7.2.5.17 </span>The "<dfn title="insertion mode: in row">in row</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     7038: 
                   7039:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
                   7040:   mode: in row">in row</a>", tokens must be handled as follows:</p>
                   7041: 
                   7042:   <dl class="switch"><dt>A start tag whose tag name is one of: "th", "td"</dt>
                   7043:    <dd>
                   7044: 
                   7045:     <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
                   7046:     context</a>. (See below.)</p>
                   7047: 
                   7048:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
                   7049:     the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion mode:
                   7050:     in cell">in cell</a>".</p>
                   7051: 
                   7052:     <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
                   7053:     formatting elements</a>.</p>
                   7054: 
                   7055:    </dd>
                   7056: 
                   7057:    <dt>An end tag whose tag name is "tr"</dt>
                   7058:    <dd>
                   7059: 
                   7060:     <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
                   7061:     scope</a> with the same tag name as the token, this is a
                   7062:     <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   7063:     case</a>)</p>
                   7064: 
                   7065:     <p>Otherwise:</p>
                   7066: 
                   7067:     <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
                   7068:     context</a>. (See below.)</p>
                   7069: 
                   7070:     <p>Pop the <a href="#current-node">current node</a> (which will be a
                   7071:     <code><a href="tabular-data.html#the-tr-element">tr</a></code> element) from the <a href="#stack-of-open-elements">stack of open
                   7072:     elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
                   7073:     "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   7074:     body</a>".</p>
                   7075: 
                   7076:    </dd>
                   7077: 
                   7078:    <dt>A start tag whose tag name is one of: "caption", "col",
                   7079:    "colgroup", "tbody", "tfoot", "thead", "tr"</dt>
                   7080:    <dt>An end tag whose tag name is "table"</dt>
                   7081:    <dd>
                   7082: 
                   7083:     <p>Act as if an end tag with the tag name "tr" had been seen,
                   7084:     then, if that token wasn't ignored, reprocess the current
                   7085:     token.</p>
                   7086: 
                   7087:     <p class="note">The fake end tag token here can only be
                   7088:     ignored in the <a href="#fragment-case">fragment case</a>.</p>
                   7089: 
                   7090:    </dd>
                   7091: 
                   7092:    <dt>An end tag whose tag name is one of: "tbody", "tfoot",
                   7093:    "thead"</dt>
                   7094:    <dd>
                   7095: 
                   7096:     <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
                   7097:     scope</a> with the same tag name as the token, this is a
                   7098:     <a href="#parse-error">parse error</a>. Ignore the token.</p>
                   7099: 
                   7100:     <p>Otherwise, act as if an end tag with the tag name "tr" had
                   7101:     been seen, then reprocess the current token.</p>
                   7102: 
                   7103:    </dd>
                   7104: 
                   7105:    <dt>An end tag whose tag name is one of: "body", "caption",
                   7106:    "col", "colgroup", "html", "td", "th"</dt>
                   7107:    <dd>
                   7108:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7109:    </dd>
                   7110: 
                   7111:    <dt>Anything else</dt>
                   7112:    <dd>
                   7113:     <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
                   7114:     mode</a>.</p>
                   7115:    </dd>
                   7116: 
                   7117:   </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-row-context">clear the stack
                   7118:   back to a table row context</dfn>, it means that the UA must,
                   7119:   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     7120:   element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1       mike     7121:   <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   7122: 
                   7123:   <p class="note">The <a href="#current-node">current node</a> being an
1.159     mike     7124:   <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     7125:   case</a>.</p>
                   7126: 
                   7127: 
1.724     mike     7128:   <h5 id="parsing-main-intd"><span class="secno">7.2.5.18 </span>The "<dfn title="insertion mode: in cell">in cell</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     7129: 
                   7130:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intd" title="insertion
                   7131:   mode: in cell">in cell</a>", tokens must be handled as follows:</p>
                   7132: 
                   7133:   <dl class="switch"><dt>An end tag whose tag name is one of: "td", "th"</dt>
                   7134:    <dd>
                   7135: 
                   7136:     <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
                   7137:     scope</a> with the same tag name as that of the token, then
                   7138:     this is a <a href="#parse-error">parse error</a> and the token must be
                   7139:     ignored.</p>
                   7140: 
                   7141:     <p>Otherwise:</p>
                   7142: 
                   7143:     <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
                   7144: 
                   7145:     <p>Now, if the <a href="#current-node">current node</a> is not an element
                   7146:     with the same tag name as the token, then this is a
                   7147:     <a href="#parse-error">parse error</a>.</p>
                   7148: 
                   7149:     <p>Pop elements from this stack until an element with the same
                   7150:     tag name as the token has been popped from the stack.</p>
                   7151: 
                   7152:     <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
                   7153:     the last marker</a>.</p>
                   7154: 
                   7155:     <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
                   7156:     <a href="#current-node">current node</a> will be a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element at
                   7157:     this point.)</p>
                   7158: 
                   7159:    </dd>
                   7160: 
                   7161:    <dt>A start tag whose tag name is one of: "caption", "col",
                   7162:    "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
                   7163:    <dd>
                   7164: 
                   7165:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does
                   7166:     <em>not</em> <a href="#has-an-element-in-table-scope" title="has an element in table scope">have
                   7167:     a <code>td</code> or <code>th</code> element in table
                   7168:     scope</a>, then this is a <a href="#parse-error">parse error</a>; ignore
                   7169:     the token. (<a href="#fragment-case">fragment case</a>)</p>
                   7170: 
                   7171:     <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
                   7172:     reprocess the current token.</p>
                   7173: 
                   7174:    </dd>
                   7175: 
                   7176:    <dt>An end tag whose tag name is one of: "body", "caption",
                   7177:    "col", "colgroup", "html"</dt>
                   7178:    <dd>
                   7179:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7180:    </dd>
                   7181: 
                   7182:    <dt>An end tag whose tag name is one of: "table", "tbody",
                   7183:    "tfoot", "thead", "tr"</dt>
                   7184:    <dd>
                   7185: 
                   7186:     <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
                   7187:     scope</a> with the same tag name as that of the token
                   7188:     (which can only happen for "tbody", "tfoot" and "thead", or,
                   7189:     in the <a href="#fragment-case">fragment case</a>), then this is a <a href="#parse-error">parse
                   7190:     error</a> and the token must be ignored.</p>
                   7191: 
                   7192:     <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
                   7193:     reprocess the current token.</p>
                   7194: 
                   7195:    </dd>
                   7196: 
                   7197:    <dt>Anything else</dt>
                   7198:    <dd>
                   7199:     <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
                   7200:     mode</a>.</p>
                   7201:    </dd>
                   7202: 
                   7203:   </dl><p>Where the steps above say to <dfn id="close-the-cell">close the cell</dfn>, they
                   7204:   mean to run the following algorithm:</p>
                   7205: 
                   7206:   <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>
                   7207:    element in table scope</a>, then act as if an end tag token
                   7208:    with the tag name "td" had been seen.</p></li>
                   7209: 
                   7210:    <li><p>Otherwise, the <a href="#stack-of-open-elements">stack of open elements</a> will
                   7211:    <a href="#has-an-element-in-table-scope" title="has an element in table scope">have a
                   7212:    <code>th</code> element in table scope</a>; act as if an end
                   7213:    tag token with the tag name "th" had been seen.</p></li>
                   7214: 
                   7215:   </ol><p class="note">The <a href="#stack-of-open-elements">stack of open elements</a> cannot
                   7216:   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
                   7217:   the same time, nor can it have neither when the <a href="#insertion-mode">insertion
                   7218:   mode</a> is "<a href="#parsing-main-intd" title="insertion mode: in cell">in
                   7219:   cell</a>".</p>
                   7220: 
                   7221: 
1.724     mike     7222:   <h5 id="parsing-main-inselect"><span class="secno">7.2.5.19 </span>The "<dfn title="insertion mode: in select">in select</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     7223: 
                   7224:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselect" title="insertion
                   7225:   mode: in select">in select</a>", tokens must be handled as follows:</p>
                   7226: 
                   7227:   <dl class="switch"><dt>A character token</dt>
                   7228:    <dd>
                   7229:     <p><a href="#insert-a-character" title="insert a character">Insert the token's
                   7230:     character</a> into the <a href="#current-node">current node</a>.</p>
                   7231:    </dd>
                   7232: 
                   7233:    <dt>A comment token</dt>
                   7234:    <dd>
                   7235:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   7236:     node</a> with the <code title="">data</code> attribute set to
                   7237:     the data given in the comment token.</p>
                   7238:    </dd>
                   7239: 
                   7240:    <dt>A DOCTYPE token</dt>
                   7241:    <dd>
                   7242:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7243:    </dd>
                   7244: 
                   7245:    <dt>A start tag whose tag name is "html"</dt>
                   7246:    <dd>
                   7247:     <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
                   7248:     mode</a>.</p>
                   7249:    </dd>
                   7250: 
                   7251:    <dt>A start tag whose tag name is "option"</dt>
                   7252:    <dd>
                   7253: 
                   7254:     <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
                   7255:     element, act as if an end tag with the tag name "option" had
                   7256:     been seen.</p>
                   7257: 
                   7258:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   7259: 
                   7260:    </dd>
                   7261: 
                   7262:    <dt>A start tag whose tag name is "optgroup"</dt>
                   7263:    <dd>
                   7264: 
                   7265:     <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
                   7266:     element, act as if an end tag with the tag name "option" had
                   7267:     been seen.</p>
                   7268: 
                   7269:     <p>If the <a href="#current-node">current node</a> is an
                   7270:     <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, act as if an end tag with the
                   7271:     tag name "optgroup" had been seen.</p>
                   7272: 
                   7273:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   7274: 
                   7275:    </dd>
                   7276: 
                   7277:    <dt>An end tag whose tag name is "optgroup"</dt>
                   7278:    <dd>
                   7279: 
                   7280:     <p>First, if the <a href="#current-node">current node</a> is an
                   7281:     <code><a href="forms.html#the-option-element">option</a></code> element, and the node immediately before
                   7282:     it in the <a href="#stack-of-open-elements">stack of open elements</a> is an
                   7283:     <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then act as if an end tag with
                   7284:     the tag name "option" had been seen.</p>
                   7285: 
                   7286:     <p>If the <a href="#current-node">current node</a> is an
                   7287:     <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then pop that node from the
                   7288:     <a href="#stack-of-open-elements">stack of open elements</a>. Otherwise, this is a
                   7289:     <a href="#parse-error">parse error</a>; ignore the token.</p>
                   7290: 
                   7291:    </dd>
                   7292: 
                   7293:    <dt>An end tag whose tag name is "option"</dt>
                   7294:    <dd>
                   7295: 
                   7296:     <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
                   7297:     element, then pop that node from the <a href="#stack-of-open-elements">stack of open
                   7298:     elements</a>. Otherwise, this is a <a href="#parse-error">parse
                   7299:     error</a>; ignore the token.</p>
                   7300: 
                   7301:    </dd>
                   7302: 
                   7303:    <dt>An end tag whose tag name is "select"</dt>
                   7304:    <dd>
                   7305: 
                   7306:     <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
                   7307:     scope</a> with the same tag name as the token, this is a
                   7308:     <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   7309:     case</a>)</p>
                   7310: 
                   7311:     <p>Otherwise:</p>
                   7312: 
                   7313:     <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   7314:     until a <code><a href="forms.html#the-select-element">select</a></code> element has been popped from the
                   7315:     stack.</p>
                   7316: 
                   7317:     <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
                   7318: 
                   7319:    </dd>
                   7320: 
                   7321:    <dt>A start tag whose tag name is "select"</dt>
                   7322:    <dd>
                   7323: 
                   7324:     <p><a href="#parse-error">Parse error</a>. Act as if the token had been
                   7325:     an end tag with the tag name "select" instead.</p>
                   7326: 
                   7327:    </dd>
                   7328: 
                   7329:    <dt>A start tag whose tag name is one of: "input", "keygen", "textarea"</dt>
                   7330:    <dd>
1.73      mike     7331: 
                   7332:     <p><a href="#parse-error">Parse error</a>.</p>
                   7333: 
1.124     mike     7334:     <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>
                   7335:     element in table scope</a>, ignore the token. (<a href="#fragment-case">fragment
                   7336:     case</a>)</p>
1.73      mike     7337: 
                   7338:     <p>Otherwise, act as if an end tag with the tag name "select" had
                   7339:     been seen, and reprocess the token.</p>
                   7340: 
1.1       mike     7341:    </dd>
                   7342: 
                   7343:    <dt>A start tag token whose tag name is "script"</dt>
                   7344:    <dd>
                   7345:     <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
                   7346:     mode</a>.</p>
                   7347:    </dd>
                   7348: 
                   7349:    <dt>An end-of-file token</dt>
                   7350:    <dd>
                   7351: 
                   7352:     <p>If the <a href="#current-node">current node</a> is not the root
1.159     mike     7353:     <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     7354:     error</a>.</p>
                   7355: 
                   7356:     <p class="note">It can only be the <a href="#current-node">current node</a> in
                   7357:     the <a href="#fragment-case">fragment case</a>.</p>
                   7358: 
                   7359:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7360: 
                   7361:    </dd>
                   7362: 
                   7363:    <dt>Anything else</dt>
                   7364:    <dd>
                   7365:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7366:    </dd>
                   7367: 
1.724     mike     7368:   </dl><h5 id="parsing-main-inselectintable"><span class="secno">7.2.5.20 </span>The "<dfn title="insertion mode: in select in table">in select in table</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     7369: 
                   7370:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselectintable" title="insertion
                   7371:   mode: in select in table">in select in table</a>", tokens must be handled as follows:</p>
                   7372: 
                   7373:   <dl class="switch"><dt>A start tag whose tag name is one of: "caption", "table",
                   7374:    "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
                   7375:    <dd>
                   7376:     <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
                   7377:     name "select" had been seen, and reprocess the token.</p>
                   7378:    </dd>
                   7379: 
                   7380:    <dt>An end tag whose tag name is one of: "caption", "table",
                   7381:    "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
                   7382:    <dd>
                   7383: 
                   7384:     <p><a href="#parse-error">Parse error</a>.</p>
                   7385: 
                   7386:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-table-scope">has an
                   7387:     element in table scope</a> with the same tag name as that
                   7388:     of the token, then act as if an end tag with the tag name
                   7389:     "select" had been seen, and reprocess the token. Otherwise,
                   7390:     ignore the token.</p>
                   7391: 
                   7392:    </dd>
                   7393: 
                   7394:    <dt>Anything else</dt>
                   7395:    <dd>
                   7396:     <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
                   7397:     mode</a>.</p>
                   7398:    </dd>
                   7399: 
1.724     mike     7400:   </dl><h5 id="parsing-main-inforeign"><span class="secno">7.2.5.21 </span>The "<dfn title="insertion mode: in foreign content">in foreign content</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     7401: 
                   7402:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inforeign" title="insertion
                   7403:   mode: in foreign content">in foreign content</a>", tokens must be
                   7404:   handled as follows:</p>
                   7405: 
                   7406:   <dl class="switch"><dt>A character token</dt>
                   7407:    <dd>
                   7408: 
                   7409:     <p><a href="#insert-a-character" title="insert a character">Insert the token's
                   7410:     character</a> into the <a href="#current-node">current node</a>.</p>
                   7411: 
                   7412:     <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
                   7413:     LINE FEED (LF), U+000C FORM FEED (FF), <!--U+000D CARRIAGE RETURN
                   7414:     (CR),--> or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
                   7415:     flag</a> to "not ok".</p>
                   7416: 
                   7417:    </dd>
                   7418: 
                   7419:    <dt>A comment token</dt>
                   7420:    <dd>
                   7421:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   7422:     node</a> with the <code title="">data</code> attribute set to
                   7423:     the data given in the comment token.</p>
                   7424:    </dd>
                   7425: 
                   7426:    <dt>A DOCTYPE token</dt>
                   7427:    <dd>
                   7428:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7429:    </dd>
                   7430: 
1.724     mike     7431:    <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="infrastructure.html#svg-namespace">SVG namespace</a>.</dt>
1.1       mike     7432:    <dd>
                   7433: 
                   7434:     <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   7435:     elements</a>.</p>
                   7436: 
                   7437:     <p>Let the <var title="">old insertion point</var> have the
                   7438:     same value as the current <a href="#insertion-point">insertion point</a>. Let
                   7439:     the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
                   7440:     input character</a>.</p>
                   7441: 
                   7442:     <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
                   7443:     one. Set the <a href="#parser-pause-flag">parser pause flag</a> to true.</p>
                   7444: 
                   7445:     <p><a href="http://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing">Process
                   7446:     the <code title="">script</code> element</a> according to the SVG
1.187     mike     7447:     rules, if the user agent supports SVG. <a href="references.html#refsSVG">[SVG]</a></p>
1.1       mike     7448: 
1.159     mike     7449:     <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     7450:     tokenizer</a>, the parser will not be executed reentrantly,
                   7451:     since the <a href="#parser-pause-flag">parser pause flag</a> is true.</p>
                   7452: 
                   7453:     <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
                   7454:     one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
                   7455:     then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
                   7456: 
                   7457:     <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
                   7458:     <a href="#insertion-point">insertion point</a> to its previous value. This value
                   7459:     might be the "undefined" value.)</p>
                   7460: 
                   7461:    </dd>
                   7462: 
1.724     mike     7463:    <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="infrastructure.html#mathml-namespace">MathML namespace</a>.</dt>
                   7464:    <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="infrastructure.html#mathml-namespace">MathML namespace</a>.</dt>
                   7465:    <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="infrastructure.html#mathml-namespace">MathML namespace</a>.</dt>
                   7466:    <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="infrastructure.html#mathml-namespace">MathML namespace</a>.</dt>
                   7467:    <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="infrastructure.html#mathml-namespace">MathML namespace</a>.</dt>
                   7468:    <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="infrastructure.html#mathml-namespace">MathML namespace</a>.</dt>
                   7469:    <dt>A start tag, if the <a href="#current-node">current node</a> is a <code title="">foreignObject</code> element in the <a href="infrastructure.html#svg-namespace">SVG namespace</a>.</dt>
                   7470:    <dt>A start tag, if the <a href="#current-node">current node</a> is a <code title="">desc</code> element in the <a href="infrastructure.html#svg-namespace">SVG namespace</a>.</dt>
                   7471:    <dt>A start tag, if the <a href="#current-node">current node</a> is a <code title="">title</code> element in the <a href="infrastructure.html#svg-namespace">SVG namespace</a>.</dt>
                   7472:    <dt>A start tag, if the <a href="#current-node">current node</a> is an element in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>.</dt>
1.1       mike     7473:    <dt>An end tag</dt>
                   7474:    <dd>
                   7475: 
                   7476:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the
                   7477:     <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
                   7478: 
                   7479:     <p>If, after doing so, the <a href="#insertion-mode">insertion mode</a> is still
                   7480:     "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
1.336     mike     7481:     content</a>", but there is no element <a href="#has-an-element-in-scope" title="has an
                   7482:     element in scope">in scope</a> that has a namespace other than
1.724     mike     7483:     the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, switch the <a href="#insertion-mode">insertion
1.1       mike     7484:     mode</a> to the <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
                   7485: 
                   7486:    </dd>
                   7487: 
                   7488:    <dt>A start tag whose tag name is one of: <!--"a",--> "b", "big",
                   7489:    "blockquote", "body"<!--by inspection-->, "br", "center", "code",
1.422     mike     7490:    "dd", "div", "dl", "dt"<!-- so that dd and dt can be handled
                   7491:    uniformly throughout the parser -->, "em", "embed", "h1", "h2",
                   7492:    "h3", "h4"<!--for completeness-->, "h5", "h6"<!--for
1.1       mike     7493:    completeness-->, "head"<!--by inspection-->, "hr", "i", "img",
                   7494:    "li", "listing"<!-- so that pre and listing can be handled
                   7495:    uniformly throughout the parser -->, "menu", "meta", "nobr",
                   7496:    "ol"<!-- so that dl, ul, and ol can be handled uniformly throughout
                   7497:    the parser -->, "p", "pre", "ruby", "s", <!--"script",--> "small",
                   7498:    "span", "strong", "strike"<!-- so that s and strike can be handled
                   7499:    uniformly throughout the parser -->, <!--"style",--> "sub", "sup",
1.305     mike     7500:    "table"<!--by inspection-->, "tt", "u", "ul", "var"</dt> <!-- this
                   7501:    list was determined empirically by studying over 6,000,000,000
1.422     mike     7502:    pages that were specifically not XML pages -->
                   7503:    <dt>A start tag whose tag name is "font", if the token has any
                   7504:    attributes named "color", "face", or "size"</dt> <!-- the
                   7505:    attributes here are required so that SVG <font> will go through as
                   7506:    SVG but legacy <font>s won't -->
                   7507:    <dt>An end-of-file token</dt> <dd>
1.1       mike     7508: 
                   7509:     <p><a href="#parse-error">Parse error</a>.</p>
                   7510: 
                   7511:     <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a> until
1.724     mike     7512:     the <a href="#current-node">current node</a> is in the <a href="infrastructure.html#html-namespace-0">HTML
1.1       mike     7513:     namespace</a>.</p>
                   7514: 
                   7515:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#secondary-insertion-mode">secondary
                   7516:     insertion mode</a>, and reprocess the token.</p>
                   7517: 
                   7518:    </dd>
                   7519: 
                   7520:    <dt>Any other start tag</dt>
                   7521:    <dd>
                   7522: 
                   7523:     <p>If the <a href="#current-node">current node</a> is an element in the
1.724     mike     7524:     <a href="infrastructure.html#mathml-namespace">MathML namespace</a>, <a href="#adjust-mathml-attributes">adjust MathML
1.1       mike     7525:     attributes</a> for the token. (This fixes the case of MathML
                   7526:     attributes that are not all lowercase.)</p>
                   7527: 
1.724     mike     7528:     <p>If the <a href="#current-node">current node</a> is an element in the <a href="infrastructure.html#svg-namespace">SVG
1.1       mike     7529:     namespace</a>, and the token's tag name is one of the ones in
                   7530:     the first column of the following table, change the tag name to
                   7531:     the name given in the corresponding cell in the second
                   7532:     column. (This fixes the case of SVG elements that are not all
                   7533:     lowercase.)</p>
                   7534: 
                   7535:     <table><thead><tr><th> Tag name </th><th> Element name
                   7536:      </th></tr></thead><tbody><tr><td> <code title="">altglyph</code> </td><td> <code title="">altGlyph</code>
                   7537:       </td></tr><tr><td> <code title="">altglyphdef</code> </td><td> <code title="">altGlyphDef</code>
                   7538:       </td></tr><tr><td> <code title="">altglyphitem</code> </td><td> <code title="">altGlyphItem</code>
                   7539:       </td></tr><tr><td> <code title="">animatecolor</code> </td><td> <code title="">animateColor</code>
                   7540:       </td></tr><tr><td> <code title="">animatemotion</code> </td><td> <code title="">animateMotion</code>
                   7541:       </td></tr><tr><td> <code title="">animatetransform</code> </td><td> <code title="">animateTransform</code>
                   7542:       </td></tr><tr><td> <code title="">clippath</code> </td><td> <code title="">clipPath</code>
                   7543:       </td></tr><tr><td> <code title="">feblend</code> </td><td> <code title="">feBlend</code>
                   7544:       </td></tr><tr><td> <code title="">fecolormatrix</code> </td><td> <code title="">feColorMatrix</code>
                   7545:       </td></tr><tr><td> <code title="">fecomponenttransfer</code> </td><td> <code title="">feComponentTransfer</code>
                   7546:       </td></tr><tr><td> <code title="">fecomposite</code> </td><td> <code title="">feComposite</code>
                   7547:       </td></tr><tr><td> <code title="">feconvolvematrix</code> </td><td> <code title="">feConvolveMatrix</code>
                   7548:       </td></tr><tr><td> <code title="">fediffuselighting</code> </td><td> <code title="">feDiffuseLighting</code>
                   7549:       </td></tr><tr><td> <code title="">fedisplacementmap</code> </td><td> <code title="">feDisplacementMap</code>
                   7550:       </td></tr><tr><td> <code title="">fedistantlight</code> </td><td> <code title="">feDistantLight</code>
                   7551:       </td></tr><tr><td> <code title="">feflood</code> </td><td> <code title="">feFlood</code>
                   7552:       </td></tr><tr><td> <code title="">fefunca</code> </td><td> <code title="">feFuncA</code>
                   7553:       </td></tr><tr><td> <code title="">fefuncb</code> </td><td> <code title="">feFuncB</code>
                   7554:       </td></tr><tr><td> <code title="">fefuncg</code> </td><td> <code title="">feFuncG</code>
                   7555:       </td></tr><tr><td> <code title="">fefuncr</code> </td><td> <code title="">feFuncR</code>
                   7556:       </td></tr><tr><td> <code title="">fegaussianblur</code> </td><td> <code title="">feGaussianBlur</code>
                   7557:       </td></tr><tr><td> <code title="">feimage</code> </td><td> <code title="">feImage</code>
                   7558:       </td></tr><tr><td> <code title="">femerge</code> </td><td> <code title="">feMerge</code>
                   7559:       </td></tr><tr><td> <code title="">femergenode</code> </td><td> <code title="">feMergeNode</code>
                   7560:       </td></tr><tr><td> <code title="">femorphology</code> </td><td> <code title="">feMorphology</code>
                   7561:       </td></tr><tr><td> <code title="">feoffset</code> </td><td> <code title="">feOffset</code>
                   7562:       </td></tr><tr><td> <code title="">fepointlight</code> </td><td> <code title="">fePointLight</code>
                   7563:       </td></tr><tr><td> <code title="">fespecularlighting</code> </td><td> <code title="">feSpecularLighting</code>
                   7564:       </td></tr><tr><td> <code title="">fespotlight</code> </td><td> <code title="">feSpotLight</code>
                   7565:       </td></tr><tr><td> <code title="">fetile</code> </td><td> <code title="">feTile</code>
                   7566:       </td></tr><tr><td> <code title="">feturbulence</code> </td><td> <code title="">feTurbulence</code>
                   7567:       </td></tr><tr><td> <code title="">foreignobject</code> </td><td> <code title="">foreignObject</code>
                   7568:       </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
                   7569:       </td></tr><tr><td> <code title="">lineargradient</code> </td><td> <code title="">linearGradient</code>
                   7570:       </td></tr><tr><td> <code title="">radialgradient</code> </td><td> <code title="">radialGradient</code>
                   7571:       <!--<tr> <td> <code title="">solidcolor</code> <td> <code title="">solidColor</code> (SVG 1.2)-->
                   7572:       </td></tr><tr><td> <code title="">textpath</code> </td><td> <code title="">textPath</code>
1.724     mike     7573:     </td></tr></tbody></table><p>If the <a href="#current-node">current node</a> is an element in the <a href="infrastructure.html#svg-namespace">SVG
1.1       mike     7574:     namespace</a>, <a href="#adjust-svg-attributes">adjust SVG attributes</a> for the
                   7575:     token. (This fixes the case of SVG attributes that are not all
                   7576:     lowercase.)</p>
                   7577: 
                   7578:     <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
                   7579:     fixes the use of namespaced attributes, in particular XLink in
                   7580:     SVG.)</p>
                   7581: 
                   7582:     <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
                   7583:     same namespace as the <a href="#current-node">current node</a>.</p>
                   7584: 
                   7585:     <p>If the token has its <i>self-closing flag</i> set, pop the
                   7586:     <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   7587:     elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
                   7588:     flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
                   7589: 
                   7590:    </dd>
                   7591: 
1.724     mike     7592:   </dl><h5 id="parsing-main-afterbody"><span class="secno">7.2.5.22 </span>The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     7593: 
                   7594:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterbody" title="insertion
                   7595:   mode: after body">after body</a>", tokens must be handled as follows:</p>
                   7596: 
                   7597:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   7598:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   7599:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   7600:    <dd>
                   7601:     <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
                   7602:     mode</a>.</p>
                   7603:    </dd>
                   7604: 
                   7605:    <dt>A comment token</dt>
                   7606:    <dd>
                   7607:     <p>Append a <code>Comment</code> node to the first element in
1.159     mike     7608:     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     7609:     element), with the <code title="">data</code> attribute set to
                   7610:     the data given in the comment token.</p>
                   7611:    </dd>
                   7612: 
                   7613:    <dt>A DOCTYPE token</dt>
                   7614:    <dd>
                   7615:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7616:    </dd>
                   7617: 
                   7618:    <dt>A start tag whose tag name is "html"</dt>
                   7619:    <dd>
                   7620:     <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
                   7621:     mode</a>.</p>
                   7622:    </dd>
                   7623: 
                   7624:    <dt>An end tag whose tag name is "html"</dt>
                   7625:    <dd>
                   7626: 
                   7627:     <p>If the parser was originally created as part of the <a href="#html-fragment-parsing-algorithm">HTML
                   7628:     fragment parsing algorithm</a>, this is a <a href="#parse-error">parse
                   7629:     error</a>; ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
                   7630: 
                   7631:     <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
                   7632:     body</a>".</p>
                   7633: 
                   7634:    </dd>
                   7635: 
                   7636:    <dt>An end-of-file token</dt>
                   7637:    <dd>
                   7638:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7639:    </dd>
                   7640: 
                   7641:    <dt>Anything else</dt>
                   7642:    <dd>
                   7643: 
                   7644:     <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion
                   7645:     mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in body">in
                   7646:     body</a>" and reprocess the token.</p>
                   7647: 
                   7648:    </dd>
                   7649: 
1.724     mike     7650:   </dl><h5 id="parsing-main-inframeset"><span class="secno">7.2.5.23 </span>The "<dfn title="insertion mode: in frameset">in frameset</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     7651: 
                   7652:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inframeset" title="insertion
                   7653:   mode: in frameset">in frameset</a>", tokens must be handled as follows:</p>
                   7654: 
                   7655:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   7656:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   7657:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   7658:    <dd>
                   7659:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   7660:     the <a href="#current-node">current node</a>.</p>
                   7661:    </dd>
                   7662: 
                   7663:    <dt>A comment token</dt>
                   7664:    <dd>
                   7665:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   7666:     node</a> with the <code title="">data</code> attribute set to
                   7667:     the data given in the comment token.</p>
                   7668:    </dd>
                   7669: 
                   7670:    <dt>A DOCTYPE token</dt>
                   7671:    <dd>
                   7672:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7673:    </dd>
                   7674: 
                   7675:    <dt>A start tag whose tag name is "html"</dt>
                   7676:    <dd>
                   7677:     <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
                   7678:     mode</a>.</p>
                   7679:    </dd>
                   7680: 
                   7681:    <dt>A start tag whose tag name is "frameset"</dt>
                   7682:    <dd>
                   7683:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   7684:    </dd>
                   7685: 
                   7686:    <dt>An end tag whose tag name is "frameset"</dt>
                   7687:    <dd>
                   7688: 
                   7689:     <p>If the <a href="#current-node">current node</a> is the root
1.159     mike     7690:     <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     7691:     error</a>; ignore the token. (<a href="#fragment-case">fragment
                   7692:     case</a>)</p>
                   7693: 
                   7694:     <p>Otherwise, pop the <a href="#current-node">current node</a> from the
                   7695:     <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   7696: 
                   7697:     <p>If the parser was <em>not</em> originally created as part
                   7698:     of the <a href="#html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>
                   7699:     (<a href="#fragment-case">fragment case</a>), and the <a href="#current-node">current
1.5       mike     7700:     node</a> is no longer a <code><a href="obsolete.html#frameset">frameset</a></code> element, then
1.1       mike     7701:     switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-afterframeset" title="insertion mode: after frameset">after
                   7702:     frameset</a>".</p>
                   7703: 
                   7704:    </dd>
                   7705: 
                   7706:    <dt>A start tag whose tag name is "frame"</dt>
                   7707:    <dd>
                   7708: 
                   7709:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.
                   7710:     Immediately pop the <a href="#current-node">current node</a> off the
                   7711:     <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   7712: 
                   7713:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   7714:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   7715: 
                   7716:    </dd>
                   7717: 
                   7718:    <dt>A start tag whose tag name is "noframes"</dt>
                   7719:    <dd>
                   7720:     <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
                   7721:     mode</a>.</p>
                   7722:    </dd>
                   7723: 
                   7724:    <dt>An end-of-file token</dt>
                   7725:    <dd>
                   7726: 
                   7727:     <p>If the <a href="#current-node">current node</a> is not the root
1.159     mike     7728:     <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     7729:     error</a>.</p>
                   7730: 
                   7731:     <p class="note">It can only be the <a href="#current-node">current node</a> in
                   7732:     the <a href="#fragment-case">fragment case</a>.</p>
                   7733: 
                   7734:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7735: 
                   7736:    </dd>
                   7737: 
                   7738:    <dt>Anything else</dt>
                   7739:    <dd>
                   7740:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7741:    </dd>
                   7742: 
1.724     mike     7743:   </dl><h5 id="parsing-main-afterframeset"><span class="secno">7.2.5.24 </span>The "<dfn title="insertion mode: after frameset">after frameset</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     7744: 
                   7745:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterframeset" title="insertion
                   7746:   mode: after frameset">after frameset</a>", tokens must be handled as follows:</p>
                   7747: 
                   7748:   <!-- due to rules in the "in frameset" mode, this can't be entered in the fragment case -->
                   7749:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   7750:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   7751:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   7752:    <dd>
                   7753:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   7754:     the <a href="#current-node">current node</a>.</p>
                   7755:    </dd>
                   7756: 
                   7757:    <dt>A comment token</dt>
                   7758:    <dd>
                   7759:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   7760:     node</a> with the <code title="">data</code> attribute set to
                   7761:     the data given in the comment token.</p>
                   7762:    </dd>
                   7763: 
                   7764:    <dt>A DOCTYPE token</dt>
                   7765:    <dd>
                   7766:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7767:    </dd>
                   7768: 
                   7769:    <dt>A start tag whose tag name is "html"</dt>
                   7770:    <dd>
                   7771:     <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
                   7772:     mode</a>.</p>
                   7773:    </dd>
                   7774: 
                   7775:    <dt>An end tag whose tag name is "html"</dt>
                   7776:    <dd>
                   7777:     <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
                   7778:     frameset</a>".</p>
                   7779:    </dd>
                   7780: 
                   7781:    <dt>A start tag whose tag name is "noframes"</dt>
                   7782:    <dd>
                   7783:     <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
                   7784:     mode</a>.</p>
                   7785:    </dd>
                   7786: 
                   7787:    <dt>An end-of-file token</dt>
                   7788:    <dd>
                   7789:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7790:    </dd>
                   7791: 
                   7792:    <dt>Anything else</dt>
                   7793:    <dd>
                   7794:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7795:    </dd>
                   7796: 
1.724     mike     7797:   </dl><h5 id="the-after-after-body-insertion-mode"><span class="secno">7.2.5.25 </span>The "<dfn title="insertion mode: after after body">after after body</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     7798: 
                   7799:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-body-insertion-mode" title="insertion
                   7800:   mode: after after body">after after body</a>", tokens must be handled as follows:</p>
                   7801: 
                   7802:   <dl class="switch"><dt>A comment token</dt>
                   7803:    <dd>
                   7804:     <p>Append a <code>Comment</code> node to the <code>Document</code>
                   7805:     object with the <code title="">data</code> attribute set to the
                   7806:     data given in the comment token.</p>
                   7807:    </dd>
                   7808: 
                   7809:    <dt>A DOCTYPE token</dt>
                   7810:    <dt>A character token that is one of U+0009 CHARACTER
                   7811:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   7812:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   7813:    <dt>A start tag whose tag name is "html"</dt>
                   7814:    <dd>
                   7815:     <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
                   7816:     mode</a>.</p>
                   7817:    </dd>
                   7818: 
                   7819:    <dt>An end-of-file token</dt>
                   7820:    <dd>
                   7821:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7822:    </dd>
                   7823: 
                   7824:    <dt>Anything else</dt>
                   7825:    <dd>
                   7826:     <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion mode</a>
                   7827:     to "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" and
                   7828:     reprocess the token.</p>
                   7829:    </dd>
                   7830: 
1.724     mike     7831:   </dl><h5 id="the-after-after-frameset-insertion-mode"><span class="secno">7.2.5.26 </span>The "<dfn title="insertion mode: after after frameset">after after frameset</dfn>" insertion mode</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     7832: 
                   7833:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-frameset-insertion-mode" title="insertion
                   7834:   mode: after after frameset">after after frameset</a>", tokens must be handled as follows:</p>
                   7835: 
                   7836:   <dl class="switch"><dt>A comment token</dt>
                   7837:    <dd>
                   7838:     <p>Append a <code>Comment</code> node to the <code>Document</code>
                   7839:     object with the <code title="">data</code> attribute set to the
                   7840:     data given in the comment token.</p>
                   7841:    </dd>
                   7842: 
                   7843:    <dt>A DOCTYPE token</dt>
                   7844:    <dt>A character token that is one of U+0009 CHARACTER
                   7845:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   7846:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   7847:    <dt>A start tag whose tag name is "html"</dt>
                   7848:    <dd>
                   7849:     <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
                   7850:     mode</a>.</p>
                   7851:    </dd>
                   7852: 
                   7853:    <dt>An end-of-file token</dt>
                   7854:    <dd>
                   7855:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7856:    </dd>
                   7857: 
                   7858:    <dt>A start tag whose tag name is "noframes"</dt>
                   7859:    <dd>
                   7860:     <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
                   7861:     mode</a>.</p>
                   7862:    </dd>
                   7863: 
                   7864:    <dt>Anything else</dt>
                   7865:    <dd>
                   7866:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7867:    </dd>
                   7868: 
1.266     mike     7869:   </dl></div><div class="impl">
                   7870: 
1.724     mike     7871:   <h4 id="the-end"><span class="secno">7.2.6 </span>The end</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     7872: 
                   7873:   <p>Once the user agent <dfn id="stop-parsing" title="stop parsing">stops parsing</dfn>
1.484     mike     7874:   the document, the user agent must run the following steps:</p>
1.1       mike     7875: 
1.484     mike     7876:   <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
                   7877:    "interactive" <!-- this also synchronously fires an event --> and
                   7878:    the <a href="#insertion-point">insertion point</a> to undefined.</p></li>
                   7879: 
                   7880:    <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
                   7881:    document has finished parsing</a> is not empty, run these
                   7882:    substeps:</p>
                   7883: 
                   7884:     <ol><li><p><a href="browsers.html#spin-the-event-loop">Spin the event loop</a> until the first
                   7885:      <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
                   7886:      execute when the document has finished parsing</a> has its
                   7887:      <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag set <em>and</em> there
                   7888:      is no <a href="semantics.html#a-style-sheet-blocking-scripts" title="a style sheet blocking scripts">style sheet
                   7889:      blocking scripts</a>.</p></li>
                   7890: 
                   7891:      <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a> the
                   7892:      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
                   7893:      execute when the document has finished parsing</a>.</p></li>
                   7894: 
                   7895:      <li><p>Remove the first <code><a href="semantics.html#script">script</a></code> element from the
                   7896:      <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
                   7897:      finished parsing</a> (i.e. shift out the first entry in the
                   7898:      list).</p></li>
                   7899:  
                   7900:      <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
                   7901:      document has finished parsing</a> is still not empty, repeat
                   7902:      these substeps again from substep 1.</p>
                   7903: 
                   7904:     </li></ol></li>
                   7905: 
1.671     mike     7906:    <li><p><a href="browsers.html#spin-the-event-loop">Spin the event loop</a> until the <a href="semantics.html#list-of-scripts-that-will-execute-as-soon-as-possible">list of
1.484     mike     7907:    scripts that will execute as soon as possible</a> is
                   7908:    empty.</p></li>
                   7909: 
                   7910:    <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
                   7911:    event</a> named <code title="event-DOMContentLoaded">DOMContentLoaded</code> at the
                   7912:    <code>Document</code>.</p></li>
                   7913: 
                   7914:    <li><p><a href="browsers.html#spin-the-event-loop">Spin the event loop</a> until there is nothing that
                   7915:    <dfn id="delay-the-load-event" title="delay the load event">delays the load event</dfn> in
                   7916:    the <code>Document</code>.</p></li>
                   7917: 
                   7918:    <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
                   7919:    readiness</a> to "complete". <!-- this also fires an event
                   7920:    synchronously during the task --></p></li>
1.1       mike     7921: 
1.484     mike     7922:    <li><p>If the <code>Document</code> is in a <a href="browsers.html#browsing-context">browsing
1.1       mike     7923:    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     7924:    simple event</a> named <code title="event-load">load</code> at
1.1       mike     7925:    the <code>Document</code>'s <code><a href="browsers.html#window">Window</a></code> object, but with
                   7926:    its <code title="dom-event-target">target</code> set to the
                   7927:    <code>Document</code> object (and the <code title="dom-event-currentTarget">currentTarget</code> set to the
1.484     mike     7928:    <code><a href="browsers.html#window">Window</a></code> object).</p></li>
1.1       mike     7929: 
1.569     mike     7930:    <li><p>If the <code>Document</code> is in a <a href="browsers.html#browsing-context">browsing
                   7931:    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
                   7932:    simple event</a> named <code title="event-pageshow">pageshow</code> at the
                   7933:    <code>Document</code>'s <code><a href="browsers.html#window">Window</a></code> object.</p></li>
                   7934: 
1.484     mike     7935:    <li><p>If the <code>Document</code> has a <a href="history.html#pending-state-object">pending state
1.651     mike     7936:    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 at the
1.1       mike     7937:    <code>Document</code>'s <code><a href="browsers.html#window">Window</a></code> object using the
                   7938:    <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
                   7939:    current value of the <a href="history.html#pending-state-object">pending state object</a>. This event
1.484     mike     7940:    must bubble but not be cancelable and has no default
                   7941:    action.</p></li>
1.1       mike     7942: 
1.725     mike     7943:    <li><p>If the <code>Document</code> has any <a href="offline.html#pending-application-cache-download-process-tasks">pending
                   7944:    application cache download process tasks</a>, then <a href="browsers.html#queue-a-task" title="queue a task">queue</a> each such <a href="browsers.html#concept-task" title="concept-task">task</a> in the order they were added to
                   7945:    the list of <a href="offline.html#pending-application-cache-download-process-tasks">pending application cache download process
                   7946:    tasks</a>, and then empty the list of <a href="offline.html#pending-application-cache-download-process-tasks">pending application
                   7947:    cache download process tasks</a>. The <a href="browsers.html#task-source">task source</a>
                   7948:    for these <a href="browsers.html#concept-task" title="concept-task">tasks</a> is the
                   7949:    <a href="browsers.html#networking-task-source">networking task source</a>.</p></li>
                   7950: 
                   7951:    <li><p>The <code>Document</code> is now <dfn id="completely-loaded">completely
                   7952:    loaded</dfn>.</p></li>
                   7953: 
                   7954:   </ol><p>Except where otherwise specified, the <a href="browsers.html#task-source">task source</a>
                   7955:   for the <a href="browsers.html#concept-task" title="concept-task">tasks</a> mentioned in this
                   7956:   section is the <a href="browsers.html#dom-manipulation-task-source">DOM manipulation task source</a>.</p>
1.1       mike     7957: 
1.266     mike     7958:   </div><div class="impl">
1.1       mike     7959: 
1.724     mike     7960:   <h4 id="coercing-an-html-dom-into-an-infoset"><span class="secno">7.2.7 </span>Coercing an HTML DOM into an infoset</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     7961: 
                   7962:   <p>When an application uses an <a href="#html-parser">HTML parser</a> in
                   7963:   conjunction with an XML pipeline, it is possible that the
                   7964:   constructed DOM is not compatible with the XML tool chain in certain
                   7965:   subtle ways. For example, an XML toolchain might not be able to
                   7966:   represent attributes with the name <code title="">xmlns</code>,
                   7967:   since they conflict with the Namespaces in XML syntax. There is also
                   7968:   some data that the <a href="#html-parser">HTML parser</a> generates that isn't
                   7969:   included in the DOM itself. This section specifies some rules for
                   7970:   handling these issues.</p>
                   7971: 
                   7972:   <p>If the XML API being used doesn't support DOCTYPEs, the tool may
                   7973:   drop DOCTYPEs altogether.</p>
                   7974: 
                   7975:   <p>If the XML API doesn't support attributes in no namespace that
                   7976:   are named "<code title="">xmlns</code>", attributes whose names
                   7977:   start with "<code title="">xmlns:</code>", or attributes in the
1.724     mike     7978:   <a href="infrastructure.html#xmlns-namespace">XMLNS namespace</a>, then the tool may drop such
1.1       mike     7979:   attributes.</p>
                   7980: 
                   7981:   <p>The tool may annotate the output with any namespace declarations
                   7982:   required for proper operation.</p>
                   7983: 
                   7984:   <p>If the XML API being used restricts the allowable characters in
                   7985:   the local names of elements and attributes, then the tool may map
                   7986:   all element and attribute local names that the API wouldn't support
                   7987:   to a set of names that <em>are</em> allowed, by replacing any
                   7988:   character that isn't supported with the uppercase letter U and the
                   7989:   six digits of the character's Unicode code point when expressed in
                   7990:   hexadecimal, using digits 0-9 and capital letters A-F as the
                   7991:   symbols, in increasing numeric order.</p>
                   7992: 
                   7993:   <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
                   7994:   parser</a>, though it is neither a legal HTML element name nor a
                   7995:   well-formed XML element name, would be converted into <code title="">fooU00003Cbar</code>, which <em>is</em> a well-formed XML
                   7996:   element name (though it's still not legal in HTML by any means).</p>
                   7997: 
                   7998:   <p class="example">As another example, consider the attribute
                   7999:   <code>xlink:href</code>. Used on a MathML element, it becomes, after
                   8000:   being <a href="#adjust-foreign-attributes" title="adjust foreign attributes">adjusted</a>, an
                   8001:   attribute with a prefix "<code title="">xlink</code>" and a local
                   8002:   name "<code title="">href</code>". However, used on an HTML element,
                   8003:   it becomes an attribute with no prefix and the local name "<code title="">xlink:href</code>", which is not a valid NCName, and thus
                   8004:   might not be accepted by an XML API. It could thus get converted,
                   8005:   becoming "<code title="">xlinkU00003Ahref</code>".</p>
                   8006: 
                   8007:   <p class="note">The resulting names from this conversion
                   8008:   conveniently can't clash with any attribute generated by the
                   8009:   <a href="#html-parser">HTML parser</a>, since those are all either lowercase or
                   8010:   those listed in the <a href="#adjust-foreign-attributes">adjust foreign attributes</a>
                   8011:   algorithm's table.</p>
                   8012: 
                   8013:   <p>If the XML API restricts comments from having two consecutive
                   8014:   U+002D HYPHEN-MINUS characters (--), the tool may insert a single
                   8015:   U+0020 SPACE character between any such offending characters.</p>
                   8016: 
                   8017:   <p>If the XML API restricts comments from ending in a
                   8018:   U+002D HYPHEN-MINUS character (-), the tool may insert a single
                   8019:   U+0020 SPACE character at the end of such comments.</p>
                   8020: 
                   8021:   <p>If the XML API restricts allowed characters in character data,
1.439     mike     8022:   attribute values, or comments, the tool may replace any U+000C FORM
                   8023:   FEED (FF) character with a U+0020 SPACE character, and any other
                   8024:   literal non-XML character with a U+FFFD REPLACEMENT CHARACTER.</p>
1.1       mike     8025: 
                   8026:   <p>If the tool has no way to convey out-of-band information, then
                   8027:   the tool may drop the following information:</p>
                   8028: 
                   8029:   <ul><li>Whether the document is set to <i><a href="dom.html#no-quirks-mode">no quirks mode</a></i>,
                   8030:    <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>
                   8031: 
                   8032:    <li>The association between form controls and forms that aren't
                   8033:    their nearest <code><a href="forms.html#the-form-element">form</a></code> element ancestor (use of the
                   8034:    <a href="#form-element-pointer"><code>form</code> element pointer</a> in the parser)</li>
                   8035: 
                   8036:   </ul><p class="note">The mutations allowed by this section apply
                   8037:   <em>after</em> the <a href="#html-parser">HTML parser</a>'s rules have been
                   8038:   applied. For example, a <code title="">&lt;a::&gt;</code> start tag
                   8039:   will be closed by a <code title="">&lt;/a::&gt;</code> end tag, and
                   8040:   never by a <code title="">&lt;/aU00003AU00003A&gt;</code> end tag, even
                   8041:   if the user agent is using the rules above to then generate an
                   8042:   actual element in the DOM with the name <code title="">aU00003AU00003A</code> for that start tag.</p>
                   8043: 
1.266     mike     8044:   </div><div class="impl">
1.1       mike     8045: 
1.724     mike     8046:   <h4 id="an-introduction-to-error-handling-and-strange-cases-in-the-parser"><span class="secno">7.2.8 </span>An introduction to error handling and strange cases in the parser</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     8047: 
                   8048:   <p><i>This section is non-normative.</i></p>
                   8049: 
                   8050:   <p>This section examines some erroneous markup and discusses how
                   8051:   the <a href="#html-parser">HTML parser</a> handles these cases.</p>
                   8052: 
                   8053: 
1.724     mike     8054:   <h5 id="misnested-tags:-b-i-b-i"><span class="secno">7.2.8.1 </span>Misnested tags: &lt;b&gt;&lt;i&gt;&lt;/b&gt;&lt;/i&gt;</h5>
1.1       mike     8055: 
                   8056:   <p><i>This section is non-normative.</i></p>
                   8057: 
                   8058:   <p>The most-often discussed example of erroneous markup is as
                   8059:   follows:</p>
                   8060: 
                   8061:   <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>
                   8062: 
                   8063:   <p>The parsing of this markup is straightforward up to the "3". At
                   8064:   this point, the DOM looks like this:</p>
                   8065: 
1.159     mike     8066:   <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
                   8067:   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     8068:   <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
                   8069:   formatting elements</a> just has two: <code><a href="text-level-semantics.html#the-b-element">b</a></code> and
                   8070:   <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>
                   8071: 
                   8072:   <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is
                   8073:   invoked. This is a simple case, in that the <var title="">formatting
                   8074:   element</var> is the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element, and there is no
                   8075:   <var title="">furthest block</var>. Thus, the <a href="#stack-of-open-elements">stack of open
1.159     mike     8076:   elements</a> ends up with just three elements: <code><a href="semantics.html#the-html-element-0">html</a></code>,
                   8077:   <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     8078:   active formatting elements</a> has just one: <code><a href="text-level-semantics.html#the-i-element">i</a></code>. The
                   8079:   DOM tree is unmodified at this point.</p>
                   8080: 
                   8081:   <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
                   8082:   the active formatting elements</a>, in this case just the
                   8083:   <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
                   8084:   for the "4" text node. After the end tag token for the "i" is also
                   8085:   received, and the "5" text node is inserted, the DOM looks as
                   8086:   follows:</p>
                   8087: 
1.724     mike     8088:   <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">7.2.8.2 </span>Misnested tags: &lt;b&gt;&lt;p&gt;&lt;/b&gt;&lt;/p&gt;</h5>
1.1       mike     8089: 
                   8090:   <p><i>This section is non-normative.</i></p>
                   8091: 
                   8092:   <p>A case similar to the previous one is the following:</p>
                   8093: 
                   8094:   <pre>&lt;b&gt;1&lt;p&gt;2&lt;/b&gt;3&lt;/p&gt;</pre>
                   8095: 
                   8096:   <p>Up to the "2" the parsing here is straightforward:</p>
                   8097: 
1.159     mike     8098:   <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     8099:   "b" is parsed.</p>
                   8100: 
                   8101:   <p>Before that token is seen, the <a href="#stack-of-open-elements">stack of open
1.159     mike     8102:   elements</a> has four elements on it: <code><a href="semantics.html#the-html-element-0">html</a></code>,
                   8103:   <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     8104:   <a href="#list-of-active-formatting-elements">list of active formatting elements</a> just has the one:
                   8105:   <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>
                   8106: 
                   8107:   <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is invoked, as
                   8108:   in the previous example. However, in this case, there <em>is</em> a
                   8109:   <var title="">furthest block</var>, namely the <code><a href="semantics.html#the-p-element">p</a></code> element. Thus,
                   8110:   this time the adoption agency algorithm isn't skipped over.</p>
                   8111: 
1.159     mike     8112:   <p>The <var title="">common ancestor</var> is the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1       mike     8113:   element. A conceptual "bookmark" marks the position of the
                   8114:   <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
                   8115:   elements</a>, but since that list has only one element in it,
                   8116:   it won't have much effect.</p>
                   8117: 
                   8118:   <p>As the algorithm progresses, <var title="">node</var> ends up set
                   8119:   to the formatting element (<code><a href="text-level-semantics.html#the-b-element">b</a></code>), and <var title="">last
                   8120:   node</var> ends up set to the <var title="">furthest block</var>
                   8121:   (<code><a href="semantics.html#the-p-element">p</a></code>).</p>
                   8122: 
                   8123:   <p>The <var title="">last node</var> gets appended (moved) to the
                   8124:   <var title="">common ancestor</var>, so that the DOM looks like:</p>
                   8125: 
1.159     mike     8126:   <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     8127:   <code><a href="semantics.html#the-p-element">p</a></code> element are moved to it:</p>
                   8128: 
1.159     mike     8129:   <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     8130:   <code><a href="semantics.html#the-p-element">p</a></code> element, so that the DOM looks like:</p>
                   8131: 
1.159     mike     8132:   <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     8133:   active formatting elements</a> and the <a href="#stack-of-open-elements">stack of open
                   8134:   elements</a>, so that when the "3" is parsed, it is appended to
                   8135:   the <code><a href="semantics.html#the-p-element">p</a></code> element:</p>
                   8136: 
1.724     mike     8137:   <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">7.2.8.3 </span>Unexpected markup in tables</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     8138: 
                   8139:   <p><i>This section is non-normative.</i></p>
                   8140: 
                   8141:   <p>Error handling in tables is, for historical reasons, especially
                   8142:   strange. For example, consider the following markup:</p>
                   8143: 
                   8144:   <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>
                   8145: 
                   8146:   <p>The highlighted <code><a href="text-level-semantics.html#the-b-element">b</a></code> element start tag is not allowed
                   8147:   directly inside a table like that, and the parser handles this case
                   8148:   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
                   8149:   examining the DOM tree as it stands just after the
                   8150:   <code><a href="tabular-data.html#the-table-element">table</a></code> element's start tag has been seen:</p>
                   8151: 
1.159     mike     8152:   <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     8153:   tag has been seen:</p>
                   8154: 
1.159     mike     8155:   <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
                   8156:   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     8157:   <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
                   8158:   resulting DOM tree); the <a href="#list-of-active-formatting-elements">list of active formatting
                   8159:   elements</a> just has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it; and the
                   8160:   <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion mode: in
                   8161:   table">in table</a>".</p>
                   8162: 
                   8163:   <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
                   8164:   to be popped off the stack and a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> start tag to be
                   8165:   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
                   8166:   then handled in a rather straight-forward manner, taking the parser
                   8167:   through the "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   8168:   body</a>" and "<a href="#parsing-main-intr" title="insertion mode: in row">in
                   8169:   row</a>" insertion modes, after which the DOM looks as
                   8170:   follows:</p>
                   8171: 
1.159     mike     8172:   <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
                   8173:   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     8174:   <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
                   8175:   formatting elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in
                   8176:   it; and the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
                   8177:   mode: in row">in row</a>".</p>
                   8178: 
                   8179:   <p>The <code><a href="tabular-data.html#the-td-element">td</a></code> element start tag token, after putting a
                   8180:   <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
                   8181:   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
                   8182:   mode</a>).</p>
                   8183: 
1.159     mike     8184:   <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     8185:   no <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created to hold the resulting text
                   8186:   node:</p>
                   8187: 
1.159     mike     8188:   <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     8189:   handling them, the <a href="#stack-of-open-elements">stack of open elements</a> has on it the
1.159     mike     8190:   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     8191:   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
                   8192:   elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it (the
                   8193:   marker having been removed by the "td" end tag token); and the
                   8194:   <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion mode: in
                   8195:   table body">in table body</a>".</p>
                   8196: 
                   8197:   <p>Thus it is that the "bbb" character tokens are found. These
                   8198:   trigger the "<a href="#parsing-main-intabletext" title="insertion mode: in table text">in table
                   8199:   text</a>" insertion mode to be used (with the <a href="#original-insertion-mode">original
                   8200:   insertion mode</a> set to "<a href="#parsing-main-intbody" title="insertion mode: in table
                   8201:   body">in table body</a>"). The character tokens are collected,
                   8202:   and when the next token (the <code><a href="tabular-data.html#the-table-element">table</a></code> element end tag) is
                   8203:   seen, they are processed as a group. Since they are not all spaces,
                   8204:   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,
                   8205:   which defer to the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
                   8206:   body</a>" insertion mode but with <a href="#foster-parent" title="foster
                   8207:   parent">foster parenting</a>.</p>
                   8208: 
                   8209:   <p>When <a href="#reconstruct-the-active-formatting-elements" title="reconstruct the active formatting elements">the
                   8210:   active formatting elements are reconstructed</a>, a
                   8211:   <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created and <a href="#foster-parent" title="foster
                   8212:   parent">foster parented</a>, and then the "bbb" text node is
                   8213:   appended to it:</p>
                   8214: 
1.159     mike     8215:   <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
                   8216:   <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     8217:   <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
                   8218:   this doesn't match the resulting tree!); the <a href="#list-of-active-formatting-elements">list of active
                   8219:   formatting elements</a> has the new <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it;
                   8220:   and the <a href="#insertion-mode">insertion mode</a> is still "<a href="#parsing-main-intbody" title="insertion
                   8221:   mode: in table body">in table body</a>".</p>
                   8222: 
                   8223:   <p>Had the character tokens been only <a href="infrastructure.html#space-character" title="space
                   8224:   character">space characters</a> instead of "bbb", then those
                   8225:   <a href="infrastructure.html#space-character" title="space character">space characters</a> would just be
                   8226:   appended to the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element.</p>
                   8227: 
                   8228:   <p>Finally, the <code><a href="tabular-data.html#the-table-element">table</a></code> is closed by a "table" end
                   8229:   tag. This pops all the nodes from the <a href="#stack-of-open-elements">stack of open
                   8230:   elements</a> up to and including the <code><a href="tabular-data.html#the-table-element">table</a></code> element,
                   8231:   but it doesn't affect the <a href="#list-of-active-formatting-elements">list of active formatting
                   8232:   elements</a>, so the "ccc" character tokens after the table
                   8233:   result in yet another <code><a href="text-level-semantics.html#the-b-element">b</a></code> element being created, this
                   8234:   time after the table:</p>
                   8235: 
1.724     mike     8236:   <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">7.2.8.4 </span>Scripts that modify the page as it is being parsed</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     8237: 
                   8238:   <p><i>This section is non-normative.</i></p>
                   8239: 
                   8240:   <p>Consider the following markup, which for this example we will
                   8241:   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     8242:   content of an <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code> in another document with the
1.1       mike     8243:   <a href="infrastructure.html#url">URL</a> <code title="">http://example.com/outer</code>:</p>
                   8244: 
                   8245:   <pre>&lt;div id=a&gt;
                   8246:  &lt;script&gt;
                   8247:   var div = document.getElementById('a');
                   8248:   parent.document.body.appendChild(div);
                   8249:  &lt;/script&gt;
                   8250:  &lt;script&gt;
                   8251:   alert(document.URL);
                   8252:  &lt;/script&gt;
                   8253: &lt;/div&gt;
                   8254: &lt;script&gt;
                   8255:  alert(document.URL);
                   8256: &lt;/script&gt;</pre>
                   8257: 
                   8258:   <p>Up to the first "script" end tag, before the script is parsed,
                   8259:   the result is relatively straightforward:</p>
                   8260: 
1.306     mike     8261:   <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="">
                   8262:  </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     8263:   and its child <code><a href="semantics.html#script">script</a></code> element are gone:</p>
                   8264: 
1.159     mike     8265:   <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     8266:   aforementioned outer <a href="browsers.html#browsing-context">browsing context</a>. However, the
                   8267:   <a href="#stack-of-open-elements">stack of open elements</a> <em>still contains the
1.306     mike     8268:   <code><a href="semantics.html#the-div-element">div</a></code> element</em>.</p>
1.1       mike     8269: 
                   8270:   <p>Thus, when the second <code><a href="semantics.html#script">script</a></code> element is parsed, it
                   8271:   is inserted <em>into the outer <code>Document</code>
                   8272:   object</em>.</p>
                   8273: 
                   8274:   <p>This also means that the <a href="browsers.html#script-s-global-object">script's global object</a> is
                   8275:   the outer <a href="browsers.html#browsing-context">browsing context</a>'s <code><a href="browsers.html#window">Window</a></code>
                   8276:   object, <em>not</em> the <code><a href="browsers.html#window">Window</a></code> object inside the
1.159     mike     8277:   <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code>.</p>
1.1       mike     8278: 
                   8279:   <p class="note">This isn't a security problem since the script that
1.306     mike     8280:   moves the <code><a href="semantics.html#the-div-element">div</a></code> into the outer <code>Document</code> can
1.714     mike     8281:   only do so because the two <code>Document</code> object have the
                   8282:   same <a href="browsers.html#origin">origin</a>.</p>
1.1       mike     8283: 
                   8284:   <p>Thus, the first alert says "http://example.com/outer".</p>
                   8285: 
1.306     mike     8286:   <p>Once the <code><a href="semantics.html#the-div-element">div</a></code> element's end tag is parsed, the
                   8287:   <code><a href="semantics.html#the-div-element">div</a></code> element is popped off the stack, and so the next
1.1       mike     8288:   <code><a href="semantics.html#script">script</a></code> element is in the inner <code>Document</code>:</p>
                   8289: 
1.159     mike     8290:   <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     8291: 
                   8292: 
                   8293: 
                   8294: 
1.724     mike     8295:   <h3 id="serializing-html-fragments"><span class="secno">7.3 </span>Serializing HTML fragments</h3><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     8296: 
                   8297:   <p>The following steps form the <dfn id="html-fragment-serialization-algorithm">HTML fragment serialization
                   8298:   algorithm</dfn>. The algorithm takes as input a DOM
                   8299:   <code>Element</code> or <code>Document</code>, referred to as <var title="">the node</var>, and either returns a string or raises an
                   8300:   exception.</p>
                   8301: 
                   8302:   <p class="note">This algorithm serializes the <em>children</em> of
                   8303:   the node being serialized, not the node itself.</p>
                   8304: 
                   8305:   <ol><li><p>Let <var title="">s</var> be a string, and initialize it to
                   8306:    the empty string.</p></li>
                   8307: 
                   8308:    <li>
                   8309: 
                   8310:     <p>For each child node of <var title="">the node</var>, in
                   8311:     <a href="infrastructure.html#tree-order">tree order</a>, run the following steps:
                   8312: 
                   8313:     </p><ol><li><p>Let <var title="">current node</var> be the child node
                   8314:      being processed.</p></li>
                   8315: 
                   8316:      <li>
                   8317: 
                   8318:       <p>Append the appropriate string from the following list to
                   8319:       <var title="">s</var>:</p>
                   8320: 
                   8321:       <dl class="switch"><dt>If <var title="">current node</var> is an <code title="">Element</code></dt>
                   8322: 
                   8323:        <dd>
                   8324: 
1.588     mike     8325:         <p>Append a U+003C LESS-THAN SIGN character character (&lt;),
                   8326:         followed by the element's tag name. (For nodes created by the
                   8327:         <a href="#html-parser">HTML parser</a> or <code title="">Document.createElement()</code>, the tag name will be
1.1       mike     8328:         lowercase.)</p>
                   8329: 
                   8330:         <p>For each attribute that the element has, append a U+0020
                   8331:         SPACE character, the attribute's name (which, for attributes
                   8332:         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
1.588     mike     8333:         U+003D EQUALS SIGN character (=), a U+0022 QUOTATION MARK
                   8334:         character ("), the attribute's value, <a href="#escapingString" title="escaping a string">escaped as described below</a> in
                   8335:         <i>attribute mode</i>, and a second U+0022 QUOTATION MARK
                   8336:         character (").</p>
1.1       mike     8337: 
                   8338:         <p>While the exact order of attributes is UA-defined, and may
                   8339:         depend on factors such as the order that the attributes were
                   8340:         given in the original markup, the sort order must be stable,
                   8341:         such that consecutive invocations of this algorithm serialize an
                   8342:         element's attributes in the same order.</p>
                   8343: 
1.588     mike     8344:         <p>Append a U+003E GREATER-THAN SIGN character (&gt;).</p>
1.1       mike     8345: 
                   8346:         <p>If <var title="">current node</var> is an
1.5       mike     8347:         <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.724     mike     8348:         <code><a href="obsolete.html#bgsound">bgsound</a></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     8349:         <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>,
                   8350:         <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>,
1.589     mike     8351:         <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>, or
1.724     mike     8352:         <code><a href="obsolete.html#wbr">wbr</a></code> element, then continue on to the next child
1.589     mike     8353:         node at this point.</p> <!-- also, i guess: image and isindex,
                   8354:         but we don't list those because we don't consider those
                   8355:         "elements", more "macros", and thus we should never serialize
                   8356:         them -->
1.1       mike     8357: 
                   8358:         <p>If <var title="">current node</var> is a <code><a href="semantics.html#the-pre-element">pre</a></code>,
1.42      mike     8359:         <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     8360:         a U+000A LINE FEED (LF) character.</p>
                   8361: 
                   8362:         <p>Append the value of running the <a href="#html-fragment-serialization-algorithm">HTML fragment
                   8363:         serialization algorithm</a> on the <var title="">current
                   8364:         node</var> element (thus recursing into this algorithm for
1.588     mike     8365:         that element), followed by a U+003C LESS-THAN SIGN character
                   8366:         (&lt;), a U+002F SOLIDUS character (/), the element's tag name
                   8367:         again, and finally a U+003E GREATER-THAN SIGN character
                   8368:         (&gt;).</p>
1.1       mike     8369: 
                   8370:        </dd>
                   8371: 
                   8372: 
                   8373:        <dt>If <var title="">current node</var> is a <code title="">Text</code> or <code title="">CDATASection</code>
                   8374:        node</dt>
                   8375: 
                   8376:        <dd>
                   8377: 
1.19      mike     8378:         <p>If the parent of <var title="">current node</var> is a
1.42      mike     8379:         <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     8380:         <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     8381:         <code><a href="obsolete.html#noframes">noframes</a></code>, or <code><a href="obsolete.html#plaintext">plaintext</a></code> element, or
                   8382:         if the parent of <var title="">current node</var> is
                   8383:         <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
                   8384:         node, then append the value of <var title="">current
                   8385:         node</var>'s <code title="">data</code> IDL attribute
                   8386:         literally.</p>
1.1       mike     8387: 
                   8388:         <p>Otherwise, append the value of <var title="">current
1.192     mike     8389:         node</var>'s <code title="">data</code> IDL attribute, <a href="#escapingString" title="escaping a string">escaped as described
1.1       mike     8390:         below</a>.</p>
                   8391: 
                   8392:        </dd>
                   8393: 
                   8394: 
                   8395:        <dt>If <var title="">current node</var> is a <code title="">Comment</code></dt>
                   8396: 
                   8397:        <dd>
                   8398: 
                   8399:         <p>Append the literal string <code>&lt;!--</code> (U+003C
                   8400:         LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS,
1.192     mike     8401:         U+002D HYPHEN-MINUS), followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1       mike     8402:         attribute, followed by the literal string <code>--&gt;</code>
                   8403:         (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN
                   8404:         SIGN).</p>
                   8405: 
                   8406:        </dd>
                   8407: 
                   8408: 
                   8409:        <dt>If <var title="">current node</var> is a <code title="">ProcessingInstruction</code></dt>
                   8410: 
                   8411:        <dd>
                   8412: 
                   8413:         <p>Append the literal string <code>&lt;?</code> (U+003C
                   8414:         LESS-THAN SIGN, U+003F QUESTION MARK), followed by the value
1.192     mike     8415:         of <var title="">current node</var>'s <code title="">target</code> IDL attribute, followed by a single
                   8416:         U+0020 SPACE character, followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1       mike     8417:         attribute, followed by a single U+003E GREATER-THAN SIGN
1.464     mike     8418:         character (&gt;).</p>
1.1       mike     8419: 
                   8420:        </dd>
                   8421: 
                   8422: 
                   8423:        <dt>If <var title="">current node</var> is a <code title="">DocumentType</code></dt>
                   8424: 
                   8425:        <dd>
                   8426: 
                   8427:         <p>Append the literal string <code>&lt;!DOCTYPE</code> (U+003C
                   8428:         LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+0044 LATIN CAPITAL
                   8429:         LETTER D, U+004F LATIN CAPITAL LETTER O, U+0043 LATIN CAPITAL
                   8430:         LETTER C, U+0054 LATIN CAPITAL LETTER T, U+0059 LATIN CAPITAL
                   8431:         LETTER Y, U+0050 LATIN CAPITAL LETTER P, U+0045 LATIN CAPITAL
                   8432:         LETTER E), followed by a space (U+0020 SPACE), followed by the
1.192     mike     8433:         value of <var title="">current node</var>'s <code title="">name</code> IDL attribute, followed by the literal
1.1       mike     8434:         string <code>&gt;</code> (U+003E GREATER-THAN SIGN).</p>
                   8435: 
                   8436:        </dd>
                   8437: 
                   8438: 
                   8439:       </dl><p>Other node types (e.g. <code title="">Attr</code>) cannot
                   8440:       occur as children of elements. If, despite this, they somehow do
                   8441:       occur, this algorithm must raise an
                   8442:       <code><a href="infrastructure.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception.</p>
                   8443: 
                   8444:      </li>
                   8445: 
                   8446:     </ol></li>
                   8447: 
                   8448:    <li><p>The result of the algorithm is the string <var title="">s</var>.</p></li>
                   8449: 
                   8450:   </ol><p><dfn id="escapingString">Escaping a string</dfn> (for the
                   8451:   purposes of the algorithm above) consists of replacing any
                   8452:   occurrences of the "<code title="">&amp;</code>" character by the
                   8453:   string "<code title="">&amp;amp;</code>", any occurrences of the
                   8454:   U+00A0 NO-BREAK SPACE character by the string "<code title="">&amp;nbsp;</code>", and, if the algorithm was invoked in
                   8455:   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
                   8456:   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>
                   8457: 
                   8458:   <p class="note">Entity reference nodes are <a href="infrastructure.html#entity-references">assumed to be expanded</a> by the user
                   8459:   agent, and are therefore not covered in the algorithm above.</p>
                   8460: 
                   8461:   <p class="note">It is possible that the output of this algorithm, if
                   8462:   parsed with an <a href="#html-parser">HTML parser</a>, will not return the
                   8463:   original tree structure. For instance, if a <code><a href="forms.html#the-textarea-element">textarea</a></code>
                   8464:   element to which a <code title="">Comment</code> node has been
                   8465:   appended is serialized and the output is then reparsed, the comment
                   8466:   will end up being displayed in the text field. Similarly, if, as a
                   8467:   result of DOM manipulation, an element contains a comment that
                   8468:   contains the literal string "<code title="">--&gt;</code>", then
                   8469:   when the result of serializing the element is parsed, the comment
                   8470:   will be truncated at that point and the rest of the comment will be
                   8471:   interpreted as markup. More examples would be making a
                   8472:   <code><a href="semantics.html#script">script</a></code> element contain a text node with the text string
                   8473:   "<code>&lt;/script&gt;</code>", or having a <code><a href="semantics.html#the-p-element">p</a></code> element that
                   8474:   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
                   8475:   <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> would imply the end
                   8476:   tag for the <code><a href="semantics.html#the-p-element">p</a></code>).</p>
                   8477: 
                   8478: 
1.724     mike     8479:   <h3 id="parsing-html-fragments"><span class="secno">7.4 </span>Parsing HTML fragments</h3><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     8480: 
                   8481:   <p>The following steps form the <dfn id="html-fragment-parsing-algorithm">HTML fragment parsing
                   8482:   algorithm</dfn>. The algorithm optionally takes as input an
                   8483:   <code>Element</code> node, referred to as the <var title="">context</var> element, which gives the context for the
                   8484:   parser, as well as <var title="">input</var>, a string to parse, and
                   8485:   returns a list of zero or more nodes.</p>
                   8486: 
                   8487:   <p class="note">Parts marked <dfn id="fragment-case">fragment case</dfn> in algorithms
                   8488:   in the parser section are parts that only occur if the parser was
                   8489:   created for the purposes of this algorithm (and with a <var title="">context</var> element). The algorithms have been annotated
                   8490:   with such markings for informational purposes only; such markings
                   8491:   have no normative weight. If it is possible for a condition
                   8492:   described as a <a href="#fragment-case">fragment case</a> to occur even when the
                   8493:   parser wasn't created for the purposes of handling this algorithm,
                   8494:   then that is an error in the specification.</p>
                   8495: 
                   8496:   <ol><li>
                   8497: 
                   8498:     <p>Create a new <code>Document</code> node, and mark it as being
                   8499:     an <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
                   8500: 
                   8501:    </li>
                   8502: 
                   8503:    <li>
                   8504: 
                   8505:     <p>If there is a <var title="">context</var> element, and the
                   8506:     <code>Document</code> of the <var title="">context</var> element
                   8507:     is in <a href="dom.html#quirks-mode">quirks mode</a>, then let the <code>Document</code>
                   8508:     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
                   8509:     the <var title="">context</var> element is in <a href="dom.html#limited-quirks-mode">limited quirks
                   8510:     mode</a>, then let the <code>Document</code> be in
                   8511:     <a href="dom.html#limited-quirks-mode">limited quirks mode</a>. Otherwise, leave the
                   8512:     <code>Document</code> in <a href="dom.html#no-quirks-mode">no quirks mode</a>.</p>
                   8513: 
                   8514:    </li>
                   8515: 
                   8516:    <li>
                   8517: 
                   8518:     <p>Create a new <a href="#html-parser">HTML parser</a>, and associate it with
                   8519:     the just created <code>Document</code> node.</p>
                   8520: 
                   8521:    </li>
                   8522: 
                   8523:    <li>
                   8524: 
                   8525:     <p>If there is a <var title="">context</var> element, run these
                   8526:     substeps:</p>
                   8527: 
                   8528:     <ol><li>
                   8529: 
1.541     mike     8530:       <p>Set the state of the <a href="#html-parser">HTML parser</a>'s
                   8531:       <a href="#tokenization">tokenization</a> stage as follows:</p>
1.1       mike     8532: 
1.159     mike     8533:       <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     8534:        element</dt>
                   8535: 
1.541     mike     8536:        <dd>Switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1       mike     8537: 
                   8538: 
1.672     mike     8539:        <dt>If it is a <code><a href="semantics.html#the-style-element">style</a></code>, <code><a href="obsolete.html#xmp">xmp</a></code>,
                   8540:        <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     8541:        <code><a href="obsolete.html#noframes">noframes</a></code> element</dt>
1.1       mike     8542: 
1.541     mike     8543:        <dd>Switch the tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1       mike     8544: 
                   8545: 
1.672     mike     8546:        <dt>If it is a <code><a href="semantics.html#script">script</a></code> element</dt>
                   8547: 
                   8548:        <dd>Switch the tokenizer to the <a href="#script-data-state">script data state</a>.</dd>
                   8549: 
                   8550: 
1.1       mike     8551:        <dt>If it is a <code><a href="semantics.html#the-noscript-element">noscript</a></code> element</dt>
                   8552: 
1.541     mike     8553:        <dd>If the <a href="#scripting-flag">scripting flag</a> is enabled, switch the
                   8554:        tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>.  Otherwise,
                   8555:        leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1       mike     8556: 
                   8557: 
1.42      mike     8558:        <dt>If it is a <code><a href="obsolete.html#plaintext">plaintext</a></code> element</dt>
1.1       mike     8559: 
1.541     mike     8560:        <dd>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT
                   8561:        state</a>.</dd>
1.1       mike     8562: 
                   8563: 
                   8564:        <dt>Otherwise</dt>
                   8565: 
1.541     mike     8566:        <dd>Leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1       mike     8567: 
1.672     mike     8568:       </dl><p class="note">For performance reasons, an implementation that
                   8569:       uses the actual state machine described in this specification
                   8570:       directly could use the PLAINTEXT state instead of the RAWTEXT
                   8571:       and script data states where those are mentioned in the list
                   8572:       above. They are equivalent, since there is no <a href="#appropriate-end-tag-token">appropriate
                   8573:       end tag token</a> in the fragment case, but involve far fewer
                   8574:       state transitions.</p>
                   8575: 
                   8576:      </li>
1.1       mike     8577: 
                   8578:      <li>
                   8579: 
1.159     mike     8580:       <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     8581:       with no attributes.</p>
                   8582: 
                   8583:      </li>
                   8584: 
                   8585:      <li>
                   8586: 
                   8587:       <p>Append the element <var title="">root</var> to the
                   8588:       <code>Document</code> node created above.</p>
                   8589: 
                   8590:      </li>
                   8591: 
                   8592:      <li>
                   8593: 
                   8594:       <p>Set up the parser's <a href="#stack-of-open-elements">stack of open elements</a> so that
                   8595:       it contains just the single element <var title="">root</var>.</p>
                   8596: 
                   8597:      </li>
                   8598: 
                   8599:      <li>
                   8600: 
                   8601:       <p><a href="#reset-the-insertion-mode-appropriately" title="reset the insertion mode appropriately">Reset the
                   8602:       parser's insertion mode appropriately</a>.</p>
                   8603: 
                   8604:       <p class="note">The parser will reference the <var title="">context</var> element as part of that algorithm.</p>
                   8605: 
                   8606:      </li>
                   8607: 
                   8608:      <li>
                   8609: 
                   8610:       <p>Set the parser's <a href="#form-element-pointer"><code>form</code> element pointer</a>
                   8611:       to the nearest node to the <var title="">context</var> element
                   8612:       that is a <code><a href="forms.html#the-form-element">form</a></code> element (going straight up the
                   8613:       ancestor chain, and including the element itself, if it is a
                   8614:       <code><a href="forms.html#the-form-element">form</a></code> element), or, if there is no such
                   8615:       <code><a href="forms.html#the-form-element">form</a></code> element, to null.</p>
                   8616: 
                   8617:      </li>
                   8618: 
                   8619:     </ol></li>
                   8620: 
                   8621:    <li>
                   8622: 
                   8623:     <p>Place into the <a href="#the-input-stream">input stream</a> for the <a href="#html-parser">HTML
                   8624:     parser</a> just created the <var title="">input</var>. The
                   8625:     encoding <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
                   8626:     <i>irrelevant</i>.</p>
                   8627: 
                   8628:    </li>
                   8629: 
                   8630:    <li>
                   8631: 
                   8632:     <p>Start the parser and let it run until it has consumed all the
                   8633:     characters just inserted into the input stream.</p>
                   8634: 
                   8635:    </li>
                   8636: 
                   8637:    <li>
                   8638: 
                   8639:     <p>If there is a <var title="">context</var> element, return the
                   8640:     child nodes of <var title="">root</var>, in <a href="infrastructure.html#tree-order">tree
                   8641:     order</a>.</p>
                   8642: 
                   8643:     <p>Otherwise, return the children of the <code>Document</code>
                   8644:     object, in <a href="infrastructure.html#tree-order">tree order</a>.</p>
                   8645: 
                   8646:    </li>
                   8647: 
1.123     mike     8648:   </ol></div></body></html>

Webmaster