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

1.2       mike        1: <!DOCTYPE HTML>
1.755     mike        2: <!-- when publishing, change bits marked ZZZ --><html lang="en-US-x-Hixie"><head><title>8 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.736     mike      169:    body.dfnEnabled dfn { cursor: pointer; }
                    170:    .dfnPanel {
                    171:      display: inline;
                    172:      position: absolute;
                    173:      z-index: 10;
                    174:      height: auto;
                    175:      width: auto;
                    176:      padding: 0.5em 0.75em;
                    177:      font: small sans-serif, Droid Sans Fallback;
                    178:      background: #DDDDDD;
                    179:      color: black;
                    180:      border: outset 0.2em;
                    181:    }
                    182:    .dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
                    183:    .dfnPanel :link, .dfnPanel :visited { color: black; }
                    184:    .dfnPanel p { font-weight: bolder; }
                    185:    .dfnPanel * + p { margin-top: 0.25em; }
                    186:    .dfnPanel li { list-style-position: inside; }
                    187: 
1.671     mike      188:    #configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
                    189:    #configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
                    190:    #configUI p label { display: block; }
                    191:    #configUI #updateUI, #configUI .loginUI { text-align: center; }
                    192:    #configUI input[type=button] { display: block; margin: auto; }
1.267     mike      193:   </style><style type="text/css">
                    194: 
1.292     mike      195:    .applies thead th > * { display: block; }
                    196:    .applies thead code { display: block; }
                    197:    .applies tbody th { whitespace: nowrap; }
                    198:    .applies td { text-align: center; }
                    199:    .applies .yes { background: yellow; }
                    200: 
1.267     mike      201:    .matrix, .matrix td { border: none; text-align: right; }
                    202:    .matrix { margin-left: 2em; }
                    203: 
                    204:    .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
                    205:    .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
                    206:    .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
                    207: 
                    208:    #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
                    209:    #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
                    210:    #table-example-1 caption { padding-bottom: 0.5em; }
                    211:    #table-example-1 thead, #table-example-1 tbody { border: none; }
                    212:    #table-example-1 th, #table-example-1 td { border: solid thin; }
                    213:    #table-example-1 th { font-weight: normal; }
                    214:    #table-example-1 td { border-style: none solid; vertical-align: top; }
                    215:    #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
                    216:    #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
                    217:    #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
                    218:    #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
                    219:    #table-example-1 tbody td:first-child::after { content: leader(". "); }
                    220:    #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
                    221:    #table-example-1 tbody td:first-child + td { width: 10em; }
                    222:    #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
                    223:    #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
                    224: 
                    225:    .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
                    226:    .apple-table-examples * { font-family: "Times", serif; }
                    227:    .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
                    228:    .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
                    229:    .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
                    230:    .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
                    231:    .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
                    232:    .apple-table-examples td { text-align: right; vertical-align: top; }
                    233:    .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
                    234:    .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
                    235:    .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
                    236:    .apple-table-examples sup { line-height: 0; }
                    237: 
1.724     mike      238:    .details-example img { vertical-align: top; }
                    239: 
                    240:   </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      241:    function getCookie(name) {
                    242:      var params = location.search.substr(1).split("&");
                    243:      for (var index = 0; index < params.length; index++) {
                    244:        if (params[index] == name)
                    245:          return "1";
                    246:        var data = params[index].split("=");
                    247:        if (data[0] == name)
                    248:          return unescape(data[1]);
                    249:      }
                    250:      var cookies = document.cookie.split("; ");
                    251:      for (var index = 0; index < cookies.length; index++) {
                    252:        var data = cookies[index].split("=");
                    253:        if (data[0] == name)
                    254:          return unescape(data[1]);
                    255:      }
                    256:      return null;
                    257:    }
                    258:    function load(script) {
                    259:      var e = document.createElement('script');
                    260:      e.setAttribute('src', 'http://www.whatwg.org/specs/web-apps/current-work/' + script + '?' + encodeURIComponent(location) + '&' + encodeURIComponent(document.referrer));
                    261:      document.body.appendChild(e);
                    262:    }
                    263:    function init() {
                    264:      if (location.search == '?slow-browser')
                    265:        return;
                    266:      var configUI = document.createElement('div');
                    267:      configUI.id = 'configUI';
                    268:      document.body.appendChild(configUI);
                    269:      // load('reviewer.js'); // would need cross-site XHR
                    270:      if (document.getElementById('head'))
                    271:        load('toc.js');
                    272:      load('styler.js');
                    273:      // load('updater.js'); // would need cross-site XHR
1.724     mike      274:      load('dfn.js'); // doesn't support split-out specs, but, oh well.
1.671     mike      275:      // load('status.js'); // would need cross-site XHR
                    276:      if (getCookie('profile') == '1')
                    277:        document.getElementsByTagName('h2')[0].textContent += '; load: ' + (new Date() - loadTimer) + 'ms';
                    278:      fixBrokenLink();
                    279:    }
                    280:   </script><link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel="stylesheet" type="text/css">
1.2       mike      281:   <script src="link-fixup.js"></script>
1.755     mike      282:   <link href="editing.html" title="7 User interaction" rel="prev">
1.2       mike      283:   <link href="spec.html#contents" title="Table of contents" rel="index">
1.755     mike      284:   <link href="named-character-references.html" title="8.5 Named character references" rel="next">
1.671     mike      285:   </head><body onload="fixBrokenLink(); init()"><div class="head" id="head">
1.1       mike      286:    <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      287:    <h1>HTML5</h1>
1.1       mike      288:    <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      289: 
1.123     mike      290:    </div><nav>
1.755     mike      291:    <a href="editing.html">&#8592; 7 User interaction</a> &#8211;
1.2       mike      292:    <a href="spec.html#contents">Table of contents</a> &#8211;
1.755     mike      293:    <a href="named-character-references.html">8.5 Named character references &#8594;</a>
1.779   ! mike      294:   </nav><p>This is revision 1.3757.</p>
1.659     mike      295: 
1.1       mike      296: 
1.755     mike      297:   <h2 id="syntax"><span class="secno">8 </span><dfn>The HTML syntax</dfn></h2><p class="note">This section only describes the rules for resources
1.725     mike      298:   labeled with an <a href="infrastructure.html#html-mime-type">HTML MIME type</a>. Rules for XML resources
                    299:   are discussed in the section below entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
1.755     mike      300:   syntax</a>".</p><h3 id="writing"><span class="secno">8.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      301: 
                    302:   <p><i>This section only applies to documents, authoring tools, and
                    303:   markup generators. In particular, it does not apply to conformance
                    304:   checkers; conformance checkers must use the requirements given in
                    305:   the next section ("parsing HTML documents").</i></p>
                    306: 
1.123     mike      307:   </div><p>Documents must consist of the following parts, in the given
                    308:   order:</p><ol><li>Optionally, a single U+FEFF BYTE ORDER MARK (BOM) character.</li>
1.1       mike      309: 
                    310:    <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
                    311:    <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    312: 
                    313:    <li>A <a href="#syntax-doctype" title="syntax-doctype">DOCTYPE</a>.
                    314: 
                    315:    </li><li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
                    316:    <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    317: 
1.159     mike      318:    <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      319: 
                    320:    <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
                    321:    <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    322: 
                    323:   </ol><p>The various types of content mentioned above are described in the
1.123     mike      324:   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      325:   declarations</a> are to be serialized, as discussed in the
1.123     mike      326:   section on that topic.</p><div class="note">
1.1       mike      327: 
1.159     mike      328:    <p>Space characters before the root <code><a href="semantics.html#the-html-element-0">html</a></code> element, and
                    329:    space characters at the start of the <code><a href="semantics.html#the-html-element-0">html</a></code> element and
                    330:    before the <code><a href="semantics.html#the-head-element-0">head</a></code> element, will be dropped when the
1.1       mike      331:    document is parsed; space characters <em>after</em> the root
1.159     mike      332:    <code><a href="semantics.html#the-html-element-0">html</a></code> element will be parsed as if they were at the end
                    333:    of the <code><a href="semantics.html#the-body-element-0">body</a></code> element. Thus, space characters around the
1.1       mike      334:    root element do not round-trip.</p>
                    335: 
                    336:    <p>It is suggested that newlines be inserted after the DOCTYPE,
                    337:    after any comments that are before the root element, after the
1.159     mike      338:    <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
                    339:    that are inside the <code><a href="semantics.html#the-html-element-0">html</a></code> element but before the
                    340:    <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1       mike      341: 
1.123     mike      342:   </div><p>Many strings in the HTML syntax (e.g. the names of elements and
1.1       mike      343:   their attributes) are case-insensitive, but only for characters in
1.547     mike      344:   the ranges U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL
                    345:   LETTER Z) and U+0061 to U+007A (LATIN SMALL LETTER A to LATIN SMALL
1.1       mike      346:   LETTER Z). For convenience, in this section this is just referred to
1.755     mike      347:   as "case-insensitive".</p><h4 id="the-doctype"><span class="secno">8.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      348:   but required, header.</p><p class="note">DOCTYPEs are required for legacy reasons. When
1.1       mike      349:   omitted, browsers tend to use a different rendering mode that is
                    350:   incompatible with some specifications. Including the DOCTYPE in a
                    351:   document ensures that the browser makes a best-effort attempt at
1.123     mike      352:   following the relevant specifications.</p><p>A DOCTYPE must consist of the following characters, in this
1.588     mike      353:   order:</p><ol class="brief"><li>A U+003C LESS-THAN SIGN character (&lt;).</li>
                    354:    <li>A U+0021 EXCLAMATION MARK character (!).</li>
1.1       mike      355:    <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>
                    356:    <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    357:    <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>
                    358:    <li>Optionally, a <a href="#doctype-legacy-string">DOCTYPE legacy string</a> (defined below).</li>
                    359:    <li>Zero or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
1.588     mike      360:    <li>A U+003E GREATER-THAN SIGN character (&gt;).</li>
1.1       mike      361:   </ol><p class="note">In other words, <code>&lt;!DOCTYPE HTML&gt;</code>,
1.123     mike      362:   case-insensitively.</p><p>For the purposes of HTML generators that cannot output HTML
1.1       mike      363:   markup with the short DOCTYPE "<code title="">&lt;!DOCTYPE
                    364:   HTML&gt;</code>", a <dfn id="doctype-legacy-string">DOCTYPE legacy string</dfn> may be inserted
                    365:   into the DOCTYPE (in the position defined above). This string must
1.123     mike      366:   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      367:    <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      368:    <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
1.1       mike      369:    <li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>quote mark</i>).</li>
1.465     mike      370:    <li>The literal string "<code><a href="infrastructure.html#about:legacy-compat">about:legacy-compat</a></code>".</li>
1.1       mike      371:    <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>
                    372:   </ol><p class="note">In other words, <code>&lt;!DOCTYPE HTML SYSTEM
                    373:   "about:legacy-compat"&gt;</code> or <code>&lt;!DOCTYPE HTML SYSTEM
                    374:   'about:legacy-compat'&gt;</code>, case-insensitively except for the bit
1.724     mike      375:   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      376:   the document is generated from a system that cannot output the
1.755     mike      377:   shorter string.</p><h4 id="elements-0"><span class="secno">8.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      378:   <a href="#raw-text-elements">raw text elements</a>, <a href="#rcdata-elements">RCDATA elements</a>,
                    379:   <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      380: 
                    381:    <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      382:    <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>,
                    383:    <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      384:    <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      385:    <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      386: 
1.373     mike      387:    <dt><dfn id="raw-text-elements">Raw text elements</dfn></dt>
1.1       mike      388: 
                    389:    <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      390:    noscript don't count as raw text for syntax purposes -->
1.1       mike      391: 
1.373     mike      392:    <dt><dfn id="rcdata-elements">RCDATA elements</dfn></dt>
1.1       mike      393: 
1.159     mike      394:    <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      395: 
1.373     mike      396:    <dt><dfn id="foreign-elements">Foreign elements</dfn></dt>
1.1       mike      397: 
1.724     mike      398:    <dd>Elements from the <a href="infrastructure.html#mathml-namespace">MathML namespace</a>
                    399:    and the <a href="infrastructure.html#svg-namespace">SVG namespace</a>.</dd>
1.1       mike      400: 
1.373     mike      401:    <dt><dfn id="normal-elements">Normal elements</dfn></dt>
1.1       mike      402: 
                    403:    <dd>All other allowed <a href="infrastructure.html#html-elements">HTML elements</a> are normal
                    404:    elements.</dd>
                    405: 
                    406:   </dl><p><dfn id="syntax-tags" title="syntax-tags">Tags</dfn> are used to delimit the start
1.373     mike      407:   and end of elements in the markup. <a href="#raw-text-elements" title="raw text
                    408:   elements">Raw text</a>, <a href="#rcdata-elements" title="RCDATA
                    409:   elements">RCDATA</a>, and <a href="#normal-elements" title="normal
                    410:   elements">normal</a> elements have a <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> to indicate where they
                    411:   begin, and an <a href="#syntax-end-tag" title="syntax-end-tag">end tag</a> to
                    412:   indicate where they end. The start and end tags of certain
                    413:   <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      414:   later. Those that cannot be omitted must not be omitted. <a href="#void-elements">Void
                    415:   elements</a> only have a start tag; end tags must not be
1.373     mike      416:   specified for <a href="#void-elements">void elements</a>. <a href="#foreign-elements">Foreign
                    417:   elements</a> must either have a start tag and an end tag, or a
                    418:   start tag that is marked as self-closing, in which case they must
                    419:   not have an end tag.</p><p>The contents of the element must be placed between just after the
1.1       mike      420:   start tag (which <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied,
                    421:   in certain cases</a>) and just before the end tag (which again,
                    422:   <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied in certain
                    423:   cases</a>). The exact allowed contents of each individual element
                    424:   depends on the content model of that element, as described earlier
                    425:   in this specification. Elements must not contain content that their
                    426:   content model disallows. In addition to the restrictions placed on
                    427:   the contents by those content models, however, the five types of
1.123     mike      428:   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      429:   no end tag, no content can be put between the start tag and the end
1.373     mike      430:   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
                    431:   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
                    432:   must not contain an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.
1.1       mike      433:   There are also <a href="#cdata-rcdata-restrictions">further
1.373     mike      434:   restrictions</a> described below.</p><p><a href="#foreign-elements">Foreign elements</a> whose start tag is marked as
                    435:   self-closing can't have any contents (since, again, as there's no
                    436:   end tag, no content can be put between the start tag and the end
                    437:   tag). <a href="#foreign-elements">Foreign elements</a> whose start tag is <em>not</em>
                    438:   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      439:   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      440: 
                    441:    <p>The HTML syntax does not support namespace
                    442:    declarations, even in <a href="#foreign-elements">foreign elements</a>.</p>
                    443: 
                    444:    <p>For instance, consider the following HTML fragment:</p>
                    445: 
                    446:    <pre>&lt;p&gt;
                    447:  &lt;svg&gt;
                    448:   &lt;metadata&gt;
                    449:    &lt;!-- this is invalid --&gt;
                    450:    &lt;cdr:license xmlns:cdr="http://www.example.com/cdr/metadata" name="MIT"/&gt;
                    451:   &lt;/metadata&gt;
                    452:  &lt;/svg&gt;
                    453: &lt;/p&gt;</pre>
                    454: 
                    455:    <p>The innermost element, <code title="">cdr:license</code>, is
                    456:    actually in the SVG namespace, as the "<code title="">xmlns:cdr</code>" attribute has no effect (unlike in
                    457:    XML). In fact, as the comment in the fragment above says, the
                    458:    fragment is actually non-conforming. This is because the SVG
                    459:    specification does not define any elements called "<code title="">cdr:license</code>" in the SVG namespace.</p>
                    460: 
                    461:   </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      462:   contain the character U+003C LESS-THAN SIGN (&lt;) or an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>. Some
                    463:   <a href="#normal-elements">normal elements</a> also have <a href="#element-restrictions">yet more restrictions</a> on what
1.1       mike      464:   content they are allowed to hold, beyond the restrictions imposed by
                    465:   the content model and those described in this paragraph. Those
1.123     mike      466:   restrictions are described below.</p><p>Tags contain a <dfn id="syntax-tag-name" title="syntax-tag-name">tag name</dfn>,
1.1       mike      467:   giving the element's name. HTML elements all have names that only
1.464     mike      468:   use characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
                    469:   NINE (9), U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER
                    470:   Z, and U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER
                    471:   Z. In the HTML syntax, tag names, even those for <a href="#foreign-elements">foreign
1.462     mike      472:   elements</a>, may be written with any mix of lower- and uppercase
                    473:   letters that, when converted to all-lowercase, matches the element's
1.755     mike      474:   tag name; tag names are case-insensitive.</p><h5 id="start-tags"><span class="secno">8.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      475:   following format:</p><ol><li>The first character of a start tag must be a U+003C LESS-THAN
1.588     mike      476:    SIGN character (&lt;).</li>
1.1       mike      477: 
                    478:    <li>The next few characters of a start tag must be the element's
                    479:    <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
                    480: 
                    481:    <li>If there are to be any attributes in the next step, there must
                    482:    first be one or more <a href="infrastructure.html#space-character" title="space character">space
                    483:    characters</a>.</li>
                    484: 
                    485:    <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
                    486:    below. Attributes may be separated from each other by one or more
                    487:    <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    488: 
1.766     mike      489:    <li>After the attributes, or after the <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a> if there are no attributes,
                    490:    there may be one or more <a href="infrastructure.html#space-character" title="space character">space
                    491:    characters</a>. (Some attributes are required to be followed by
                    492:    a space. See the <a href="#syntax-attributes" title="syntax-attributes">attributes
                    493:    section</a> below.)</li>
1.1       mike      494: 
                    495:    <li>Then, if the element is one of the <a href="#void-elements">void elements</a>,
1.373     mike      496:    or if the element is a <a href="#foreign-elements" title="foreign elements">foreign
1.588     mike      497:    element</a>, then there may be a single U+002F SOLIDUS character
                    498:    (/). This character has no effect on <a href="#void-elements">void elements</a>,
                    499:    but on <a href="#foreign-elements">foreign elements</a> it marks the start tag as
                    500:    self-closing.</li>
1.1       mike      501: 
                    502:    <li>Finally, start tags must be closed by a U+003E GREATER-THAN
1.588     mike      503:    SIGN character (&gt;).</li>
1.1       mike      504: 
1.755     mike      505:   </ol><h5 id="end-tags"><span class="secno">8.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      506:   following format:</p><ol><li>The first character of an end tag must be a U+003C LESS-THAN
1.588     mike      507:    SIGN character (&lt;).</li>
1.1       mike      508: 
                    509:    <li>The second character of an end tag must be a U+002F SOLIDUS
1.588     mike      510:    character (/).</li>
1.1       mike      511: 
                    512:    <li>The next few characters of an end tag must be the element's
                    513:    <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
                    514: 
                    515:    <li>After the tag name, there may be one or more <a href="infrastructure.html#space-character" title="space
                    516:    character">space characters</a>.</li>
                    517: 
1.588     mike      518:    <li>Finally, end tags must be closed by a U+003E GREATER-THAN SIGN
                    519:    character (&gt;).</li>
1.1       mike      520: 
1.755     mike      521:   </ol><h5 id="attributes"><span class="secno">8.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      522:   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      523:   one or more characters other than the <a href="infrastructure.html#space-character" title="space
                    524:   character">space characters</a>, U+0000 NULL, U+0022 QUOTATION
                    525:   MARK ("), U+0027 APOSTROPHE ('), U+003E GREATER-THAN SIGN
                    526:   (&gt;), U+002F SOLIDUS (/), and U+003D EQUALS SIGN (=) characters,
                    527:   the control characters, and any characters that are not defined by
1.462     mike      528:   Unicode. In the HTML syntax, attribute names, even those for
                    529:   <a href="#foreign-elements">foreign elements</a>, may be written with any mix of lower-
                    530:   and uppercase letters that are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.123     mike      531:   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      532:   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      533:   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      534: 
                    535:    <dd>
                    536: 
                    537:     <p>Just the <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute
                    538:     name</a>.</p>
                    539: 
                    540:     <div class="example">
                    541: 
                    542:      <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
                    543:      the empty attribute syntax:</p>
                    544: 
                    545:      <pre>&lt;input <em>disabled</em>&gt;</pre>
                    546: 
                    547:     </div>
                    548: 
                    549:     <p>If an attribute using the empty attribute syntax is to be
                    550:     followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
                    551:     character</a> separating the two.</p>
                    552: 
                    553:    </dd>
                    554: 
1.2       mike      555:    <dt id="unquoted">Unquoted attribute value syntax</dt>
1.1       mike      556: 
                    557:    <dd>
                    558: 
                    559:     <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
                    560:     followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
                    561:     characters</a>, followed by a single U+003D EQUALS SIGN
                    562:     character, followed by zero or more <a href="infrastructure.html#space-character" title="space
                    563:     character">space characters</a>, followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
                    564:     addition to the requirements given above for attribute values,
                    565:     must not contain any literal <a href="infrastructure.html#space-character" title="space character">space
1.588     mike      566:     characters</a>, any U+0022 QUOTATION MARK characters ("),
                    567:     U+0027 APOSTROPHE characters ('), U+003D EQUALS SIGN
                    568:     characters (=), U+003C LESS-THAN SIGN characters (&lt;), U+003E
                    569:     GREATER-THAN SIGN characters (&gt;), or U+0060 GRAVE ACCENT
                    570:     characters (`), and must not be the empty string.</p>
1.463     mike      571: 
                    572:     <!-- The ` character is in this list on a temporary basis, waiting
                    573:          for IE to fix it's parsing bug whereby it treats ` as an
                    574:          attribute value delimiter. Otherwise, escaping software that
                    575:          tries to be clever and not use quotes when it doesn't need to
                    576:          could be tricked by an attacker.
                    577: 
                    578:          Posit a site that allows the user to input text that is used
                    579:          verbatim in two attributes, such that the user can set the
                    580:          first attribute's value to:
                    581: 
                    582:             `
                    583: 
                    584:          ...and the second to:
                    585: 
                    586:             ` onload='...payload...' end=x
                    587: 
                    588:          ...with the assumption that the site is going to not quote
                    589:          the first one, and quote the second one with double quotes:
                    590: 
                    591:             <body title=` class="` onload='...payload...' end=x">
                    592: 
                    593:          In IE, this is treated as:
                    594: 
                    595:             <body title=' class="'
                    596:                   onload='...payload...'
                    597:                   end='x"'>
                    598: 
                    599:     -->
                    600: 
1.1       mike      601: 
                    602:     <div class="example">
                    603: 
                    604:      <p>In the following example, the <code title="attr-input-value"><a href="forms.html#attr-input-value">value</a></code> attribute is given
                    605:      with the unquoted attribute value syntax:</p>
                    606: 
                    607:      <pre>&lt;input <em>value=yes</em>&gt;</pre>
                    608: 
                    609:     </div>
                    610: 
                    611:     <p>If an attribute using the unquoted attribute syntax is to be
1.101     mike      612:     followed by another attribute or by the optional U+002F SOLIDUS
1.464     mike      613:     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      614:     must be a <a href="infrastructure.html#space-character">space character</a> separating the two.</p>
                    615: 
                    616:    </dd>
                    617: 
                    618:    <dt>Single-quoted attribute value syntax</dt>
                    619: 
                    620:    <dd>
                    621: 
                    622:     <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
                    623:     followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
                    624:     characters</a>, followed by a single U+003D EQUALS SIGN
                    625:     character, followed by zero or more <a href="infrastructure.html#space-character" title="space
                    626:     character">space characters</a>, followed by a single U+0027
1.588     mike      627:     APOSTROPHE character ('), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1       mike      628:     addition to the requirements given above for attribute values,
1.588     mike      629:     must not contain any literal U+0027 APOSTROPHE characters ('), and
                    630:     finally followed by a second single U+0027 APOSTROPHE character
                    631:     (').</p>
1.1       mike      632: 
                    633:     <div class="example">
                    634: 
                    635:      <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
                    636:      single-quoted attribute value syntax:</p>
                    637: 
                    638:      <pre>&lt;input <em>type='checkbox'</em>&gt;</pre>
                    639: 
                    640:     </div>
                    641: 
                    642:     <p>If an attribute using the single-quoted attribute syntax is to
                    643:     be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
                    644:     character</a> separating the two.</p>
                    645: 
                    646:    </dd>
                    647: 
                    648:    <dt>Double-quoted attribute value syntax</dt>
                    649: 
                    650:    <dd>
                    651: 
                    652:     <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
                    653:     followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
                    654:     characters</a>, followed by a single U+003D EQUALS SIGN
                    655:     character, followed by zero or more <a href="infrastructure.html#space-character" title="space
                    656:     character">space characters</a>, followed by a single U+0022
1.588     mike      657:     QUOTATION MARK character ("), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1       mike      658:     addition to the requirements given above for attribute values,
1.588     mike      659:     must not contain any literal U+0022 QUOTATION MARK characters ("),
                    660:     and finally followed by a second single U+0022 QUOTATION MARK
                    661:     character (").</p>
1.1       mike      662: 
                    663:     <div class="example">
                    664: 
                    665:      <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
                    666:      double-quoted attribute value syntax:</p>
                    667: 
                    668:      <pre>&lt;input <em>name="be evil"</em>&gt;</pre>
                    669: 
                    670:     </div>
                    671: 
                    672:     <p>If an attribute using the double-quoted attribute syntax is to
                    673:     be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
                    674:     character</a> separating the two.</p>
                    675: 
                    676:    </dd>
                    677: 
                    678:   </dl><p>There must never be two or more attributes on the same start tag
                    679:   whose names are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for
1.462     mike      680:   each other.</p><hr><p>When a <a href="#foreign-elements" title="foreign elements">foreign element</a> has
                    681:   one of the namespaced attributes given by the local name and
                    682:   namespace of the first and second cells of a row from the following
                    683:   table, it must be written using the name given by the third cell
                    684:   from the same row.</p><table><thead><tr><th> Local name </th><th> Namespace </th><th> Attribute name
1.724     mike      685:    </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>
                    686:     </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>
                    687:     </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>
                    688:     </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>
                    689:     </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>
                    690:     </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>
                    691:     </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>
                    692:     </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>
                    693:     </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>
                    694:     </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>
                    695:     </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>
                    696:     </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      697:   </td></tr></tbody></table><p>No other namespaced attribute can be expressed in <a href="#syntax">the
1.755     mike      698:   HTML syntax</a>.</p><h5 id="optional-tags"><span class="secno">8.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      699:   is not present; it is implied, but it is still there. An HTML
1.159     mike      700:   document always has a root <code><a href="semantics.html#the-html-element-0">html</a></code> element, even if the
1.1       mike      701:   string <code title="">&lt;html&gt;</code> doesn't appear anywhere in
1.159     mike      702:   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
                    703:   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
                    704:   tag</a> may be omitted if the <code><a href="semantics.html#the-html-element-0">html</a></code> element is not
                    705:   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      706:   element is empty, or--> if the first thing inside the
1.159     mike      707:   <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
                    708:   tag</a> may be omitted if the <code><a href="semantics.html#the-head-element-0">head</a></code> element is not
                    709:   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
                    710:   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      711:   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      712:   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      713:   <code><a href="semantics.html#the-style-element">style</a></code> element. <!-- Note that even if the </head> end
1.724     mike      714:   tag is present, the parser makes <style> and <script type="text/javascript"> elements
1.1       mike      715:   between </head> and <body> end up in the <head> instead of implying
1.159     mike      716:   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
                    717:   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      718:   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      719:   tag</a> may be omitted if the <code><a href="semantics.html#the-li-element">li</a></code> element is
                    720:   immediately followed by another <code><a href="semantics.html#the-li-element">li</a></code> element or if there
1.422     mike      721:   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      722:   tag</a> may be omitted if the <code><a href="semantics.html#the-dt-element">dt</a></code> element is
                    723:   immediately followed by another <code><a href="semantics.html#the-dt-element">dt</a></code> element or a
1.123     mike      724:   <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      725:   tag</a> may be omitted if the <code><a href="semantics.html#the-dd-element">dd</a></code> element is
                    726:   immediately followed by another <code><a href="semantics.html#the-dd-element">dd</a></code> element or a
                    727:   <code><a href="semantics.html#the-dt-element">dt</a></code> element, or if there is no more content in the
1.123     mike      728:   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      729:   tag</a> may be omitted if the <code><a href="semantics.html#the-p-element">p</a></code> element is
                    730:   immediately followed by an <code><a href="semantics.html#the-address-element">address</a></code>,
                    731:   <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      732:   <!--v2DATAGRID <code>datagrid</code>,--> <code><a href="obsolete.html#dir">dir</a></code>,
1.306     mike      733:   <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      734:   <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>,
                    735:   <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>,
                    736:   <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>,
                    737:   <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>,
                    738:   <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      739:   <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>,
                    740:   element, or if there is no more content in the parent element and
1.123     mike      741:   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      742:   tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rt-element">rt</a></code> element is
                    743:   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      744:   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      745:   tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rp-element">rp</a></code> element is
                    746:   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      747:   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      748:   <select>; commented out text below can handle the non-<select> case
1.123     mike      749:   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      750:   <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element <!--has an ancestor
                    751:   <code>select</code> element and--> is immediately followed by
                    752:   another <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or if <!--all of the elements
                    753:   that are ancestors of the <code>optgroup</code> element, up to and
                    754:   including the first ancestor element that is not an
                    755:   <code>optgroup</code> element, have no more content--> there is no
1.123     mike      756:   more content in the parent element.</p><!-- so e.g. the max number of </optgroup>s are omitted here:
1.1       mike      757:    <select><optgroup></select>
                    758:    <p id=x><optgroup></optgroup>x</p>
                    759:    <p id=x><optgroup><optgroup></optgroup></optgroup>x</p>
                    760:    <p><optgroup id=x><optgroup></optgroup>x</p>
                    761:    <p><optgroup><optgroup id=x>x</p>
1.123     mike      762:   --><!-- </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      763:   tag</a> may be omitted if the <code><a href="forms.html#the-option-element">option</a></code> element is
                    764:   immediately followed by another <code><a href="forms.html#the-option-element">option</a></code> element, or if
                    765:   it is immediately followed by an <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or
1.123     mike      766:   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      767:   first thing inside the <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is a
                    768:   <code><a href="tabular-data.html#the-col-element">col</a></code> element, and if the element is not immediately
                    769:   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      770:   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      771:   <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is not immediately followed by a
1.123     mike      772:   <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      773:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-thead-element">thead</a></code> element is
                    774:   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      775:   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      776:   first thing inside the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is a
                    777:   <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, and if the element is not immediately
                    778:   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
                    779:   <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element whose <a href="#syntax-end-tag" title="syntax-end-tag">end
                    780:   tag</a> has been omitted. (It can't be omitted if the element is
1.123     mike      781:   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      782:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is
                    783:   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      784:   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      785:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element is
                    786:   immediately followed by a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element, or if there is
1.123     mike      787:   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      788:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
                    789:   immediately followed by another <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, or if there
1.123     mike      790:   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      791:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-td-element">td</a></code> element is
                    792:   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      793:   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      794:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-th-element">th</a></code> element is
                    795:   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      796:   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.755     mike      797:   tag</a> must never be omitted if it has any attributes.</p><h5 id="element-restrictions"><span class="secno">8.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      798:   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      799:   elements, even though these elements are technically allowed inside
                    800:   <code><a href="tabular-data.html#the-table-element">table</a></code> elements according to the content models
                    801:   described in this specification. (If a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
                    802:   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      803:   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
                    804:   placed immediately after the <a href="#syntax-start-tag" title="syntax-start-tag">start
1.1       mike      805:   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>
                    806:   elements. This does not affect the processing of the element. The
1.304     mike      807:   otherwise optional <a href="#syntax-newlines" title="syntax-newlines">newline</a>
1.381     mike      808:   <em>must</em> be included if the element's contents themselves start
                    809:   with a <a href="#syntax-newlines" title="syntax-newlines">newline</a> (because
                    810:   otherwise the leading newline in the contents would be treated like
                    811:   the optional newline, and ignored).</p><div class="example">
1.1       mike      812:    <p>The following two <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are equivalent:</p>
                    813:    <pre>&lt;pre&gt;Hello&lt;/pre&gt;</pre>
                    814:    <pre>&lt;pre&gt;<br>Hello&lt;/pre&gt;</pre>
1.755     mike      815:   </div><h5 id="cdata-rcdata-restrictions"><span class="secno">8.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      816:   <a href="#rcdata-elements" title="RCDATA elements">RCDATAs</a> element must not
                    817:   contain any occurrences of the string "<code title="">&lt;/</code>"
                    818:   (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that
1.1       mike      819:   case-insensitively match the tag name of the element followed by one
                    820:   of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM
1.304     mike      821:   FEED (FF), U+000D CARRIAGE RETURN (CR), U+0020 SPACE, U+003E
1.755     mike      822:   GREATER-THAN SIGN (&gt;), or U+002F SOLIDUS (/).</p><h4 id="text"><span class="secno">8.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      823:   attributes, and comments. Text must consist of Unicode characters.
                    824:   Text must not contain U+0000 characters. Text must not contain
1.316     mike      825:   permanently undefined Unicode characters (noncharacters). Text must
                    826:   not contain control characters other than <a href="infrastructure.html#space-character" title="space
                    827:   character">space characters</a>. Extra constraints are placed on
                    828:   what is and what is not allowed in text based on where the text is
1.755     mike      829:   to be put, as described in the other sections.</p><h5 id="newlines"><span class="secno">8.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      830:   represented either as U+000D CARRIAGE RETURN (CR) characters, U+000A
                    831:   LINE FEED (LF) characters, or pairs of U+000D CARRIAGE RETURN (CR),
1.755     mike      832:   U+000A LINE FEED (LF) characters in that order.</p><h4 id="character-references"><span class="secno">8.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      833:   to escape characters that couldn't otherwise legally be included in
1.588     mike      834:   <a href="#syntax-text" title="syntax-text">text</a>.</p><p>Character references must start with a U+0026 AMPERSAND character
                    835:   (&amp;). Following this, there are three possible kinds of character
                    836:   references:</p><dl><dt>Named character references</dt>
1.1       mike      837: 
                    838:    <dd>The ampersand must be followed by one of the names given in the
                    839:    <a href="named-character-references.html#named-character-references">named character references</a> section, using the same
1.677     mike      840:    case. <span class="impl">The name must be one that is terminated by
                    841:    a U+003B SEMICOLON character (;).</span></dd>
1.1       mike      842: 
                    843: 
                    844:    <dt>Decimal numeric character reference</dt>
                    845: 
                    846:    <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588     mike      847:    character (#), followed by one or more digits in the range U+0030
                    848:    DIGIT ZERO (0) to U+0039 DIGIT NINE (9), representing a base-ten
                    849:    integer that corresponds to a Unicode code point that is allowed
                    850:    according to the definition below. The digits must then be followed
                    851:    by a U+003B SEMICOLON character (;).</dd>
1.1       mike      852: 
                    853: 
                    854:    <dt>Hexadecimal numeric character reference</dt>
                    855: 
                    856:    <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588     mike      857:    character (#), which must be followed by either a U+0078 LATIN
                    858:    SMALL LETTER X character (x) or a U+0058 LATIN CAPITAL LETTER X
                    859:    character (X), which must then be followed by one or more digits in
                    860:    the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061
                    861:    LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041
                    862:    LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F,
1.464     mike      863:    representing a base-sixteen integer that corresponds to a Unicode
                    864:    code point that is allowed according to the definition below. The
                    865:    digits must then be followed by a U+003B SEMICOLON character
                    866:    (;).</dd>
1.378     mike      867: 
                    868:   </dl><p>The numeric character reference forms described above are allowed
                    869:   to reference any Unicode code point other than U+0000, permanently
                    870:   undefined Unicode characters (noncharacters), and control characters
                    871:   other than <a href="infrastructure.html#space-character" title="space character">space
                    872:   characters</a>.</p><p>An <dfn id="syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous
1.464     mike      873:   ampersand</dfn> is a U+0026 AMPERSAND character (&amp;) that is
                    874:   followed by some <a href="#syntax-text" title="syntax-text">text</a> other than a
                    875:   <a href="infrastructure.html#space-character">space character</a>, a U+003C LESS-THAN SIGN character
1.755     mike      876:   (&lt;), or another U+0026 AMPERSAND character (&amp;).</p><h4 id="cdata-sections"><span class="secno">8.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      877:   the character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
                    878:   MARK, U+005B LEFT SQUARE BRACKET, U+0043 LATIN CAPITAL LETTER C,
                    879:   U+0044 LATIN CAPITAL LETTER D, U+0041 LATIN CAPITAL LETTER A, U+0054
                    880:   LATIN CAPITAL LETTER T, U+0041 LATIN CAPITAL LETTER A, U+005B LEFT
                    881:   SQUARE BRACKET (<code title="">&lt;![CDATA[</code>). Following this
                    882:   sequence, the CDATA section may have <a href="#syntax-text" title="syntax-text">text</a>, with the additional restriction
                    883:   that the text must not contain the three character sequence U+005D
                    884:   RIGHT SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E
                    885:   GREATER-THAN SIGN (<code title="">]]&gt;</code>). Finally, the CDATA
                    886:   section must be ended by the three character sequence U+005D RIGHT
                    887:   SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E GREATER-THAN
1.724     mike      888:   SIGN (<code title="">]]&gt;</code>).</p><div class="example">
                    889: 
                    890:    <p>CDATA sections can only be used in foreign content (MathML or
                    891:    SVG). In this example, a CDATA section is used to escape the
                    892:    contents of an <code>ms</code> element:</p>
                    893: 
                    894:    <pre>&lt;p&gt;You can add a string to a number, but this stringifies the number:&lt;/p&gt;
                    895: &lt;math&gt;
                    896:  &lt;ms&gt;&lt;![CDATA[x&lt;y]]&gt;&lt;/ms&gt;
                    897:  &lt;mo&gt;+&lt;/mo&gt;
                    898:  &lt;mn&gt;3&lt;/mn&gt;
                    899:  &lt;mo&gt;=&lt;/mo&gt;
                    900:  &lt;ms&gt;&lt;![CDATA[x&lt;y3]]&gt;&lt;/ms&gt;
                    901: &lt;/math&gt;</pre>
                    902: 
1.755     mike      903:   </div><h4 id="comments"><span class="secno">8.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      904:   four character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
                    905:   MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS (<code title="">&lt;!--</code>). Following this sequence, the comment may
                    906:   have <a href="#syntax-text" title="syntax-text">text</a>, with the additional
                    907:   restriction that the text must not start with a single U+003E
1.588     mike      908:   GREATER-THAN SIGN character (&gt;), nor start with a U+002D
                    909:   HYPHEN-MINUS character (-) followed by a U+003E GREATER-THAN SIGN
                    910:   (&gt;) character, nor contain two consecutive U+002D HYPHEN-MINUS
                    911:   characters (<code title="">--</code>), nor end with a U+002D
                    912:   HYPHEN-MINUS character (-). Finally, the comment must be ended by
1.1       mike      913:   the three character sequence U+002D HYPHEN-MINUS, U+002D
1.123     mike      914:   HYPHEN-MINUS, U+003E GREATER-THAN SIGN (<code title="">--&gt;</code>).</p><div class="impl">
1.1       mike      915: 
1.755     mike      916:   <h3 id="parsing"><span class="secno">8.2 </span>Parsing HTML documents</h3><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike      917: 
                    918:   <p><i>This section only applies to user agents, data mining tools,
                    919:   and conformance checkers.</i></p>
                    920: 
                    921:   <p class="note">The rules for parsing XML documents into DOM trees
                    922:   are covered by the next section, entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
                    923:   syntax</a>".</p>
                    924: 
                    925:   <p>For <a href="dom.html#html-documents">HTML documents</a>, user agents must use the parsing
                    926:   rules described in this section to generate the DOM trees. Together,
                    927:   these rules define what is referred to as the <dfn id="html-parser">HTML
                    928:   parser</dfn>.</p>
                    929: 
                    930:   <div class="note">
                    931: 
                    932:    <p>While the HTML syntax described in this specification bears a
                    933:    close resemblance to SGML and XML, it is a separate language with
                    934:    its own parsing rules.</p>
                    935: 
1.183     mike      936:    <p>Some earlier versions of HTML (in particular from HTML2 to
                    937:    HTML4) were based on SGML and used SGML parsing rules. However, few
1.1       mike      938:    (if any) web browsers ever implemented true SGML parsing for HTML
                    939:    documents; the only user agents to strictly handle HTML as an SGML
                    940:    application have historically been validators. The resulting
                    941:    confusion &#8212; with validators claiming documents to have one
                    942:    representation while widely deployed Web browsers interoperably
                    943:    implemented a different representation &#8212; has wasted decades
                    944:    of productivity. This version of HTML thus returns to a non-SGML
                    945:    basis.</p>
                    946: 
                    947:    <p>Authors interested in using SGML tools in their authoring
                    948:    pipeline are encouraged to use XML tools and the XML serialization
                    949:    of HTML.</p>
                    950: 
                    951:   </div>
                    952: 
                    953:   <p>This specification defines the parsing rules for HTML documents,
                    954:   whether they are syntactically correct or not. Certain points in the
                    955:   parsing algorithm are said to be <dfn id="parse-error" title="parse error">parse
                    956:   errors</dfn>. The error handling for parse errors is well-defined:
                    957:   user agents must either act as described below when encountering
                    958:   such problems, or must abort processing at the first error that they
                    959:   encounter for which they do not wish to apply the rules described
                    960:   below.</p>
                    961: 
                    962:   <p>Conformance checkers must report at least one parse error
                    963:   condition to the user if one or more parse error conditions exist in
                    964:   the document and must not report parse error conditions if none
                    965:   exist in the document. Conformance checkers may report more than one
1.174     mike      966:   parse error condition if more than one parse error condition exists
1.1       mike      967:   in the document. Conformance checkers are not required to recover
                    968:   from parse errors.</p>
                    969: 
                    970:   <p class="note">Parse errors are only errors with the
                    971:   <em>syntax</em> of HTML. In addition to checking for parse errors,
                    972:   conformance checkers will also verify that the document obeys all
                    973:   the other conformance requirements described in this
                    974:   specification.</p>
                    975: 
                    976:   <p>For the purposes of conformance checkers, if a resource is
                    977:   determined to be in <a href="#syntax">the HTML syntax</a>, then it is an
                    978:   <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
                    979: 
1.266     mike      980:   </div><div class="impl">
1.1       mike      981: 
1.755     mike      982:   <h4 id="overview-of-the-parsing-model"><span class="secno">8.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      983: 
                    984:   <p>The input to the HTML parsing process consists of a stream of
                    985:   Unicode characters, which is passed through a
                    986:   <a href="#tokenization">tokenization</a> stage followed by a <a href="#tree-construction">tree
                    987:   construction</a> stage. The output is a <code>Document</code>
                    988:   object.</p>
                    989: 
                    990:   <p class="note">Implementations that <a href="infrastructure.html#non-scripted">do not
                    991:   support scripting</a> do not have to actually create a DOM
                    992:   <code>Document</code> object, but the DOM tree in such cases is
                    993:   still used as the model for the rest of the specification.</p>
                    994: 
                    995:   <p>In the common case, the data handled by the tokenization stage
1.159     mike      996:   comes from the network, but <a href="embedded-content-0.html#dynamic-markup-insertion" title="dynamic markup
                    997:   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      998: 
1.724     mike      999:   <p><img alt="" src="http://dev.w3.org/html5/spec/images/parsing-model-overview.png"></p>
1.1       mike     1000: 
                   1001:   <p id="nestedParsing">There is only one set of states for the
                   1002:   tokenizer stage and the tree construction stage, but the tree
                   1003:   construction stage is reentrant, meaning that while the tree
                   1004:   construction stage is handling one token, the tokenizer might be
                   1005:   resumed, causing further tokens to be emitted and processed before
                   1006:   the first token's processing is complete.</p>
                   1007: 
                   1008:   <div class="example">
                   1009: 
                   1010:    <p>In the following example, the tree construction stage will be
                   1011:    called upon to handle a "p" start tag token while handling the
                   1012:    "script" start tag token:</p>
                   1013: 
                   1014:    <pre>...
                   1015: &lt;script&gt;
                   1016:  document.write('&lt;p&gt;');
                   1017: &lt;/script&gt;
                   1018: ...</pre>
                   1019: 
                   1020:   </div>
                   1021: 
                   1022:   <p>To handle these cases, parsers have a <dfn id="script-nesting-level">script nesting
                   1023:   level</dfn>, which must be initially set to zero, and a <dfn id="parser-pause-flag">parser
                   1024:   pause flag</dfn>, which must be initially set to false.</p>
                   1025: 
1.266     mike     1026:   </div><div class="impl">
1.1       mike     1027: 
1.755     mike     1028:   <h4 id="the-input-stream"><span class="secno">8.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     1029: 
                   1030:   <p>The stream of Unicode characters that comprises the input to the
                   1031:   tokenization stage will be initially seen by the user agent as a
                   1032:   stream of bytes (typically coming over the network or from the local
                   1033:   file system). The bytes encode the actual characters according to a
                   1034:   particular <em>character encoding</em>, which the user agent must
                   1035:   use to decode the bytes into characters.</p>
                   1036: 
                   1037:   <p class="note">For XML documents, the algorithm user agents must
                   1038:   use to determine the character encoding is given by the XML
1.104     mike     1039:   specification. This section does not apply to XML documents. <a href="references.html#refsXML">[XML]</a></p>
1.1       mike     1040: 
                   1041: 
1.755     mike     1042:   <h5 id="determining-the-character-encoding"><span class="secno">8.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     1043: 
                   1044:   <p>In some cases, it might be impractical to unambiguously determine
                   1045:   the encoding before parsing the document. Because of this, this
                   1046:   specification provides for a two-pass mechanism with an optional
                   1047:   pre-scan. Implementations are allowed, as described below, to apply
                   1048:   a simplified parsing algorithm to whatever bytes they have available
                   1049:   before beginning to parse the document. Then, the real parser is
                   1050:   started, using a tentative encoding derived from this pre-parse and
                   1051:   other out-of-band metadata. If, while the document is being loaded,
                   1052:   the user agent discovers an encoding declaration that conflicts with
                   1053:   this information, then the parser can get reinvoked to perform a
                   1054:   parse of the document with the real encoding.</p>
                   1055: 
                   1056:   <p id="documentEncoding">User agents must use the following
                   1057:   algorithm (the <dfn id="encoding-sniffing-algorithm">encoding sniffing algorithm</dfn>) to determine
                   1058:   the character encoding to use when decoding a document in the first
                   1059:   pass. This algorithm takes as input any out-of-band metadata
                   1060:   available to the user agent (e.g. the <a href="infrastructure.html#content-type" title="Content-Type">Content-Type metadata</a> of the document)
                   1061:   and all the bytes available so far, and returns an encoding and a
                   1062:   <dfn id="concept-encoding-confidence" title="concept-encoding-confidence">confidence</dfn>. The
                   1063:   confidence is either <i>tentative</i>, <i>certain</i>, or
                   1064:   <i>irrelevant</i>. The encoding used, and whether the confidence in
                   1065:   that encoding is <i>tentative</i> or <i>certain</i>, is <a href="#meta-charset-during-parse">used during the parsing</a> to
                   1066:   determine whether to <a href="#change-the-encoding">change the encoding</a>. If no
                   1067:   encoding is necessary, e.g. because the parser is operating on a
                   1068:   stream of Unicode characters and doesn't have to use an encoding at
                   1069:   all, then the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
                   1070:   <i>irrelevant</i>.</p>
                   1071: 
                   1072:   <ol><li><p>If the transport layer specifies an encoding, and it is
                   1073:    supported, return that encoding with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1074:    <i>certain</i>, and abort these steps.</p></li>
                   1075: 
                   1076:    <li><p>The user agent may wait for more bytes of the resource to be
                   1077:    available, either in this step or at any later step in this
                   1078:    algorithm. For instance, a user agent might wait 500ms or 512
                   1079:    bytes, whichever came first. In general preparsing the source to
                   1080:    find the encoding improves performance, as it reduces the need to
                   1081:    throw away the data structures used when parsing upon finding the
                   1082:    encoding information. However, if the user agent delays too long to
                   1083:    obtain data to determine the encoding, then the cost of the delay
                   1084:    could outweigh any performance improvements from the
                   1085:    preparse.</p></li>
                   1086: 
                   1087:    <li><p>For each of the rows in the following table, starting with
                   1088:    the first one and going down, if there are as many or more bytes
                   1089:    available than the number of bytes in the first column, and the
                   1090:    first bytes of the file match the bytes given in the first column,
                   1091:    then return the encoding given in the cell in the second column of
                   1092:    that row, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1093:    <i>certain</i>, and abort these steps:</p>
                   1094: 
                   1095:     <!-- this table is present in several forms in this file; keep them in sync -->
                   1096:     <table><thead><tr><th>Bytes in Hexadecimal
                   1097:        </th><th>Encoding
                   1098:      </th></tr></thead><tbody><!-- nobody uses this
                   1099:       <tr>
                   1100:        <td>00 00 FE FF
                   1101:        <td>UTF-32BE
                   1102:       <tr>
                   1103:        <td>FF FE 00 00
                   1104:        <td>UTF-32LE
                   1105: --><tr><td>FE FF
                   1106:        </td><td>UTF-16BE
                   1107:       </td></tr><tr><td>FF FE
                   1108:        </td><td>UTF-16LE
                   1109:       </td></tr><tr><td>EF BB BF
                   1110:        </td><td>UTF-8
                   1111: <!-- nobody uses this
                   1112:       <tr>
                   1113:        <td>DD 73 66 73
                   1114:        <td>UTF-EBCDIC
                   1115: -->
                   1116:     </td></tr></tbody></table><p class="note">This step looks for Unicode Byte Order Marks
                   1117:    (BOMs).</p></li>
                   1118: 
                   1119:    <li><p>Otherwise, the user agent will have to search for explicit
                   1120:    character encoding information in the file itself. This should
                   1121:    proceed as follows:
                   1122: 
                   1123:     </p><p>Let <var title="">position</var> be a pointer to a byte in the
                   1124:     input stream, initially pointing at the first byte. If at any
                   1125:     point during these substeps the user agent either runs out of
                   1126:     bytes or decides that scanning further bytes would not be
                   1127:     efficient, then skip to the next step of the overall character
                   1128:     encoding detection algorithm. User agents may decide that scanning
                   1129:     <em>any</em> bytes is not efficient, in which case these substeps
                   1130:     are entirely skipped.</p>
                   1131: 
                   1132:     <p>Now, repeat the following "two" steps until the algorithm
                   1133:     aborts (either because user agent aborts, as described above, or
                   1134:     because a character encoding is found):</p>
                   1135: 
                   1136:     <ol><li><p>If <var title="">position</var> points to:</p>
                   1137: 
                   1138:       <dl class="switch"><dt>A sequence of bytes starting with: 0x3C 0x21 0x2D 0x2D (ASCII '&lt;!--')</dt>
                   1139:        <dd>
                   1140: 
                   1141:         <p>Advance the <var title="">position</var> pointer so that it
                   1142:         points at the first 0x3E byte which is preceded by two 0x2D
                   1143:         bytes (i.e. at the end of an ASCII '--&gt;' sequence) and comes
                   1144:         after the 0x3C byte that was found. (The two 0x2D bytes can be
                   1145:         the same as the those in the '&lt;!--' sequence.)</p>
                   1146: 
                   1147:        </dd>
                   1148: 
                   1149:        <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>
                   1150:        <dd>
                   1151: 
                   1152:         <ol><li><p>Advance the <var title="">position</var> pointer so
                   1153:          that it points at the next 0x09, 0x0A, 0x0C, 0x0D, 0x20, or
                   1154:          0x2F byte (the one in sequence of characters matched
                   1155:          above).</p></li>
                   1156: 
                   1157:          <li><p><a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">Get
                   1158:          an attribute</a> and its value. If no attribute was
                   1159:          sniffed, then skip this inner set of steps, and jump to the
                   1160:          second step in the overall "two step" algorithm.</p></li>
                   1161: 
                   1162:          <li><p>If the attribute's name is neither "<code title="">charset</code>" nor "<code title="">content</code>",
                   1163:          then return to step 2 in these inner steps.</p></li>
                   1164: 
                   1165:          <li><p>If the attribute's name is "<code title="">charset</code>", let <var title="">charset</var> be
                   1166:          the attribute's value, interpreted as a character
                   1167:          encoding.</p></li>
                   1168: 
                   1169:          <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
                   1170:          extracting an encoding from a Content-Type</a>, giving the
                   1171:          attribute's value as the string to parse. If an encoding is
                   1172:          returned, let <var title="">charset</var> be that
                   1173:          encoding. Otherwise, return to step 2 in these inner
                   1174:          steps.</p></li>
                   1175: 
                   1176:          <li><p>If <var title="">charset</var> is a UTF-16 encoding,
                   1177:          change the value of <var title="">charset</var> to
                   1178:          UTF-8.</p></li>
                   1179: 
                   1180:          <li><p>If <var title="">charset</var> is a supported
                   1181:          character encoding, then return the given encoding, with
                   1182:          <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1183:          <i>tentative</i>, and abort all these steps.</p></li>
                   1184: 
                   1185:          <li><p>Otherwise, return to step 2 in these inner
                   1186:          steps.</p></li>
                   1187: 
                   1188:         </ol></dd>
                   1189: 
1.464     mike     1190:        <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     1191:        <dd>
                   1192: 
                   1193:         <ol><li><p>Advance the <var title="">position</var> pointer so
                   1194:          that it points at the next 0x09 (ASCII TAB), 0x0A (ASCII LF),
                   1195:          0x0C (ASCII FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E
1.464     mike     1196:          (ASCII &gt;) byte.</p></li>
1.1       mike     1197: 
                   1198:          <li><p>Repeatedly <a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">get an
                   1199:          attribute</a> until no further attributes can be found,
                   1200:          then jump to the second step in the overall "two step"
                   1201:          algorithm.</p></li>
                   1202: 
                   1203:         </ol></dd>
                   1204: 
                   1205:        <dt>A sequence of bytes starting with: 0x3C 0x21 (ASCII '&lt;!')</dt>
                   1206:        <dt>A sequence of bytes starting with: 0x3C 0x2F (ASCII '&lt;/')</dt>
                   1207:        <dt>A sequence of bytes starting with: 0x3C 0x3F (ASCII '&lt;?')</dt>
                   1208:        <dd>
                   1209: 
                   1210:         <p>Advance the <var title="">position</var> pointer so that it
1.464     mike     1211:         points at the first 0x3E byte (ASCII &gt;) that comes after the
1.1       mike     1212:         0x3C byte that was found.</p>
                   1213: 
                   1214:        </dd>
                   1215: 
                   1216:        <dt>Any other byte</dt>
                   1217:        <dd>
                   1218: 
                   1219:         <p>Do nothing with that byte.</p>
                   1220: 
                   1221:        </dd>
                   1222: 
                   1223:       </dl></li>
                   1224: 
                   1225:      <li>Move <var title="">position</var> so it points at the next
                   1226:      byte in the input stream, and return to the first step of this
                   1227:      "two step" algorithm.</li>
                   1228: 
                   1229:     </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
                   1230:     attribute</dfn>, it means doing this:</p>
                   1231: 
                   1232:     <ol><li><p>If the byte at <var title="">position</var> is one of 0x09
                   1233:      (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR),
1.464     mike     1234:      0x20 (ASCII space), or 0x2F (ASCII /) then advance <var title="">position</var> to the next byte and redo this
1.1       mike     1235:      substep.</p></li>
                   1236: 
                   1237:      <li><p>If the byte at <var title="">position</var> is 0x3E (ASCII
1.464     mike     1238:      &gt;), then abort the "get an attribute" algorithm. There isn't
1.1       mike     1239:      one.</p></li>
                   1240: 
                   1241:      <li><p>Otherwise, the byte at <var title="">position</var> is the
                   1242:      start of the attribute name. Let <var title="">attribute
                   1243:      name</var> and <var title="">attribute value</var> be the empty
                   1244:      string.</p></li>
                   1245: 
                   1246:      <li><p><i>Attribute name</i>: Process the byte at <var title="">position</var> as follows:</p>
                   1247: 
1.464     mike     1248:       <dl class="switch"><dt>If it is 0x3D (ASCII =), and the <var title="">attribute
1.1       mike     1249:        name</var> is longer than the empty string</dt>
                   1250: 
                   1251:        <dd>Advance <var title="">position</var> to the next byte and
                   1252:        jump to the step below labeled <i>value</i>.</dd>
                   1253: 
                   1254:        <dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
                   1255:        FF), 0x0D (ASCII CR), or 0x20 (ASCII space)</dt>
                   1256: 
                   1257:        <dd>Jump to the step below labeled <i>spaces</i>.</dd>
                   1258: 
1.464     mike     1259:        <dt>If it is 0x2F (ASCII /) or 0x3E (ASCII &gt;)</dt>
1.1       mike     1260: 
                   1261:        <dd>Abort the "get an attribute" algorithm. The attribute's
                   1262:        name is the value of <var title="">attribute name</var>, its
                   1263:        value is the empty string.</dd>
                   1264: 
1.464     mike     1265:        <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
                   1266:        Z)</dt>
1.1       mike     1267: 
                   1268:        <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
                   1269:        name</var> (where <var title="">b</var> is the value of the
                   1270:        byte at <var title="">position</var>).</dd>
                   1271: 
                   1272:        <dt>Anything else</dt>
                   1273: 
                   1274:        <dd>Append the Unicode character with the same code point as the
                   1275:        value of the byte at <var title="">position</var>) to <var title="">attribute name</var>. (It doesn't actually matter how
                   1276:        bytes outside the ASCII range are handled here, since only
                   1277:        ASCII characters can contribute to the detection of a character
                   1278:        encoding.)</dd>
                   1279: 
                   1280:       </dl></li>
                   1281: 
                   1282:      <li><p>Advance <var title="">position</var> to the next byte and
                   1283:      return to the previous step.</p></li>
                   1284: 
                   1285:      <li><p><i>Spaces</i>: If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
                   1286:      LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
                   1287:      advance <var title="">position</var> to the next byte, then,
                   1288:      repeat this step.</p></li>
                   1289: 
                   1290:      <li><p>If the byte at <var title="">position</var> is
1.464     mike     1291:      <em>not</em> 0x3D (ASCII =), abort the "get an attribute"
1.1       mike     1292:      algorithm. The attribute's name is the value of <var title="">attribute name</var>, its value is the empty
                   1293:      string.</p></li>
                   1294: 
                   1295:      <li><p>Advance <var title="">position</var> past the 0x3D (ASCII
1.464     mike     1296:      =) byte.</p></li>
1.1       mike     1297: 
                   1298:      <li><p><i>Value:</i> If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
                   1299:      LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
                   1300:      advance <var title="">position</var> to the next byte, then,
                   1301:      repeat this step.</p></li>
                   1302: 
                   1303:      <li><p>Process the byte at <var title="">position</var> as
                   1304:      follows:</p>
                   1305: 
1.464     mike     1306:       <dl class="switch"><dt>If it is 0x22 (ASCII ") or 0x27 (ASCII ')</dt>
1.1       mike     1307: 
                   1308:        <dd>
                   1309: 
                   1310:         <ol><li>Let <var title="">b</var> be the value of the byte at
                   1311:          <var title="">position</var>.</li>
                   1312: 
                   1313:          <li>Advance <var title="">position</var> to the next
                   1314:          byte.</li>
                   1315: 
                   1316:          <li>If the value of the byte at <var title="">position</var>
                   1317:          is the value of <var title="">b</var>, then advance <var title="">position</var> to the next byte and abort the "get
                   1318:          an attribute" algorithm. The attribute's name is the value of
                   1319:          <var title="">attribute name</var>, and its value is the
                   1320:          value of <var title="">attribute value</var>.</li>
                   1321: 
1.464     mike     1322:          <li>Otherwise, if the value of the byte at <var title="">position</var> is in the range 0x41 (ASCII A) to
                   1323:          0x5A (ASCII Z), then append a Unicode character to <var title="">attribute value</var> whose code point is 0x20 more
1.1       mike     1324:          than the value of the byte at <var title="">position</var>.</li>
                   1325: 
                   1326:          <li>Otherwise, append a Unicode character to <var title="">attribute value</var> whose code point is the same as
                   1327:          the value of the byte at <var title="">position</var>.</li>
                   1328: 
                   1329:          <li>Return to the second step in these substeps.</li>
                   1330: 
                   1331:         </ol></dd>
                   1332: 
1.464     mike     1333:        <dt>If it is 0x3E (ASCII &gt;)</dt>
1.1       mike     1334: 
                   1335:        <dd>Abort the "get an attribute" algorithm. The attribute's
                   1336:        name is the value of <var title="">attribute name</var>, its
                   1337:        value is the empty string.</dd>
                   1338: 
                   1339: 
1.464     mike     1340:        <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
                   1341:        Z)</dt>
1.1       mike     1342: 
                   1343:        <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
                   1344:        value</var> (where <var title="">b</var> is the value of the
                   1345:        byte at <var title="">position</var>). Advance <var title="">position</var> to the next byte.</dd>
                   1346: 
                   1347:        <dt>Anything else</dt>
                   1348: 
                   1349:        <dd>Append the Unicode character with the same code point as the
                   1350:        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>
                   1351: 
                   1352:       </dl></li>
                   1353: 
                   1354:      <li><p>Process the byte at <var title="">position</var> as
                   1355:      follows:</p>
                   1356: 
                   1357:       <dl class="switch"><dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
                   1358:        FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E (ASCII
1.464     mike     1359:        &gt;)</dt>
1.1       mike     1360: 
                   1361:        <dd>Abort the "get an attribute" algorithm. The attribute's
                   1362:        name is the value of <var title="">attribute name</var> and its
                   1363:        value is the value of <var title="">attribute value</var>.</dd>
                   1364: 
1.464     mike     1365:        <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
                   1366:        Z)</dt>
1.1       mike     1367: 
                   1368:        <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
                   1369:        value</var> (where <var title="">b</var> is the value of the
                   1370:        byte at <var title="">position</var>).</dd>
                   1371: 
                   1372:        <dt>Anything else</dt>
                   1373: 
                   1374:        <dd>Append the Unicode character with the same code point as the
                   1375:        value of the byte at <var title="">position</var>) to <var title="">attribute value</var>.</dd>
                   1376: 
                   1377:       </dl></li>
                   1378: 
                   1379:      <li><p>Advance <var title="">position</var> to the next byte and
                   1380:      return to the previous step.</p></li>
                   1381: 
                   1382:     </ol><p>For the sake of interoperability, user agents should not use a
                   1383:     pre-scan algorithm that returns different results than the one
                   1384:     described above. (But, if you do, please at least let us know, so
                   1385:     that we can improve this algorithm and benefit everyone...)</p>
                   1386: 
                   1387:    </li>
                   1388: 
                   1389:    <li><p>If the user agent has information on the likely encoding for
                   1390:    this page, e.g. based on the encoding of the page when it was last
                   1391:    visited, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1392:    <i>tentative</i>, and abort these steps.</p></li>
                   1393: 
1.322     mike     1394:    <li>
                   1395: 
                   1396:     <p>The user agent may attempt to autodetect the character encoding
                   1397:     from applying frequency analysis or other algorithms to the data
1.568     mike     1398:     stream. Such algorithms may use information about the resource
                   1399:     other than the resource's contents, including the address of the
                   1400:     resource. If autodetection succeeds in determining a character
1.322     mike     1401:     encoding, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1402:     <i>tentative</i>, and abort these steps. <a href="references.html#refsUNIVCHARDET">[UNIVCHARDET]</a></p>
                   1403: 
                   1404:     <p class="note">The UTF-8 encoding has a highly detectable bit
                   1405:     pattern. Documents that contain bytes with values greater than
                   1406:     0x7F which match the UTF-8 pattern are very likely to be UTF-8,
                   1407:     while documents with byte sequences that do not match it are very
                   1408:     likely not. User-agents are therefore encouraged to search for
1.485     mike     1409:     this common encoding. <a href="references.html#refsPPUTF8">[PPUTF8]</a> <a href="references.html#refsUTF8DET">[UTF8DET]</a></p>
1.322     mike     1410: 
                   1411:    </li>
1.1       mike     1412: 
1.501     mike     1413:    <li>
                   1414: 
                   1415:     <p>Otherwise, return an implementation-defined or user-specified
                   1416:     default character encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1417:     <i>tentative</i>.</p>
                   1418: 
                   1419:     <p>In controlled environments or in environments where the
                   1420:     encoding of documents can be prescribed (for example, for user
                   1421:     agents intended for dedicated use in new networks), the
                   1422:     comprehensive <code title="">UTF-8</code> encoding is
                   1423:     suggested.</p>
                   1424: 
                   1425:     <p>In other environments, the default encoding is typically
                   1426:     dependent on the user's locale (an approximation of the languages,
1.760     mike     1427:     and thus often encodings, of the pages that the user is likely to
                   1428:     frequent). The following table gives suggested defaults based on
                   1429:     the user's locale, for compatibility with legacy content. Locales
                   1430:     are identified by BCP 47 language codes. <a href="references.html#refsBCP47">[BCP47]</a></p>
1.501     mike     1431: 
                   1432:     <!-- based on mozilla 1.9.1 localizations: 
                   1433:          http://mxr.mozilla.org/l10n-mozilla1.9.1/find?string=global%2Fintl.properties&tree=l10n-mozilla1.9.1&hint= -->
                   1434: 
1.504     mike     1435:     <table><thead><tr><th>Locale language
1.501     mike     1436:        </th><th>Suggested default encoding
                   1437:      </th></tr></thead><tbody><tr><td>ar
                   1438:        </td><td>UTF-8
                   1439: 
                   1440:       </td></tr><tr><td>be
                   1441:        </td><td>ISO-8859-5
                   1442: 
                   1443:       </td></tr><tr><td>bg
                   1444:        </td><td>windows-1251
                   1445: 
                   1446:       </td></tr><tr><td>cs<!-- -CZ -->
                   1447:        </td><td>ISO-8859-2
                   1448: 
                   1449:       </td></tr><tr><td>cy
                   1450:        </td><td>UTF-8
                   1451: 
                   1452:       </td></tr><tr><td>fa<!-- -IR -->
                   1453:        </td><td>UTF-8
                   1454: 
                   1455:       </td></tr><tr><td>he<!-- -IL -->
                   1456:        </td><td>windows-1255
                   1457: 
                   1458:       </td></tr><tr><td>hr
                   1459:        </td><td>UTF-8
                   1460: 
                   1461:       </td></tr><tr><td>hu<!-- -HU -->
                   1462:        </td><td>ISO-8859-2
                   1463: 
                   1464:       </td></tr><tr><td>ja <!-- and ja-JP-mac -->
                   1465:        </td><td>windows-31J <!-- Shift_JIS -->
                   1466: 
                   1467:       </td></tr><tr><td>kk
                   1468:        </td><td>UTF-8
                   1469: 
                   1470:       </td></tr><tr><td>ko<!-- -KR -->
                   1471:        </td><td>windows-949 <!-- EUC-KR -->
                   1472: 
                   1473:       </td></tr><tr><td>ku
                   1474:        </td><td>windows-1254 <!-- ISO-8859-9 -->
                   1475: 
                   1476:       </td></tr><tr><td>lt
                   1477:        </td><td>windows-1257
                   1478: 
                   1479:       </td></tr><tr><td>lv<!-- -LV -->
                   1480:        </td><td>ISO-8859-13
                   1481: 
                   1482:       </td></tr><tr><td>mk<!-- -MK -->
                   1483:        </td><td>UTF-8
                   1484: 
                   1485:       </td></tr><tr><td>or
                   1486:        </td><td>UTF-8
                   1487: 
                   1488:       </td></tr><tr><td>pl<!-- -PL -->
                   1489:        </td><td>ISO-8859-2
                   1490: 
                   1491:       </td></tr><tr><td>ro
                   1492:        </td><td>UTF-8
                   1493: 
                   1494:       </td></tr><tr><td>ru
                   1495:        </td><td>windows-1251
                   1496: 
                   1497:       </td></tr><tr><td>sk
                   1498:        </td><td>windows-1250
                   1499: 
                   1500:       </td></tr><tr><td>sl
                   1501:        </td><td>ISO-8859-2
                   1502: 
                   1503:       </td></tr><tr><td>sr
                   1504:        </td><td>UTF-8
                   1505: 
                   1506:       </td></tr><tr><td>th
                   1507:        </td><td>windows-874 <!-- TIS-620 -->
                   1508: 
                   1509:       </td></tr><tr><td>tr<!-- -TR -->
                   1510:        </td><td>windows-1254 <!-- ISO-8859-9 -->
                   1511: 
1.503     mike     1512:       </td></tr><tr><td>uk
1.501     mike     1513:        </td><td>windows-1251
                   1514: 
                   1515:       </td></tr><tr><td>vi
                   1516:        </td><td>UTF-8
                   1517: 
                   1518:       </td></tr><tr><td>zh-CN
                   1519:        </td><td>GB18030
                   1520: 
                   1521:       </td></tr><tr><td>zh-TW
                   1522:        </td><td>Big5
                   1523: 
                   1524:       </td></tr><tr><td>All other locales
                   1525:        </td><td>windows-1252
                   1526: 
                   1527:     </td></tr></tbody></table></li>
1.1       mike     1528: 
                   1529:   </ol><p>The <a href="dom.html#document-s-character-encoding">document's character encoding</a> must immediately
                   1530:   be set to the value returned from this algorithm, at the same time
                   1531:   as the user agent uses the returned value to select the decoder to
                   1532:   use for the input stream.</p>
                   1533: 
1.582     mike     1534:   <p class="note">This algorithm is a <a href="introduction.html#willful-violation">willful violation</a>
                   1535:   of the HTTP specification, which requires that the encoding be
                   1536:   assumed to be ISO-8859-1 in the absence of a <a href="semantics.html#character-encoding-declaration">character
1.647     mike     1537:   encoding declaration</a> to the contrary, and of RFC 2046,
1.582     mike     1538:   which requires that the encoding be assumed to be US-ASCII in the
                   1539:   absence of a <a href="semantics.html#character-encoding-declaration">character encoding declaration</a> to the
                   1540:   contrary. This specification's third approach is motivated by a
                   1541:   desire to be maximally compatible with legacy content. <a href="references.html#refsHTTP">[HTTP]</a> <a href="references.html#refsRFC2046">[RFC2046]</a></p>
                   1542: 
1.1       mike     1543: 
1.755     mike     1544:   <h5 id="character-encodings-0"><span class="secno">8.2.2.2 </span>Character encodings</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     1545: 
1.237     mike     1546:   <p>User agents must at a minimum support the UTF-8 and Windows-1252
                   1547:   encodings, but may support more.</p>
                   1548: 
                   1549:   <p class="note">It is not unusual for Web browsers to support dozens
                   1550:   if not upwards of a hundred distinct character encodings.</p>
                   1551: 
1.365     mike     1552:   <p>User agents must support the <a href="infrastructure.html#preferred-mime-name">preferred MIME name</a> of
                   1553:   every character encoding they support, and should support all the
                   1554:   IANA-registered names and aliases of every character encoding they
                   1555:   support. <a href="references.html#refsIANACHARSET">[IANACHARSET]</a></p>
1.237     mike     1556: 
                   1557:   <p>When comparing a string specifying a character encoding with the
                   1558:   name or alias of a character encoding to determine if they are
                   1559:   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
                   1560:   then perform the comparison in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   1561:   case-insensitive</a> manner.</p>
                   1562: 
1.539     mike     1563:   <hr><p>When a user agent would otherwise use an encoding given in the
1.237     mike     1564:   first column of the following table to either convert content to
                   1565:   Unicode characters or convert Unicode characters to bytes, it must
                   1566:   instead use the encoding given in the cell in the second column of
                   1567:   the same row. When a byte or sequence of bytes is treated
                   1568:   differently due to this encoding aliasing, it is said to have been
                   1569:   <dfn id="misinterpreted-for-compatibility">misinterpreted for compatibility</dfn>.</p>
                   1570: 
                   1571:   <table><caption>Character encoding overrides</caption>
                   1572:    <thead><tr><th> Input encoding </th><th> Replacement encoding </th><th> References
                   1573:    </th></tr></thead><tbody><!-- how about EUC-JP? --><tr><td> EUC-KR </td><td> windows-949 </td><td>
                   1574:          <a href="references.html#refsEUCKR">[EUCKR]</a>
                   1575:          <a href="references.html#refsWIN949">[WIN949]</a>
                   1576:     </td></tr><tr><td> GB2312 </td><td> GBK </td><td>
                   1577:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1578:          <a href="references.html#refsGBK">[GBK]</a>
                   1579:     </td></tr><tr><td> GB_2312-80 </td><td> GBK </td><td>
                   1580:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1581:          <a href="references.html#refsGBK">[GBK]</a>
                   1582:     </td></tr><tr><td> ISO-8859-1 </td><td> windows-1252 </td><td>
                   1583:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1584:          <a href="references.html#refsWIN1252">[WIN1252]</a>
                   1585:     </td></tr><tr><td> ISO-8859-9 </td><td> windows-1254 </td><td>
                   1586:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1587:          <a href="references.html#refsWIN1254">[WIN1254]</a>
                   1588:     </td></tr><tr><td> ISO-8859-11 </td><td> windows-874 </td><td>
                   1589:          <a href="references.html#refsISO885911">[ISO885911]</a>
                   1590:          <a href="references.html#refsWIN874">[WIN874]</a>
                   1591:     </td></tr><tr><td> KS_C_5601-1987 </td><td> windows-949 </td><td>
                   1592:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1593:          <a href="references.html#refsWIN949">[WIN949]</a>
                   1594:     </td></tr><tr><td> Shift_JIS </td><td> windows-31J </td><td>
                   1595:          <a href="references.html#refsSHIFTJIS">[SHIFTJIS]</a>
                   1596:          <a href="references.html#refsWIN31J">[WIN31J]</a>
                   1597:     </td></tr><tr><td> TIS-620 </td><td> windows-874 </td><td>
                   1598:          <a href="references.html#refsTIS620">[TIS620]</a>
                   1599:          <a href="references.html#refsWIN874">[WIN874]</a>
                   1600:     </td></tr><tr><td> US-ASCII </td><td> windows-1252 </td><td>
                   1601:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1602:          <a href="references.html#refsWIN1252">[WIN1252]</a>
                   1603:    </td></tr></tbody></table><p class="note">The requirement to treat certain encodings as other
                   1604:   encodings according to the table above is a <a href="introduction.html#willful-violation">willful
                   1605:   violation</a> of the W3C Character Model specification, motivated
                   1606:   by a desire for compatibility with legacy content. <a href="references.html#refsCHARMOD">[CHARMOD]</a></p>
                   1607: 
                   1608:   <p>When a user agent is to use the UTF-16 encoding but no BOM has
                   1609:   been found, user agents must default to UTF-16LE.</p>
                   1610: 
                   1611:   <p class="note">The requirement to default UTF-16 to LE rather than
                   1612:   BE is a <a href="introduction.html#willful-violation">willful violation</a> of RFC 2781, motivated by a
1.581     mike     1613:   desire for compatibility with legacy content. <a href="references.html#refsRFC2781">[RFC2781]</a></p>
1.237     mike     1614: 
                   1615:   <hr><p>User agents must not support the CESU-8, UTF-7, BOCU-1 and SCSU
                   1616:   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>
                   1617: 
                   1618:   <p>Support for encodings based on EBCDIC is not recommended. This
                   1619:   encoding is rarely used for publicly-facing Web content.</p>
                   1620: 
                   1621:   <p>Support for UTF-32 is not recommended. This encoding is rarely
                   1622:   used, and frequently implemented incorrectly.</p>
                   1623: 
                   1624:   <p class="note">This specification does not make any attempt to
                   1625:   support EBCDIC-based encodings and UTF-32 in its algorithms; support
                   1626:   and use of these encodings can thus lead to unexpected behavior in
                   1627:   implementations of this specification.</p>
                   1628: 
                   1629: 
                   1630: 
1.755     mike     1631:   <h5 id="preprocessing-the-input-stream"><span class="secno">8.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     1632: 
                   1633:   <p>Given an encoding, the bytes in the input stream must be
                   1634:   converted to Unicode characters for the tokenizer, as described by
                   1635:   the rules for that encoding, except that the leading U+FEFF BYTE
                   1636:   ORDER MARK character, if any, must not be stripped by the encoding
                   1637:   layer (it is stripped by the rule below).</p> <!-- this is to
                   1638:   prevent two leading BOMs from being both stripped, once by the
                   1639:   decoder, and once by the parser -->
                   1640: 
                   1641:   <p>Bytes or sequences of bytes in the original byte stream that
1.393     mike     1642:   could not be converted to Unicode code points must be converted to
                   1643:   U+FFFD REPLACEMENT CHARACTERs.</p>
1.1       mike     1644: 
                   1645:   <p class="note">Bytes or sequences of bytes in the original byte
                   1646:   stream that did not conform to the encoding specification
                   1647:   (e.g. invalid UTF-8 byte sequences in a UTF-8 input stream) are
                   1648:   errors that conformance checkers are expected to report.</p>
                   1649: 
1.438     mike     1650:   <p>Any byte or sequence of bytes in the original byte stream that is
                   1651:   <a href="#misinterpreted-for-compatibility">misinterpreted for compatibility</a> is a <a href="#parse-error">parse
1.1       mike     1652:   error</a>.</p>
                   1653: 
                   1654:   <p>One leading U+FEFF BYTE ORDER MARK character must be ignored if
                   1655:   any are present.</p>
                   1656: 
1.300     mike     1657:   <p class="note">The requirement to strip a U+FEFF BYTE ORDER MARK
                   1658:   character regardless of whether that character was used to determine
                   1659:   the byte order is a <a href="introduction.html#willful-violation">willful violation</a> of Unicode,
                   1660:   motivated by a desire to increase the resilience of user agents in
                   1661:   the face of na&#239;ve transcoders.</p>
                   1662: 
1.316     mike     1663:   <p>All U+0000 NULL characters and code points in the range U+D800 to
1.315     mike     1664:   U+DFFF<!-- surrogates not allowed e.g. in UTF-8, and we don't want
                   1665:   them to suddenly turn into codepoints when they go through a UTF-16
                   1666:   pipe --> in the input must be replaced by U+FFFD REPLACEMENT
1.316     mike     1667:   CHARACTERs. Any occurrences of such characters and code points are
                   1668:   <a href="#parse-error" title="parse error">parse errors</a>.</p>
1.1       mike     1669: 
                   1670:   <p>Any occurrences of any characters in the ranges U+0001 to U+0008,
                   1671:   <!-- HT, LF allowed --> <!-- U+000B is in the next list --> <!-- FF,
                   1672:   CR allowed --> U+000E to U+001F, <!-- ASCII allowed --> U+007F
1.315     mike     1673:   <!--to U+0084, (U+0085 NEL not allowed), U+0086--> to U+009F, U+FDD0
                   1674:   to U+FDEF, and characters U+000B, U+FFFE, U+FFFF, U+1FFFE, U+1FFFF,
                   1675:   U+2FFFE, U+2FFFF, U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE,
                   1676:   U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF,
                   1677:   U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE,
                   1678:   U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF,
                   1679:   U+10FFFE, and U+10FFFF are <a href="#parse-error" title="parse error">parse
1.316     mike     1680:   errors</a>. These are all control characters or permanently
                   1681:   undefined Unicode characters (noncharacters).</p>
1.1       mike     1682: 
                   1683:   <p>U+000D CARRIAGE RETURN (CR) characters and U+000A LINE FEED (LF)
                   1684:   characters are treated specially. Any CR characters that are
                   1685:   followed by LF characters must be removed, and any CR characters not
                   1686:   followed by LF characters must be converted to LF characters. Thus,
                   1687:   newlines in HTML DOMs are represented by LF characters, and there
                   1688:   are never any CR characters in the input to the
                   1689:   <a href="#tokenization">tokenization</a> stage.</p>
                   1690: 
                   1691:   <p>The <dfn id="next-input-character">next input character</dfn> is the first character in the
                   1692:   input stream that has not yet been <dfn id="consumed">consumed</dfn>. Initially,
                   1693:   the <i><a href="#next-input-character">next input character</a></i> is the first character in the
                   1694:   input. The <dfn id="current-input-character">current input character</dfn> is the last character
                   1695:   to have been <i><a href="#consumed">consumed</a></i>.</p>
                   1696: 
                   1697:   <p>The <dfn id="insertion-point">insertion point</dfn> is the position (just before a
                   1698:   character or just before the end of the input stream) where content
1.159     mike     1699:   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     1700:   inserted. The insertion point is relative to the position of the
                   1701:   character immediately after it, it is not an absolute offset into
                   1702:   the input stream. Initially, the insertion point is
1.10      mike     1703:   undefined.</p>
1.1       mike     1704: 
                   1705:   <p>The "EOF" character in the tables below is a conceptual character
                   1706:   representing the end of the <a href="#the-input-stream">input stream</a>. If the parser
1.159     mike     1707:   is a <a href="embedded-content-0.html#script-created-parser">script-created parser</a>, then the end of the
1.1       mike     1708:   <a href="#the-input-stream">input stream</a> is reached when an <dfn id="explicit-eof-character">explicit "EOF"
1.159     mike     1709:   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     1710:   consumed. Otherwise, the "EOF" character is not a real character in
                   1711:   the stream, but rather the lack of any further characters.</p>
                   1712: 
                   1713: 
1.755     mike     1714:   <h5 id="changing-the-encoding-while-parsing"><span class="secno">8.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     1715: 
                   1716:   <p>When the parser requires the user agent to <dfn id="change-the-encoding">change the
                   1717:   encoding</dfn>, it must run the following steps. This might happen
                   1718:   if the <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> described above
                   1719:   failed to find an encoding, or if it found an encoding that was not
                   1720:   the actual encoding of the file.</p>
                   1721: 
                   1722:   <ol><li>If the new encoding is identical or equivalent to the encoding
                   1723:    that is already being used to interpret the input stream, then set
                   1724:    the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1725:    <i>certain</i> and abort these steps. This happens when the
                   1726:    encoding information found in the file matches what the
                   1727:    <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> determined to be the
                   1728:    encoding, and in the second pass through the parser if the first
                   1729:    pass found that the encoding sniffing algorithm described in the
                   1730:    earlier section failed to find the right encoding.</li>
                   1731: 
                   1732:    <li>If the encoding that is already being used to interpret the
                   1733:    input stream is a UTF-16 encoding, then set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1734:    <i>certain</i> and abort these steps. The new encoding is ignored;
                   1735:    if it was anything but the same encoding, then it would be clearly
                   1736:    incorrect.</li>
                   1737: 
                   1738:    <li>If the new encoding is a UTF-16 encoding, change it to
                   1739:    UTF-8.</li>
                   1740: 
                   1741:    <li>If all the bytes up to the last byte converted by the current
                   1742:    decoder have the same Unicode interpretations in both the current
                   1743:    encoding and the new encoding, and if the user agent supports
                   1744:    changing the converter on the fly, then the user agent may change
                   1745:    to the new converter for the encoding on the fly. Set the
                   1746:    <a href="dom.html#document-s-character-encoding">document's character encoding</a> and the encoding used to
                   1747:    convert the input stream to the new encoding, set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1748:    <i>certain</i>, and abort these steps.</li>
                   1749: 
                   1750:    <li>Otherwise, <a href="history.html#navigate">navigate</a> to the document again, with
                   1751:    <a href="history.html#replacement-enabled">replacement enabled</a>, and using the same <a href="history.html#source-browsing-context">source
                   1752:    browsing context</a>, but this time skip the <a href="#encoding-sniffing-algorithm">encoding
                   1753:    sniffing algorithm</a> and instead just set the encoding to the
                   1754:    new encoding and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1755:    <i>certain</i>. Whenever possible, this should be done without
                   1756:    actually contacting the network layer (the bytes should be
                   1757:    re-parsed from memory), even if, e.g., the document is marked as
                   1758:    not being cacheable. If this is not possible and contacting the
                   1759:    network layer would involve repeating a request that uses a method
                   1760:    other than HTTP GET (<a href="infrastructure.html#concept-http-equivalent-get" title="concept-http-equivalent-get">or
                   1761:    equivalent</a> for non-HTTP URLs), then instead set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1762:    <i>certain</i> and ignore the new encoding. The resource will be
                   1763:    misinterpreted. User agents may notify the user of the situation,
                   1764:    to aid in application development.</li>
                   1765: 
1.266     mike     1766:   </ol></div><div class="impl">
                   1767: 
1.755     mike     1768:   <h4 id="parse-state"><span class="secno">8.2.3 </span>Parse state</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     1769: 
1.755     mike     1770:   <h5 id="the-insertion-mode"><span class="secno">8.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     1771: 
                   1772:   <p>The <dfn id="insertion-mode">insertion mode</dfn> is a state variable that controls
                   1773:   the primary operation of the tree construction stage.</p>
                   1774: 
                   1775:   <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
                   1776:   "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before html</a>",
                   1777:   "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before head</a>",
                   1778:   "<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     1779:   "<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     1780:   "<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>",
                   1781:   "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table body</a>",
                   1782:   "<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
                   1783:   table</a>", "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in
                   1784:   foreign content</a>", "<a href="#parsing-main-afterbody" title="insertion mode: after
                   1785:   body">after body</a>", "<a href="#parsing-main-inframeset" title="insertion mode: in
                   1786:   frameset">in frameset</a>", "<a href="#parsing-main-afterframeset" title="insertion mode: after
                   1787:   frameset">after frameset</a>", "<a href="#the-after-after-body-insertion-mode" title="insertion mode:
                   1788:   after after body">after after body</a>", and "<a href="#the-after-after-frameset-insertion-mode" title="insertion mode: after after frameset">after after
                   1789:   frameset</a>" during the course of the parsing, as described in
                   1790:   the <a href="#tree-construction">tree construction</a> stage. The insertion mode affects
                   1791:   how tokens are processed and whether CDATA sections are
                   1792:   supported.</p>
                   1793: 
                   1794:   <p>Seven of these modes, namely "<a href="#parsing-main-inhead" title="insertion mode: in
                   1795:   head">in head</a>", "<a href="#parsing-main-inbody" title="insertion mode: in body">in
                   1796:   body</a>", "<a href="#parsing-main-intable" title="insertion mode: in table">in
                   1797:   table</a>", "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   1798:   body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in row</a>",
                   1799:   "<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
                   1800:   that the other modes defer to them at various times. When the
                   1801:   algorithm below says that the user agent is to do something
                   1802:   "<dfn id="using-the-rules-for">using the rules for</dfn> the <var title="">m</var> insertion
                   1803:   mode", where <var title="">m</var> is one of these modes, the user
                   1804:   agent must use the rules described under the <var title="">m</var>
                   1805:   <a href="#insertion-mode">insertion mode</a>'s section, but must leave the
                   1806:   <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>
                   1807:   to a new value.</p>
                   1808: 
                   1809:   <p>When the insertion mode is switched to "<a href="#parsing-main-incdata" title="insertion
1.540     mike     1810:   mode: text">text</a>" or "<a href="#parsing-main-intabletext" title="insertion mode: in table
                   1811:   text">in table text</a>", the <dfn id="original-insertion-mode">original insertion mode</dfn>
                   1812:   is also set. This is the insertion mode to which the tree
                   1813:   construction stage will return.</p>
1.1       mike     1814: 
                   1815:   <p>When the insertion mode is switched to "<a href="#parsing-main-inforeign" title="insertion
                   1816:   mode: in foreign content">in foreign content</a>", the
                   1817:   <dfn id="secondary-insertion-mode">secondary insertion mode</dfn> is also set. This secondary mode
                   1818:   is used within the rules for the "<a href="#parsing-main-inforeign" title="insertion mode: in
                   1819:   foreign content">in foreign content</a>" mode to handle HTML
                   1820:   (i.e. not foreign) content.</p>
                   1821: 
                   1822:   <hr><p>When the steps below require the UA to <dfn id="reset-the-insertion-mode-appropriately">reset the insertion
                   1823:   mode appropriately</dfn>, it means the UA must follow these
                   1824:   steps:</p>
                   1825: 
                   1826:   <ol><li>Let <var title="">last</var> be false.</li>
                   1827: 
1.604     mike     1828:    <li>Let <var title="">foreign</var> be false.</li>
                   1829: 
1.1       mike     1830:    <li>Let <var title="">node</var> be the last node in the
                   1831:    <a href="#stack-of-open-elements">stack of open elements</a>.</li>
                   1832: 
1.604     mike     1833:    <li><i>Loop</i>: If <var title="">node</var> is the first node in
                   1834:    the stack of open elements, then set <var title="">last</var> to
                   1835:    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     1836: 
                   1837:    <li>If <var title="">node</var> is a <code><a href="forms.html#the-select-element">select</a></code> element,
1.604     mike     1838:    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
                   1839:    step marked <i title="">end</i>. (<a href="#fragment-case">fragment case</a>)</li>
1.1       mike     1840: 
                   1841:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-td-element">td</a></code> or
                   1842:    <code><a href="tabular-data.html#the-th-element">th</a></code> element and <var title="">last</var> is false, then
                   1843:    switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion
1.604     mike     1844:    mode: in cell">in cell</a>" and jump to the step marked <i title="">end</i>.</li>
1.1       mike     1845: 
                   1846:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then
                   1847:    switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion
1.604     mike     1848:    mode: in row">in row</a>" and jump to the step marked <i title="">end</i>.</li>
1.1       mike     1849: 
                   1850:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>,
                   1851:    <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
                   1852:    <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in
1.604     mike     1853:    table body">in table body</a>" and jump to the step marked <i title="">end</i>.</li>
1.1       mike     1854: 
                   1855:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-caption-element">caption</a></code> element,
1.604     mike     1856:    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
                   1857:    the step marked <i title="">end</i>.</li>
1.1       mike     1858: 
                   1859:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element,
                   1860:    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     1861:    jump to the step marked <i title="">end</i>. (<a href="#fragment-case">fragment
                   1862:    case</a>)</li>
1.1       mike     1863: 
                   1864:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-table-element">table</a></code> element,
1.604     mike     1865:    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
                   1866:    step marked <i title="">end</i>.</li>
1.1       mike     1867: 
1.159     mike     1868:    <li>If <var title="">node</var> is a <code><a href="semantics.html#the-head-element-0">head</a></code> element,
1.604     mike     1869:    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
                   1870:    the step marked <i title="">end</i>. (<a href="#fragment-case">fragment
                   1871:    case</a>)</li> <!-- This is only here for now in case people
                   1872:    think that the spec accidentally omitted it and try to "fix"
                   1873:    it. Note that noscript-in-head is also handled this way. This is
                   1874:    all intentional. The only thing it doesn't handle is the
                   1875:    scripting-disabled fragment parsing case for a <head> element
                   1876:    containing a <noscript> which itself contains something other than
                   1877:    a <link> or a <style> element; you'd expect that to break out of
                   1878:    the <noscript> but it doesn't. This is an edge case that doesn't
                   1879:    affect the spec, since the algorithm for fragment parsing is only
                   1880:    used for innerHTML/outerHTML/insertAdjacentHTML(), where we know
                   1881:    scripting is enabled. -->
1.1       mike     1882: 
1.159     mike     1883:    <li>If <var title="">node</var> is a <code><a href="semantics.html#the-body-element-0">body</a></code> element,
1.604     mike     1884:    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
                   1885:    step marked <i title="">end</i>.</li>
1.1       mike     1886: 
1.5       mike     1887:    <li>If <var title="">node</var> is a <code><a href="obsolete.html#frameset">frameset</a></code> element,
1.604     mike     1888:    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
                   1889:    the step marked <i title="">end</i>. (<a href="#fragment-case">fragment
                   1890:    case</a>)</li>
1.1       mike     1891: 
1.159     mike     1892:    <li>If <var title="">node</var> is an <code><a href="semantics.html#the-html-element-0">html</a></code> element,
1.333     mike     1893:    then <!--: if the <span><code title="">head</code> element
                   1894:    pointer</span> is null,--> switch the <a href="#insertion-mode">insertion mode</a>
                   1895:    to "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before
                   1896:    head</a>"<!--, otherwise, switch the <span>insertion mode</span>
                   1897:    to "<span title="insertion mode: after head">after head</span>".-->
1.604     mike     1898:    Then, <!-- in either case, --> jump to the step marked <i title="">end</i>. (<a href="#fragment-case">fragment case</a>)</li> <!-- if the
                   1899:    head element pointer can ever be non-null when we're going through
                   1900:    these steps, we'll need to uncomment out the commented-out bits -->
                   1901: 
1.724     mike     1902:    <li>If <var title="">node</var> is an element from the <a href="infrastructure.html#mathml-namespace">MathML
                   1903:    namespace</a> or the <a href="infrastructure.html#svg-namespace">SVG namespace</a>, then set the
1.604     mike     1904:    <var title="">foreign</var> flag to true.</li>
1.1       mike     1905: 
                   1906:    <li>If <var title="">last</var> is true, then switch the
                   1907:    <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in
1.604     mike     1908:    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     1909: 
                   1910:    <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
                   1911:    elements</a>.</li>
                   1912: 
1.604     mike     1913:    <li>Return to the step marked <i>loop</i>.</li>
                   1914: 
                   1915:    <li><i>End</i>: If <var title="">foreign</var> is true, switch the
                   1916:    <a href="#secondary-insertion-mode">secondary insertion mode</a> to whatever the
                   1917:    <a href="#insertion-mode">insertion mode</a> is set to, and switch the
                   1918:    <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
                   1919:    foreign content">in foreign content</a>".</li>
1.1       mike     1920: 
1.755     mike     1921:   </ol><h5 id="the-stack-of-open-elements"><span class="secno">8.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     1922: 
                   1923:   <p>Initially, the <dfn id="stack-of-open-elements">stack of open elements</dfn> is empty. The
                   1924:   stack grows downwards; the topmost node on the stack is the first
                   1925:   one added to the stack, and the bottommost node of the stack is the
                   1926:   most recently added node in the stack (notwithstanding when the
                   1927:   stack is manipulated in a random access fashion as part of <a href="#adoptionAgency">the handling for misnested tags</a>).</p>
                   1928: 
                   1929:   <p>The "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before
                   1930:   html</a>" <a href="#insertion-mode">insertion mode</a> creates the
1.159     mike     1931:   <code><a href="semantics.html#the-html-element-0">html</a></code> root element node, which is then added to the
1.1       mike     1932:   stack.</p>
                   1933: 
                   1934:   <p>In the <a href="#fragment-case">fragment case</a>, the <a href="#stack-of-open-elements">stack of open
1.159     mike     1935:   elements</a> is initialized to contain an <code><a href="semantics.html#the-html-element-0">html</a></code>
1.1       mike     1936:   element that is created as part of <a href="#html-fragment-parsing-algorithm" title="html fragment
                   1937:   parsing algorithm">that algorithm</a>. (The <a href="#fragment-case">fragment
                   1938:   case</a> skips the "<a href="#the-before-html-insertion-mode" title="insertion mode: before
                   1939:   html">before html</a>" <a href="#insertion-mode">insertion mode</a>.)</p>
                   1940: 
1.159     mike     1941:   <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     1942:   node of the stack. It never gets popped off the stack.</p>
                   1943: 
                   1944:   <p>The <dfn id="current-node">current node</dfn> is the bottommost node in this
                   1945:   stack.</p>
                   1946: 
                   1947:   <p>The <dfn id="current-table">current table</dfn> is the last <code><a href="tabular-data.html#the-table-element">table</a></code>
                   1948:   element in the <a href="#stack-of-open-elements">stack of open elements</a>, if there is
                   1949:   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
                   1950:   open elements</a> (<a href="#fragment-case">fragment case</a>), then the
                   1951:   <a href="#current-table">current table</a> is the first element in the <a href="#stack-of-open-elements">stack
1.159     mike     1952:   of open elements</a> (the <code><a href="semantics.html#the-html-element-0">html</a></code> element).</p>
1.1       mike     1953: 
                   1954:   <p>Elements in the stack fall into the following categories:</p>
                   1955: 
                   1956:   <dl><dt><dfn id="special">Special</dfn></dt>
                   1957: 
                   1958:    <dd><p>The following HTML elements have varying levels of special
                   1959:    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>,
                   1960:    <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     1961:    <code><a href="obsolete.html#basefont">basefont</a></code>, <code><a href="obsolete.html#bgsound">bgsound</a></code>,
1.159     mike     1962:    <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     1963:    <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.755     mike     1964:    <code><a href="interactive-elements.html#the-command">command</a></code>, <!--v2DDATAGRID <code>datagrid</code>-->,
1.422     mike     1965:    <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>,
                   1966:    <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>,
1.762     mike     1967:    <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="semantics.html#the-figure-element">figure</a></code>,
1.422     mike     1968:    <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>,
                   1969:    <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>,
                   1970:    <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>,
                   1971:    <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>,
                   1972:    <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>,
                   1973:    (commented out because this isn't an element that can end up on the
                   1974:    stack, so it doesn't matter) --> <code><a href="text-level-semantics.html#the-img-element">img</a></code>,
                   1975:    <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>,
                   1976:    <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>,
                   1977:    <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>,
                   1978:    <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>,
                   1979:    <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>,
                   1980:    <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     1981:    <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>,
                   1982:    <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>,
                   1983:    <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     1984:    <code><a href="obsolete.html#wbr">wbr</a></code>, and <code><a href="obsolete.html#xmp">xmp</a></code>.</p></dd>
1.1       mike     1985: 
                   1986:    <dt><dfn id="scoping">Scoping</dfn></dt>
                   1987:    <dd><p>The following HTML elements introduce new <a href="#has-an-element-in-scope" title="has
                   1988:    an element in scope">scopes</a> for various parts of the
1.5       mike     1989:    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     1990:    <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>,
                   1991:    <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     1992:    <code><a href="tabular-data.html#the-th-element">th</a></code>, and SVG's <code>foreignObject</code>.</p></dd>
                   1993: 
                   1994:    <dt><dfn id="formatting">Formatting</dfn></dt>
                   1995:    <dd><p>The following HTML elements are those that end up in the
                   1996:    <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     1997:    <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>,
                   1998:    <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     1999:    <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     2000:    <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
                   2001:    <code><a href="obsolete.html#u">u</a></code>.</p></dd>
1.1       mike     2002: 
                   2003:    <dt><dfn id="phrasing">Phrasing</dfn></dt>
                   2004:    <dd><p>All other elements found while parsing an HTML
                   2005:    document.</p></dd>
                   2006: 
1.234     mike     2007:   </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
                   2008:   specific scope</dfn> consisting of a list of element types <var title="">list</var> when the following algorithm terminates in a
                   2009:   match state:</p>
1.1       mike     2010: 
                   2011:   <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
                   2012:    node</a> (the bottommost node of the stack).</p></li>
                   2013: 
                   2014:    <li><p>If <var title="">node</var> is the target node, terminate in
                   2015:    a match state.</p></li>
                   2016: 
1.234     mike     2017:    <li><p>Otherwise, if <var title="">node</var> is one of the element
                   2018:    types in <var title="">list</var>, terminate in a failure
                   2019:    state.</p></li>
1.1       mike     2020: 
                   2021:    <li><p>Otherwise, set <var title="">node</var> to the previous
                   2022:    entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to step
                   2023:    2. (This will never fail, since the loop will always terminate in
                   2024:    the previous step if the top of the stack &#8212; an
1.159     mike     2025:    <code><a href="semantics.html#the-html-element-0">html</a></code> element &#8212; is reached.)</p></li>
1.1       mike     2026: 
1.234     mike     2027:   </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
                   2028:   it <a href="#has-an-element-in-the-specific-scope">has an element in the specific scope</a> consisting
                   2029:   of the following element types:</p>
                   2030: 
                   2031:   <ul class="brief"><li><code><a href="obsolete.html#the-applet-element">applet</a></code> in the HTML namespace</li>
                   2032:    <li><code><a href="tabular-data.html#the-caption-element">caption</a></code> in the HTML namespace</li>
                   2033:    <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.) -->
                   2034:    <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
                   2035:    <li><code><a href="tabular-data.html#the-td-element">td</a></code> in the HTML namespace</li>
                   2036:    <li><code><a href="tabular-data.html#the-th-element">th</a></code> in the HTML namespace</li>
                   2037:    <li><code><a href="forms.html#the-button-element">button</a></code> in the HTML namespace</li>
                   2038:    <li><code><a href="obsolete.html#the-marquee-element">marquee</a></code> in the HTML namespace</li>
                   2039:    <li><code><a href="text-level-semantics.html#the-object-element">object</a></code> in the HTML namespace</li>
                   2040:    <li><code title="">foreignObject</code> in the SVG namespace</li>
                   2041:   </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
                   2042:   item scope</dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
                   2043:   scope</a> consisting of the following element types:</p>
                   2044: 
                   2045:   <ul class="brief"><li>All the element types listed above for the <i><a href="#has-an-element-in-scope">has an element
                   2046:    in scope</a></i> algorithm.</li>
                   2047:    <li><code><a href="semantics.html#the-ol-element">ol</a></code> in the HTML namespace</li>
                   2048:    <li><code><a href="semantics.html#the-ul-element">ul</a></code> in the HTML namespace</li>
                   2049:   </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
                   2050:   scope</em></dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
                   2051:   scope</a> consisting of the following element types:</p>
                   2052: 
                   2053:   <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.) -->
                   2054:    <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
                   2055:   </ul><p>Nothing happens if at any time any of the elements in the
1.1       mike     2056:   <a href="#stack-of-open-elements">stack of open elements</a> are moved to a new location in,
                   2057:   or removed from, the <code>Document</code> tree. In particular, the
                   2058:   stack is not changed in this situation. This can cause, amongst
                   2059:   other strange effects, content to be appended to nodes that are no
                   2060:   longer in the DOM.</p>
                   2061: 
                   2062:   <p class="note">In some cases (namely, when <a href="#adoptionAgency">closing misnested formatting elements</a>),
                   2063:   the stack is manipulated in a random-access fashion.</p>
                   2064: 
                   2065: 
1.755     mike     2066:   <h5 id="the-list-of-active-formatting-elements"><span class="secno">8.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     2067: 
                   2068:   <p>Initially, the <dfn id="list-of-active-formatting-elements">list of active formatting elements</dfn> is
                   2069:   empty. It is used to handle mis-nested <a href="#formatting" title="formatting">formatting element tags</a>.</p>
                   2070: 
                   2071:   <p>The list contains elements in the <a href="#formatting">formatting</a>
                   2072:   category, and scope markers. The scope markers are inserted when
1.159     mike     2073:   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     2074:   elements, marquees, table cells, and table captions, and are used to
1.5       mike     2075:   prevent formatting from "leaking" <em>into</em> <code><a href="obsolete.html#the-applet-element">applet</a></code>
1.159     mike     2076:   elements, buttons, <code><a href="text-level-semantics.html#the-object-element">object</a></code> elements, marquees, and
1.1       mike     2077:   tables.</p>
                   2078: 
                   2079:   <p class="note">The scope markers are unrelated to the concept of an
                   2080:   element being <a href="#has-an-element-in-scope" title="has an element in scope">in
                   2081:   scope</a>.</p>
                   2082: 
                   2083:   <p>In addition, each element in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2084:   elements</a> is associated with the token for which it was
                   2085:   created, so that further elements can be created for that token if
                   2086:   necessary.</p>
                   2087: 
                   2088:   <p>When the steps below require the UA to <dfn id="reconstruct-the-active-formatting-elements">reconstruct the
                   2089:   active formatting elements</dfn>, the UA must perform the following
                   2090:   steps:</p>
                   2091: 
                   2092:   <ol><li>If there are no entries in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2093:    elements</a>, then there is nothing to reconstruct; stop this
                   2094:    algorithm.</li>
                   2095: 
                   2096:    <li>If the last (most recently added) entry in the <a href="#list-of-active-formatting-elements">list of
                   2097:    active formatting elements</a> is a marker, or if it is an
                   2098:    element that is in the <a href="#stack-of-open-elements">stack of open elements</a>, then
                   2099:    there is nothing to reconstruct; stop this algorithm.</li>
                   2100: 
                   2101:    <li>Let <var title="">entry</var> be the last (most recently added)
                   2102:    element in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2103:    elements</a>.</li>
                   2104: 
                   2105:    <li>If there are no entries before <var title="">entry</var> in the
                   2106:    <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, then jump to step
                   2107:    8.</li>
                   2108: 
                   2109:    <li>Let <var title="">entry</var> be the entry one earlier than
                   2110:    <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2111:    elements</a>.</li>
                   2112: 
                   2113:    <li>If <var title="">entry</var> is neither a marker nor an element
                   2114:    that is also in the <a href="#stack-of-open-elements">stack of open elements</a>, go to step
                   2115:    4.</li>
                   2116: 
                   2117:    <li>Let <var title="">entry</var> be the element one later than
                   2118:    <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2119:    elements</a>.</li>
                   2120: 
                   2121:    <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
                   2122:    element <var title="">entry</var> was created, to obtain <var title="">new element</var>.</li>
                   2123: 
                   2124:    <li>Append <var title="">new element</var> to the <a href="#current-node">current
                   2125:    node</a> and push it onto the <a href="#stack-of-open-elements">stack of open
                   2126:    elements</a> so that it is the new <a href="#current-node">current
                   2127:    node</a>.</li>
                   2128: 
                   2129:    <li>Replace the entry for <var title="">entry</var> in the list
                   2130:    with an entry for <var title="">new element</var>.</li>
                   2131: 
                   2132:    <li>If the entry for <var title="">new element</var> in the
                   2133:    <a href="#list-of-active-formatting-elements">list of active formatting elements</a> is not the last
                   2134:    entry in the list, return to step 7.</li>
                   2135: 
                   2136:   </ol><p>This has the effect of reopening all the formatting elements that
                   2137:   were opened in the current body, cell, or caption (whichever is
                   2138:   youngest) that haven't been explicitly closed.</p>
                   2139: 
                   2140:   <p class="note">The way this specification is written, the
                   2141:   <a href="#list-of-active-formatting-elements">list of active formatting elements</a> always consists of
                   2142:   elements in chronological order with the least recently added
                   2143:   element first and the most recently added element last (except for
                   2144:   while steps 8 to 11 of the above algorithm are being executed, of
                   2145:   course).</p>
                   2146: 
                   2147:   <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
                   2148:   active formatting elements up to the last marker</dfn>, the UA must
                   2149:   perform the following steps:</p>
                   2150: 
                   2151:   <ol><li>Let <var title="">entry</var> be the last (most recently added)
                   2152:    entry in the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</li>
                   2153: 
                   2154:    <li>Remove <var title="">entry</var> from the <a href="#list-of-active-formatting-elements">list of active
                   2155:    formatting elements</a>.</li>
                   2156: 
                   2157:    <li>If <var title="">entry</var> was a marker, then stop the
                   2158:    algorithm at this point. The list has been cleared up to the last
                   2159:    marker.</li>
                   2160: 
                   2161:    <li>Go to step 1.</li>
                   2162: 
1.755     mike     2163:   </ol><h5 id="the-element-pointers"><span class="secno">8.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     2164: 
                   2165:   <p>Initially, the <dfn id="head-element-pointer"><code title="">head</code> element
                   2166:   pointer</dfn> and the <dfn id="form-element-pointer"><code title="">form</code> element
                   2167:   pointer</dfn> are both null.</p>
                   2168: 
1.159     mike     2169:   <p>Once a <code><a href="semantics.html#the-head-element-0">head</a></code> element has been parsed (whether
1.1       mike     2170:   implicitly or explicitly) the <a href="#head-element-pointer"><code title="">head</code>
                   2171:   element pointer</a> gets set to point to this node.</p>
                   2172: 
                   2173:   <p>The <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
                   2174:   points to the last <code><a href="forms.html#the-form-element">form</a></code> element that was opened and
                   2175:   whose end tag has not yet been seen. It is used to make form
                   2176:   controls associate with forms in the face of dramatically bad
                   2177:   markup, for historical reasons.</p>
                   2178: 
                   2179: 
1.755     mike     2180:   <h5 id="other-parsing-state-flags"><span class="secno">8.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     2181: 
1.755     mike     2182:   <p>The <dfn id="scripting-flag">scripting flag</dfn> is set to "enabled" if <a href="web-application-apis.html#concept-n-script" title="concept-n-script">scripting was enabled</a> for the
1.1       mike     2183:   <code>Document</code> with which the parser is associated when the
                   2184:   parser was created, and "disabled" otherwise.</p>
                   2185: 
                   2186:   <p class="note">The <a href="#scripting-flag">scripting flag</a> can be enabled even
                   2187:   when the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML fragment
                   2188:   parsing algorithm</a>, even though <code><a href="semantics.html#script">script</a></code> elements
                   2189:   don't execute in that case.</p>
                   2190: 
                   2191:   <p>The <dfn id="frameset-ok-flag">frameset-ok flag</dfn> is set to "ok" when the parser is
                   2192:   created. It is set to "not ok" after certain tokens are seen.</p>
                   2193: 
1.266     mike     2194:   </div><div class="impl">
1.1       mike     2195: 
1.755     mike     2196:   <h4 id="tokenization"><span class="secno">8.2.4 </span><dfn>Tokenization</dfn></h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     2197: 
                   2198:   <p>Implementations must act as if they used the following state
                   2199:   machine to tokenize HTML. The state machine must start in the
                   2200:   <a href="#data-state">data state</a>. Most states consume a single character,
                   2201:   which may have various side-effects, and either switches the state
                   2202:   machine to a new state to <em>reconsume</em> the same character, or
                   2203:   switches it to a new state (to consume the next character), or
                   2204:   repeats the same state (to consume the next character). Some states
                   2205:   have more complicated behavior and can consume several characters
1.541     mike     2206:   before switching to another state. In some cases, the tokenizer
                   2207:   state is also changed by the tree construction stage.</p>
1.1       mike     2208: 
1.541     mike     2209:   <p>The exact behavior of certain states depends on the
                   2210:   <a href="#insertion-mode">insertion mode</a> and the <a href="#stack-of-open-elements">stack of open
                   2211:   elements</a>. Certain states also use a <dfn id="temporary-buffer"><var>temporary
                   2212:   buffer</var></dfn> to track progress.</p>
1.1       mike     2213: 
                   2214:   <p>The output of the tokenization step is a series of zero or more
                   2215:   of the following tokens: DOCTYPE, start tag, end tag, comment,
                   2216:   character, end-of-file. DOCTYPE tokens have a name, a public
                   2217:   identifier, a system identifier, and a <i>force-quirks
                   2218:   flag</i>. When a DOCTYPE token is created, its name, public
                   2219:   identifier, and system identifier must be marked as missing (which
                   2220:   is a distinct state from the empty string), and the <i>force-quirks
                   2221:   flag</i> must be set to <i>off</i> (its other state is
                   2222:   <i>on</i>). Start and end tag tokens have a tag name, a
                   2223:   <i>self-closing flag</i>, and a list of attributes, each of which
                   2224:   has a name and a value. When a start or end tag token is created,
                   2225:   its <i>self-closing flag</i> must be unset (its other state is that
                   2226:   it be set), and its attributes list must be empty. Comment and
                   2227:   character tokens have data.</p>
                   2228: 
                   2229:   <p>When a token is emitted, it must immediately be handled by the
                   2230:   <a href="#tree-construction">tree construction</a> stage. The tree construction stage
1.541     mike     2231:   can affect the state of the tokenization stage, and can insert
                   2232:   additional characters into the stream. (For example, the
1.1       mike     2233:   <code><a href="semantics.html#script">script</a></code> element can result in scripts executing and
1.159     mike     2234:   using the <a href="embedded-content-0.html#dynamic-markup-insertion">dynamic markup insertion</a> APIs to insert
1.1       mike     2235:   characters into the stream being tokenized.)</p>
                   2236: 
                   2237:   <p>When a start tag token is emitted with its <i>self-closing
                   2238:   flag</i> set, if the flag is not <dfn id="acknowledge-self-closing-flag" title="acknowledge
                   2239:   self-closing flag">acknowledged</dfn> when it is processed by the
                   2240:   tree construction stage, that is a <a href="#parse-error">parse error</a>.</p>
                   2241: 
                   2242:   <p>When an end tag token is emitted with attributes, that is a
                   2243:   <a href="#parse-error">parse error</a>.</p>
                   2244: 
                   2245:   <p>When an end tag token is emitted with its <i>self-closing
                   2246:   flag</i> set, that is a <a href="#parse-error">parse error</a>.</p>
                   2247: 
1.541     mike     2248:   <p>An <dfn id="appropriate-end-tag-token">appropriate end tag token</dfn> is an end tag token whose
                   2249:   tag name matches the tag name of the last start tag to have been
                   2250:   emitted from this tokenizer, if any. If no start tag has been
                   2251:   emitted from this tokenizer, then no end tag token is
                   2252:   appropriate.</p>
                   2253: 
1.1       mike     2254:   <p>Before each step of the tokenizer, the user agent must first
                   2255:   check the <a href="#parser-pause-flag">parser pause flag</a>. If it is true, then the
                   2256:   tokenizer must abort the processing of any nested invocations of the
1.479     mike     2257:   tokenizer, yielding control back to the caller.</p>
1.1       mike     2258: 
                   2259:   <p>The tokenizer state machine consists of the states defined in the
                   2260:   following subsections.</p>
                   2261: 
1.541     mike     2262: 
1.333     mike     2263:   <!-- Order of the lists below is supposed to be non-error then
                   2264:   error, by unicode, then EOF, ending with "anything else" -->
1.1       mike     2265: 
1.541     mike     2266: 
1.755     mike     2267:   <h5 id="data-state"><span class="secno">8.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     2268: 
                   2269:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2270: 
                   2271:   <dl class="switch"><dt>U+0026 AMPERSAND (&amp;)</dt>
1.541     mike     2272:    <dd>Switch to the <a href="#character-reference-in-data-state">character reference in data
1.56      mike     2273:    state</a>.</dd>
1.1       mike     2274: 
1.541     mike     2275:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2276:    <dd>Switch to the <a href="#tag-open-state">tag open state</a>.</dd>
                   2277: 
                   2278:    <dt>EOF</dt>
                   2279:    <dd>Emit an end-of-file token.</dd>
                   2280: 
                   2281:    <dt>Anything else</dt>
                   2282:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2283:    token. Stay in the <a href="#data-state">data state</a>.</dd>
1.1       mike     2284: 
1.755     mike     2285:   </dl><h5 id="character-reference-in-data-state"><span class="secno">8.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     2286: 
                   2287:   <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>, with no
                   2288:   <a href="#additional-allowed-character">additional allowed character</a>.</p>
                   2289: 
                   2290:   <p>If nothing is returned, emit a U+0026 AMPERSAND character
                   2291:   token.</p>
                   2292: 
                   2293:   <p>Otherwise, emit the character token that was returned.</p>
                   2294: 
                   2295:   <p>Finally, switch to the <a href="#data-state">data state</a>.</p>
                   2296: 
                   2297: 
1.755     mike     2298:   <h5 id="rcdata-state"><span class="secno">8.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     2299: 
1.541     mike     2300:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2301: 
1.541     mike     2302:   <dl class="switch"><dt>U+0026 AMPERSAND (&amp;)</dt>
1.618     mike     2303:    <dd>Switch to the <a href="#character-reference-in-rcdata-state">character reference in RCDATA
1.541     mike     2304:    state</a>.</dd>
1.1       mike     2305: 
                   2306:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
1.541     mike     2307:    <dd>Switch to the <a href="#rcdata-less-than-sign-state">RCDATA less-than sign state</a>.</dd>
                   2308: 
                   2309:    <dt>EOF</dt>
                   2310:    <dd>Emit an end-of-file token.</dd>
1.1       mike     2311: 
1.541     mike     2312:    <dt>Anything else</dt>
                   2313:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2314:    token. Stay in the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1       mike     2315: 
1.755     mike     2316:   </dl><h5 id="character-reference-in-rcdata-state"><span class="secno">8.2.4.4 </span><dfn>Character reference in RCDATA state</dfn></h5>
1.618     mike     2317: 
                   2318:   <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>, with no
                   2319:   <a href="#additional-allowed-character">additional allowed character</a>.</p>
                   2320: 
                   2321:   <p>If nothing is returned, emit a U+0026 AMPERSAND character
                   2322:   token.</p>
                   2323: 
                   2324:   <p>Otherwise, emit the character token that was returned.</p>
                   2325: 
                   2326:   <p>Finally, switch to the <a href="#rcdata-state">RCDATA state</a>.</p>
                   2327: 
                   2328: 
1.755     mike     2329:   <h5 id="rawtext-state"><span class="secno">8.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     2330: 
1.541     mike     2331:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2332: 
1.541     mike     2333:   <dl class="switch"><dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2334:    <dd>Switch to the <a href="#rawtext-less-than-sign-state">RAWTEXT less-than sign state</a>.</dd>
1.1       mike     2335: 
                   2336:    <dt>EOF</dt>
                   2337:    <dd>Emit an end-of-file token.</dd>
                   2338: 
                   2339:    <dt>Anything else</dt>
1.541     mike     2340:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2341:    token. Stay in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1       mike     2342: 
1.755     mike     2343:   </dl><h5 id="script-data-state"><span class="secno">8.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     2344: 
1.541     mike     2345:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2346: 
1.541     mike     2347:   <dl class="switch"><dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2348:    <dd>Switch to the <a href="#script-data-less-than-sign-state">script data less-than sign state</a>.</dd>
1.1       mike     2349: 
1.541     mike     2350:    <dt>EOF</dt>
                   2351:    <dd>Emit an end-of-file token.</dd>
1.1       mike     2352: 
1.541     mike     2353:    <dt>Anything else</dt>
                   2354:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2355:    token. Stay in the <a href="#script-data-state">script data state</a>.</dd>
1.1       mike     2356: 
1.755     mike     2357:   </dl><h5 id="plaintext-state"><span class="secno">8.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     2358: 
1.541     mike     2359:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2360: 
1.541     mike     2361:   <dl class="switch"><dt>EOF</dt>
                   2362:    <dd>Emit an end-of-file token.</dd>
1.1       mike     2363: 
1.541     mike     2364:    <dt>Anything else</dt>
                   2365:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2366:    token. Stay in the <a href="#plaintext-state">PLAINTEXT state</a>.</dd>
1.1       mike     2367: 
1.755     mike     2368:   </dl><h5 id="tag-open-state"><span class="secno">8.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     2369: 
1.541     mike     2370:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2371: 
1.541     mike     2372:   <dl class="switch"><dt>U+0021 EXCLAMATION MARK (!)</dt>
                   2373:    <dd>Switch to the <a href="#markup-declaration-open-state">markup declaration open state</a>.</dd>
1.1       mike     2374: 
1.541     mike     2375:    <dt>U+002F SOLIDUS (/)</dt>
1.755     mike     2376:    <dd>Switch to the <a href="#end-tag-open-state">end tag open state</a>.</dd>
1.1       mike     2377: 
1.541     mike     2378:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2379:    <dd>Create a new start tag token, set its tag name to the
                   2380:    lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
                   2381:    character's code point), then switch to the <a href="#tag-name-state">tag name
                   2382:    state</a>. (Don't emit the token yet; further details will
                   2383:    be filled in before it is emitted.)</dd>
1.1       mike     2384: 
1.541     mike     2385:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2386:    <dd>Create a new start tag token, set its tag name to the
                   2387:    <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
                   2388:    name state</a>. (Don't emit the token yet; further details will
                   2389:    be filled in before it is emitted.)</dd>
1.1       mike     2390: 
1.541     mike     2391:    <dt>U+003F QUESTION MARK (?)</dt>
                   2392:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
                   2393:    comment state</a>.</dd>
1.1       mike     2394: 
1.541     mike     2395:    <dt>Anything else</dt>
                   2396:    <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
                   2397:    character token and reconsume the <a href="#current-input-character">current input
                   2398:    character</a> in the <a href="#data-state">data state</a>.</dd>
1.1       mike     2399: 
1.755     mike     2400:   </dl><h5 id="end-tag-open-state"><span class="secno">8.2.4.9 </span><dfn>End tag open state</dfn></h5>
1.1       mike     2401: 
1.541     mike     2402:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2403: 
                   2404:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2405:    <dd>Create a new end tag token, set its tag name to the lowercase
1.541     mike     2406:    version of the <a href="#current-input-character">current input character</a> (add 0x0020 to
                   2407:    the character's code point), then switch to the <a href="#tag-name-state">tag name
1.1       mike     2408:    state</a>. (Don't emit the token yet; further details will be
                   2409:    filled in before it is emitted.)</dd>
                   2410: 
                   2411:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
1.541     mike     2412:    <dd>Create a new end tag token, set its tag name to the
                   2413:    <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
                   2414:    name state</a>. (Don't emit the token yet; further details will
                   2415:    be filled in before it is emitted.)</dd>
1.1       mike     2416: 
                   2417:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2418:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#data-state">data
                   2419:    state</a>.</dd>
                   2420: 
                   2421:    <dt>EOF</dt>
                   2422:    <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
                   2423:    character token and a U+002F SOLIDUS character token. Reconsume
                   2424:    the EOF character in the <a href="#data-state">data state</a>.</dd>
                   2425: 
                   2426:    <dt>Anything else</dt>
                   2427:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
                   2428:    comment state</a>.</dd>
                   2429: 
1.755     mike     2430:   </dl><h5 id="tag-name-state"><span class="secno">8.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     2431: 
                   2432:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2433: 
                   2434:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2435:    <dt>U+000A LINE FEED (LF)</dt>
                   2436:    <dt>U+000C FORM FEED (FF)</dt>
                   2437:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2438:    <dt>U+0020 SPACE</dt>
                   2439:    <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   2440: 
                   2441:    <dt>U+002F SOLIDUS (/)</dt>
                   2442:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   2443: 
                   2444:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2445:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   2446:    state</a>.</dd>
                   2447: 
                   2448:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541     mike     2449:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2450:    character</a> (add 0x0020 to the character's code point) to the
                   2451:    current tag token's tag name. Stay in the <a href="#tag-name-state">tag name
                   2452:    state</a>.</dd>
                   2453: 
                   2454:    <dt>EOF</dt>
                   2455:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2456:    <a href="#data-state">data state</a>.</dd>
                   2457: 
                   2458:    <dt>Anything else</dt>
                   2459:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2460:    tag token's tag name. Stay in the <a href="#tag-name-state">tag name state</a>.</dd>
                   2461: 
1.755     mike     2462:   </dl><h5 id="rcdata-less-than-sign-state"><span class="secno">8.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     2463:   <!-- identical to the RAWTEXT less-than sign state, except s/RAWTEXT/RCDATA/g -->
                   2464: 
                   2465:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2466: 
                   2467:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   2468:    <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
                   2469:    to the <a href="#rcdata-end-tag-open-state">RCDATA end tag open state</a>.</dd>
                   2470: 
                   2471:    <dt>Anything else</dt>
                   2472:    <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
                   2473:    <a href="#current-input-character">current input character</a> in the <a href="#rcdata-state">RCDATA
                   2474:    state</a>.</dd>
                   2475: 
1.755     mike     2476:   </dl><h5 id="rcdata-end-tag-open-state"><span class="secno">8.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     2477:   <!-- identical to the RAWTEXT (and Script data) end tag open state, except s/RAWTEXT/RCDATA/g -->
                   2478: 
                   2479:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2480: 
                   2481:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2482:    <dd>Create a new end tag token, and set its tag name to the
                   2483:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2484:    0x0020 to the character's code point). Append the <a href="#current-input-character">current
                   2485:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2486:    switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
                   2487:    the token yet; further details will be filled in before it is
                   2488:    emitted.)</dd>
                   2489: 
                   2490:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2491:    <dd>Create a new end tag token, and set its tag name to the
                   2492:    <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
                   2493:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2494:    switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
                   2495:    the token yet; further details will be filled in before it is
                   2496:    emitted.)</dd>
                   2497: 
                   2498:    <dt>Anything else</dt>
                   2499:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2500:    character token, and reconsume the <a href="#current-input-character">current input
                   2501:    character</a> in the <a href="#rcdata-state">RCDATA state</a>.</dd>
                   2502: 
1.755     mike     2503:   </dl><h5 id="rcdata-end-tag-name-state"><span class="secno">8.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     2504:   <!-- identical to the RAWTEXT (and Script data) end tag name state, except s/RAWTEXT/RCDATA/g -->
                   2505: 
                   2506:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2507: 
                   2508:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2509:    <dt>U+000A LINE FEED (LF)</dt>
                   2510:    <dt>U+000C FORM FEED (FF)</dt>
                   2511:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2512:    <dt>U+0020 SPACE</dt>
                   2513:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2514:    token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
                   2515:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2516:    below.</dd>
                   2517: 
                   2518:    <dt>U+002F SOLIDUS (/)</dt>
                   2519:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2520:    token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
                   2521:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2522:    below.</dd>
                   2523: 
                   2524:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2525:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2526:    token</a>, then emit the current tag token and switch to the
                   2527:    <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
                   2528:    else" entry below.</dd>
                   2529: 
                   2530:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2531:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2532:    character</a> (add 0x0020 to the character's code point) to the
                   2533:    current tag token's tag name. Append the <a href="#current-input-character">current input
                   2534:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2535:    <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
                   2536: 
                   2537:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2538:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2539:    tag token's tag name. Append the <a href="#current-input-character">current input
                   2540:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2541:    <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
                   2542: 
                   2543:    <dt>Anything else</dt>
                   2544:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2545:    character token, a character token for each of the characters in
                   2546:    the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
                   2547:    the buffer), and reconsume the <a href="#current-input-character">current input character</a>
                   2548:    in the <a href="#rcdata-state">RCDATA state</a>.</dd>
                   2549: 
1.755     mike     2550:   </dl><h5 id="rawtext-less-than-sign-state"><span class="secno">8.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     2551:   <!-- identical to the RCDATA less-than sign state, except s/RCDATA/RAWTEXT/g -->
                   2552: 
                   2553:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2554: 
                   2555:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   2556:    <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
                   2557:    to the <a href="#rawtext-end-tag-open-state">RAWTEXT end tag open state</a>.</dd>
                   2558: 
                   2559:    <dt>Anything else</dt>
                   2560:    <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
                   2561:    <a href="#current-input-character">current input character</a> in the <a href="#rawtext-state">RAWTEXT
                   2562:    state</a>.</dd>
                   2563: 
1.755     mike     2564:   </dl><h5 id="rawtext-end-tag-open-state"><span class="secno">8.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     2565:   <!-- identical to the RCDATA (and Script data) end tag open state, except s/RCDATA/RAWTEXT/g -->
                   2566: 
                   2567:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2568: 
                   2569:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2570:    <dd>Create a new end tag token, and set its tag name to the
                   2571:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2572:    0x0020 to the character's code point). Append the <a href="#current-input-character">current
                   2573:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2574:    switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
                   2575:    the token yet; further details will be filled in before it is
                   2576:    emitted.)</dd>
                   2577: 
                   2578:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2579:    <dd>Create a new end tag token, and set its tag name to the
                   2580:    <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
                   2581:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2582:    switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
                   2583:    the token yet; further details will be filled in before it is
                   2584:    emitted.)</dd>
                   2585: 
                   2586:    <dt>Anything else</dt>
                   2587:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2588:    character token, and reconsume the <a href="#current-input-character">current input
                   2589:    character</a> in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
                   2590: 
1.755     mike     2591:   </dl><h5 id="rawtext-end-tag-name-state"><span class="secno">8.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     2592:   <!-- identical to the RCDATA (and Script data) end tag name state, except s/RCDATA/RAWTEXT/g -->
                   2593: 
                   2594:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2595: 
                   2596:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2597:    <dt>U+000A LINE FEED (LF)</dt>
                   2598:    <dt>U+000C FORM FEED (FF)</dt>
                   2599:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2600:    <dt>U+0020 SPACE</dt>
                   2601:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2602:    token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
                   2603:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2604:    below.</dd>
                   2605: 
                   2606:    <dt>U+002F SOLIDUS (/)</dt>
                   2607:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2608:    token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
                   2609:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2610:    below.</dd>
                   2611: 
                   2612:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2613:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2614:    token</a>, then emit the current tag token and switch to the
                   2615:    <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
                   2616:    else" entry below.</dd>
                   2617: 
                   2618:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2619:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2620:    character</a> (add 0x0020 to the character's code point) to the
                   2621:    current tag token's tag name. Append the <a href="#current-input-character">current input
                   2622:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2623:    <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
                   2624: 
                   2625:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2626:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2627:    tag token's tag name. Append the <a href="#current-input-character">current input
                   2628:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2629:    <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
                   2630: 
                   2631:    <dt>Anything else</dt>
                   2632:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2633:    character token, a character token for each of the characters in
                   2634:    the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
                   2635:    the buffer), and reconsume the <a href="#current-input-character">current input character</a>
                   2636:    in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
                   2637: 
1.755     mike     2638:   </dl><h5 id="script-data-less-than-sign-state"><span class="secno">8.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     2639: 
                   2640:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2641: 
                   2642:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   2643:    <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
                   2644:    to the <a href="#script-data-end-tag-open-state">script data end tag open state</a>.</dd>
                   2645: 
                   2646:    <dt>U+0021 EXCLAMATION MARK (!)</dt>
                   2647:    <dd>Emit a U+003C LESS-THAN SIGN character token and a U+0021
                   2648:    EXCLAMATION MARK character token. Switch to the <a href="#script-data-escape-start-state">script data
                   2649:    escape start state</a>.</dd>
                   2650: 
                   2651:    <dt>Anything else</dt>
                   2652:    <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
                   2653:    <a href="#current-input-character">current input character</a> in the <a href="#script-data-state">script data
                   2654:    state</a>.</dd>
                   2655: 
1.755     mike     2656:   </dl><h5 id="script-data-end-tag-open-state"><span class="secno">8.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     2657:   <!-- identical to the RCDATA (and RAWTEXT) end tag open state, except s/RCDATA/Script data/g -->
                   2658: 
                   2659:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2660: 
                   2661:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2662:    <dd>Create a new end tag token, and set its tag name to the
                   2663:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2664:    0x0020 to the character's code point). Append the <a href="#current-input-character">current
                   2665:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2666:    switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
                   2667:    the token yet; further details will be filled in before it is
                   2668:    emitted.)</dd>
                   2669: 
                   2670:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2671:    <dd>Create a new end tag token, and set its tag name to the
                   2672:    <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
                   2673:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2674:    switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
                   2675:    the token yet; further details will be filled in before it is
                   2676:    emitted.)</dd>
                   2677: 
                   2678:    <dt>Anything else</dt>
                   2679:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2680:    character token, and reconsume the <a href="#current-input-character">current input
                   2681:    character</a> in the <a href="#script-data-state">script data state</a>.</dd>
                   2682: 
1.755     mike     2683:   </dl><h5 id="script-data-end-tag-name-state"><span class="secno">8.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     2684:   <!-- identical to the RCDATA (and RAWTEXT) end tag name state, except s/RCDATA/Script data/g -->
                   2685: 
                   2686:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2687: 
                   2688:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2689:    <dt>U+000A LINE FEED (LF)</dt>
                   2690:    <dt>U+000C FORM FEED (FF)</dt>
                   2691:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2692:    <dt>U+0020 SPACE</dt>
                   2693:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2694:    token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
                   2695:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2696:    below.</dd>
                   2697: 
                   2698:    <dt>U+002F SOLIDUS (/)</dt>
                   2699:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2700:    token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
                   2701:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2702:    below.</dd>
                   2703: 
                   2704:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2705:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2706:    token</a>, then emit the current tag token and switch to the
                   2707:    <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
                   2708:    else" entry below.</dd>
                   2709: 
                   2710:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2711:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2712:    character</a> (add 0x0020 to the character's code point) to the
                   2713:    current tag token's tag name. Append the <a href="#current-input-character">current input
                   2714:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542     mike     2715:    <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541     mike     2716: 
                   2717:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2718:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2719:    tag token's tag name. Append the <a href="#current-input-character">current input
                   2720:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542     mike     2721:    <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541     mike     2722: 
                   2723:    <dt>Anything else</dt>
                   2724:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2725:    character token, a character token for each of the characters in
                   2726:    the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
                   2727:    the buffer), and reconsume the <a href="#current-input-character">current input character</a>
                   2728:    in the <a href="#script-data-state">script data state</a>.</dd>
                   2729: 
1.755     mike     2730:   </dl><h5 id="script-data-escape-start-state"><span class="secno">8.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     2731: 
                   2732:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2733: 
                   2734:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2735:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2736:    <a href="#script-data-escape-start-dash-state">script data escape start dash state</a>.</dd>
                   2737: 
                   2738:    <dt>Anything else</dt>
                   2739:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   2740:    <a href="#script-data-state">script data state</a>.</dd>
                   2741: 
1.755     mike     2742:   </dl><h5 id="script-data-escape-start-dash-state"><span class="secno">8.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     2743: 
                   2744:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2745: 
                   2746:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2747:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2748:    <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
                   2749: 
                   2750:    <dt>Anything else</dt>
                   2751:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   2752:    <a href="#script-data-state">script data state</a>.</dd>
                   2753: 
1.755     mike     2754:   </dl><h5 id="script-data-escaped-state"><span class="secno">8.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     2755: 
                   2756:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2757: 
                   2758:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2759:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2760:    <a href="#script-data-escaped-dash-state">script data escaped dash state</a>.</dd>
                   2761: 
1.542     mike     2762:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2763:    <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
                   2764:    state</a>.</p></dd>
                   2765: 
1.541     mike     2766:    <dt>EOF</dt>
                   2767:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2768:    <a href="#data-state">data state</a>.</dd>
                   2769: 
                   2770:    <dt>Anything else</dt>
1.542     mike     2771:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2772:    token. Stay in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541     mike     2773: 
1.755     mike     2774:   </dl><h5 id="script-data-escaped-dash-state"><span class="secno">8.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     2775: 
                   2776:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2777: 
                   2778:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2779:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2780:    <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
                   2781: 
1.542     mike     2782:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2783:    <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
                   2784:    state</a>.</p></dd>
                   2785: 
1.541     mike     2786:    <dt>EOF</dt>
                   2787:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2788:    <a href="#data-state">data state</a>.</dd>
                   2789: 
                   2790:    <dt>Anything else</dt>
1.542     mike     2791:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2792:    token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541     mike     2793: 
1.755     mike     2794:   </dl><h5 id="script-data-escaped-dash-dash-state"><span class="secno">8.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     2795: 
                   2796:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2797: 
                   2798:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2799:    <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
                   2800:    <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
                   2801: 
1.542     mike     2802:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2803:    <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
                   2804:    state</a>.</p></dd>
                   2805: 
1.541     mike     2806:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2807:    <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
                   2808:    <a href="#script-data-state">script data state</a>.</dd>
1.1       mike     2809: 
                   2810:    <dt>EOF</dt>
                   2811:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2812:    <a href="#data-state">data state</a>.</dd>
                   2813: 
                   2814:    <dt>Anything else</dt>
1.542     mike     2815:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2816:    token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
                   2817: 
1.755     mike     2818:   </dl><h5 id="script-data-escaped-less-than-sign-state"><span class="secno">8.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     2819: 
                   2820:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2821: 
                   2822:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   2823:    <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
                   2824:    to the <a href="#script-data-escaped-end-tag-open-state">script data escaped end tag open state</a>.</dd>
                   2825: 
                   2826:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2827:    <dd>Emit a U+003C LESS-THAN SIGN character token and the
                   2828:    <a href="#current-input-character">current input character</a> as a character token. Set the
                   2829:    <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
                   2830:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2831:    0x0020 to the character's code point) to the <var><a href="#temporary-buffer">temporary
                   2832:    buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
                   2833:    state</a>.</dd>
                   2834: 
                   2835:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2836:    <dd>Emit a U+003C LESS-THAN SIGN character token and the
                   2837:    <a href="#current-input-character">current input character</a> as a character token. Set the
                   2838:    <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
                   2839:    <a href="#current-input-character">current input character</a> to the <var><a href="#temporary-buffer">temporary
                   2840:    buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
                   2841:    state</a>.</dd>
                   2842: 
                   2843:    <dt>Anything else</dt>
                   2844:    <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
                   2845:    <a href="#current-input-character">current input character</a> in the <a href="#script-data-escaped-state">script data
                   2846:    escaped state</a>.</dd>
                   2847: 
1.755     mike     2848:   </dl><h5 id="script-data-escaped-end-tag-open-state"><span class="secno">8.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     2849: 
                   2850:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2851: 
                   2852:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2853:    <dd>Create a new end tag token, and set its tag name to the
                   2854:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2855:    0x0020 to the character's code point). Append the <a href="#current-input-character">current
                   2856:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2857:    switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
                   2858:    state</a>. (Don't emit the token yet; further details will be
                   2859:    filled in before it is emitted.)</dd>
                   2860: 
                   2861:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2862:    <dd>Create a new end tag token, and set its tag name to the
                   2863:    <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
                   2864:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2865:    switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
                   2866:    state</a>. (Don't emit the token yet; further details will be
                   2867:    filled in before it is emitted.)</dd>
                   2868: 
                   2869:    <dt>Anything else</dt>
                   2870:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2871:    character token, and reconsume the <a href="#current-input-character">current input
                   2872:    character</a> in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
                   2873: 
1.755     mike     2874:   </dl><h5 id="script-data-escaped-end-tag-name-state"><span class="secno">8.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     2875: 
                   2876:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2877: 
                   2878:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2879:    <dt>U+000A LINE FEED (LF)</dt>
                   2880:    <dt>U+000C FORM FEED (FF)</dt>
                   2881:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2882:    <dt>U+0020 SPACE</dt>
                   2883:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2884:    token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
                   2885:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2886:    below.</dd>
                   2887: 
                   2888:    <dt>U+002F SOLIDUS (/)</dt>
                   2889:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2890:    token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
                   2891:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2892:    below.</dd>
                   2893: 
                   2894:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2895:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2896:    token</a>, then emit the current tag token and switch to the
                   2897:    <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
                   2898:    else" entry below.</dd>
                   2899: 
                   2900:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2901:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2902:    character</a> (add 0x0020 to the character's code point) to the
                   2903:    current tag token's tag name. Append the <a href="#current-input-character">current input
                   2904:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2905:    <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
                   2906: 
                   2907:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2908:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2909:    tag token's tag name. Append the <a href="#current-input-character">current input
                   2910:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2911:    <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
                   2912: 
                   2913:    <dt>Anything else</dt>
                   2914:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2915:    character token, a character token for each of the characters in
                   2916:    the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
                   2917:    the buffer), and reconsume the <a href="#current-input-character">current input character</a>
                   2918:    in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
                   2919: 
1.755     mike     2920:   </dl><h5 id="script-data-double-escape-start-state"><span class="secno">8.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     2921: 
                   2922:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2923: 
                   2924:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2925:    <dt>U+000A LINE FEED (LF)</dt>
                   2926:    <dt>U+000C FORM FEED (FF)</dt>
                   2927:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2928:    <dt>U+0020 SPACE</dt>
                   2929:    <dt>U+002F SOLIDUS (/)</dt>
                   2930:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2931:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2932:    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
                   2933:    double escaped state</a>. Otherwise, switch to the <a href="#script-data-escaped-state">script
                   2934:    data escaped state</a>.</dd>
                   2935: 
                   2936:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2937:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2938:    token. Append the lowercase version of the <a href="#current-input-character">current input
                   2939:    character</a> (add 0x0020 to the character's code point) to the
                   2940:    <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
                   2941:    escape start state</a>.</dd>
                   2942: 
                   2943:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2944:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2945:    token. Append the <a href="#current-input-character">current input character</a> to the
                   2946:    <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
                   2947:    escape start state</a>.</dd>
                   2948: 
                   2949:    <dt>Anything else</dt>
                   2950:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   2951:    <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
                   2952: 
1.755     mike     2953:   </dl><h5 id="script-data-double-escaped-state"><span class="secno">8.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     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-state">script data double escaped 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. Stay in the <a href="#script-data-double-escaped-state">script data double escaped
                   2973:    state</a>.</dd>
                   2974: 
1.755     mike     2975:   </dl><h5 id="script-data-double-escaped-dash-state"><span class="secno">8.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     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. Switch to 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>EOF</dt>
                   2989:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2990:    <a href="#data-state">data state</a>.</dd>
                   2991: 
                   2992:    <dt>Anything else</dt>
                   2993:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2994:    token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
                   2995:    state</a>.</dd>
                   2996: 
1.755     mike     2997:   </dl><h5 id="script-data-double-escaped-dash-dash-state"><span class="secno">8.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     2998: 
                   2999:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3000: 
                   3001:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3002:    <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
                   3003:    <a href="#script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>.</dd>
                   3004: 
                   3005:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3006:    <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
                   3007:    <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
                   3008:    state</a>.</p></dd>
                   3009: 
                   3010:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3011:    <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
                   3012:    <a href="#script-data-state">script data state</a>.</dd>
                   3013: 
                   3014:    <dt>EOF</dt>
                   3015:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3016:    <a href="#data-state">data state</a>.</dd>
                   3017: 
                   3018:    <dt>Anything else</dt>
                   3019:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   3020:    token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
                   3021:    state</a>.</dd>
                   3022: 
1.755     mike     3023:   </dl><h5 id="script-data-double-escaped-less-than-sign-state"><span class="secno">8.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     3024: 
                   3025:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3026: 
                   3027:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   3028:    <dd>Emit a U+002F SOLIDUS character token. Set the <var><a href="#temporary-buffer">temporary
                   3029:    buffer</a></var> to the empty string. Switch to the <a href="#script-data-double-escape-end-state">script data
                   3030:    double escape end state</a>.</dd>
                   3031: 
                   3032:    <dt>Anything else</dt>
                   3033:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   3034:    <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
                   3035: 
1.755     mike     3036:   </dl><h5 id="script-data-double-escape-end-state"><span class="secno">8.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     3037: 
                   3038:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3039: 
                   3040:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3041:    <dt>U+000A LINE FEED (LF)</dt>
                   3042:    <dt>U+000C FORM FEED (FF)</dt>
                   3043:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3044:    <dt>U+0020 SPACE</dt>
                   3045:    <dt>U+002F SOLIDUS (/)</dt>
                   3046:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3047:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   3048:    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
                   3049:    escaped state</a>. Otherwise, switch to the <a href="#script-data-double-escaped-state">script data
                   3050:    double escaped state</a>.</dd>
                   3051: 
                   3052:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   3053:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   3054:    token. Append the lowercase version of the <a href="#current-input-character">current input
                   3055:    character</a> (add 0x0020 to the character's code point) to the
                   3056:    <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
                   3057:    escape end state</a>.</dd>
                   3058: 
                   3059:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   3060:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   3061:    token. Append the <a href="#current-input-character">current input character</a> to the
                   3062:    <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
                   3063:    escape end state</a>.</dd>
                   3064: 
                   3065:    <dt>Anything else</dt>
                   3066:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   3067:    <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
1.1       mike     3068: 
1.755     mike     3069:   </dl><h5 id="before-attribute-name-state"><span class="secno">8.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     3070: 
                   3071:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3072: 
                   3073:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3074:    <dt>U+000A LINE FEED (LF)</dt>
                   3075:    <dt>U+000C FORM FEED (FF)</dt>
                   3076:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3077:    <dt>U+0020 SPACE</dt>
                   3078:    <dd>Stay in the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3079: 
                   3080:    <dt>U+002F SOLIDUS (/)</dt>
                   3081:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   3082: 
                   3083:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3084:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3085:    state</a>.</dd>
                   3086: 
                   3087:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   3088:    <dd>Start a new attribute in the current tag token. Set that
                   3089:    attribute's name to the lowercase version of the <a href="#current-input-character">current input
                   3090:    character</a> (add 0x0020 to the character's code point), and its
                   3091:    value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
                   3092:    state</a>.</dd>
                   3093: 
                   3094:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3095:    <dt>U+0027 APOSTROPHE (')</dt>
                   3096:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3097:    <dt>U+003D EQUALS SIGN (=)</dt>
                   3098:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3099:    entry below.</dd>
                   3100: 
                   3101:    <dt>EOF</dt>
                   3102:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3103:    <a href="#data-state">data state</a>.</dd>
                   3104: 
                   3105:    <dt>Anything else</dt>
                   3106:    <dd>Start a new attribute in the current tag token. Set that
                   3107:    attribute's name to the <a href="#current-input-character">current input character</a>, and its value to
                   3108:    the empty string. Switch to the <a href="#attribute-name-state">attribute name
                   3109:    state</a>.</dd>
                   3110: 
1.755     mike     3111:   </dl><h5 id="attribute-name-state"><span class="secno">8.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     3112: 
                   3113:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3114: 
                   3115:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3116:    <dt>U+000A LINE FEED (LF)</dt>
                   3117:    <dt>U+000C FORM FEED (FF)</dt>
                   3118:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3119:    <dt>U+0020 SPACE</dt>
                   3120:    <dd>Switch to the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
                   3121: 
                   3122:    <dt>U+002F SOLIDUS (/)</dt>
                   3123:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   3124: 
                   3125:    <dt>U+003D EQUALS SIGN (=)</dt>
                   3126:    <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
                   3127: 
                   3128:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3129:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3130:    state</a>.</dd>
                   3131: 
                   3132:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541     mike     3133:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   3134:    character</a> (add 0x0020 to the character's code point) to the
                   3135:    current attribute's name. Stay in the <a href="#attribute-name-state">attribute name
1.1       mike     3136:    state</a>.</dd>
                   3137: 
                   3138:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3139:    <dt>U+0027 APOSTROPHE (')</dt>
                   3140:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3141:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3142:    entry below.</dd>
                   3143: 
                   3144:    <dt>EOF</dt>
                   3145:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3146:    <a href="#data-state">data state</a>.</dd>
                   3147: 
                   3148:    <dt>Anything else</dt>
1.541     mike     3149:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3150:    attribute's name. Stay in the <a href="#attribute-name-state">attribute name
                   3151:    state</a>.</dd>
1.1       mike     3152: 
                   3153:   </dl><p>When the user agent leaves the attribute name state (and before
                   3154:   emitting the tag token, if appropriate), the complete attribute's
                   3155:   name must be compared to the other attributes on the same token;
                   3156:   if there is already an attribute on the token with the exact same
                   3157:   name, then this is a <a href="#parse-error">parse error</a> and the new
                   3158:   attribute must be dropped, along with the value that gets
                   3159:   associated with it (if any).</p>
                   3160: 
                   3161: 
1.755     mike     3162:   <h5 id="after-attribute-name-state"><span class="secno">8.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     3163: 
                   3164:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3165: 
                   3166:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3167:    <dt>U+000A LINE FEED (LF)</dt>
                   3168:    <dt>U+000C FORM FEED (FF)</dt>
                   3169:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3170:    <dt>U+0020 SPACE</dt>
                   3171:    <dd>Stay in the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
                   3172: 
                   3173:    <dt>U+002F SOLIDUS (/)</dt>
                   3174:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   3175: 
                   3176:    <dt>U+003D EQUALS SIGN (=)</dt>
                   3177:    <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
                   3178: 
                   3179:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3180:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3181:    state</a>.</dd>
                   3182: 
                   3183:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   3184:    <dd>Start a new attribute in the current tag token. Set that
1.541     mike     3185:    attribute's name to the lowercase version of the <a href="#current-input-character">current
                   3186:    input character</a> (add 0x0020 to the character's code point),
                   3187:    and its value to the empty string. Switch to the <a href="#attribute-name-state">attribute
                   3188:    name state</a>.</dd>
1.1       mike     3189: 
                   3190:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3191:    <dt>U+0027 APOSTROPHE (')</dt>
                   3192:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3193:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3194:    entry below.</dd>
                   3195: 
                   3196:    <dt>EOF</dt>
                   3197:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3198:    <a href="#data-state">data state</a>.</dd>
                   3199: 
                   3200:    <dt>Anything else</dt>
                   3201:    <dd>Start a new attribute in the current tag token. Set that
1.541     mike     3202:    attribute's name to the <a href="#current-input-character">current input character</a>, and
                   3203:    its value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
1.1       mike     3204:    state</a>.</dd>
                   3205: 
1.755     mike     3206:   </dl><h5 id="before-attribute-value-state"><span class="secno">8.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     3207: 
                   3208:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3209: 
                   3210:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3211:    <dt>U+000A LINE FEED (LF)</dt>
                   3212:    <dt>U+000C FORM FEED (FF)</dt>
                   3213:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3214:    <dt>U+0020 SPACE</dt>
                   3215:    <dd>Stay in the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
                   3216: 
                   3217:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3218:    <dd>Switch to the <a href="#attribute-value-double-quoted-state">attribute value (double-quoted) state</a>.</dd>
                   3219: 
                   3220:    <dt>U+0026 AMPERSAND (&amp;)</dt>
                   3221:    <dd>Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted) state</a>
1.541     mike     3222:    and reconsume this <a href="#current-input-character">current input character</a>.</dd>
1.1       mike     3223: 
                   3224:    <dt>U+0027 APOSTROPHE (')</dt>
                   3225:    <dd>Switch to the <a href="#attribute-value-single-quoted-state">attribute value (single-quoted) state</a>.</dd>
                   3226: 
                   3227:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3228:    <dd><a href="#parse-error">Parse error</a>. Emit the current tag token. Switch to
                   3229:    the <a href="#data-state">data state</a>.</dd>
                   3230: 
                   3231:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3232:    <dt>U+003D EQUALS SIGN (=)</dt>
1.463     mike     3233:    <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1       mike     3234:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3235:    entry below.</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>
                   3242:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3243:    attribute's value. Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
                   3244:    state</a>.</dd>
                   3245: 
1.755     mike     3246:   </dl><h5 id="attribute-value-double-quoted-state"><span class="secno">8.2.4.38 </span><dfn>Attribute value (double-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+0022 QUOTATION MARK (")</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+0022 QUOTATION MARK (").</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-double-quoted-state">attribute value
                   3266:    (double-quoted) state</a>.</dd>
1.1       mike     3267: 
1.755     mike     3268:   </dl><h5 id="attribute-value-single-quoted-state"><span class="secno">8.2.4.39 </span><dfn>Attribute value (single-quoted) 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+0027 APOSTROPHE (')</dt>
                   3273:    <dd>Switch to the <a href="#after-attribute-value-quoted-state">after attribute value (quoted)
                   3274:    state</a>.</dd>
                   3275: 
                   3276:    <dt>U+0026 AMPERSAND (&amp;)</dt>
                   3277:    <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
                   3278:    state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
                   3279:    being U+0027 APOSTROPHE (').</dd>
                   3280: 
                   3281:    <dt>EOF</dt>
                   3282:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3283:    <a href="#data-state">data state</a>.</dd>
                   3284: 
                   3285:    <dt>Anything else</dt>
1.541     mike     3286:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3287:    attribute's value. Stay in the <a href="#attribute-value-single-quoted-state">attribute value
                   3288:    (single-quoted) state</a>.</dd>
1.1       mike     3289: 
1.755     mike     3290:   </dl><h5 id="attribute-value-unquoted-state"><span class="secno">8.2.4.40 </span><dfn>Attribute value (unquoted) state</dfn></h5>
1.1       mike     3291: 
                   3292:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3293: 
                   3294:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3295:    <dt>U+000A LINE FEED (LF)</dt>
                   3296:    <dt>U+000C FORM FEED (FF)</dt>
                   3297:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3298:    <dt>U+0020 SPACE</dt>
                   3299:    <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3300: 
                   3301:    <dt>U+0026 AMPERSAND (&amp;)</dt>
                   3302:    <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
1.299     mike     3303:    state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
                   3304:    being U+003E GREATER-THAN SIGN (&gt;).</dd>
1.1       mike     3305: 
                   3306:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3307:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3308:    state</a>.</dd>
                   3309: 
                   3310:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3311:    <dt>U+0027 APOSTROPHE (')</dt>
                   3312:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3313:    <dt>U+003D EQUALS SIGN (=)</dt>
1.463     mike     3314:    <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1       mike     3315:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3316:    entry below.</dd>
                   3317: 
                   3318:    <dt>EOF</dt>
                   3319:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3320:    <a href="#data-state">data state</a>.</dd>
                   3321: 
                   3322:    <dt>Anything else</dt>
1.541     mike     3323:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3324:    attribute's value. Stay in the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
1.1       mike     3325:    state</a>.</dd>
                   3326: 
1.755     mike     3327:   </dl><h5 id="character-reference-in-attribute-value-state"><span class="secno">8.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     3328: 
                   3329:   <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>.</p>
                   3330: 
                   3331:   <p>If nothing is returned, append a U+0026 AMPERSAND character to
                   3332:   the current attribute's value.</p>
                   3333: 
                   3334:   <p>Otherwise, append the returned character token to the current
                   3335:   attribute's value.</p>
                   3336: 
                   3337:   <p>Finally, switch back to the attribute value state that you were
                   3338:   in when were switched into this state.</p>
                   3339: 
                   3340: 
1.755     mike     3341:   <h5 id="after-attribute-value-quoted-state"><span class="secno">8.2.4.42 </span><dfn>After attribute value (quoted) state</dfn></h5>
1.1       mike     3342: 
                   3343:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3344: 
                   3345:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3346:    <dt>U+000A LINE FEED (LF)</dt>
                   3347:    <dt>U+000C FORM FEED (FF)</dt>
                   3348:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3349:    <dt>U+0020 SPACE</dt>
                   3350:    <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3351: 
                   3352:    <dt>U+002F SOLIDUS (/)</dt>
                   3353:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   3354: 
                   3355:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3356:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3357:    state</a>.</dd>
                   3358: 
                   3359:    <dt>EOF</dt>
                   3360:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3361:    <a href="#data-state">data state</a>.</dd>
                   3362: 
                   3363:    <dt>Anything else</dt>
                   3364:    <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
                   3365:    the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3366: 
1.755     mike     3367:   </dl><h5 id="self-closing-start-tag-state"><span class="secno">8.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     3368: 
                   3369:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3370: 
                   3371:   <dl class="switch"><dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3372:    <dd>Set the <i>self-closing flag</i> of the current tag
                   3373:    token. Emit the current tag token. Switch to the <a href="#data-state">data
                   3374:    state</a>.</dd>
                   3375: 
                   3376:    <dt>EOF</dt>
                   3377:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3378:    <a href="#data-state">data state</a>.</dd>
                   3379: 
                   3380:    <dt>Anything else</dt>
                   3381:    <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
                   3382:    the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3383: 
1.755     mike     3384:   </dl><h5 id="bogus-comment-state"><span class="secno">8.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     3385: 
                   3386:   <p>Consume every character up to and including the first U+003E
                   3387:   GREATER-THAN SIGN character (&gt;) or the end of the file (EOF),
                   3388:   whichever comes first. Emit a comment token whose data is the
                   3389:   concatenation of all the characters starting from and including
                   3390:   the character that caused the state machine to switch into the
                   3391:   bogus comment state, up to and including the character immediately
                   3392:   before the last consumed character (i.e. up to the character just
                   3393:   before the U+003E or EOF character). (If the comment was started
                   3394:   by the end of the file (EOF), the token is empty.)</p>
                   3395: 
                   3396:   <p>Switch to the <a href="#data-state">data state</a>.</p>
                   3397: 
                   3398:   <p>If the end of the file was reached, reconsume the EOF
                   3399:   character.</p>
                   3400: 
                   3401: 
1.755     mike     3402:   <h5 id="markup-declaration-open-state"><span class="secno">8.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     3403: 
1.588     mike     3404:   <p>If the next two characters are both U+002D HYPHEN-MINUS
                   3405:   characters (-), consume those two characters, create a comment token
1.1       mike     3406:   whose data is the empty string, and switch to the <a href="#comment-start-state">comment
                   3407:   start state</a>.</p>
                   3408: 
                   3409:   <p>Otherwise, if the next seven characters are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   3410:   case-insensitive</a> match for the word "DOCTYPE", then consume
                   3411:   those characters and switch to the <a href="#doctype-state">DOCTYPE state</a>.</p>
                   3412: 
                   3413:   <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
                   3414:   content</a>" and the <a href="#current-node">current node</a> is not an element
1.724     mike     3415:   in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a> and the next seven characters are
1.585     mike     3416:   an <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string "[CDATA[" (the
                   3417:   five uppercase letters "CDATA" with a U+005B LEFT SQUARE BRACKET
                   3418:   character before and after), then consume those characters and
                   3419:   switch to the <a href="#cdata-section-state">CDATA section state</a>.</p>
1.1       mike     3420: 
                   3421:   <p>Otherwise, this is a <a href="#parse-error">parse error</a>. Switch to the
                   3422:   <a href="#bogus-comment-state">bogus comment state</a>. The next character that is
                   3423:   consumed, if any, is the first character that will be in the
                   3424:   comment.</p>
                   3425: 
                   3426: 
1.755     mike     3427:   <h5 id="comment-start-state"><span class="secno">8.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     3428: 
                   3429:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3430: 
                   3431:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3432:    <dd>Switch to the <a href="#comment-start-dash-state">comment start dash state</a>.</dd>
                   3433: 
                   3434:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3435:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to the
                   3436:    <a href="#data-state">data state</a>.</dd> <!-- see comment in comment end state
                   3437:    -->
                   3438: 
                   3439:    <dt>EOF</dt>
                   3440:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
                   3441:    the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3442: 
                   3443:    <dt>Anything else</dt>
1.541     mike     3444:    <dd>Append the <a href="#current-input-character">current input character</a> to the comment
                   3445:    token's data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3446: 
1.755     mike     3447:   </dl><h5 id="comment-start-dash-state"><span class="secno">8.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     3448: 
                   3449:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3450: 
                   3451:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3452:    <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
                   3453: 
                   3454:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3455:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to
                   3456:    the <a href="#data-state">data state</a>.</dd>
                   3457: 
                   3458:    <dt>EOF</dt>
                   3459:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
                   3460:    EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
                   3461:    in comment end state -->
                   3462: 
                   3463:    <dt>Anything else</dt>
1.541     mike     3464:    <dd>Append a U+002D HYPHEN-MINUS character (-) and the
                   3465:    <a href="#current-input-character">current input character</a> to the comment token's
                   3466:    data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3467: 
1.755     mike     3468:   </dl><h5 id="comment-state"><span class="secno">8.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     3469: 
                   3470:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3471: 
                   3472:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3473:    <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a></dd>
                   3474: 
                   3475:    <dt>EOF</dt>
                   3476:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
                   3477:    EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
                   3478:    in comment end state -->
                   3479: 
                   3480:    <dt>Anything else</dt>
1.541     mike     3481:    <dd>Append the <a href="#current-input-character">current input character</a> to the comment
                   3482:    token's data. Stay in the <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3483: 
1.755     mike     3484:   </dl><h5 id="comment-end-dash-state"><span class="secno">8.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     3485: 
                   3486:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3487: 
                   3488:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3489:    <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
                   3490: 
                   3491:    <dt>EOF</dt>
                   3492:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
                   3493:    EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
                   3494:    in comment end state -->
                   3495: 
                   3496:    <dt>Anything else</dt>
1.541     mike     3497:    <dd>Append a U+002D HYPHEN-MINUS character (-) and the
                   3498:    <a href="#current-input-character">current input character</a> to the comment token's
                   3499:    data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3500: 
1.755     mike     3501:   </dl><h5 id="comment-end-state"><span class="secno">8.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     3502: 
                   3503:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3504: 
                   3505:   <dl class="switch"><dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3506:    <dd>Emit the comment token. Switch to the <a href="#data-state">data
                   3507:    state</a>.</dd>
                   3508: 
                   3509:    <dt>U+0009 CHARACTER TABULATION</dt>
                   3510:    <dt>U+000A LINE FEED (LF)</dt>
                   3511:    <dt>U+000C FORM FEED (FF)</dt>
                   3512:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3513:    <dt>U+0020 SPACE</dt>
1.588     mike     3514:    <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS
                   3515:    characters (-) and the <a href="#current-input-character">current input character</a> to the
1.541     mike     3516:    comment token's data. Switch to the <a href="#comment-end-space-state">comment end space
                   3517:    state</a>.</dd>
1.1       mike     3518: 
                   3519:    <dt>U+0021 EXCLAMATION MARK (!)</dt>
                   3520:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#comment-end-bang-state">comment end bang
                   3521:    state</a>.</dd>
                   3522: 
1.333     mike     3523:    <dt>U+002D HYPHEN-MINUS (-)</dt>
                   3524:    <dd><a href="#parse-error">Parse error</a>. Append a U+002D HYPHEN-MINUS
1.464     mike     3525:    character (-) to the comment token's data. Stay in the
1.333     mike     3526:    <a href="#comment-end-state">comment end state</a>.</dd>
                   3527: 
1.1       mike     3528:    <dt>EOF</dt>
                   3529:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
                   3530:    the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- For
1.724     mike     3531:    security reasons: otherwise, hostile user could put a <script type="text/javascript"> in
1.1       mike     3532:    a comment e.g. in a blog comment and then DOS the server so that
1.724     mike     3533:    the end tag isn't read, and then the commented <script type="text/javascript"> tag would
1.1       mike     3534:    be treated as live code -->
                   3535: 
                   3536:    <dt>Anything else</dt>
1.588     mike     3537:    <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS
                   3538:    characters (-) and the <a href="#current-input-character">current input character</a> to the
1.541     mike     3539:    comment token's data. Switch to the <a href="#comment-state">comment
                   3540:    state</a>.</dd>
1.1       mike     3541: 
1.755     mike     3542:   </dl><h5 id="comment-end-bang-state"><span class="secno">8.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     3543: 
                   3544:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3545: 
1.333     mike     3546:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
1.588     mike     3547:    <dd>Append two U+002D HYPHEN-MINUS characters (-) and a U+0021
1.464     mike     3548:    EXCLAMATION MARK character (!) to the comment token's data. Switch
1.1       mike     3549:    to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
                   3550: 
1.333     mike     3551:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3552:    <dd>Emit the comment token. Switch to the <a href="#data-state">data
                   3553:    state</a>.</dd>
                   3554: 
1.1       mike     3555:    <dt>EOF</dt>
                   3556:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
                   3557:    the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
                   3558:    comment in comment end state -->
                   3559: 
                   3560:    <dt>Anything else</dt>
1.588     mike     3561:    <dd>Append two U+002D HYPHEN-MINUS characters (-), a U+0021
1.541     mike     3562:    EXCLAMATION MARK character (!), and the <a href="#current-input-character">current input
                   3563:    character</a> to the comment token's data. Switch to the
                   3564:    <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3565: 
1.755     mike     3566:   </dl><h5 id="comment-end-space-state"><span class="secno">8.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     3567: 
                   3568:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3569: 
1.333     mike     3570:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
1.1       mike     3571:    <dt>U+000A LINE FEED (LF)</dt>
                   3572:    <dt>U+000C FORM FEED (FF)</dt>
                   3573:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3574:    <dt>U+0020 SPACE</dt>
1.541     mike     3575:    <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Stay in
1.1       mike     3576:    the <a href="#comment-end-space-state">comment end space state</a>.</dd>
                   3577: 
1.333     mike     3578:    <dt>U+002D HYPHEN-MINUS (-)</dt>
                   3579:    <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
                   3580: 
                   3581:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3582:    <dd>Emit the comment token. Switch to the <a href="#data-state">data
                   3583:    state</a>.</dd>
                   3584: 
1.1       mike     3585:    <dt>EOF</dt>
                   3586:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
                   3587:    the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
                   3588:    comment in comment end state -->
                   3589: 
                   3590:    <dt>Anything else</dt>
1.541     mike     3591:    <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Switch
1.1       mike     3592:    to the <a href="#comment-state">comment state</a>.</dd>
                   3593: 
1.755     mike     3594:   </dl><h5 id="doctype-state"><span class="secno">8.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     3595: 
                   3596:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3597: 
                   3598:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3599:    <dt>U+000A LINE FEED (LF)</dt>
                   3600:    <dt>U+000C FORM FEED (FF)</dt>
                   3601:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3602:    <dt>U+0020 SPACE</dt>
                   3603:    <dd>Switch to the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
                   3604: 
                   3605:    <dt>EOF</dt>
                   3606:    <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
                   3607:    <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
                   3608:    the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3609: 
                   3610:    <dt>Anything else</dt>
1.608     mike     3611:    <dd><a href="#parse-error">Parse error</a>. Reconsume the character in the
                   3612:    <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
1.1       mike     3613: 
1.755     mike     3614:   </dl><h5 id="before-doctype-name-state"><span class="secno">8.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     3615: 
                   3616:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3617: 
                   3618:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3619:    <dt>U+000A LINE FEED (LF)</dt>
                   3620:    <dt>U+000C FORM FEED (FF)</dt>
                   3621:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3622:    <dt>U+0020 SPACE</dt>
                   3623:    <dd>Stay in the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
                   3624: 
                   3625:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   3626:    <dd>Create a new DOCTYPE token. Set the token's name to the
1.541     mike     3627:    lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
1.1       mike     3628:    character's code point). Switch to the <a href="#doctype-name-state">DOCTYPE name
                   3629:    state</a>.</dd>
                   3630: 
1.333     mike     3631:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3632:    <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
                   3633:    <i>force-quirks flag</i> to <i>on</i>. Emit the token. Switch to
                   3634:    the <a href="#data-state">data state</a>.</dd>
                   3635: 
1.1       mike     3636:    <dt>EOF</dt>
                   3637:    <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
                   3638:    <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
                   3639:    the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3640: 
                   3641:    <dt>Anything else</dt>
                   3642:    <dd>Create a new DOCTYPE token. Set the token's name to the
                   3643:    <a href="#current-input-character">current input character</a>. Switch to the <a href="#doctype-name-state">DOCTYPE name
                   3644:    state</a>.</dd>
                   3645: 
1.755     mike     3646:   </dl><h5 id="doctype-name-state"><span class="secno">8.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     3647: 
                   3648:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3649: 
                   3650:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3651:    <dt>U+000A LINE FEED (LF)</dt>
                   3652:    <dt>U+000C FORM FEED (FF)</dt>
                   3653:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3654:    <dt>U+0020 SPACE</dt>
                   3655:    <dd>Switch to the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
                   3656: 
                   3657:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3658:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   3659:    state</a>.</dd>
                   3660: 
                   3661:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541     mike     3662:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   3663:    character</a> (add 0x0020 to the character's code point) to the
                   3664:    current DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
                   3665:    state</a>.</dd>
1.1       mike     3666: 
                   3667:    <dt>EOF</dt>
                   3668:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3669:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3670:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3671: 
                   3672:    <dt>Anything else</dt>
1.541     mike     3673:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3674:    DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
                   3675:    state</a>.</dd>
1.1       mike     3676: 
1.755     mike     3677:   </dl><h5 id="after-doctype-name-state"><span class="secno">8.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     3678: 
                   3679:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3680: 
                   3681:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3682:    <dt>U+000A LINE FEED (LF)</dt>
                   3683:    <dt>U+000C FORM FEED (FF)</dt>
                   3684:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3685:    <dt>U+0020 SPACE</dt>
                   3686:    <dd>Stay in the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
                   3687: 
                   3688:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3689:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   3690:    state</a>.</dd>
                   3691: 
                   3692:    <dt>EOF</dt>
                   3693:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3694:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3695:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3696: 
                   3697:    <dt>Anything else</dt>
                   3698:    <dd>
                   3699: 
                   3700:     <p>If the six characters starting from the <a href="#current-input-character">current input
                   3701:     character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match
                   3702:     for the word "PUBLIC", then consume those characters and switch to
1.444     mike     3703:     the <a href="#after-doctype-public-keyword-state">after DOCTYPE public keyword state</a>.</p>
1.1       mike     3704: 
                   3705:     <p>Otherwise, if the six characters starting from the
                   3706:     <a href="#current-input-character">current input character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   3707:     case-insensitive</a> match for the word "SYSTEM", then consume
1.444     mike     3708:     those characters and switch to the <a href="#after-doctype-system-keyword-state">after DOCTYPE system
                   3709:     keyword state</a>.</p>
1.1       mike     3710: 
                   3711:     <p>Otherwise, this is the <a href="#parse-error">parse error</a>. Set the
                   3712:     DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to
                   3713:     the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</p>
                   3714: 
                   3715:    </dd>
                   3716: 
1.755     mike     3717:   </dl><h5 id="after-doctype-public-keyword-state"><span class="secno">8.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     3718: 
                   3719:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3720: 
                   3721:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3722:    <dt>U+000A LINE FEED (LF)</dt>
                   3723:    <dt>U+000C FORM FEED (FF)</dt>
                   3724:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3725:    <dt>U+0020 SPACE</dt>
                   3726:    <dd>Switch to the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier
                   3727:    state</a>.</dd>
                   3728: 
1.620     mike     3729:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3730:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's public
                   3731:    identifier to the empty string (not missing), then switch to the
                   3732:    <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public identifier (double-quoted) state</a>.</dd>
                   3733: 
                   3734:    <dt>U+0027 APOSTROPHE (')</dt>
                   3735:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's public
                   3736:    identifier to the empty string (not missing), then switch to the
                   3737:    <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public identifier (single-quoted) state</a>.</dd>
                   3738: 
                   3739:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3740:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3741:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3742:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3743: 
1.444     mike     3744:    <dt>EOF</dt>
                   3745:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3746:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3747:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3748: 
                   3749:    <dt>Anything else</dt>
1.620     mike     3750:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3751:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3752:    DOCTYPE state</a>.</dd>
1.444     mike     3753: 
1.755     mike     3754:   </dl><h5 id="before-doctype-public-identifier-state"><span class="secno">8.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     3755: 
                   3756:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3757: 
                   3758:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3759:    <dt>U+000A LINE FEED (LF)</dt>
                   3760:    <dt>U+000C FORM FEED (FF)</dt>
                   3761:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3762:    <dt>U+0020 SPACE</dt>
                   3763:    <dd>Stay in the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier state</a>.</dd>
                   3764: 
                   3765:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3766:    <dd>Set the DOCTYPE token's public identifier to the empty string
                   3767:    (not missing), then switch to the <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public identifier
                   3768:    (double-quoted) state</a>.</dd>
                   3769: 
                   3770:    <dt>U+0027 APOSTROPHE (')</dt>
                   3771:    <dd>Set the DOCTYPE token's public identifier to the empty string
                   3772:    (not missing), then switch to the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public identifier
                   3773:    (single-quoted) 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><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3787:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3788:    DOCTYPE state</a>.</dd>
                   3789: 
1.755     mike     3790:   </dl><h5 id="doctype-public-identifier-double-quoted-state"><span class="secno">8.2.4.59 </span><dfn>DOCTYPE public identifier (double-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+0022 QUOTATION MARK (")</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-double-quoted-state">DOCTYPE public
                   3810:    identifier (double-quoted) state</a>.</dd>
                   3811: 
1.755     mike     3812:   </dl><h5 id="doctype-public-identifier-single-quoted-state"><span class="secno">8.2.4.60 </span><dfn>DOCTYPE public identifier (single-quoted) state</dfn></h5>
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+0027 APOSTROPHE (')</dt>
                   3817:    <dd>Switch to the <a href="#after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd>
                   3818: 
                   3819:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3820:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3821:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3822:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3823: 
                   3824:    <dt>EOF</dt>
                   3825:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3826:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3827:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3828: 
                   3829:    <dt>Anything else</dt>
                   3830:    <dd>Append the <a href="#current-input-character">current input character</a> to the current DOCTYPE
                   3831:    token's public identifier. Stay in the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public
                   3832:    identifier (single-quoted) state</a>.</dd>
                   3833: 
1.755     mike     3834:   </dl><h5 id="after-doctype-public-identifier-state"><span class="secno">8.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     3835: 
                   3836:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3837: 
                   3838:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3839:    <dt>U+000A LINE FEED (LF)</dt>
                   3840:    <dt>U+000C FORM FEED (FF)</dt>
                   3841:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3842:    <dt>U+0020 SPACE</dt>
1.541     mike     3843:    <dd>Switch to the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system
                   3844:    identifiers state</a>.</dd>
1.444     mike     3845: 
                   3846:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3847:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   3848:    state</a>.</dd>
                   3849: 
                   3850:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3851:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
                   3852:    identifier to the empty string (not missing), then switch to the
                   3853:    <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier (double-quoted) state</a>.</dd>
                   3854: 
                   3855:    <dt>U+0027 APOSTROPHE (')</dt>
                   3856:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
                   3857:    identifier to the empty string (not missing), then switch to the
                   3858:    <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier (single-quoted) state</a>.</dd>
                   3859: 
                   3860:    <dt>EOF</dt>
                   3861:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3862:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3863:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3864: 
                   3865:    <dt>Anything else</dt>
                   3866:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3867:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3868:    DOCTYPE state</a>.</dd>
                   3869: 
1.755     mike     3870:   </dl><h5 id="between-doctype-public-and-system-identifiers-state"><span class="secno">8.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     3871: 
                   3872:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3873: 
                   3874:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3875:    <dt>U+000A LINE FEED (LF)</dt>
                   3876:    <dt>U+000C FORM FEED (FF)</dt>
                   3877:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3878:    <dt>U+0020 SPACE</dt>
1.541     mike     3879:    <dd>Stay in the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system identifiers
                   3880:    state</a>.</dd>
1.444     mike     3881: 
                   3882:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3883:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   3884:    state</a>.</dd>
1.1       mike     3885: 
                   3886:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3887:    <dd>Set the DOCTYPE token's system identifier to the empty string
                   3888:    (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
                   3889:    (double-quoted) state</a>.</dd>
                   3890: 
                   3891:    <dt>U+0027 APOSTROPHE (')</dt>
                   3892:    <dd>Set the DOCTYPE token's system identifier to the empty string
                   3893:    (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
                   3894:    (single-quoted) state</a>.</dd>
                   3895: 
                   3896:    <dt>EOF</dt>
                   3897:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3898:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3899:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3900: 
                   3901:    <dt>Anything else</dt>
                   3902:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3903:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3904:    DOCTYPE state</a>.</dd>
                   3905: 
1.755     mike     3906:   </dl><h5 id="after-doctype-system-keyword-state"><span class="secno">8.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     3907: 
                   3908:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3909: 
                   3910:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3911:    <dt>U+000A LINE FEED (LF)</dt>
                   3912:    <dt>U+000C FORM FEED (FF)</dt>
                   3913:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3914:    <dt>U+0020 SPACE</dt>
                   3915:    <dd>Switch to the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier
                   3916:    state</a>.</dd>
                   3917: 
1.620     mike     3918:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3919:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
                   3920:    identifier to the empty string (not missing), then switch to the
                   3921:    <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier (double-quoted) state</a>.</dd>
                   3922: 
                   3923:    <dt>U+0027 APOSTROPHE (')</dt>
                   3924:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
                   3925:    identifier to the empty string (not missing), then switch to the
                   3926:    <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier (single-quoted) state</a>.</dd>
                   3927: 
                   3928:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3929:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3930:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3931:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3932: 
1.444     mike     3933:    <dt>EOF</dt>
                   3934:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3935:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3936:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3937: 
                   3938:    <dt>Anything else</dt>
1.620     mike     3939:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3940:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3941:    DOCTYPE state</a>.</dd>
1.444     mike     3942: 
1.755     mike     3943:   </dl><h5 id="before-doctype-system-identifier-state"><span class="secno">8.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     3944: 
                   3945:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3946: 
                   3947:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3948:    <dt>U+000A LINE FEED (LF)</dt>
                   3949:    <dt>U+000C FORM FEED (FF)</dt>
                   3950:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3951:    <dt>U+0020 SPACE</dt>
                   3952:    <dd>Stay in the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier state</a>.</dd>
                   3953: 
                   3954:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3955:    <dd>Set the DOCTYPE token's system identifier to the empty string
                   3956:    (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
                   3957:    (double-quoted) state</a>.</dd>
                   3958: 
                   3959:    <dt>U+0027 APOSTROPHE (')</dt>
                   3960:    <dd>Set the DOCTYPE token's system identifier to the empty string
                   3961:    (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
                   3962:    (single-quoted) state</a>.</dd>
                   3963: 
                   3964:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3965:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3966:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3967:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3968: 
                   3969:    <dt>EOF</dt>
                   3970:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3971:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3972:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3973: 
                   3974:    <dt>Anything else</dt>
                   3975:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3976:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3977:    DOCTYPE state</a>.</dd>
                   3978: 
1.755     mike     3979:   </dl><h5 id="doctype-system-identifier-double-quoted-state"><span class="secno">8.2.4.65 </span><dfn>DOCTYPE system identifier (double-quoted) state</dfn></h5>
1.1       mike     3980: 
                   3981:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3982: 
                   3983:   <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
1.541     mike     3984:    <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
                   3985:    state</a>.</dd>
1.1       mike     3986: 
                   3987:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3988:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3989:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3990:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3991: 
                   3992:    <dt>EOF</dt>
                   3993:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3994:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3995:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3996: 
                   3997:    <dt>Anything else</dt>
1.541     mike     3998:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3999:    DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system
1.1       mike     4000:    identifier (double-quoted) state</a>.</dd>
                   4001: 
1.755     mike     4002:   </dl><h5 id="doctype-system-identifier-single-quoted-state"><span class="secno">8.2.4.66 </span><dfn>DOCTYPE system identifier (single-quoted) state</dfn></h5>
1.1       mike     4003: 
                   4004:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   4005: 
                   4006:   <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
1.541     mike     4007:    <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
                   4008:    state</a>.</dd>
1.1       mike     4009: 
                   4010:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   4011:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   4012:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   4013:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   4014: 
                   4015:    <dt>EOF</dt>
                   4016:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   4017:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   4018:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   4019: 
                   4020:    <dt>Anything else</dt>
1.541     mike     4021:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   4022:    DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system
1.1       mike     4023:    identifier (single-quoted) state</a>.</dd>
                   4024: 
1.755     mike     4025:   </dl><h5 id="after-doctype-system-identifier-state"><span class="secno">8.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     4026: 
                   4027:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   4028: 
                   4029:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   4030:    <dt>U+000A LINE FEED (LF)</dt>
                   4031:    <dt>U+000C FORM FEED (FF)</dt>
                   4032:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   4033:    <dt>U+0020 SPACE</dt>
1.541     mike     4034:    <dd>Stay in the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
                   4035:    state</a>.</dd>
1.1       mike     4036: 
                   4037:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   4038:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   4039:    state</a>.</dd>
                   4040: 
                   4041:    <dt>EOF</dt>
                   4042:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   4043:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   4044:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   4045: 
                   4046:    <dt>Anything else</dt>
                   4047:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-doctype-state">bogus DOCTYPE
                   4048:    state</a>. (This does <em>not</em> set the DOCTYPE token's
                   4049:    <i>force-quirks flag</i> to <i>on</i>.)</dd>
                   4050: 
1.755     mike     4051:   </dl><h5 id="bogus-doctype-state"><span class="secno">8.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     4052: 
                   4053:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   4054: 
                   4055:   <dl class="switch"><dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   4056:    <dd>Emit the DOCTYPE token. Switch to the <a href="#data-state">data
                   4057:    state</a>.</dd>
                   4058: 
                   4059:    <dt>EOF</dt>
                   4060:    <dd>Emit the DOCTYPE token. Reconsume the EOF character in the
                   4061:    <a href="#data-state">data state</a>.</dd>
                   4062: 
                   4063:    <dt>Anything else</dt>
                   4064:    <dd>Stay in the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</dd>
                   4065: 
1.755     mike     4066:   </dl><h5 id="cdata-section-state"><span class="secno">8.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     4067: 
                   4068:   <p>Consume every character up to the next occurrence of the three
                   4069:   character sequence U+005D RIGHT SQUARE BRACKET U+005D RIGHT SQUARE
                   4070:   BRACKET U+003E GREATER-THAN SIGN (<code title="">]]&gt;</code>), or the
                   4071:   end of the file (EOF), whichever comes first. Emit a series of
                   4072:   character tokens consisting of all the characters consumed except
                   4073:   the matching three character sequence at the end (if one was found
                   4074:   before the end of the file).</p>
                   4075: 
                   4076:   <p>Switch to the <a href="#data-state">data state</a>.</p>
                   4077: 
                   4078:   <p>If the end of the file was reached, reconsume the EOF
                   4079:   character.</p>
                   4080: 
                   4081: 
                   4082: 
1.755     mike     4083:   <h5 id="tokenizing-character-references"><span class="secno">8.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     4084: 
                   4085:   <p>This section defines how to <dfn id="consume-a-character-reference">consume a character
                   4086:   reference</dfn>. This definition is used when parsing character
1.299     mike     4087:   references <a href="#character-reference-in-data-state" title="character reference in data state">in
1.1       mike     4088:   text</a> and <a href="#character-reference-in-attribute-value-state" title="character reference in attribute value
                   4089:   state">in attributes</a>.</p>
                   4090: 
                   4091:   <p>The behavior depends on the identity of the next character (the
                   4092:   one immediately after the U+0026 AMPERSAND character):</p>
                   4093: 
                   4094:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   4095:    <dt>U+000A LINE FEED (LF)</dt>
                   4096:    <dt>U+000C FORM FEED (FF)</dt>
                   4097:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   4098:    <dt>U+0020 SPACE</dt>
                   4099:    <dt>U+003C LESS-THAN SIGN</dt>
                   4100:    <dt>U+0026 AMPERSAND</dt>
                   4101:    <dt>EOF</dt>
                   4102:    <dt>The <dfn id="additional-allowed-character">additional allowed character</dfn>, if there is one</dt>
                   4103: 
                   4104:    <dd>Not a character reference. No characters are consumed, and
                   4105:    nothing is returned. (This is not an error, either.)</dd>
                   4106: 
                   4107: 
                   4108:    <dt>U+0023 NUMBER SIGN (#)</dt>
                   4109: 
                   4110:    <dd>
                   4111: 
                   4112:     <p>Consume the U+0023 NUMBER SIGN.</p>
                   4113: 
                   4114:     <p>The behavior further depends on the character after the U+0023
                   4115:     NUMBER SIGN:</p>
                   4116: 
                   4117:     <dl class="switch"><dt>U+0078 LATIN SMALL LETTER X</dt>
                   4118:      <dt>U+0058 LATIN CAPITAL LETTER X</dt>
                   4119: 
                   4120:      <dd>
                   4121: 
                   4122:       <p>Consume the X.</p>
                   4123: 
                   4124:       <p>Follow the steps below, but using the range of characters
1.464     mike     4125:       U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061 LATIN
                   4126:       SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041 LATIN
                   4127:       CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F (in other
                   4128:       words, 0-9, A-F, a-f).</p>
1.1       mike     4129: 
                   4130:       <p>When it comes to interpreting the number, interpret it as a
                   4131:       hexadecimal number.</p>
                   4132: 
                   4133:      </dd>
                   4134: 
                   4135: 
                   4136:      <dt>Anything else</dt>
                   4137: 
                   4138:      <dd>
                   4139: 
                   4140:       <p>Follow the steps below, but using the range of characters
1.464     mike     4141:       U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</p>
1.1       mike     4142: 
                   4143:       <p>When it comes to interpreting the number, interpret it as a
                   4144:       decimal number.</p>
                   4145: 
                   4146:      </dd>
                   4147: 
                   4148:     </dl><p>Consume as many characters as match the range of characters
                   4149:     given above.</p>
                   4150: 
                   4151:     <p>If no characters match the range, then don't consume any
                   4152:     characters (and unconsume the U+0023 NUMBER SIGN character and, if
                   4153:     appropriate, the X character). This is a <a href="#parse-error">parse
                   4154:     error</a>; nothing is returned.</p>
                   4155: 
                   4156:     <p>Otherwise, if the next character is a U+003B SEMICOLON, consume
                   4157:     that too. If it isn't, there is a <a href="#parse-error">parse
                   4158:     error</a>.</p>
                   4159: 
                   4160:     <p>If one or more characters match the range, then take them all
                   4161:     and interpret the string of characters as a number (either
                   4162:     hexadecimal or decimal as appropriate).</p>
                   4163: 
                   4164:     <p>If that number is one of the numbers in the first column of the
                   4165:     following table, then this is a <a href="#parse-error">parse error</a>. Find the
                   4166:     row with that number in the first column, and return a character
                   4167:     token for the Unicode character given in the second column of that
                   4168:     row.</p>
                   4169: 
                   4170:     <table><thead><tr><th>Number </th><th colspan="2">Unicode character
                   4171:      </th></tr></thead><tbody><tr><td>0x00 </td><td>U+FFFD </td><td>REPLACEMENT CHARACTER
                   4172:       </td></tr><tr><td>0x0D </td><td>U+000A </td><td>LINE FEED (LF)
1.464     mike     4173:       </td></tr><tr><td>0x80 </td><td>U+20AC </td><td>EURO SIGN (&#8364;)
1.1       mike     4174:       </td></tr><tr><td>0x81 </td><td>U+0081 </td><td>&lt;control&gt;
1.464     mike     4175:       </td></tr><tr><td>0x82 </td><td>U+201A </td><td>SINGLE LOW-9 QUOTATION MARK (&#8218;)
                   4176:       </td></tr><tr><td>0x83 </td><td>U+0192 </td><td>LATIN SMALL LETTER F WITH HOOK (&#402;)
                   4177:       </td></tr><tr><td>0x84 </td><td>U+201E </td><td>DOUBLE LOW-9 QUOTATION MARK (&#8222;)
                   4178:       </td></tr><tr><td>0x85 </td><td>U+2026 </td><td>HORIZONTAL ELLIPSIS (&#8230;)
                   4179:       </td></tr><tr><td>0x86 </td><td>U+2020 </td><td>DAGGER (&#8224;)
                   4180:       </td></tr><tr><td>0x87 </td><td>U+2021 </td><td>DOUBLE DAGGER (&#8225;)
                   4181:       </td></tr><tr><td>0x88 </td><td>U+02C6 </td><td>MODIFIER LETTER CIRCUMFLEX ACCENT (&#710;)
                   4182:       </td></tr><tr><td>0x89 </td><td>U+2030 </td><td>PER MILLE SIGN (&#8240;)
                   4183:       </td></tr><tr><td>0x8A </td><td>U+0160 </td><td>LATIN CAPITAL LETTER S WITH CARON (&#352;)
                   4184:       </td></tr><tr><td>0x8B </td><td>U+2039 </td><td>SINGLE LEFT-POINTING ANGLE QUOTATION MARK (&#8249;)
                   4185:       </td></tr><tr><td>0x8C </td><td>U+0152 </td><td>LATIN CAPITAL LIGATURE OE (&#338;)
1.1       mike     4186:       </td></tr><tr><td>0x8D </td><td>U+008D </td><td>&lt;control&gt;
1.464     mike     4187:       </td></tr><tr><td>0x8E </td><td>U+017D </td><td>LATIN CAPITAL LETTER Z WITH CARON (&#381;)
1.1       mike     4188:       </td></tr><tr><td>0x8F </td><td>U+008F </td><td>&lt;control&gt;
                   4189:       </td></tr><tr><td>0x90 </td><td>U+0090 </td><td>&lt;control&gt;
1.464     mike     4190:       </td></tr><tr><td>0x91 </td><td>U+2018 </td><td>LEFT SINGLE QUOTATION MARK (&#8216;)
                   4191:       </td></tr><tr><td>0x92 </td><td>U+2019 </td><td>RIGHT SINGLE QUOTATION MARK (&#8217;)
                   4192:       </td></tr><tr><td>0x93 </td><td>U+201C </td><td>LEFT DOUBLE QUOTATION MARK (&#8220;)
                   4193:       </td></tr><tr><td>0x94 </td><td>U+201D </td><td>RIGHT DOUBLE QUOTATION MARK (&#8221;)
                   4194:       </td></tr><tr><td>0x95 </td><td>U+2022 </td><td>BULLET (&#8226;)
                   4195:       </td></tr><tr><td>0x96 </td><td>U+2013 </td><td>EN DASH (&#8211;)
                   4196:       </td></tr><tr><td>0x97 </td><td>U+2014 </td><td>EM DASH (&#8212;)
                   4197:       </td></tr><tr><td>0x98 </td><td>U+02DC </td><td>SMALL TILDE (&#732;)
                   4198:       </td></tr><tr><td>0x99 </td><td>U+2122 </td><td>TRADE MARK SIGN (&#8482;)
                   4199:       </td></tr><tr><td>0x9A </td><td>U+0161 </td><td>LATIN SMALL LETTER S WITH CARON (&#353;)
                   4200:       </td></tr><tr><td>0x9B </td><td>U+203A </td><td>SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (&#8250;)
                   4201:       </td></tr><tr><td>0x9C </td><td>U+0153 </td><td>LATIN SMALL LIGATURE OE (&#339;)
1.1       mike     4202:       </td></tr><tr><td>0x9D </td><td>U+009D </td><td>&lt;control&gt;
1.464     mike     4203:       </td></tr><tr><td>0x9E </td><td>U+017E </td><td>LATIN SMALL LETTER Z WITH CARON (&#382;)
                   4204:       </td></tr><tr><td>0x9F </td><td>U+0178 </td><td>LATIN CAPITAL LETTER Y WITH DIAERESIS (&#376;)
1.315     mike     4205:     </td></tr></tbody></table><p>Otherwise, if the number is in the range 0xD800 to 0xDFFF<!--
                   4206:     surrogates not allowed; see the comment in the "preprocessing the
                   4207:     input stream" section for details --> or is greater than 0x10FFFF,
                   4208:     then this is a <a href="#parse-error">parse error</a>. Return a U+FFFD
                   4209:     REPLACEMENT CHARACTER.</p>
1.18      mike     4210: 
                   4211:     <p>Otherwise, return a character token for the Unicode character
1.1       mike     4212:     whose code point is that number.
                   4213: 
                   4214:     <!-- this is the same as the equivalent list in the input stream
                   4215:     section -->
                   4216:     If the number is in the range 0x0001 to 0x0008, <!-- HT, LF
                   4217:     allowed --> <!-- U+000B is in the next list --> <!-- FF, CR
                   4218:     allowed --> 0x000E to 0x001F, <!-- ASCII allowed --> 0x007F <!--to
1.315     mike     4219:     0x0084, (0x0085 NEL not allowed), 0x0086--> to 0x009F, 0xFDD0 to
                   4220:     0xFDEF, or is one of 0x000B, 0xFFFE, 0xFFFF, 0x1FFFE, 0x1FFFF,
                   4221:     0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE,
                   4222:     0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF,
                   4223:     0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF, 0xCFFFE,
                   4224:     0xCFFFF, 0xDFFFE, 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF,
                   4225:     0x10FFFE, or 0x10FFFF, then this is a <a href="#parse-error">parse
                   4226:     error</a>.</p>
1.1       mike     4227: 
                   4228:    </dd>
                   4229: 
                   4230: 
                   4231:    <dt>Anything else</dt>
                   4232: 
                   4233:    <dd>
                   4234: 
                   4235:     <p>Consume the maximum number of characters possible, with the
                   4236:     consumed characters matching one of the identifiers in the first
                   4237:     column of the <a href="named-character-references.html#named-character-references">named character references</a> table (in a
                   4238:     <a href="infrastructure.html#case-sensitive">case-sensitive</a> manner).</p>
                   4239: 
                   4240:     <p>If no match can be made, then this is a <a href="#parse-error">parse
                   4241:     error</a>. No characters are consumed, and nothing is
                   4242:     returned.</p>
                   4243: 
1.588     mike     4244:     <p>If the last character matched is not a U+003B SEMICOLON
                   4245:     character (;), there is a <a href="#parse-error">parse error</a>.</p>
1.1       mike     4246: 
                   4247:     <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
                   4248:     attribute</a>, and the last character matched is not a U+003B
1.588     mike     4249:     SEMICOLON character (;), and the next character is in the range
                   4250:     U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN
                   4251:     CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z, or U+0061 LATIN
                   4252:     SMALL LETTER A to U+007A LATIN SMALL LETTER Z, then, for
                   4253:     historical reasons, all the characters that were matched after the
                   4254:     U+0026 AMPERSAND character (&amp;) must be unconsumed, and nothing
                   4255:     is returned.</p>
1.1       mike     4256: 
                   4257:     <p>Otherwise, return a character token for the character
                   4258:     corresponding to the character reference name (as given by the
                   4259:     second column of the <a href="named-character-references.html#named-character-references">named character references</a>
                   4260:     table).</p>
                   4261: 
                   4262:     <div class="example">
                   4263: 
                   4264:      <p>If the markup contains <code title="">I'm &amp;notit; I tell
                   4265:      you</code>, the character reference is parsed as "not", as in,
                   4266:      <code title="">I'm &#172;it; I tell you</code>. But if the markup
                   4267:      was <code title="">I'm &amp;notin; I tell you</code>, the
                   4268:      character reference would be parsed as "notin;", resulting in
                   4269:      <code title="">I'm &#8713; I tell you</code>.</p>
                   4270: 
                   4271:     </div>
                   4272: 
                   4273:    </dd>
                   4274: 
1.266     mike     4275:   </dl></div><div class="impl">
                   4276: 
1.363     mike     4277:   <!-- v2: One thing that this doesn't define is handling deeply
                   4278:   nested documents. There are compatibility requirements around that:
                   4279:   you can't throw away the elements altogether, consider Tux made only
                   4280:   with opening <font> elements, one per character. Seems that the best
                   4281:   thing to do is to close some formatting elements from the middle of
                   4282:   the stack when you hit a limit, or something. -->
                   4283: 
1.755     mike     4284:   <h4 id="tree-construction"><span class="secno">8.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     4285: 
                   4286:   <p>The input to the tree construction stage is a sequence of tokens
                   4287:   from the <a href="#tokenization">tokenization</a> stage. The tree construction
                   4288:   stage is associated with a DOM <code>Document</code> object when a
                   4289:   parser is created. The "output" of this stage consists of
                   4290:   dynamically modifying or extending that document's DOM tree.</p>
                   4291: 
                   4292:   <p>This specification does not define when an interactive user agent
                   4293:   has to render the <code>Document</code> so that it is available to
                   4294:   the user, or when it has to begin accepting user input.</p>
                   4295: 
                   4296:   <p>As each token is emitted from the tokenizer, the user agent must
                   4297:   process the token according to the rules given in the section
                   4298:   corresponding to the current <a href="#insertion-mode">insertion mode</a>.</p>
                   4299: 
                   4300:   <p>When the steps below require the UA to <dfn id="insert-a-character">insert a
                   4301:   character</dfn> into a node, if that node has a child immediately
                   4302:   before where the character is to be inserted, and that child is a
                   4303:   <code>Text</code> node, and that <code>Text</code> node was the last
                   4304:   node that the parser inserted into the document, then the character
                   4305:   must be appended to that <code>Text</code> node; otherwise, a new
                   4306:   <code>Text</code> node whose data is just that character must be
                   4307:   inserted in the appropriate place.</p>
                   4308: 
                   4309:   <div class="example">
                   4310: 
                   4311:    <p>Here are some sample inputs to the parser and the corresponding
                   4312:    number of text nodes that they result in, assuming a user agent
                   4313:    that executes scripts.</p>
                   4314: 
                   4315:    <table><thead><tr><th>Input </th><th>Number of text nodes
                   4316:     </th></tr></thead><tbody><tr><td><pre>A&lt;script&gt;
                   4317: var&#160;script&#160;=&#160;document.getElementsByTagName('script')[0];
                   4318: document.body.removeChild(script);
                   4319: &lt;/script&gt;B</pre>
                   4320:       </td><td>Two adjacent text nodes in the document, containing "A" and "B".
                   4321:      </td></tr><tr><td><pre>A&lt;script&gt;
                   4322: var&#160;text&#160;=&#160;document.createTextNode('B');
                   4323: document.body.appendChild(text);
                   4324: &lt;/script&gt;C</pre>
                   4325:       </td><td>Four text nodes; "A" before the script, the script's contents, "B" after the script, and then, immediately after that, "C".
                   4326:      </td></tr><tr><td><pre>A&lt;script&gt;
                   4327: var&#160;text&#160;=&#160;document.getElementsByTagName('script')[0].firstChild;
                   4328: text.data&#160;=&#160;'B';
                   4329: document.body.appendChild(text);
                   4330: &lt;/script&gt;B</pre>
                   4331:       </td><td>Two adjacent text nodes in the document, containing "A" and "BB".
                   4332:      </td></tr><tr><td><pre>A&lt;table&gt;B&lt;tr&gt;C&lt;/tr&gt;C&lt;/table&gt;</pre>
                   4333:       </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>.)
                   4334:      </td></tr><tr><td><pre>A&lt;table&gt;&lt;tr&gt;&#160;B&lt;/tr&gt;&#160;B&lt;/table&gt;</pre>
                   4335:       </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>.)
                   4336:      </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>
                   4337:       </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.)
                   4338:    </td></tr></tbody></table></div>
                   4339: 
                   4340:   <p id="mutation-during-parsing">DOM mutation events must not fire
                   4341:   for changes caused by the UA parsing the document. (Conceptually,
                   4342:   the parser is not mutating the DOM, it is constructing it.) This
1.159     mike     4343:   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     4344: 
                   4345:   <p class="note">Not all of the tag names mentioned below are
                   4346:   conformant tag names in this specification; many are included to
                   4347:   handle legacy content. They still form part of the algorithm that
                   4348:   implementations are required to implement to claim conformance.</p>
                   4349: 
                   4350:   <p class="note">The algorithm described below places no limit on the
                   4351:   depth of the DOM tree generated, or on the length of tag names,
                   4352:   attribute names, attribute values, text nodes, etc. While
                   4353:   implementors are encouraged to avoid arbitrary limits, it is
                   4354:   recognized that <a href="infrastructure.html#hardwareLimitations">practical
1.445     mike     4355:   concerns</a> will likely force user agents to impose nesting depth
                   4356:   constraints.</p>
1.1       mike     4357: 
                   4358: 
1.755     mike     4359:   <h5 id="creating-and-inserting-elements"><span class="secno">8.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     4360: 
                   4361:   <p>When the steps below require the UA to <dfn id="create-an-element-for-the-token" title="create an
                   4362:   element for the token">create an element for a token</dfn> in a
                   4363:   particular namespace, the UA must create a node implementing the
                   4364:   interface appropriate for the element type corresponding to the tag
                   4365:   name of the token in the given namespace (as given in the
                   4366:   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     4367:   element in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, this specification
1.1       mike     4368:   defines it to be the <code><a href="text-level-semantics.html#htmlanchorelement">HTMLAnchorElement</a></code> interface), with
                   4369:   the tag name being the name of that element, with the node being in
                   4370:   the given namespace, and with the attributes on the node being those
                   4371:   given in the given token.</p>
                   4372: 
1.724     mike     4373:   <p>The interface appropriate for an element in the <a href="infrastructure.html#html-namespace-0">HTML
1.426     mike     4374:   namespace</a> that is not defined in this specification (or
                   4375:   <a href="infrastructure.html#other-applicable-specifications">other applicable specifications</a>) is
1.44      mike     4376:   <code><a href="dom.html#htmlunknownelement">HTMLUnknownElement</a></code>. Element in other namespaces whose
1.1       mike     4377:   interface is not defined by that namespace's specification must use
                   4378:   the interface <code>Element</code>.</p>
                   4379: 
                   4380:   <p>When a <a href="forms.html#category-reset" title="category-reset">resettable</a> element is
                   4381:   created in this manner, its <a href="forms.html#concept-form-reset-control" title="concept-form-reset-control">reset algorithm</a> must be
                   4382:   invoked once the attributes are set. (This initializes the element's
                   4383:   <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
                   4384:   attributes.)</p>
                   4385: 
                   4386:   <hr><p>When the steps below require the UA to <dfn id="insert-an-html-element">insert an HTML
                   4387:   element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
1.724     mike     4388:   for the token</a> in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, and then
1.1       mike     4389:   append this node to the <a href="#current-node">current node</a>, and push it onto
                   4390:   the <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
                   4391:   <a href="#current-node">current node</a>.</p>
                   4392: 
                   4393:   <p>The steps below may also require that the UA insert an HTML
                   4394:   element in a particular place, in which case the UA must follow the
                   4395:   same steps except that it must insert or append the new node in the
                   4396:   location specified instead of appending it to the <a href="#current-node">current
                   4397:   node</a>. (This happens in particular during the parsing of
                   4398:   tables with invalid content.)</p>
                   4399: 
                   4400:   <p>If an element created by the <a href="#insert-an-html-element">insert an HTML element</a>
                   4401:   algorithm is a <a href="forms.html#form-associated-element">form-associated element</a>, and the
                   4402:   <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is not null,
                   4403:   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
                   4404:   <a href="forms.html#concept-form-association" title="concept-form-association">associate</a> the newly
                   4405:   created element with the <code><a href="forms.html#the-form-element">form</a></code> element pointed to by the
                   4406:   <a href="#form-element-pointer"><code title="">form</code> element pointer</a> before
                   4407:   inserting it wherever it is to be inserted.</p>
                   4408: 
                   4409:   <hr><p>When the steps below require the UA to <dfn id="insert-a-foreign-element">insert a foreign
                   4410:   element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
                   4411:   for the token</a> in the given namespace, and then append this
                   4412:   node to the <a href="#current-node">current node</a>, and push it onto the
                   4413:   <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
1.724     mike     4414:   <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     4415:   whose value is not exactly the same as the element's namespace, that
                   4416:   is a <a href="#parse-error">parse error</a>. Similarly, if the newly created
                   4417:   element has an <code title="">xmlns:xlink</code> attribute in the
1.724     mike     4418:   <a href="infrastructure.html#xmlns-namespace">XMLNS namespace</a> whose value is not the <a href="infrastructure.html#xlink-namespace">XLink
1.1       mike     4419:   Namespace</a>, that is a <a href="#parse-error">parse error</a>.</p>
                   4420: 
                   4421:   <p>When the steps below require the user agent to <dfn id="adjust-mathml-attributes">adjust MathML
                   4422:   attributes</dfn> for a token, then, if the token has an attribute
                   4423:   named <code title="">definitionurl</code>, change its name to <code title="">definitionURL</code> (note the case difference).</p>
                   4424: 
                   4425:   <p>When the steps below require the user agent to <dfn id="adjust-svg-attributes">adjust SVG
                   4426:   attributes</dfn> for a token, then, for each attribute on the token
                   4427:   whose attribute name is one of the ones in the first column of the
                   4428:   following table, change the attribute's name to the name given in
                   4429:   the corresponding cell in the second column. (This fixes the case of
                   4430:   SVG attributes that are not all lowercase.)</p>
                   4431: 
                   4432:   <table><thead><tr><th> Attribute name on token </th><th> Attribute name on element
                   4433:    </th></tr></thead><tbody><tr><td> <code title="">attributename</code> </td><td> <code title="">attributeName</code>
                   4434:     </td></tr><tr><td> <code title="">attributetype</code> </td><td> <code title="">attributeType</code>
                   4435:     </td></tr><tr><td> <code title="">basefrequency</code> </td><td> <code title="">baseFrequency</code>
                   4436:     </td></tr><tr><td> <code title="">baseprofile</code> </td><td> <code title="">baseProfile</code>
                   4437:     </td></tr><tr><td> <code title="">calcmode</code> </td><td> <code title="">calcMode</code>
                   4438:     </td></tr><tr><td> <code title="">clippathunits</code> </td><td> <code title="">clipPathUnits</code>
                   4439:     </td></tr><tr><td> <code title="">contentscripttype</code> </td><td> <code title="">contentScriptType</code>
                   4440:     </td></tr><tr><td> <code title="">contentstyletype</code> </td><td> <code title="">contentStyleType</code>
                   4441:     </td></tr><tr><td> <code title="">diffuseconstant</code> </td><td> <code title="">diffuseConstant</code>
                   4442:     </td></tr><tr><td> <code title="">edgemode</code> </td><td> <code title="">edgeMode</code>
                   4443:     </td></tr><tr><td> <code title="">externalresourcesrequired</code> </td><td> <code title="">externalResourcesRequired</code>
                   4444:     </td></tr><tr><td> <code title="">filterres</code> </td><td> <code title="">filterRes</code>
                   4445:     </td></tr><tr><td> <code title="">filterunits</code> </td><td> <code title="">filterUnits</code>
                   4446:     </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
                   4447:     </td></tr><tr><td> <code title="">gradienttransform</code> </td><td> <code title="">gradientTransform</code>
                   4448:     </td></tr><tr><td> <code title="">gradientunits</code> </td><td> <code title="">gradientUnits</code>
                   4449:     </td></tr><tr><td> <code title="">kernelmatrix</code> </td><td> <code title="">kernelMatrix</code>
                   4450:     </td></tr><tr><td> <code title="">kernelunitlength</code> </td><td> <code title="">kernelUnitLength</code>
                   4451:     </td></tr><tr><td> <code title="">keypoints</code> </td><td> <code title="">keyPoints</code>
                   4452:     </td></tr><tr><td> <code title="">keysplines</code> </td><td> <code title="">keySplines</code>
                   4453:     </td></tr><tr><td> <code title="">keytimes</code> </td><td> <code title="">keyTimes</code>
                   4454:     </td></tr><tr><td> <code title="">lengthadjust</code> </td><td> <code title="">lengthAdjust</code>
                   4455:     </td></tr><tr><td> <code title="">limitingconeangle</code> </td><td> <code title="">limitingConeAngle</code>
                   4456:     </td></tr><tr><td> <code title="">markerheight</code> </td><td> <code title="">markerHeight</code>
                   4457:     </td></tr><tr><td> <code title="">markerunits</code> </td><td> <code title="">markerUnits</code>
                   4458:     </td></tr><tr><td> <code title="">markerwidth</code> </td><td> <code title="">markerWidth</code>
                   4459:     </td></tr><tr><td> <code title="">maskcontentunits</code> </td><td> <code title="">maskContentUnits</code>
                   4460:     </td></tr><tr><td> <code title="">maskunits</code> </td><td> <code title="">maskUnits</code>
                   4461:     </td></tr><tr><td> <code title="">numoctaves</code> </td><td> <code title="">numOctaves</code>
                   4462:     </td></tr><tr><td> <code title="">pathlength</code> </td><td> <code title="">pathLength</code>
                   4463:     </td></tr><tr><td> <code title="">patterncontentunits</code> </td><td> <code title="">patternContentUnits</code>
                   4464:     </td></tr><tr><td> <code title="">patterntransform</code> </td><td> <code title="">patternTransform</code>
                   4465:     </td></tr><tr><td> <code title="">patternunits</code> </td><td> <code title="">patternUnits</code>
                   4466:     </td></tr><tr><td> <code title="">pointsatx</code> </td><td> <code title="">pointsAtX</code>
                   4467:     </td></tr><tr><td> <code title="">pointsaty</code> </td><td> <code title="">pointsAtY</code>
                   4468:     </td></tr><tr><td> <code title="">pointsatz</code> </td><td> <code title="">pointsAtZ</code>
                   4469:     </td></tr><tr><td> <code title="">preservealpha</code> </td><td> <code title="">preserveAlpha</code>
                   4470:     </td></tr><tr><td> <code title="">preserveaspectratio</code> </td><td> <code title="">preserveAspectRatio</code>
                   4471:     </td></tr><tr><td> <code title="">primitiveunits</code> </td><td> <code title="">primitiveUnits</code>
                   4472:     </td></tr><tr><td> <code title="">refx</code> </td><td> <code title="">refX</code>
                   4473:     </td></tr><tr><td> <code title="">refy</code> </td><td> <code title="">refY</code>
                   4474:     </td></tr><tr><td> <code title="">repeatcount</code> </td><td> <code title="">repeatCount</code>
                   4475:     </td></tr><tr><td> <code title="">repeatdur</code> </td><td> <code title="">repeatDur</code>
                   4476:     </td></tr><tr><td> <code title="">requiredextensions</code> </td><td> <code title="">requiredExtensions</code>
                   4477:     </td></tr><tr><td> <code title="">requiredfeatures</code> </td><td> <code title="">requiredFeatures</code>
                   4478:     </td></tr><tr><td> <code title="">specularconstant</code> </td><td> <code title="">specularConstant</code>
                   4479:     </td></tr><tr><td> <code title="">specularexponent</code> </td><td> <code title="">specularExponent</code>
                   4480:     </td></tr><tr><td> <code title="">spreadmethod</code> </td><td> <code title="">spreadMethod</code>
                   4481:     </td></tr><tr><td> <code title="">startoffset</code> </td><td> <code title="">startOffset</code>
                   4482:     </td></tr><tr><td> <code title="">stddeviation</code> </td><td> <code title="">stdDeviation</code>
                   4483:     </td></tr><tr><td> <code title="">stitchtiles</code> </td><td> <code title="">stitchTiles</code>
                   4484:     </td></tr><tr><td> <code title="">surfacescale</code> </td><td> <code title="">surfaceScale</code>
                   4485:     </td></tr><tr><td> <code title="">systemlanguage</code> </td><td> <code title="">systemLanguage</code>
                   4486:     </td></tr><tr><td> <code title="">tablevalues</code> </td><td> <code title="">tableValues</code>
                   4487:     </td></tr><tr><td> <code title="">targetx</code> </td><td> <code title="">targetX</code>
                   4488:     </td></tr><tr><td> <code title="">targety</code> </td><td> <code title="">targetY</code>
                   4489:     </td></tr><tr><td> <code title="">textlength</code> </td><td> <code title="">textLength</code>
                   4490:     </td></tr><tr><td> <code title="">viewbox</code> </td><td> <code title="">viewBox</code>
                   4491:     </td></tr><tr><td> <code title="">viewtarget</code> </td><td> <code title="">viewTarget</code>
                   4492:     </td></tr><tr><td> <code title="">xchannelselector</code> </td><td> <code title="">xChannelSelector</code>
                   4493:     </td></tr><tr><td> <code title="">ychannelselector</code> </td><td> <code title="">yChannelSelector</code>
                   4494:     </td></tr><tr><td> <code title="">zoomandpan</code> </td><td> <code title="">zoomAndPan</code>
                   4495:   </td></tr></tbody></table><p>When the steps below require the user agent to <dfn id="adjust-foreign-attributes">adjust
                   4496:   foreign attributes</dfn> for a token, then, if any of the attributes
                   4497:   on the token match the strings given in the first column of the
                   4498:   following table, let the attribute be a namespaced attribute, with
                   4499:   the prefix being the string given in the corresponding cell in the
                   4500:   second column, the local name being the string given in the
                   4501:   corresponding cell in the third column, and the namespace being the
                   4502:   namespace given in the corresponding cell in the fourth
                   4503:   column. (This fixes the use of namespaced attributes, in particular
                   4504:   <a href="dom.html#attr-xml-lang" title="attr-xml-lang"><code title="">lang</code> attributes in
                   4505:   the <span>XML namespace</span></a>.)</p>
                   4506: 
                   4507:   <table><thead><tr><th> Attribute name </th><th> Prefix </th><th> Local name </th><th> Namespace
1.724     mike     4508:    </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>
                   4509:     </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>
                   4510:     </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>
                   4511:     </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>
                   4512:     </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>
                   4513:     </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>
                   4514:     </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>
                   4515:     </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 -->
                   4516:     </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>
                   4517:     </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>
                   4518:     </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>
                   4519:     </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     4520:   </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     4521:   <dfn id="generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</dfn> consist of the
                   4522:   following steps. These algorithms are always invoked in response to
                   4523:   a start tag token.</p>
                   4524: 
                   4525:   <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p></li>
                   4526: 
1.91      mike     4527:    <li><p>If the algorithm that was invoked is the <a href="#generic-raw-text-element-parsing-algorithm">generic raw
1.541     mike     4528:    text element parsing algorithm</a>, switch the tokenizer to the
                   4529:    <a href="#rawtext-state">RAWTEXT state</a>; otherwise the algorithm invoked
                   4530:    was the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>,
                   4531:    switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</p></li>
1.1       mike     4532: 
                   4533:    <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
                   4534:    <a href="#insertion-mode">insertion mode</a>.</p>
                   4535: 
1.540     mike     4536:    </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     4537: 
1.755     mike     4538:   </ol><h5 id="closing-elements-that-have-implied-end-tags"><span class="secno">8.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     4539: 
                   4540:   <p>When the steps below require the UA to <dfn id="generate-implied-end-tags">generate implied end
                   4541:   tags</dfn>, then, while the <a href="#current-node">current node</a> is a
1.422     mike     4542:   <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     4543:   <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
                   4544:   <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
                   4545:   <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
                   4546:   pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   4547:   elements</a>.</p>
                   4548: 
                   4549:   <p>If a step requires the UA to generate implied end tags but lists
                   4550:   an element to exclude from the process, then the UA must perform the
                   4551:   above steps as if that element was not in the above list.</p>
                   4552: 
                   4553: 
1.755     mike     4554:   <h5 id="foster-parenting"><span class="secno">8.2.5.3 </span>Foster parenting</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     4555: 
                   4556:   <p>Foster parenting happens when content is misnested in tables.</p>
                   4557: 
                   4558:   <p>When a node <var title="">node</var> is to be <dfn id="foster-parent" title="foster
                   4559:   parent">foster parented</dfn>, the node <var title="">node</var>
                   4560:   must be inserted into the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
                   4561: 
                   4562:   <p>The <dfn id="foster-parent-element">foster parent element</dfn> is the parent element of the
                   4563:   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
                   4564:   elements</a>, if there is a <code><a href="tabular-data.html#the-table-element">table</a></code> element and it has
                   4565:   such a parent element. If there is no <code><a href="tabular-data.html#the-table-element">table</a></code> element in
                   4566:   the <a href="#stack-of-open-elements">stack of open elements</a> (<a href="#fragment-case">fragment
                   4567:   case</a>), then the <i><a href="#foster-parent-element">foster parent element</a></i> is the first
                   4568:   element in the <a href="#stack-of-open-elements">stack of open elements</a> (the
1.159     mike     4569:   <code><a href="semantics.html#the-html-element-0">html</a></code> element). Otherwise, if there is a
1.1       mike     4570:   <code><a href="tabular-data.html#the-table-element">table</a></code> element in the <a href="#stack-of-open-elements">stack of open
                   4571:   elements</a>, but the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
                   4572:   <a href="#stack-of-open-elements">stack of open elements</a> has no parent, or its parent
                   4573:   node is not an element, then the <i><a href="#foster-parent-element">foster parent element</a></i> is
                   4574:   the element before the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
                   4575:   <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   4576: 
                   4577:   <p>If the <i><a href="#foster-parent-element">foster parent element</a></i> is the parent element of the
                   4578:   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
                   4579:   elements</a>, then <var title="">node</var> must be inserted
                   4580:   immediately <em>before</em> the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in
                   4581:   the <a href="#stack-of-open-elements">stack of open elements</a> in the <i><a href="#foster-parent-element">foster parent
                   4582:   element</a></i>; otherwise, <var title="">node</var> must be
                   4583:   <em>appended</em> to the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
                   4584: 
                   4585: 
                   4586: 
1.755     mike     4587:   <h5 id="the-initial-insertion-mode"><span class="secno">8.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     4588: 
                   4589:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-initial-insertion-mode" title="insertion
                   4590:   mode: initial">initial</a>", tokens must be handled as follows:</p>
                   4591: 
                   4592:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   4593:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   4594:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   4595:    <dd>
                   4596:     <p>Ignore the token.</p>
                   4597:    </dd>
                   4598: 
                   4599:    <dt>A comment token</dt>
                   4600:    <dd>
                   4601:     <p>Append a <code>Comment</code> node to the <code>Document</code>
                   4602:     object with the <code title="">data</code> attribute set to the
                   4603:     data given in the comment token.</p>
                   4604:    </dd>
                   4605: 
                   4606:    <dt>A DOCTYPE token</dt>
                   4607:    <dd>
                   4608: 
                   4609:     <p>If the DOCTYPE token's name is not a
                   4610:     <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
                   4611:     missing, or the token's system identifier is neither missing nor a
                   4612:     <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string
1.465     mike     4613:     "<code><a href="infrastructure.html#about:legacy-compat">about:legacy-compat</a></code>", and none of the sets of
1.1       mike     4614:     conditions in the following list are matched, then there is a
                   4615:     <a href="#parse-error">parse error</a>. If one of the sets of conditions in the
                   4616:     following list is matched, then there is an <dfn id="obsolete-permitted-doctype">obsolete
                   4617:     permitted DOCTYPE</dfn>.</p>
                   4618: 
                   4619:     <ul><!-- only things that trigger no-quirks mode and were valid in
1.688     mike     4620:      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>
                   4621:      match for the string "<code title="">html</code>", the token's
                   4622:      public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
                   4623:      "<code title="">-//W3C//DTD&#160;HTML&#160;4.0//EN</code>", and
                   4624:      the token's system identifier is either missing or the
1.1       mike     4625:      <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/REC-html40/strict.dtd</code>".</li>
                   4626: 
1.688     mike     4627:      <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
                   4628:      match for the string "<code title="">html</code>", the token's
                   4629:      public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
                   4630:      "<code title="">-//W3C//DTD&#160;HTML&#160;4.01//EN</code>", and
                   4631:      the token's system identifier is either missing or the
1.1       mike     4632:      <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/html4/strict.dtd</code>".</li>
                   4633: 
1.688     mike     4634:      <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
                   4635:      match for the string "<code title="">html</code>", the token's
                   4636:      public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
                   4637:      "<code title="">-//W3C//DTD&#160;XHTML&#160;1.0&#160;Strict//EN</code>",
1.1       mike     4638:      and the token's system identifier is the
                   4639:      <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</code>".</li>
                   4640: 
1.688     mike     4641:      <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
                   4642:      match for the string "<code title="">html</code>", the token's
                   4643:      public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
                   4644:      "<code title="">-//W3C//DTD&#160;XHTML&#160;1.1//EN</code>", and
                   4645:      the token's system identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a>
1.1       mike     4646:      string "<code title="">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</code>".</li>
                   4647: 
                   4648:     </ul><p>Conformance checkers may, based on the values (including
                   4649:     presence or lack thereof) of the DOCTYPE token's name, public
                   4650:     identifier, or system identifier, switch to a conformance checking
                   4651:     mode for another language (e.g. based on the DOCTYPE token a
                   4652:     conformance checker could recognize that the document is an
1.183     mike     4653:     HTML4-era document, and defer to an HTML4 conformance
1.1       mike     4654:     checker.)</p>
                   4655: 
                   4656:     <p>Append a <code>DocumentType</code> node to the
                   4657:     <code>Document</code> node, with the <code title="">name</code>
                   4658:     attribute set to the name given in the DOCTYPE token, or the empty
                   4659:     string if the name was missing; the <code title="">publicId</code>
                   4660:     attribute set to the public identifier given in the DOCTYPE token,
                   4661:     or the empty string if the public identifier was missing; the
                   4662:     <code title="">systemId</code> attribute set to the system
                   4663:     identifier given in the DOCTYPE token, or the empty string if the
                   4664:     system identifier was missing; and the other attributes specific
                   4665:     to <code>DocumentType</code> objects set to null and empty lists
                   4666:     as appropriate. Associate the <code>DocumentType</code> node with
                   4667:     the <code>Document</code> object so that it is returned as the
                   4668:     value of the <code title="">doctype</code> attribute of the
                   4669:     <code>Document</code> object.</p>
                   4670: 
                   4671:     <p id="quirks-mode-doctypes">Then, if the DOCTYPE token matches
                   4672:     one of the conditions in the following list, then set the
                   4673:     <code>Document</code> to <a href="dom.html#quirks-mode">quirks mode</a>:</p>
                   4674: 
                   4675:     <ul class="brief"><li> The <i>force-quirks flag</i> is set to <i>on</i>. </li>
1.688     mike     4676:      <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     4677:      <li> The public identifier starts with: "<code title="">+//Silmaril//dtd html Pro v0r11 19970101//<!--EN--></code>" </li>
                   4678:      <li> The public identifier starts with: "<code title="">-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
                   4679:      <li> The public identifier starts with: "<code title="">-//AS//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
                   4680:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 1//<!--EN--></code>" </li>
                   4681:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 2//<!--EN--></code>" </li>
                   4682:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 1//<!--EN--></code>" </li>
                   4683:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 2//<!--EN--></code>" </li>
                   4684:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict//<!--EN--></code>" </li>
                   4685:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0//<!--EN--></code>" </li>
                   4686:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.1E//<!--EN--></code>" </li>
                   4687:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.0//<!--EN--></code>" </li>
                   4688:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML 3.0//EN//</code>" </li>-->
                   4689:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2 Final//<!--EN--></code>" </li>
                   4690:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2//<!--EN--></code>" </li>
                   4691:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3//<!--EN--></code>" </li>
                   4692:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 0//<!--EN--></code>" </li>
                   4693:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 0//EN//2.0</code>" </li>-->
                   4694:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 1//<!--EN--></code>" </li>
                   4695:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 1//EN//2.0</code>" </li>-->
                   4696:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 2//<!--EN--></code>" </li>
                   4697:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 2//EN//2.0</code>" </li>-->
                   4698:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 3//<!--EN--></code>" </li>
                   4699:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 3//EN//3.0</code>" </li>-->
                   4700:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 0//<!--EN--></code>" </li>
                   4701:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 0//EN//2.0</code>" </li>-->
                   4702:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 1//<!--EN--></code>" </li>
                   4703:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 1//EN//2.0</code>" </li>-->
                   4704:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 2//<!--EN--></code>" </li>
                   4705:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 2//EN//2.0</code>" </li>-->
                   4706:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 3//<!--EN--></code>" </li>
                   4707:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 3//EN//3.0</code>" </li>-->
                   4708:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict//<!--EN--></code>" </li>
                   4709:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//2.0</code>" </li>-->
                   4710:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//3.0</code>" </li>-->
                   4711:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML//<!--EN--></code>" </li>
                   4712:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//2.0</code>" </li>-->
                   4713:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//3.0</code>" </li>-->
                   4714:      <li> The public identifier starts with: "<code title="">-//Metrius//DTD Metrius Presentational//<!--EN--></code>" </li>
                   4715:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//<!--EN--></code>" </li>
                   4716:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML//<!--EN--></code>" </li>
                   4717:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 Tables//<!--EN--></code>" </li>
                   4718:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//<!--EN--></code>" </li>
                   4719:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML//<!--EN--></code>" </li>
                   4720:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 Tables//<!--EN--></code>" </li>
                   4721:      <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD HTML//<!--EN--></code>" </li>
                   4722:      <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD Strict HTML//<!--EN--></code>" </li>
                   4723:      <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML 2.0//<!--EN--></code>" </li>
                   4724:      <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended 1.0//<!--EN--></code>" </li>
                   4725:      <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//<!--EN--></code>" </li>
                   4726:      <li> The public identifier starts with: "<code title="">-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//<!--EN--></code>" </li>
                   4727:      <li> The public identifier starts with: "<code title="">-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//<!--EN--></code>" </li>
                   4728:      <li> The public identifier starts with: "<code title="">-//Spyglass//DTD HTML 2.0 Extended//<!--EN--></code>" </li>
                   4729:      <li> The public identifier starts with: "<code title="">-//SQ//DTD HTML 2.0 HoTMetaL + extensions//<!--EN--></code>" </li>
                   4730:      <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava HTML//<!--EN--></code>" </li>
                   4731:      <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava Strict HTML//<!--EN--></code>" </li>
                   4732:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3 1995-03-24//<!--EN--></code>" </li>
                   4733:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Draft//<!--EN--></code>" </li>
                   4734:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Final//<!--EN--></code>" </li>
                   4735:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2//<!--EN--></code>" </li>
                   4736:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2S Draft//<!--EN--></code>" </li>
                   4737:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Frameset//<!--EN--></code>" </li>
                   4738:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Transitional//<!--EN--></code>" </li>
                   4739:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 19960712//<!--EN--></code>" </li>
                   4740:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 970421//<!--EN--></code>" </li>
                   4741:      <li> The public identifier starts with: "<code title="">-//W3C//DTD W3 HTML//<!--EN--></code>" </li>
                   4742:      <li> The public identifier starts with: "<code title="">-//W3O//DTD W3 HTML 3.0//<!--EN--></code>" </li>
                   4743:    <!--<li> The public identifier is set to: "<code title="">-//W3O//DTD W3 HTML 3.0//EN//</code>" </li>-->
                   4744:      <li> The public identifier is set to: "<code title="">-//W3O//DTD W3 HTML Strict 3.0//EN//</code>" </li>
                   4745:      <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML 2.0//<!--EN--></code>" </li>
                   4746:      <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML//<!--EN--></code>" </li>
                   4747:      <li> The public identifier is set to: "<code title="">-/W3C/DTD HTML 4.0 Transitional/EN</code>" </li>
                   4748:      <li> The public identifier is set to: "<code title="">HTML</code>" </li>
                   4749:      <li> The system identifier is set to: "<code title="">http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd</code>" </li>
                   4750:      <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
                   4751:      <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Transitional//<!--EN--></code>" </li>
                   4752:     </ul><p>Otherwise, if the DOCTYPE token matches one of the conditions
                   4753:     in the following list, then set the <code>Document</code> to
                   4754:     <a href="dom.html#limited-quirks-mode">limited quirks mode</a>:</p>
                   4755: 
                   4756:     <ul class="brief"><li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Frameset//<!--EN--></code>" </li>
                   4757:      <li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Transitional//<!--EN--></code>" </li>
                   4758:      <li> The system identifier is not missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
                   4759:      <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     4760:     </ul><p>The system identifier and public identifier strings must be
                   4761:     compared to the values given in the lists above in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   4762:     case-insensitive</a> manner. A system identifier whose value is
                   4763:     the empty string is not considered missing for the purposes of the
                   4764:     conditions above.</p>
1.1       mike     4765: 
                   4766:     <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>
                   4767: 
                   4768:    </dd>
                   4769: 
                   4770:    <dt>Anything else</dt>
                   4771:    <dd>
                   4772: 
1.727     mike     4773:     <p>If the document is <em>not</em> <a href="text-level-semantics.html#an-iframe-srcdoc-document">an <code>iframe</code>
                   4774:     <code title="attr-iframe-srcdoc">srcdoc</code> document</a>,
                   4775:     then this is a <a href="#parse-error">parse error</a>; set the
                   4776:     <code>Document</code> to <a href="dom.html#quirks-mode">quirks mode</a>.</p>
1.1       mike     4777: 
1.727     mike     4778:     <p>In any case, 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
1.1       mike     4779:     reprocess the current token.</p>
                   4780: 
                   4781:    </dd>
                   4782: 
1.755     mike     4783:   </dl><h5 id="the-before-html-insertion-mode"><span class="secno">8.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     4784: 
                   4785:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-html-insertion-mode" title="insertion
                   4786:   mode: before html">before html</a>", tokens must be handled as follows:</p>
                   4787: 
                   4788:   <dl class="switch"><dt>A DOCTYPE token</dt>
                   4789:    <dd>
                   4790:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4791:    </dd>
                   4792: 
                   4793:    <dt>A comment token</dt>
                   4794:    <dd>
                   4795:     <p>Append a <code>Comment</code> node to the <code>Document</code>
                   4796:     object with the <code title="">data</code> attribute set to the
                   4797:     data given in the comment token.</p>
                   4798:    </dd>
                   4799: 
                   4800:    <dt>A character token that is one of U+0009 CHARACTER
                   4801:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   4802:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   4803:    <dd>
                   4804:     <p>Ignore the token.</p>
                   4805:    </dd>
                   4806: 
                   4807:    <dt>A start tag whose tag name is "html"</dt>
                   4808:    <dd>
                   4809: 
1.724     mike     4810:     <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     4811:     namespace</a>. Append it to the <code>Document</code>
                   4812:     object. Put this element in the <a href="#stack-of-open-elements">stack of open
                   4813:     elements</a>.</p>
                   4814: 
                   4815:     <p id="parser-appcache">If the <code>Document</code> is being
                   4816:     loaded as part of <a href="history.html#navigate" title="navigate">navigation</a> of a
                   4817:     <a href="browsers.html#browsing-context">browsing context</a>, then: if the newly created element
                   4818:     has a <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code> attribute,
                   4819:     then <a href="infrastructure.html#resolve-a-url" title="resolve a url">resolve</a> the value of that
                   4820:     attribute to an <a href="infrastructure.html#absolute-url">absolute URL</a>, relative to the newly
                   4821:     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     4822:     algorithm</a> with the resulting <a href="infrastructure.html#absolute-url">absolute URL</a> with
                   4823:     any <a href="infrastructure.html#url-fragment" title="url-fragment">&lt;fragment&gt;</a> component
                   4824:     removed; otherwise, if there is no such attribute or resolving it
                   4825:     fails, run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application
                   4826:     cache selection algorithm</a> with no manifest. The algorithm
                   4827:     must be passed the <code>Document</code> object.</p>
1.1       mike     4828: 
                   4829:     <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>
                   4830: 
                   4831:    </dd>
                   4832: 
1.334     mike     4833:    <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
                   4834:    <dd>
                   4835:     <p>Act as described in the "anything else" entry below.</p>
                   4836:    </dd>
                   4837: 
                   4838:    <dt>Any other end tag</dt>
                   4839:    <dd>
                   4840:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4841:    </dd>
                   4842: 
1.1       mike     4843:    <dt>Anything else</dt>
                   4844:    <dd>
                   4845: 
1.159     mike     4846:     <p>Create an <code><a href="semantics.html#the-html-element-0">html</a></code> element. Append it to the
1.1       mike     4847:     <code>Document</code> object. Put this element in the <a href="#stack-of-open-elements">stack
                   4848:     of open elements</a>.</p>
                   4849: 
                   4850:     <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
                   4851:     context</a>, then: run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application cache selection
                   4852:     algorithm</a> with no manifest, passing it the
                   4853:     <code>Document</code> object.</p>
                   4854: 
                   4855:     <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
                   4856:     reprocess the current token.</p>
                   4857: 
                   4858:    </dd>
                   4859: 
                   4860:   </dl><p>The root element can end up being removed from the
                   4861:   <code>Document</code> object, e.g. by scripts; nothing in particular
                   4862:   happens in such cases, content continues being appended to the nodes
                   4863:   as described in the next section.</p>
                   4864: 
                   4865: 
1.755     mike     4866:   <h5 id="the-before-head-insertion-mode"><span class="secno">8.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     4867: 
                   4868:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-head-insertion-mode" title="insertion
                   4869:   mode: before head">before head</a>", tokens must be handled as follows:</p>
                   4870: 
                   4871:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   4872:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   4873:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   4874:    <dd>
                   4875:     <p>Ignore the token.</p> <!-- :-( -->
                   4876:    </dd>
                   4877: 
                   4878:    <dt>A comment token</dt>
                   4879:    <dd>
                   4880:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   4881:     node</a> with the <code title="">data</code> attribute set to
                   4882:     the data given in the comment token.</p>
                   4883:    </dd>
                   4884: 
                   4885:    <dt>A DOCTYPE token</dt>
                   4886:    <dd>
                   4887:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4888:    </dd>
                   4889: 
                   4890:    <dt>A start tag whose tag name is "html"</dt>
                   4891:    <dd>
                   4892:     <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
                   4893:     mode</a>.</p>
                   4894:    </dd>
                   4895: 
                   4896:    <dt>A start tag whose tag name is "head"</dt>
                   4897:    <dd>
                   4898: 
                   4899:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   4900: 
                   4901:     <p>Set the <a href="#head-element-pointer"><code title="">head</code> element pointer</a>
1.159     mike     4902:     to the newly created <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1       mike     4903: 
                   4904:     <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>
                   4905: 
                   4906:    </dd>
                   4907: 
                   4908:    <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
                   4909:    <dd>
                   4910: 
                   4911:     <p>Act as if a start tag token with the tag name "head" and no
                   4912:     attributes had been seen, then reprocess the current token.</p>
                   4913: 
                   4914:    </dd>
                   4915: 
                   4916:    <dt>Any other end tag</dt>
                   4917:    <dd>
                   4918: 
                   4919:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4920: 
                   4921:    </dd>
                   4922: 
                   4923:    <dt>Anything else</dt>
                   4924:    <dd>
                   4925: 
                   4926:     <p>Act as if a start tag token with the tag name "head" and no
                   4927:     attributes had been seen, then reprocess the current
                   4928:     token.</p>
                   4929: 
                   4930:    </dd>
                   4931: 
1.755     mike     4932:   </dl><h5 id="parsing-main-inhead"><span class="secno">8.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     4933: 
                   4934:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inhead" title="insertion
                   4935:   mode: in head">in head</a>", tokens must be handled as follows:</p>
                   4936: 
                   4937:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   4938:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   4939:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   4940:    <dd>
                   4941:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   4942:     the <a href="#current-node">current node</a>.</p>
                   4943:    </dd>
                   4944: 
                   4945:    <dt>A comment token</dt>
                   4946:    <dd>
                   4947:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   4948:     node</a> with the <code title="">data</code> attribute set to
                   4949:     the data given in the comment token.</p>
                   4950:    </dd>
                   4951: 
                   4952:    <dt>A DOCTYPE token</dt>
                   4953:    <dd>
                   4954:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4955:    </dd>
                   4956: 
                   4957:    <dt>A start tag whose tag name is "html"</dt>
                   4958:    <dd>
                   4959:     <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
                   4960:     mode</a>.</p>
                   4961:    </dd>
                   4962: 
                   4963:    <dt>A start tag whose tag name is one of: "base", "command",
                   4964:    "link"</dt>
                   4965:    <dd>
                   4966: 
                   4967:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   4968:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   4969:     elements</a>.</p>
                   4970: 
                   4971:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   4972:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   4973: 
                   4974:    </dd>
                   4975: 
                   4976:    <dt>A start tag whose tag name is "meta"</dt>
                   4977:    <dd>
                   4978: 
                   4979:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   4980:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   4981:     elements</a>.</p>
                   4982: 
                   4983:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   4984:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   4985: 
                   4986:     <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
                   4987:     value is a supported encoding, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
                   4988:     currently <i>tentative</i>, then <a href="#change-the-encoding">change the
                   4989:     encoding</a> to the encoding given by the value of the
                   4990:     <code title="attr-meta-charset"><a href="semantics.html#attr-meta-charset">charset</a></code> attribute.</p>
                   4991: 
                   4992:     <p>Otherwise, if the element has a <code title="attr-meta-charset"><a href="semantics.html#attr-meta-charset">content</a></code> attribute, and
                   4993:     applying the <a href="infrastructure.html#algorithm-for-extracting-an-encoding-from-a-content-type">algorithm for extracting an encoding from a
                   4994:     Content-Type</a> to its value returns a supported encoding
                   4995:     <var title="">encoding</var>, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
                   4996:     currently <i>tentative</i>, then <a href="#change-the-encoding">change the
                   4997:     encoding</a> to the encoding <var title="">encoding</var>.</p>
                   4998: 
                   4999:    </dd>
                   5000: 
                   5001:    <dt>A start tag whose tag name is "title"</dt>
                   5002:    <dd>
                   5003:     <p>Follow the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>.</p>
                   5004:    </dd>
                   5005: 
                   5006:    <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
                   5007:    <dt>A start tag whose tag name is one of: "noframes", "style"</dt>
                   5008:    <dd>
1.91      mike     5009:     <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1       mike     5010:    </dd>
                   5011: 
                   5012:    <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is disabled</dt>
                   5013:    <dd>
                   5014: 
                   5015:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5016: 
                   5017:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inheadnoscript" title="insertion mode: in head noscript">in head
                   5018:     noscript</a>".</p>
                   5019: 
                   5020:    </dd>
                   5021: 
                   5022:    <dt id="scriptTag">A start tag whose tag name is "script"</dt>
                   5023:    <dd>
                   5024: 
                   5025:     <ol><li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> in the
1.724     mike     5026:      <a href="infrastructure.html#html-namespace-0">HTML namespace</a>.</p></li>
1.1       mike     5027: 
                   5028:      <li>
                   5029: 
                   5030:       <p>Mark the element as being <a href="semantics.html#parser-inserted">"parser-inserted"</a>.</p>
                   5031: 
                   5032:       <p class="note">This ensures that, if the script is external,
1.159     mike     5033:       any <code title="dom-document-write"><a href="embedded-content-0.html#dom-document-write">document.write()</a></code>
1.1       mike     5034:       calls in the script will execute in-line, instead of blowing the
                   5035:       document away, as would happen in most other cases. It also
                   5036:       prevents the script from executing until the end tag is
                   5037:       seen.</p>
                   5038: 
                   5039:      </li>
                   5040: 
                   5041:      <li><p>If the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML
                   5042:      fragment parsing algorithm</a>, then mark the
1.484     mike     5043:      <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
                   5044:      started"</a>. (<a href="#fragment-case">fragment case</a>)</p></li>
1.1       mike     5045: 
                   5046:      <li><p>Append the new element to the <a href="#current-node">current node</a>
                   5047:      and push it onto the <a href="#stack-of-open-elements">stack of open
                   5048:      elements</a>.</p></li>
                   5049: 
1.541     mike     5050:      <li><p>Switch the tokenizer to the <a href="#script-data-state">script data
                   5051:      state</a>.</p></li>
1.1       mike     5052: 
                   5053:      <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
                   5054:      <a href="#insertion-mode">insertion mode</a>.</p>
                   5055: 
1.540     mike     5056:      </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     5057: 
                   5058:     </ol></dd>
                   5059: 
                   5060:    <dt>An end tag whose tag name is "head"</dt>
                   5061:    <dd>
                   5062: 
                   5063:     <p>Pop the <a href="#current-node">current node</a> (which will be the
1.159     mike     5064:     <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     5065:     elements</a>.</p>
                   5066: 
                   5067:     <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>
                   5068: 
                   5069:    </dd>
                   5070: 
                   5071:    <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
                   5072:    <dd>
                   5073:     <p>Act as described in the "anything else" entry below.</p>
                   5074:    </dd>
                   5075: 
                   5076:    <dt>A start tag whose tag name is "head"</dt>
                   5077:    <dt>Any other end tag</dt>
                   5078:    <dd>
                   5079:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5080:    </dd>
                   5081: 
                   5082:    <dt>Anything else</dt>
                   5083:    <dd>
                   5084: 
                   5085:     <!-- can't get here with an EOF and a fragment case -->
                   5086: 
                   5087:     <p>Act as if an end tag token with the tag name "head" had
                   5088:     been seen, and reprocess the current token.</p>
                   5089: 
                   5090:    </dd>
                   5091: 
1.755     mike     5092:   </dl><h5 id="parsing-main-inheadnoscript"><span class="secno">8.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     5093: 
                   5094:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inheadnoscript" title="insertion
                   5095:   mode: in head noscript">in head noscript</a>", tokens must be handled as follows:</p>
                   5096: 
                   5097:   <dl class="switch"><dt>A DOCTYPE token</dt>
                   5098:    <dd>
                   5099:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5100:    </dd>
                   5101: 
                   5102:    <dt>A start tag whose tag name is "html"</dt>
                   5103:    <dd>
                   5104:     <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
                   5105:     mode</a>.</p>
                   5106:    </dd>
                   5107: 
                   5108:    <dt>An end tag whose tag name is "noscript"</dt>
                   5109:    <dd>
                   5110: 
                   5111:     <p>Pop the <a href="#current-node">current node</a> (which will be a
                   5112:     <code><a href="semantics.html#the-noscript-element">noscript</a></code> element) from the <a href="#stack-of-open-elements">stack of open
                   5113:     elements</a>; the new <a href="#current-node">current node</a> will be a
1.159     mike     5114:     <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1       mike     5115: 
                   5116:     <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>
                   5117: 
                   5118:    </dd>
                   5119: 
                   5120:    <dt>A character token that is one of U+0009 CHARACTER
                   5121:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   5122:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   5123:    <dt>A comment token</dt>
                   5124:    <dt>A start tag whose tag name is one of: "link", "meta", "noframes", "style"</dt>
                   5125:    <dd>
                   5126:     <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
                   5127:     mode</a>.</p>
                   5128:    </dd>
                   5129: 
                   5130:    <dt>An end tag whose tag name is "br"</dt>
                   5131:    <dd>
                   5132:     <p>Act as described in the "anything else" entry below.</p>
                   5133:    </dd>
                   5134: 
                   5135:    <dt>A start tag whose tag name is one of: "head", "noscript"</dt>
                   5136:    <dt>Any other end tag</dt>
                   5137:    <dd>
                   5138:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5139:    </dd>
                   5140: 
                   5141:    <dt>Anything else</dt>
                   5142:    <dd>
                   5143: 
                   5144:     <!-- can't get here with an EOF and a fragment case -->
                   5145: 
                   5146:     <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
                   5147:     name "noscript" had been seen and reprocess the current
                   5148:     token.</p>
                   5149: 
                   5150:    </dd>
                   5151: 
1.755     mike     5152:   </dl><h5 id="the-after-head-insertion-mode"><span class="secno">8.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     5153: 
                   5154:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-head-insertion-mode" title="insertion
                   5155:   mode: after head">after head</a>", tokens must be handled as follows:</p>
                   5156: 
                   5157:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   5158:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   5159:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   5160:    <dd>
                   5161:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   5162:     the <a href="#current-node">current node</a>.</p>
                   5163:    </dd>
                   5164: 
                   5165:    <dt>A comment token</dt>
                   5166:    <dd>
                   5167:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   5168:     node</a> with the <code title="">data</code> attribute set to
                   5169:     the data given in the comment token.</p>
                   5170:    </dd>
                   5171: 
                   5172:    <dt>A DOCTYPE token</dt>
                   5173:    <dd>
                   5174:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5175:    </dd>
                   5176: 
                   5177:    <dt>A start tag whose tag name is "html"</dt>
                   5178:    <dd>
                   5179:     <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
                   5180:     mode</a>.</p>
                   5181:    </dd>
                   5182: 
                   5183:    <dt>A start tag whose tag name is "body"</dt>
                   5184:    <dd>
                   5185: 
                   5186:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5187: 
                   5188:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   5189: 
                   5190:     <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>
                   5191: 
                   5192:    </dd>
                   5193: 
                   5194:    <dt>A start tag whose tag name is "frameset"</dt>
                   5195:    <dd>
                   5196: 
                   5197:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5198: 
                   5199:     <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>
                   5200: 
                   5201:    </dd>
                   5202: 
                   5203:    <dt>A start tag token whose tag name is one of: "base", "link",
                   5204:    "meta", "noframes", "script", "style", "title"</dt>
                   5205:    <dd>
                   5206: 
                   5207:     <p><a href="#parse-error">Parse error</a>.</p>
                   5208: 
                   5209:     <p>Push the node pointed to by the <a href="#head-element-pointer"><code title="">head</code> element pointer</a> onto the
                   5210:     <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   5211: 
                   5212:     <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
                   5213:     mode</a>.</p>
                   5214: 
                   5215:     <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
                   5216:     of open elements</a>.</p>
                   5217: 
                   5218:     <p class="note">The <a href="#head-element-pointer"><code title="">head</code> element
                   5219:     pointer</a> cannot be null at this point.</p>
                   5220: 
                   5221:    </dd>
                   5222: 
                   5223:    <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
                   5224:    <dd>
                   5225:     <p>Act as described in the "anything else" entry below.</p>
                   5226:    </dd>
                   5227: 
                   5228:    <dt>A start tag whose tag name is "head"</dt>
                   5229:    <dt>Any other end tag</dt>
                   5230:    <dd>
                   5231:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5232:    </dd>
                   5233: 
                   5234:    <dt>Anything else</dt>
                   5235:    <dd>
                   5236:     <p>Act as if a start tag token with the tag name "body" and no
                   5237:     attributes had been seen, then set the <a href="#frameset-ok-flag">frameset-ok
                   5238:     flag</a> back to "ok", and then reprocess the current
                   5239:     token.</p>
                   5240:    </dd>
                   5241: 
1.755     mike     5242:   </dl><h5 id="parsing-main-inbody"><span class="secno">8.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     5243: 
                   5244:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inbody" title="insertion
                   5245:   mode: in body">in body</a>", tokens must be handled as follows:</p>
                   5246: 
                   5247:   <dl class="switch"><dt>A character token</dt>
                   5248:    <dd>
                   5249: 
                   5250:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5251:     any.</p>
                   5252: 
                   5253:     <p><a href="#insert-a-character" title="insert a character">Insert the token's
                   5254:     character</a> into the <a href="#current-node">current node</a>.</p>
                   5255: 
                   5256:     <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
                   5257:     LINE FEED (LF), U+000C FORM FEED (FF), <!--U+000D CARRIAGE RETURN
                   5258:     (CR),--> or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
                   5259:     flag</a> to "not ok".</p>
                   5260: 
                   5261:    </dd>
                   5262: 
                   5263:    <dt>A comment token</dt>
                   5264:    <dd>
                   5265:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   5266:     node</a> with the <code title="">data</code> attribute set to
                   5267:     the data given in the comment token.</p>
                   5268:    </dd>
                   5269: 
                   5270:    <dt>A DOCTYPE token</dt>
                   5271:    <dd>
                   5272:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5273:    </dd>
                   5274: 
                   5275:    <dt>A start tag whose tag name is "html"</dt>
                   5276:    <dd>
                   5277:     <p><a href="#parse-error">Parse error</a>. For each attribute on the token,
                   5278:     check to see if the attribute is already present on the top
                   5279:     element of the <a href="#stack-of-open-elements">stack of open elements</a>. If it is not,
                   5280:     add the attribute and its corresponding value to that element.</p>
                   5281:    </dd>
                   5282: 
                   5283:    <dt>A start tag token whose tag name is one of: "base", "command",
                   5284:    "link", "meta", "noframes", "script", "style", "title"</dt>
                   5285:    <dd>
                   5286:     <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
                   5287:     mode</a>.</p>
                   5288:    </dd>
                   5289: 
                   5290:    <dt>A start tag whose tag name is "body"</dt>
                   5291:    <dd>
                   5292: 
                   5293:     <p><a href="#parse-error">Parse error</a>.</p>
                   5294: 
                   5295:     <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159     mike     5296:     elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1       mike     5297:     <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
                   5298:     then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
                   5299: 
                   5300:     <p>Otherwise, for each attribute on the token, check to see if
1.159     mike     5301:     the attribute is already present on the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1       mike     5302:     element (the second element) on the <a href="#stack-of-open-elements">stack of open
                   5303:     elements</a>. If it is not, add the attribute and its
                   5304:     corresponding value to that element.</p>
                   5305: 
                   5306:    </dd>
                   5307: 
                   5308:    <dt>A start tag whose tag name is "frameset"</dt>
                   5309:    <dd>
                   5310: 
                   5311:     <p><a href="#parse-error">Parse error</a>.</p>
                   5312: 
                   5313:     <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159     mike     5314:     elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1       mike     5315:     <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
                   5316:     then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
                   5317: 
                   5318:     <p>If the <a href="#frameset-ok-flag">frameset-ok flag</a> is set to "not ok", ignore
                   5319:     the token.</p>
                   5320: 
                   5321:     <p>Otherwise, run the following steps:</p>
                   5322: 
                   5323:     <ol><li><p>Remove the second element on the <a href="#stack-of-open-elements">stack of open
                   5324:      elements</a> from its parent node, if it has one.</p></li>
                   5325: 
                   5326:      <li><p>Pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of
                   5327:      open elements</a>, from the <a href="#current-node">current node</a> up to,
1.159     mike     5328:      but not including, the root <code><a href="semantics.html#the-html-element-0">html</a></code> element.</p>
1.1       mike     5329: 
                   5330:      </li><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
                   5331:      token.</p></li>
                   5332: 
                   5333:      <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>
                   5334: 
                   5335:     </li></ol></dd>
                   5336: 
                   5337:    <dt>An end-of-file token</dt>
                   5338:    <dd>
                   5339: 
                   5340:     <p>If there is a node in the <a href="#stack-of-open-elements">stack of open elements</a>
1.422     mike     5341:     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>
                   5342:     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     5343:     <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
                   5344:     <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
                   5345:     <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     5346:     <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     5347:     this is a <a href="#parse-error">parse error</a>.</p> <!-- (some of those are
1.422     mike     5348:     fragment cases) -->
1.1       mike     5349: 
                   5350:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   5351: 
                   5352:    </dd>
                   5353: 
                   5354:    <dt>An end tag whose tag name is "body"</dt>
                   5355:    <dd>
                   5356: 
                   5357:     <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
                   5358:     in scope</a>, this is a <a href="#parse-error">parse error</a>; ignore the
                   5359:     token.</p>
                   5360: 
                   5361:     <!-- if we get here, the insertion mode here is forcibly "in
                   5362:     body". -->
                   5363: 
                   5364:     <p>Otherwise, if there is a node in the <a href="#stack-of-open-elements">stack of open
1.422     mike     5365:     elements</a> that is not either a <code><a href="semantics.html#the-dd-element">dd</a></code> element, a
1.1       mike     5366:     <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
                   5367:     <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
                   5368:     <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
                   5369:     <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
                   5370:     <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
                   5371:     <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     5372:     <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
                   5373:     <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     5374:     error</a>.</p> <!-- (some of those are fragment cases, e.g. for
                   5375:     <tbody> you'd have hit the first paragraph since the <body>
1.422     mike     5376:     wouldn't be in scope, unless it was a fragment case) -->
1.1       mike     5377: 
                   5378:     <!-- If we ever change the frameset-ok flag to an insertion mode,
                   5379:     then we'd have to somehow keep track of its state when we switch
                   5380:     to after-body. -->
                   5381: 
                   5382:     <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>
                   5383: 
                   5384:    </dd>
                   5385: 
                   5386:    <dt>An end tag whose tag name is "html"</dt>
                   5387:    <dd>
                   5388: 
                   5389:     <p>Act as if an end tag with tag name "body" had been seen,
                   5390:     then, if that token wasn't ignored, reprocess the current
                   5391:     token.</p>
                   5392: 
                   5393:    </dd>
                   5394: 
                   5395:    <!-- start tags for non-phrasing flow content elements -->
                   5396: 
                   5397:    <!-- the normal ones -->
                   5398:    <dt>A start tag whose tag name is one of: "address", "article",
1.683     mike     5399:    "aside", "blockquote", "center", <!--v2DATAGRID"datagrid",-->
1.305     mike     5400:    "details", "dir", "div", "dl", "fieldset", "figure", "footer",
                   5401:    "header", "hgroup", "menu", "nav", "ol", "p", "section", "ul"</dt>
1.1       mike     5402:    <dd>
                   5403: 
                   5404:     <!-- As of May 2008 this doesn't match any browser exactly, but is
                   5405:     as close to what IE does as I can get without doing the non-tree
                   5406:     DOM nonsense, and thus should actually afford better compatibility
                   5407:     when implemented by the other browsers. -->
                   5408: 
                   5409:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5410:     an element in scope">has a <code>p</code> element in
                   5411:     scope</a>, then act as if an end tag with the tag name
                   5412:     "p" had been seen.</p>
                   5413: 
                   5414:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5415: 
                   5416:    </dd>
                   5417: 
                   5418:    <!-- as normal, but close h1-h6 if it's the current node -->
                   5419:    <dt>A start tag whose tag name is one of: "h1", "h2", "h3", "h4",
                   5420:    "h5", "h6"</dt>
                   5421:    <dd>
                   5422: 
                   5423:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5424:     an element in scope">has a <code>p</code> element in
                   5425:     scope</a>, then act as if an end tag with the tag name
                   5426:     "p" had been seen.</p>
                   5427: 
                   5428:     <p>If the <a href="#current-node">current node</a> is an element whose tag name
                   5429:     is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is a
                   5430:     <a href="#parse-error">parse error</a>; pop the <a href="#current-node">current node</a> off
                   5431:     the <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   5432:     <!-- See https://bugs.webkit.org/show_bug.cgi?id=12646 -->
                   5433: 
                   5434:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5435: 
                   5436:    </dd>
                   5437: 
                   5438:    <!-- as normal, but drops leading newline -->
                   5439:    <dt>A start tag whose tag name is one of: "pre", "listing"</dt>
                   5440:    <dd>
                   5441: 
                   5442:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5443:     an element in scope">has a <code>p</code> element in
                   5444:     scope</a>, then act as if an end tag with the tag name
                   5445:     "p" had been seen.</p>
                   5446: 
                   5447:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5448: 
                   5449:     <p>If the next token is a U+000A LINE FEED (LF) character
                   5450:     token, then ignore that token and move on to the next
                   5451:     one. (Newlines at the start of <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are
                   5452:     ignored as an authoring convenience.)</p>
                   5453: 
                   5454:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   5455: 
                   5456:    </dd>
                   5457: 
                   5458:    <!-- as normal, but interacts with the form element pointer -->
                   5459:    <dt>A start tag whose tag name is "form"</dt>
                   5460:    <dd>
                   5461: 
                   5462:     <p>If the <a href="#form-element-pointer"><code title="form">form</code> element
                   5463:     pointer</a> is not null, then this is a <a href="#parse-error">parse
                   5464:     error</a>; ignore the token.</p>
                   5465: 
                   5466:     <p>Otherwise:</p>
                   5467: 
                   5468:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5469:     an element in scope">has a <code>p</code> element in
                   5470:     scope</a>, then act as if an end tag with the tag name
                   5471:     "p" had been seen.</p>
                   5472: 
                   5473:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, and set the
                   5474:     <a href="#form-element-pointer"><code title="form">form</code> element pointer</a> to
                   5475:     point to the element created.</p>
                   5476: 
                   5477:    </dd>
                   5478: 
                   5479:    <!-- as normal, but imply </li> when there's another <li> open in weird cases -->
                   5480:    <dt>A start tag whose tag name is "li"</dt>
                   5481:    <dd>
                   5482: 
                   5483:     <p>Run the following algorithm:</p>
                   5484: 
                   5485:     <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
                   5486: 
                   5487:      <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
                   5488:      node</a> (the bottommost node of the stack).</p></li>
                   5489: 
1.578     mike     5490:      <li><p><i>Loop</i>: If <var title="">node</var> is an
                   5491:      <code><a href="semantics.html#the-li-element">li</a></code> element, then act as if an end tag with the tag
                   5492:      name "li" had been seen, then jump to the last step.</p></li>
1.1       mike     5493: 
1.578     mike     5494:      <li><p>If <var title="">node</var> is not in the
1.1       mike     5495:      <a href="#formatting">formatting</a> category, and is not in the
                   5496:      <a href="#phrasing">phrasing</a> category, and is not an
1.306     mike     5497:      <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     5498:      element, then jump to the last step.</p></li> <!-- an element
                   5499:      <foo> is in this list if the following markup:
                   5500: 
                   5501:          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><ol><li><foo><li>
                   5502: 
                   5503:      ...results in the second <li> not being (in any way) a descendant
                   5504:      of the first <li>, or if <foo> is a formatting element that gets
                   5505:      reopened later. -->
                   5506: 
                   5507:      <li><p>Otherwise, set <var title="">node</var> to the previous
                   5508:      entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
                   5509:      the step labeled <i>loop</i>.</p></li>
                   5510: 
                   5511:      <li>
                   5512: 
                   5513:       <p>This is the last step.</p>
                   5514: 
                   5515:       <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5516:       an element in scope">has a <code>p</code> element in
                   5517:       scope</a>, then act as if an end tag with the tag name
                   5518:       "p" had been seen.</p>
                   5519: 
                   5520:       <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
                   5521:       token.</p>
                   5522: 
                   5523:      </li>
                   5524: 
                   5525:     </ol></dd>
                   5526: 
                   5527:    <!-- as normal, but imply </dt> or </dd> when there's another <dt> or <dd> open in weird cases  -->
1.422     mike     5528:    <dt>A start tag whose tag name is one of: "dd", "dt"</dt>
1.1       mike     5529:    <dd>
                   5530: 
                   5531:     <p>Run the following algorithm:</p>
                   5532: 
                   5533:     <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
                   5534: 
                   5535:      <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
                   5536:      node</a> (the bottommost node of the stack).</p></li>
                   5537: 
                   5538:      <li><p><i>Loop</i>: If <var title="">node</var> is a
1.422     mike     5539:      <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
                   5540:      tag with the same tag name as <var title="">node</var> had been
                   5541:      seen, then jump to the last step.</p></li>
1.1       mike     5542: 
                   5543:      <li><p>If <var title="">node</var> is not in the
                   5544:      <a href="#formatting">formatting</a> category, and is not in the
                   5545:      <a href="#phrasing">phrasing</a> category, and is not an
1.306     mike     5546:      <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     5547:      element, then jump to the last step.</p></li> <!-- an element
                   5548:      <foo> is in this list if the following markup:
                   5549: 
                   5550:          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><dl><dt><foo><dt>
                   5551: 
                   5552:      ...results in the second <dt> not being (in any way) a descendant
                   5553:      of the first <dt>, or if <foo> is a formatting element that gets
                   5554:      reopened later. -->
                   5555: 
                   5556:      <li><p>Otherwise, set <var title="">node</var> to the previous
                   5557:      entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
                   5558:      the step labeled <i>loop</i>.</p></li>
                   5559: 
                   5560:      <li>
                   5561: 
                   5562:       <p>This is the last step.</p>
                   5563: 
                   5564:       <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5565:       an element in scope">has a <code>p</code> element in
                   5566:       scope</a>, then act as if an end tag with the tag name
                   5567:       "p" had been seen.</p>
                   5568: 
                   5569:       <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
                   5570:       token.</p>
                   5571: 
                   5572:      </li>
                   5573: 
                   5574:     </ol></dd>
                   5575: 
                   5576:    <!-- same as normal, but effectively ends parsing -->
                   5577:    <dt>A start tag whose tag name is "plaintext"</dt>
                   5578:    <dd>
                   5579: 
                   5580:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5581:     an element in scope">has a <code>p</code> element in
                   5582:     scope</a>, then act as if an end tag with the tag name
                   5583:     "p" had been seen.</p>
                   5584: 
                   5585:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5586: 
1.541     mike     5587:     <p>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1       mike     5588: 
1.541     mike     5589:     <p class="note">Once a start tag with the tag name "plaintext" has
                   5590:     been seen, that will be the last token ever seen other than
                   5591:     character tokens (and the end-of-file token), because there is no
                   5592:     way to switch out of the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1       mike     5593: 
                   5594:    </dd>
                   5595: 
                   5596:    <!-- end tags for non-phrasing flow content elements -->
                   5597: 
                   5598:    <!-- the normal ones -->
                   5599:    <dt>An end tag whose tag name is one of: "address", "article",
1.683     mike     5600:    "aside", "blockquote", "center", <!--v2DATAGRID"datagrid",-->
1.305     mike     5601:    "details", "dir", "div", "dl", "fieldset", "figure", "footer",
                   5602:    "header", "hgroup", "listing", "menu", "nav", "ol", "pre",
                   5603:    "section", "ul"</dt>
1.1       mike     5604:    <dd>
                   5605: 
                   5606:     <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>
                   5607:     with the same tag name as that of the token, then this is a
                   5608:     <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5609: 
                   5610:     <p>Otherwise, run these steps:</p>
                   5611: 
                   5612:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   5613: 
                   5614:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5615:      the same tag name as that of the token, then this is a
                   5616:      <a href="#parse-error">parse error</a>.</p></li>
                   5617: 
                   5618:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5619:      until an element with the same tag name as the token has been
                   5620:      popped from the stack.</p></li>
                   5621: 
                   5622:     </ol></dd>
                   5623: 
                   5624:    <!-- removes the form element pointer instead of the matching node -->
                   5625:    <dt>An end tag whose tag name is "form"</dt>
                   5626:    <dd>
                   5627: 
                   5628:     <p>Let <var title="">node</var> be the element that the
                   5629:     <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is set
                   5630:     to.</p>
                   5631: 
                   5632:     <p>Set the <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
                   5633:     to null.</p>
                   5634: 
                   5635:     <p>If <var title="">node</var> is null or the <a href="#stack-of-open-elements">stack of open
                   5636:     elements</a> does not <a href="#has-an-element-in-scope" title="has an element in
                   5637:     scope">have <var title="">node</var> in scope</a>, then this is
                   5638:     a <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5639: 
                   5640:     <p>Otherwise, run these steps:</p>
                   5641: 
                   5642:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   5643: 
                   5644:      <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
                   5645:      error</a>.</p></li>
                   5646: 
                   5647:      <li><p>Remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of
                   5648:      open elements</a>.</p></li>
                   5649: 
                   5650:     </ol></dd>
                   5651: 
                   5652:    <!-- as normal, except </p> implies <p> if there's no <p> in scope, and needs care as the elements have optional tags -->
                   5653:    <dt>An end tag whose tag name is "p"</dt>
                   5654:    <dd>
                   5655: 
                   5656:     <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>
                   5657:     with the same tag name as that of the token, then this is a
                   5658:     <a href="#parse-error">parse error</a>; act as if a start tag with the tag name
                   5659:     "p" had been seen, then reprocess the current 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.234     mike     5676:    <!-- as normal, but needs care as the elements have optional tags, and are further scoped by <ol>/<ul> -->
                   5677:    <dt>An end tag whose tag name is "li"</dt>
                   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-list-item-scope" title="has an element in list item scope">have an element in list
                   5681:     item scope</a> with the same tag name as that of the token,
                   5682:     then this is a <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: 
1.1       mike     5699:    <!-- as normal, but needs care as the elements have optional tags -->
1.422     mike     5700:    <dt>An end tag whose tag name is one of: "dd", "dt"</dt>
1.1       mike     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:     with the same tag name as that of the token, then this is a
                   5705:     <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>, except
                   5710:      for elements with the same tag name as the token.</p></li>
                   5711: 
                   5712:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5713:      the same tag name as that of the token, then this is a
                   5714:      <a href="#parse-error">parse error</a>.</p></li>
                   5715: 
                   5716:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5717:      until an element with the same tag name as the token has been
                   5718:      popped from the stack.</p></li>
                   5719: 
                   5720:     </ol></dd>
                   5721: 
                   5722:    <!-- as normal, except acts as a closer for any of the h1-h6 elements -->
                   5723:    <dt>An end tag whose tag name is one of: "h1", "h2", "h3", "h4", "h5", "h6"</dt>
                   5724:    <dd>
                   5725: 
                   5726:     <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>
                   5727:     whose tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6",
                   5728:     then this is a <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5729: 
                   5730:     <p>Otherwise, run these steps:</p>
                   5731: 
                   5732:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   5733: 
                   5734:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5735:      the same tag name as that of the token, then this is a
                   5736:      <a href="#parse-error">parse error</a>.</p></li>
                   5737: 
                   5738:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5739:      until an element whose tag name is one of "h1", "h2", "h3", "h4",
                   5740:      "h5", or "h6" has been popped from the stack.</p></li>
                   5741: 
                   5742:     </ol></dd>
                   5743: 
                   5744:    <dt>An end tag whose tag name is "sarcasm"</dt>
                   5745:    <dd>
                   5746:     <p>Take a deep breath, then act as described in the "any other end
                   5747:     tag" entry below.</p>
                   5748:    </dd>
                   5749: 
                   5750:    <!-- ADOPTION AGENCY ELEMENTS
                   5751:         Mozilla-only: bdo blink del ins sub sup q
                   5752:         Safari-only: code dfn kbd nobr samp var wbr
                   5753:         Both: a b big em font i s small strike strong tt u -->
                   5754: 
                   5755:    <dt>A start tag whose tag name is "a"</dt>
                   5756:    <dd>
                   5757: 
                   5758:     <p>If the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>
                   5759:     contains an element whose tag name is "a" between the end of
                   5760:     the list and the last marker on the list (or the start of the
                   5761:     list if there is no marker on the list), then this is a
                   5762:     <a href="#parse-error">parse error</a>; act as if an end tag with the tag
                   5763:     name "a" had been seen, then remove that element from the
                   5764:     <a href="#list-of-active-formatting-elements">list of active formatting elements</a> and the
                   5765:     <a href="#stack-of-open-elements">stack of open elements</a> if the end tag didn't
                   5766:     already remove it (it might not have if the element is not
                   5767:     <a href="#has-an-element-in-table-scope" title="has an element in table scope">in table
                   5768:     scope</a>).</p>
                   5769: 
                   5770:     <p class="example">In the non-conforming stream
                   5771:     <code>&lt;a&#160;href="a"&gt;a&lt;table&gt;&lt;a&#160;href="b"&gt;b&lt;/table&gt;x</code>,
                   5772:     the first <code><a href="text-level-semantics.html#the-a-element">a</a></code> element would be closed upon seeing
                   5773:     the second one, and the "x" character would be inside a link
                   5774:     to "b", not to "a". This is despite the fact that the outer
                   5775:     <code><a href="text-level-semantics.html#the-a-element">a</a></code> element is not in table scope (meaning that a
                   5776:     regular <code>&lt;/a&gt;</code> end tag at the start of the table
                   5777:     wouldn't close the outer <code><a href="text-level-semantics.html#the-a-element">a</a></code> element).</p>
                   5778: 
                   5779:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5780:     any.</p>
                   5781: 
                   5782:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
                   5783:     element to the <a href="#list-of-active-formatting-elements">list of active formatting
                   5784:     elements</a>.</p>
                   5785: 
                   5786:    </dd>
                   5787: 
                   5788:    <dt>A start tag whose tag name is one of: "b", "big", "code", "em",
                   5789:    "font", "i", "s", "small", "strike", "strong", "tt", "u"</dt>
                   5790:    <dd>
                   5791: 
                   5792:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5793:     any.</p>
                   5794: 
                   5795:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
                   5796:     element to the <a href="#list-of-active-formatting-elements">list of active formatting
                   5797:     elements</a>.</p>
                   5798: 
                   5799:    </dd>
                   5800: 
                   5801:    <dt>A start tag whose tag name is "nobr"</dt>
                   5802:    <dd>
                   5803: 
                   5804:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5805:     any.</p>
                   5806: 
                   5807:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
                   5808:     element in scope">has a <code>nobr</code> element in scope</a>,
                   5809:     then this is a <a href="#parse-error">parse error</a>; act as if an end tag with
                   5810:     the tag name "nobr" had been seen, then once again
                   5811:     <a href="#reconstruct-the-active-formatting-elements">reconstruct the active formatting elements</a>, if
                   5812:     any.</p>
                   5813: 
                   5814:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
                   5815:     element to the <a href="#list-of-active-formatting-elements">list of active formatting
                   5816:     elements</a>.</p>
                   5817: 
                   5818:    </dd>
                   5819: 
                   5820:    <dt id="adoptionAgency">An end tag whose tag name is one of: "a",
                   5821:    "b", "big", "code", "em", "font", "i", "nobr", "s", "small",
                   5822:    "strike", "strong", "tt", "u"</dt>
                   5823:    <dd>
                   5824: 
                   5825:     <p>Follow these steps:</p>
                   5826: 
                   5827:     <ol><li>
                   5828: 
                   5829:       <p>Let the <var title="">formatting element</var> be the
                   5830:       last element in the <a href="#list-of-active-formatting-elements">list of active formatting
                   5831:       elements</a> that:</p>
                   5832: 
                   5833:       <ul><li>is between the end of the list and the last scope
                   5834:        marker in the list, if any, or the start of the list
                   5835:        otherwise, and</li>
                   5836: 
                   5837:        <li>has the same tag name as the token.</li>
                   5838: 
                   5839:       </ul><p>If there is no such node, or, if that node is also in the
                   5840:       <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
                   5841:       <a href="#parse-error">parse error</a>; ignore the token, and abort these
                   5842:       steps.</p>
                   5843: 
                   5844:       <p>Otherwise, if there is such a node, but that node is not
                   5845:       in the <a href="#stack-of-open-elements">stack of open elements</a>, then this is a
                   5846:       <a href="#parse-error">parse error</a>; remove the element from the list,
                   5847:       and abort these steps.</p>
                   5848: 
                   5849:       <p>Otherwise, there is a <var title="">formatting
                   5850:       element</var> and that element is in <a href="#stack-of-open-elements" title="stack of
                   5851:       open elements">the stack</a> and is <a href="#has-an-element-in-scope" title="has an
                   5852:       element in scope">in scope</a>. If the element is not the
                   5853:       <a href="#current-node">current node</a>, this is a <a href="#parse-error">parse
                   5854:       error</a>. In any case, proceed with the algorithm as
                   5855:       written in the following steps.</p>
                   5856: 
                   5857:      </li>
                   5858: 
                   5859:      <li><p>Let the <var title="">furthest block</var> be the
                   5860:      topmost node in the <a href="#stack-of-open-elements">stack of open elements</a> that
                   5861:      is lower in the stack than the <var title="">formatting
                   5862:      element</var>, and is not an element in the
                   5863:      <a href="#phrasing">phrasing</a> or <a href="#formatting">formatting</a>
                   5864:      categories. There might not be one.</p></li>
                   5865: 
                   5866:      <li><p>If there is no <var title="">furthest block</var>,
                   5867:      then the UA must skip the subsequent steps and instead just
                   5868:      pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of open
                   5869:      elements</a>, from the <a href="#current-node">current node</a> up to and
                   5870:      including the <var title="">formatting element</var>, and
                   5871:      remove the <var title="">formatting element</var> from the
                   5872:      <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</p></li>
                   5873: 
                   5874:      <li><p>Let the <var title="">common ancestor</var> be the element
                   5875:      immediately above the <var title="">formatting element</var> in the
                   5876:      <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
                   5877: 
                   5878:      <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
                   5879:      formatting elements</a> relative to the elements on either
                   5880:      side of it in the list.</p></li>
                   5881: 
                   5882:      <li>
                   5883: 
                   5884:       <p>Let <var title="">node</var> and <var title="">last node</var> be the
                   5885:       <var title="">furthest block</var>. Follow these steps:</p>
                   5886: 
                   5887:       <ol><li>Let <var title="">node</var> be the element immediately
                   5888:        above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
1.436     mike     5889:        elements</a>, or if <var title="">node</var> is no longer in
                   5890:        the <a href="#stack-of-open-elements">stack of open elements</a> (e.g. because it got
                   5891:        removed by the next step), the element that was immediately
                   5892:        above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
                   5893:        elements</a> before <var title="">node</var> was
                   5894:        removed.</li>
1.1       mike     5895: 
                   5896:        <li>If <var title="">node</var> is not in the <a href="#list-of-active-formatting-elements">list of
                   5897:        active formatting elements</a>, then remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of open
                   5898:        elements</a> and then go back to step 1.</li>
                   5899: 
                   5900:        <li>Otherwise, if <var title="">node</var> is the <var title="">formatting element</var>, then go to the next step
                   5901:        in the overall algorithm.</li>
                   5902: 
                   5903:        <li>Otherwise, if <var title="">last node</var> is the <var title="">furthest block</var>, then move the aforementioned
                   5904:        bookmark to be immediately after the <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
                   5905:        elements</a>.</li>
                   5906: 
                   5907:        <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
                   5908:        element <var title="">node</var> was created, replace the entry
                   5909:        for <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active
                   5910:        formatting elements</a> with an entry for the new element,
                   5911:        replace the entry for <var title="">node</var> in the
                   5912:        <a href="#stack-of-open-elements">stack of open elements</a> with an entry for the new
                   5913:        element, and let <var title="">node</var> be the new
                   5914:        element.</li>
                   5915: 
                   5916:        <li>Insert <var title="">last node</var> into <var title="">node</var>, first removing it from its previous
                   5917:        parent node if any.</li>
                   5918: 
                   5919:        <li>Let <var title="">last node</var> be <var title="">node</var>.</li>
                   5920: 
                   5921:        <li>Return to step 1 of this inner set of steps.</li>
                   5922: 
                   5923:       </ol></li>
                   5924: 
                   5925:      <li>
                   5926: 
                   5927:       <p>If the <var title="">common ancestor</var> node is a
                   5928:       <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>,
                   5929:       <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,
                   5930:       <a href="#foster-parent">foster parent</a> whatever <var title="">last
                   5931:       node</var> ended up being in the previous step, first removing
                   5932:       it from its previous parent node if any.</p>
                   5933: 
                   5934:       <p>Otherwise, append whatever <var title="">last node</var>
                   5935:       ended up being in the previous step to the <var title="">common
                   5936:       ancestor</var> node, first removing it from its previous parent
                   5937:       node if any.</p>
                   5938: 
                   5939:      </li>
                   5940: 
                   5941:      <li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
                   5942:      <var title="">formatting element</var> was created.</p></li>
                   5943: 
                   5944:      <li><p>Take all of the child nodes of the <var title="">furthest
                   5945:      block</var> and append them to the element created in the last
                   5946:      step.</p></li>
                   5947: 
                   5948:      <li><p>Append that new element to the <var title="">furthest
                   5949:      block</var>.</p></li>
                   5950: 
                   5951:      <li><p>Remove the <var title="">formatting element</var> from the
                   5952:      <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, and insert the
                   5953:      new element into the <a href="#list-of-active-formatting-elements">list of active formatting
                   5954:      elements</a> at the position of the aforementioned
                   5955:      bookmark.</p></li>
                   5956: 
                   5957:      <li><p>Remove the <var title="">formatting element</var> from the
                   5958:      <a href="#stack-of-open-elements">stack of open elements</a>, and insert the new element
                   5959:      into the <a href="#stack-of-open-elements">stack of open elements</a> immediately below
                   5960:      the position of the <var title="">furthest block</var> in that
                   5961:      stack.</p></li>
                   5962: 
                   5963:      <li><p>Jump back to step 1 in this series of steps.</p></li>
                   5964: 
1.334     mike     5965:     </ol><p class="note">Because of the way this algorithm causes elements
1.304     mike     5966:     to change parents, it has been dubbed the "adoption agency
                   5967:     algorithm" (in contrast with other possible algorithms for dealing
                   5968:     with misnested content, which included the "incest algorithm", the
1.1       mike     5969:     "secret affair algorithm", and the "Heisenberg algorithm").</p>
                   5970: 
                   5971:    </dd>
                   5972: 
                   5973:    <dt>A start tag whose tag name is "button"</dt>
                   5974:    <dd>
                   5975: 
                   5976:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5977:     an element in scope">has a <code>button</code> element in
                   5978:     scope</a>, then this is a <a href="#parse-error">parse error</a>;
                   5979:     act as if an end tag with the tag name "button" had been seen,
                   5980:     then reprocess the token.</p>
                   5981: 
                   5982:     <p>Otherwise:</p>
                   5983: 
                   5984:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5985:     any.</p>
                   5986: 
                   5987:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5988: 
                   5989:     <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
                   5990:     formatting elements</a>.</p>
                   5991: 
                   5992:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   5993: 
                   5994:    </dd>
                   5995: 
                   5996:    <dt>A start tag token whose tag name is one of: "applet",
                   5997:    "marquee", "object"</dt>
                   5998:    <dd>
                   5999: 
                   6000:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6001:     any.</p>
                   6002: 
                   6003:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6004: 
                   6005:     <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
                   6006:     formatting elements</a>.</p>
                   6007: 
                   6008:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6009: 
                   6010:    </dd>
                   6011: 
                   6012:    <dt>An end tag token whose tag name is one of: "applet", "button",
                   6013:    "marquee", "object"</dt>
                   6014:    <dd>
                   6015: 
                   6016:     <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>
                   6017:     with the same tag name as that of the token, then this is a
                   6018:     <a href="#parse-error">parse error</a>; ignore the token.</p>
                   6019: 
                   6020:     <p>Otherwise, run these steps:</p>
                   6021: 
                   6022:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   6023: 
                   6024:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   6025:      the same tag name as that of the token, then this is a
                   6026:      <a href="#parse-error">parse error</a>.</p></li>
                   6027: 
                   6028:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   6029:      until an element with the same tag name as the token has been
                   6030:      popped from the stack.</p></li>
                   6031: 
                   6032:      <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
                   6033:      last marker</a>.</li>
                   6034: 
                   6035:     </ol></dd>
                   6036: 
                   6037:    <dt>A start tag whose tag name is "table"</dt>
                   6038:    <dd>
                   6039: 
                   6040:     <p>If the <code>Document</code> is <em>not</em> set to
                   6041:     <a href="dom.html#quirks-mode">quirks mode</a>, and the <a href="#stack-of-open-elements">stack of open
                   6042:     elements</a> <a href="#has-an-element-in-scope" title="has an element in scope">has a
                   6043:     <code>p</code> element in scope</a>, then act as if an end tag
                   6044:     with the tag name "p" had been seen.</p> <!-- i hate myself (this
                   6045:     quirk was basically caused by acid2; if i'd realised we could
                   6046:     change the specs when i wrote acid2, we could have avoided having
                   6047:     any parsing-mode quirks) -Hixie -->
                   6048: 
                   6049:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6050: 
                   6051:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6052: 
                   6053:     <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>
                   6054: 
                   6055:    </dd>
                   6056: 
                   6057:    <dt>A start tag whose tag name is one of: "area", "basefont",
1.589     mike     6058:    "bgsound", "br", "embed", "img", "input", "keygen", "wbr"</dt>
1.1       mike     6059:    <dd>
                   6060: 
                   6061:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6062:     any.</p>
                   6063: 
                   6064:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   6065:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6066:     elements</a>.</p>
                   6067: 
                   6068:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   6069:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   6070: 
                   6071:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p> <!--
1.589     mike     6072:     shouldn't really do it for <area>, <basefont>, and <bgsound> -->
1.1       mike     6073: 
                   6074:    </dd>
                   6075: 
                   6076:    <dt>A start tag whose tag name is one of: "param", "source"</dt>
                   6077:    <dd>
                   6078: 
                   6079:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   6080:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6081:     elements</a>.</p>
                   6082: 
                   6083:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   6084:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   6085: 
                   6086:    </dd>
                   6087: 
                   6088:    <dt>A start tag whose tag name is "hr"</dt>
                   6089:    <dd>
                   6090: 
                   6091:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   6092:     an element in scope">has a <code>p</code> element in
                   6093:     scope</a>, then act as if an end tag with the tag name
                   6094:     "p" had been seen.</p>
                   6095: 
                   6096:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   6097:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6098:     elements</a>.</p>
                   6099: 
                   6100:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   6101:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   6102: 
                   6103:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6104: 
                   6105:    </dd>
                   6106: 
                   6107:    <dt>A start tag whose tag name is "image"</dt>
                   6108:    <dd>
                   6109:     <p><a href="#parse-error">Parse error</a>. Change the token's tag name
                   6110:     to "img" and reprocess it. (Don't ask.)</p> <!-- As of
                   6111:     2005-12, studies showed that around 0.2% of pages used the
                   6112:     <image> element. -->
                   6113:    </dd>
                   6114: 
                   6115:    <dt id="isindex">A start tag whose tag name is "isindex"</dt>
                   6116:    <dd>
                   6117: 
                   6118:     <p><a href="#parse-error">Parse error</a>.</p>
                   6119: 
                   6120:     <p>If the <a href="#form-element-pointer"><code title="">form</code> element
                   6121:     pointer</a> is not null, then ignore the token.</p>
                   6122: 
                   6123:     <p>Otherwise:</p>
                   6124: 
                   6125:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   6126:     token's <i>self-closing flag</i></a>, if it is set.</p> <!--
                   6127:     purely to reduce the number of errors (we don't care if they
                   6128:     included the /, they're not supposed to be including the tag at
                   6129:     all! -->
                   6130: 
                   6131:     <p>Act as if a start tag token with the tag name "form" had been seen.</p>
                   6132: 
                   6133:     <p>If the token has an attribute called "action", set the
                   6134:     <code title="attr-form-action">action</code> attribute on the
                   6135:     resulting <code><a href="forms.html#the-form-element">form</a></code> element to the value of the
                   6136:     "action" attribute of the token.</p>
                   6137: 
                   6138:     <p>Act as if a start tag token with the tag name "hr" had been
                   6139:     seen.</p>
                   6140: 
                   6141:     <p>Act as if a start tag token with the tag name "label" had been
                   6142:     seen.</p>
                   6143: 
                   6144:     <p>Act as if a stream of character tokens had been seen (see below
                   6145:     for what they should say).</p>
                   6146: 
                   6147:     <p>Act as if a start tag token with the tag name "input" had been
                   6148:     seen, with all the attributes from the "isindex" token except
                   6149:     "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
                   6150:     <code><a href="forms.html#the-input-element">input</a></code> element to the value "<code title="">isindex</code>".</p>
                   6151: 
                   6152:     <p>Act as if a stream of character tokens had been seen (see
                   6153:     below for what they should say).</p>
                   6154: 
                   6155:     <p>Act as if an end tag token with the tag name "label" had been
                   6156:     seen.</p>
                   6157: 
                   6158:     <p>Act as if a start tag token with the tag name "hr" had been
                   6159:     seen.</p>
                   6160: 
                   6161:     <p>Act as if an end tag token with the tag name "form" had been
                   6162:     seen.</p>
                   6163: 
                   6164:     <p>If the token has an attribute with the name "prompt", then the
                   6165:     first stream of characters must be the same string as given in
                   6166:     that attribute, and the second stream of characters must be
                   6167:     empty. Otherwise, the two streams of character tokens together
                   6168:     should, together with the <code><a href="forms.html#the-input-element">input</a></code> element, express the
                   6169:     equivalent of "This is a searchable index. Insert your search
                   6170:     keywords here: (input field)" in the user's preferred
                   6171:     language.</p>
                   6172: 
                   6173:    </dd>
                   6174: 
                   6175:    <dt>A start tag whose tag name is "textarea"</dt>
                   6176:    <dd>
                   6177: 
                   6178:     <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
                   6179:      token.</p></li>
                   6180: 
                   6181:      <li><p>If the next token is a U+000A LINE FEED (LF) character
                   6182:      token, then ignore that token and move on to the next
                   6183:      one. (Newlines at the start of <code><a href="forms.html#the-textarea-element">textarea</a></code> elements are
                   6184:      ignored as an authoring convenience.)</p></li>
                   6185: 
1.671     mike     6186:      <li><p>Switch the tokenizer to the <a href="#rcdata-state">RCDATA
1.541     mike     6187:      state</a>.</p></li>
1.1       mike     6188: 
                   6189:      <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the
                   6190:      current <a href="#insertion-mode">insertion mode</a>.</p>
                   6191: 
                   6192:      </li><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not
                   6193:      ok".</p></li>
                   6194: 
1.540     mike     6195:      <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     6196: 
                   6197:     </ol></dd>
                   6198: 
                   6199:    <dt>A start tag whose tag name is "xmp"</dt>
                   6200:    <dd>
                   6201: 
1.233     mike     6202:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   6203:     an element in scope">has a <code>p</code> element in
                   6204:     scope</a>, then act as if an end tag with the tag name
                   6205:     "p" had been seen.</p>
                   6206: 
1.1       mike     6207:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6208:     any.</p>
                   6209: 
                   6210:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6211: 
1.91      mike     6212:     <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1       mike     6213: 
                   6214:    </dd>
                   6215: 
                   6216:    <dt>A start tag whose tag name is "iframe"</dt>
                   6217:    <dd>
                   6218: 
                   6219:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6220: 
1.91      mike     6221:     <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1       mike     6222: 
                   6223:    </dd>
                   6224: 
                   6225:    <dt>A start tag whose tag name is "noembed"</dt>
                   6226:    <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
                   6227:    <dd>
                   6228: 
1.91      mike     6229:     <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1       mike     6230: 
                   6231:    </dd>
                   6232: 
                   6233:    <dt>A start tag whose tag name is "select"</dt>
                   6234:    <dd>
                   6235: 
                   6236:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6237:     any.</p>
                   6238: 
                   6239:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6240: 
                   6241:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6242: 
                   6243:     <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>",
                   6244:     "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   6245:     body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in
                   6246:     row</a>", or "<a href="#parsing-main-intd" title="insertion mode: in cell">in
                   6247:     cell</a>", then switch the <a href="#insertion-mode">insertion mode</a> to
                   6248:     "<a href="#parsing-main-inselectintable" title="insertion mode: in select in table">in select in
                   6249:     table</a>". Otherwise, switch the <a href="#insertion-mode">insertion mode</a>
                   6250:     to "<a href="#parsing-main-inselect" title="insertion mode: in select">in select</a>".</p>
                   6251: 
                   6252:    </dd>
                   6253: 
                   6254:    <dt>A start tag whose tag name is one of: "optgroup", "option"</dt>
                   6255:    <dd>
                   6256: 
                   6257:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
                   6258:     element in scope">has an <code>option</code> element in
                   6259:     scope</a>, then act as if an end tag with the tag name "option"
                   6260:     had been seen.</p>
                   6261: 
                   6262:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6263:     any.</p>
                   6264: 
                   6265:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6266: 
                   6267:    </dd>
                   6268: 
                   6269:    <dt>A start tag whose tag name is one of: "rp", "rt"</dt>
                   6270:    <dd>
                   6271: 
                   6272:     <!-- the parsing rules for ruby really don't match IE much at all,
                   6273:          but in practice the markup used is very simple and so strict
                   6274:          compatibility with IE isn't required. For example, as defined
                   6275:          here we get very, very different behaviour than IE for
                   6276:          pathological cases like:
                   6277: 
                   6278:            <ruby><ol><li><p>a<rt>b
                   6279:            <ruby>a<rt>b<p>c
                   6280: 
                   6281:          But in practice most ruby markup falls into these cases:
                   6282: 
                   6283:            <ruby>a<rt>b</ruby>
                   6284:            <ruby>a<rp>b<rt>c<rp>d</ruby>
                   6285:            <ruby>a<rt>b</rt></ruby>
                   6286:            <ruby>a<rp>b</rp><rt>c</rt><rp>d</rp></ruby>
                   6287: 
                   6288:     -->
                   6289: 
                   6290:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
                   6291:     element in scope">has a <code>ruby</code> element in scope</a>,
                   6292:     then <a href="#generate-implied-end-tags">generate implied end tags</a>. If the <a href="#current-node">current
                   6293:     node</a> is not then a <code><a href="text-level-semantics.html#the-ruby-element">ruby</a></code> element, this is a
                   6294:     <a href="#parse-error">parse error</a>; pop all the nodes from the <a href="#current-node">current
                   6295:     node</a> up to the node immediately before the bottommost
                   6296:     <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
                   6297:     elements</a>.</p>
                   6298: 
                   6299:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6300: 
                   6301:    </dd>
                   6302: 
                   6303:    <dt>An end tag whose tag name is "br"</dt>
                   6304:    <dd>
                   6305:     <p><a href="#parse-error">Parse error</a>. Act as if a start tag token with
                   6306:     the tag name "br" had been seen. Ignore the end tag token.</p>
                   6307:    </dd>
                   6308: 
                   6309:    <dt>A start tag whose tag name is "math"</dt>
                   6310:    <dd>
                   6311: 
                   6312:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6313:     any.</p>
                   6314: 
                   6315:     <p><a href="#adjust-mathml-attributes">Adjust MathML attributes</a> for the token. (This
                   6316:     fixes the case of MathML attributes that are not all
                   6317:     lowercase.)</p>
                   6318: 
                   6319:     <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
                   6320:     fixes the use of namespaced attributes, in particular XLink.)</p>
                   6321: 
                   6322:     <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
1.724     mike     6323:     <a href="infrastructure.html#mathml-namespace">MathML namespace</a>.</p>
1.1       mike     6324: 
                   6325:     <!-- If we ever change the frameset-ok flag to an insertion mode,
                   6326:     the following change would be implied, except we'd have to do it
                   6327:     even in the face of a self-closed tag:
                   6328:     <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
                   6329:     -->
                   6330: 
                   6331:     <p>If the token has its <i>self-closing flag</i> set, pop the
                   6332:     <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6333:     elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
                   6334:     flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
                   6335: 
                   6336:     <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
                   6337:     "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
                   6338:     content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
                   6339:     the current <a href="#insertion-mode">insertion mode</a>, and then switch the
                   6340:     <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
                   6341:     foreign content">in foreign content</a>".</p>
                   6342: 
                   6343:    </dd>
                   6344: 
                   6345:    <dt>A start tag whose tag name is "svg"</dt>
                   6346:    <dd>
                   6347: 
                   6348:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6349:     any.</p>
                   6350: 
                   6351:     <p><a href="#adjust-svg-attributes">Adjust SVG attributes</a> for the token. (This fixes
                   6352:     the case of SVG attributes that are not all lowercase.)</p>
                   6353: 
                   6354:     <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
                   6355:     fixes the use of namespaced attributes, in particular XLink in
                   6356:     SVG.)</p>
                   6357: 
                   6358:     <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
1.724     mike     6359:     <a href="infrastructure.html#svg-namespace">SVG namespace</a>.</p>
1.1       mike     6360: 
                   6361:     <!-- If we ever change the frameset-ok flag to an insertion mode,
                   6362:     the following change would be implied, except we'd have to do it
                   6363:     even in the face of a self-closed tag:
                   6364:     <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
                   6365:     -->
                   6366: 
                   6367:     <p>If the token has its <i>self-closing flag</i> set, pop the
                   6368:     <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6369:     elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
                   6370:     flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
                   6371: 
                   6372:     <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
                   6373:     "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
                   6374:     content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
                   6375:     the current <a href="#insertion-mode">insertion mode</a>, and then switch the
                   6376:     <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
                   6377:     foreign content">in foreign content</a>".</p>
                   6378: 
                   6379:    </dd>
                   6380: 
                   6381:    <dt>A start <!--or end--> tag whose tag name is one of: "caption",
                   6382:    "col", "colgroup", "frame", "head", "tbody", "td", "tfoot", "th",
                   6383:    "thead", "tr"</dt>
                   6384:    <!--<dt>An end tag whose tag name is one of: "area", "base",
                   6385:    "basefont", "bgsound", "command", "embed", "hr", "iframe", "image",
                   6386:    "img", "input", "isindex", "keygen", "link", "meta", "noembed",
1.589     mike     6387:    "noframes", "param", "script", "select", "source", "style",
                   6388:    "table", "textarea", "title", "wbr"</dt>-->
1.1       mike     6389:    <!--<dt>An end tag whose tag name is "noscript", if the
                   6390:    <span>scripting flag</span> is enabled</dt>-->
                   6391:    <dd>
                   6392:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6393:     <!-- end tags are commented out because since they can never end
                   6394:     up on the stack anyway, the default end tag clause will
                   6395:     automatically handle them. we don't want to have text in the spec
                   6396:     that is just an optimisation, as that detracts from the spec
                   6397:     itself -->
                   6398:    </dd>
                   6399: 
                   6400:    <dt>Any other start tag</dt>
                   6401:    <dd>
                   6402: 
                   6403:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6404:     any.</p>
                   6405: 
                   6406:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6407: 
                   6408:     <p class="note">This element will be a <a href="#phrasing">phrasing</a>
                   6409:     element.</p>
                   6410: 
                   6411:    </dd>
                   6412: 
                   6413:    <dt>Any other end tag</dt>
                   6414:    <dd>
                   6415: 
                   6416:     <p>Run the following steps:</p>
                   6417: 
                   6418:     <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
                   6419:      node</a> (the bottommost node of the stack).</p></li>
                   6420: 
                   6421:      <li><p>If <var title="">node</var> has the same tag name as
                   6422:      the end tag token, then:</p>
                   6423: 
                   6424:       <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   6425: 
                   6426:        <li><p>If the tag name of the end tag token does not match
                   6427:        the tag name of the <a href="#current-node">current node</a>, this is a
                   6428:        <a href="#parse-error">parse error</a>.</p></li>
                   6429: 
                   6430:        <li><p>Pop all the nodes from the <a href="#current-node">current node</a> up
                   6431:        to <var title="">node</var>, including <var title="">node</var>, then stop these steps.</p></li>
                   6432: 
                   6433:       </ol></li>
                   6434: 
                   6435:      <li><p>Otherwise, if <var title="">node</var> is in neither the
                   6436:      <a href="#formatting">formatting</a> category nor the <a href="#phrasing">phrasing</a>
                   6437:      category, then this is a <a href="#parse-error">parse error</a>; ignore the
                   6438:      token, and abort these steps.</p></li>
                   6439: 
                   6440:      <li><p>Set <var title="">node</var> to the previous entry in the
                   6441:      <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
                   6442: 
                   6443:      <li><p>Return to step 2.</p></li>
                   6444: 
                   6445:     </ol></dd>
                   6446: 
1.755     mike     6447:   </dl><h5 id="parsing-main-incdata"><span class="secno">8.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     6448: 
                   6449:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incdata" title="insertion
1.540     mike     6450:   mode: text">text</a>", tokens must be handled as follows:</p>
1.1       mike     6451: 
                   6452:   <dl class="switch"><dt>A character token</dt>
                   6453:    <dd>
                   6454: 
                   6455:     <p><a href="#insert-a-character" title="insert a character">Insert the token's
                   6456:     character</a> into the <a href="#current-node">current node</a>.</p>
                   6457: 
                   6458:    </dd>
                   6459: 
                   6460:    <dt>An end-of-file token</dt>
                   6461:    <dd>
                   6462: 
                   6463:     <!-- can't be the fragment case -->
                   6464:     <p><a href="#parse-error">Parse error</a>.</p>
                   6465: 
                   6466:     <p>If the <a href="#current-node">current node</a> is a <code><a href="semantics.html#script">script</a></code>
1.484     mike     6467:     element, mark the <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
                   6468:     started"</a>.</p>
1.1       mike     6469: 
                   6470:     <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6471:     elements</a>.</p>
                   6472: 
                   6473:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
                   6474:     insertion mode</a> and reprocess the current token.</p>
                   6475: 
                   6476:    </dd>
                   6477: 
                   6478:    <dt>An end tag whose tag name is "script"</dt>
                   6479:    <dd>
                   6480: 
                   6481:     <p>Let <var title="">script</var> be the <a href="#current-node">current node</a>
                   6482:     (which will be a <code><a href="semantics.html#script">script</a></code> element).</p>
                   6483: 
                   6484:     <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6485:     elements</a>.</p>
                   6486: 
                   6487:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
                   6488:     insertion mode</a>.</p>
                   6489: 
                   6490:     <p>Let the <var title="">old insertion point</var> have the
                   6491:     same value as the current <a href="#insertion-point">insertion point</a>. Let
                   6492:     the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
                   6493:     input character</a>.</p>
                   6494: 
                   6495:     <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
                   6496:     one.</p>
                   6497: 
                   6498:     <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     6499:     which might cause <a href="embedded-content-0.html#dom-document-write" title="dom-document-write">new characters
1.1       mike     6500:     to be inserted into the tokenizer</a>, and might cause the
                   6501:     tokenizer to output more tokens, resulting in a <a href="#nestedParsing">reentrant invocation of the parser</a>.</p>
                   6502: 
                   6503:     <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
                   6504:     one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
                   6505:     then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
                   6506: 
                   6507:     <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
                   6508:     <a href="#insertion-point">insertion point</a> to its previous value. This value
                   6509:     might be the "undefined" value.)</p>
                   6510: 
                   6511:     <p id="scriptTagParserResumes">At this stage, if there is a
1.484     mike     6512:     <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking script</a>, then:</p>
1.1       mike     6513: 
                   6514:     <dl class="switch"><dt>If the <a href="#script-nesting-level">script nesting level</a> is not zero:</dt>
                   6515: 
                   6516:      <dd>
                   6517: 
                   6518:       <p>Set the <a href="#parser-pause-flag">parser pause flag</a> to true, and abort the
                   6519:       processing of any nested invocations of the tokenizer, yielding
                   6520:       control back to the caller. (Tokenization will resume when the
                   6521:       caller returns to the "outer" tree construction stage.)</p>
                   6522: 
                   6523:       <p class="note">The tree construction stage of this particular
                   6524:       parser is <a href="#nestedParsing">being called reentrantly</a>,
1.159     mike     6525:       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     6526: 
                   6527:      </dd>
                   6528: 
                   6529: 
                   6530:      <dt>Otherwise:</dt>
                   6531: 
                   6532:      <dd>
                   6533: 
                   6534:       <p>Follow these steps:</p>
                   6535: 
1.484     mike     6536:       <ol><li><p>Let <var title="">the script</var> be the <a href="semantics.html#pending-parsing-blocking-script">pending
                   6537:        parsing-blocking script</a>. There is no longer a <a href="semantics.html#pending-parsing-blocking-script">pending
                   6538:        parsing-blocking script</a>.</p></li>
                   6539: 
                   6540:        <li><p>Block the <a href="#tokenization" title="tokenization">tokenizer</a>
                   6541:        for this instance of the <a href="#html-parser">HTML parser</a>, such that
1.755     mike     6542:        the <a href="web-application-apis.html#event-loop">event loop</a> will not run <a href="web-application-apis.html#concept-task" title="concept-task">tasks</a> that invoke the <a href="#tokenization" title="tokenization">tokenizer</a>.</p></li>
1.484     mike     6543: 
1.755     mike     6544:        <li><p><a href="web-application-apis.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
1.484     mike     6545:        scripts</a> and <var title="">the script</var>'s
                   6546:        <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag is set.</p></li>
                   6547: 
                   6548:        <li><p>Unblock the <a href="#tokenization" title="tokenization">tokenizer</a>
                   6549:        for this instance of the <a href="#html-parser">HTML parser</a>, such that
1.755     mike     6550:        <a href="web-application-apis.html#concept-task" title="concept-task">tasks</a> that invoke the <a href="#tokenization" title="tokenization">tokenizer</a> can again be
1.484     mike     6551:        run.</p></li>
1.1       mike     6552: 
                   6553:        <li><p>Let the <a href="#insertion-point">insertion point</a> be just before the
                   6554:        <a href="#next-input-character">next input character</a>.</p></li>
                   6555: 
                   6556:        <li><p>Increment the parser's <a href="#script-nesting-level">script nesting level</a>
                   6557:        by one (it should be zero before this step, so this sets it to
                   6558:        one).</p></li>
                   6559: 
1.484     mike     6560:        <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a>
                   6561:        <var title="">the script</var>.</p></li>
1.1       mike     6562: 
                   6563:        <li><p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a>
                   6564:        by one. If the parser's <a href="#script-nesting-level">script nesting level</a> is
                   6565:        zero (which it always should be at this point), then set the
                   6566:        <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
                   6567: 
                   6568:        </li><li><p>Let the <a href="#insertion-point">insertion point</a> be undefined
                   6569:        again.</p></li>
                   6570: 
1.484     mike     6571:        <li><p>If there is once again a <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking
1.1       mike     6572:        script</a>, then repeat these steps from step 1.</p></li>
                   6573: 
                   6574:       </ol></dd>
                   6575: 
                   6576:     </dl></dd>
                   6577: 
                   6578:    <dt>Any other end tag</dt>
                   6579:    <dd>
                   6580: 
                   6581:     <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6582:     elements</a>.</p>
                   6583: 
                   6584:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
                   6585:     insertion mode</a>.</p>
                   6586: 
                   6587:    </dd>
                   6588: 
1.755     mike     6589:   </dl><h5 id="parsing-main-intable"><span class="secno">8.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     6590: 
                   6591:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion
                   6592:   mode: in table">in table</a>", tokens must be handled as follows:</p>
                   6593: 
                   6594:   <dl class="switch"><dt>A character token</dt>
                   6595:    <dd>
                   6596: 
                   6597:      <p>Let the <dfn id="pending-table-character-tokens"><var>pending table character tokens</var></dfn>
                   6598:      be an empty list of tokens.</p>
                   6599: 
                   6600:      <p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
                   6601:      <a href="#insertion-mode">insertion mode</a>.</p>
                   6602: 
                   6603:      <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
                   6604:      reprocess the token.</p>
                   6605: 
                   6606:    </dd>
                   6607: 
                   6608:    <dt>A comment token</dt>
                   6609:    <dd>
                   6610:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   6611:     node</a> with the <code title="">data</code> attribute set to
                   6612:     the data given in the comment token.</p>
                   6613:    </dd>
                   6614: 
                   6615:    <dt>A DOCTYPE token</dt>
                   6616:    <dd>
                   6617:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6618:    </dd>
                   6619: 
                   6620:    <dt>A start tag whose tag name is "caption"</dt>
                   6621:    <dd>
                   6622: 
                   6623:     <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
                   6624:     below.)</p>
                   6625: 
                   6626:     <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
                   6627:     formatting elements</a>.</p>
                   6628: 
                   6629:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
                   6630:     switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incaption" title="insertion mode: in caption">in caption</a>".</p>
                   6631: 
                   6632:    </dd>
                   6633: 
                   6634:    <dt>A start tag whose tag name is "colgroup"</dt>
                   6635:    <dd>
                   6636: 
                   6637:     <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
                   6638:     below.)</p>
                   6639: 
                   6640:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
                   6641:     switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incolgroup" title="insertion mode: in column group">in column
                   6642:     group</a>".</p>
                   6643: 
                   6644:    </dd>
                   6645: 
                   6646:    <dt>A start tag whose tag name is "col"</dt>
                   6647:    <dd>
                   6648:     <p>Act as if a start tag token with the tag name "colgroup"
                   6649:     had been seen, then reprocess the current token.</p>
                   6650:    </dd>
                   6651: 
                   6652:    <dt>A start tag whose tag name is one of: "tbody", "tfoot", "thead"</dt>
                   6653:    <dd>
                   6654: 
                   6655:     <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
                   6656:     below.)</p>
                   6657: 
                   6658:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
                   6659:     switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   6660:     body</a>".</p>
                   6661: 
                   6662:    </dd>
                   6663: 
                   6664:    <dt>A start tag whose tag name is one of: "td", "th", "tr"</dt>
                   6665:    <dd>
                   6666:     <p>Act as if a start tag token with the tag name "tbody" had
                   6667:     been seen, then reprocess the current token.</p>
                   6668:    </dd>
                   6669: 
                   6670:    <dt>A start tag whose tag name is "table"</dt>
                   6671:    <dd>
                   6672: 
                   6673:     <p><a href="#parse-error">Parse error</a>. Act as if an end tag token with
                   6674:     the tag name "table" had been seen, then, if that token wasn't
                   6675:     ignored, reprocess the current token.</p>
                   6676: 
                   6677:     <p class="note">The fake end tag token here can only be
                   6678:     ignored in the <a href="#fragment-case">fragment case</a>.</p>
                   6679: 
                   6680:    </dd>
                   6681: 
                   6682:    <dt>An end tag whose tag name is "table"</dt>
                   6683:    <dd>
                   6684: 
                   6685:     <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
                   6686:     scope</a> with the same tag name as the token, this is a
                   6687:     <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   6688:     case</a>)</p>
                   6689: 
                   6690:     <p>Otherwise:</p>
                   6691: 
                   6692:     <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-table-element">table</a></code>
                   6693:     element has been popped from the stack.</p>
                   6694: 
                   6695:     <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
                   6696: 
                   6697:    </dd>
                   6698: 
                   6699:    <dt>An end tag whose tag name is one of: "body", "caption",
                   6700:    "col", "colgroup", "html", "tbody", "td", "tfoot", "th",
                   6701:    "thead", "tr"</dt>
                   6702:    <dd>
                   6703:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6704:    </dd>
                   6705: 
                   6706:    <dt>A start tag whose tag name is one of: "style", "script"</dt>
                   6707:    <dd>
                   6708: 
                   6709:     <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
                   6710:     mode</a>.</p>
                   6711: 
                   6712:    </dd>
                   6713: 
                   6714:    <dt>A start tag whose tag name is "input"</dt>
                   6715:    <dd>
                   6716: 
                   6717:     <p>If the token does not have an attribute with the name "type",
                   6718:     or if it does, but that attribute's value is not an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   6719:     case-insensitive</a> match for the string "<code title="">hidden</code>", then: act as described in the "anything
                   6720:     else" entry below.</p>
                   6721: 
                   6722:     <p>Otherwise:</p>
                   6723: 
                   6724:     <p><a href="#parse-error">Parse error</a>.</p>
                   6725: 
                   6726:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6727: 
                   6728:     <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
                   6729:     open elements</a>.</p>
                   6730: 
                   6731:    </dd>
                   6732: 
1.603     mike     6733:    <dt>A start tag whose tag name is "form"</dt>
                   6734:    <dd>
                   6735: 
                   6736:     <p><a href="#parse-error">Parse error</a>.</p>
                   6737: 
1.717     mike     6738:     <p>If the <a href="#form-element-pointer"><code title="form">form</code> element
                   6739:     pointer</a> is not null, ignore the token.</p>
                   6740: 
                   6741:     <p>Otherwise:</p>
                   6742: 
1.603     mike     6743:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6744: 
1.637     mike     6745:     <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     6746:     open elements</a>.</p>
                   6747: 
                   6748:    </dd>
                   6749: 
1.721     mike     6750:    <!-- "form" end tag falls through to in-body, which does the right thing -->
1.717     mike     6751: 
1.1       mike     6752:    <dt>An end-of-file token</dt>
                   6753:    <dd>
                   6754: 
                   6755:     <p>If the <a href="#current-node">current node</a> is not the root
1.159     mike     6756:     <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     6757:     error</a>.</p>
                   6758: 
                   6759:     <p class="note">It can only be the <a href="#current-node">current node</a> in
                   6760:     the <a href="#fragment-case">fragment case</a>.</p>
                   6761: 
                   6762:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   6763: 
                   6764:    </dd>
                   6765: 
                   6766:    <dt>Anything else</dt>
                   6767:    <dd>
                   6768: 
                   6769:     <p><a href="#parse-error">Parse error</a>. Process the token <a href="#using-the-rules-for">using the
                   6770:     rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
                   6771:     body</a>" <a href="#insertion-mode">insertion mode</a>, except that if the
                   6772:     <a href="#current-node">current node</a> is a <code><a href="tabular-data.html#the-table-element">table</a></code>,
                   6773:     <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
                   6774:     <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then, whenever a node would be inserted
                   6775:     into the <a href="#current-node">current node</a>, it must instead be <a href="#foster-parent" title="foster parent">foster parented</a>.</p>
                   6776: 
                   6777:    </dd>
                   6778: 
                   6779:   </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-context">clear the stack
                   6780:   back to a table context</dfn>, it means that the UA must, while
                   6781:   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     6782:   element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1       mike     6783:   <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   6784: 
                   6785:   <p class="note">The <a href="#current-node">current node</a> being an
1.159     mike     6786:   <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     6787:   case</a>.</p>
                   6788: 
                   6789: 
                   6790: 
1.755     mike     6791:   <h5 id="parsing-main-intabletext"><span class="secno">8.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     6792: 
                   6793:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intabletext" title="insertion
                   6794:   mode: in table text">in table text</a>", tokens must be handled
                   6795:   as follows:</p>
                   6796: 
                   6797:   <dl class="switch"><dt>A character token</dt>
                   6798:    <dd>
                   6799: 
                   6800:     <p>Append the character token to the <var><a href="#pending-table-character-tokens">pending table character
                   6801:     tokens</a></var> list.</p>
                   6802: 
                   6803:    </dd>
                   6804: 
                   6805: 
                   6806:    <dt>Anything else</dt>
                   6807:    <dd>
                   6808: 
                   6809:     <p>If any of the tokens in the <var><a href="#pending-table-character-tokens">pending table character
                   6810:     tokens</a></var> list are character tokens that are not one of U+0009
                   6811:     CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED
                   6812:     (FF), <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE, then
                   6813:     reprocess those character tokens using the rules given in the
                   6814:     "anything else" entry in the <a href="#parsing-main-intable" title="insertion mode: in
                   6815:     table">in table</a>" insertion mode.</p>
                   6816: 
                   6817:     <p>Otherwise, <a href="#insert-a-character" title="insert a character">insert the
                   6818:     characters</a> given by the <var><a href="#pending-table-character-tokens">pending table character
                   6819:     tokens</a></var> list into the <a href="#current-node">current node</a>.</p>
                   6820: 
                   6821:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
                   6822:     insertion mode</a> and reprocess the token.</p>
                   6823: 
                   6824:    </dd>
                   6825: 
1.755     mike     6826:   </dl><h5 id="parsing-main-incaption"><span class="secno">8.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     6827: 
                   6828:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incaption" title="insertion
                   6829:   mode: in caption">in caption</a>", tokens must be handled as follows:</p>
                   6830: 
                   6831:   <dl class="switch"><dt>An end tag whose tag name is "caption"</dt>
                   6832:    <dd>
                   6833: 
                   6834:     <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
                   6835:     scope</a> with the same tag name as the token, this is a
                   6836:     <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   6837:     case</a>)</p>
                   6838: 
                   6839:     <p>Otherwise:</p>
                   6840: 
                   6841:     <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
                   6842: 
                   6843:     <p>Now, if the <a href="#current-node">current node</a> is not a
                   6844:     <code><a href="tabular-data.html#the-caption-element">caption</a></code> element, then this is a <a href="#parse-error">parse
                   6845:     error</a>.</p>
                   6846: 
                   6847:     <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-caption-element">caption</a></code>
                   6848:     element has been popped from the stack.</p>
                   6849: 
                   6850:     <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
                   6851:     the last marker</a>.</p>
                   6852: 
                   6853:     <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>
                   6854: 
                   6855:    </dd>
                   6856: 
                   6857:    <dt>A start tag whose tag name is one of: "caption", "col",
                   6858:    "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
                   6859:    <dt>An end tag whose tag name is "table"</dt>
                   6860:    <dd>
                   6861: 
                   6862:     <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
                   6863:     name "caption" had been seen, then, if that token wasn't
                   6864:     ignored, reprocess the current token.</p>
                   6865: 
                   6866:     <p class="note">The fake end tag token here can only be
                   6867:     ignored in the <a href="#fragment-case">fragment case</a>.</p>
                   6868: 
                   6869:    </dd>
                   6870: 
                   6871:    <dt>An end tag whose tag name is one of: "body", "col",
                   6872:    "colgroup", "html", "tbody", "td", "tfoot", "th", "thead",
                   6873:    "tr"</dt>
                   6874:    <dd>
                   6875:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6876:    </dd>
                   6877: 
                   6878:    <dt>Anything else</dt>
                   6879:    <dd>
                   6880:     <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
                   6881:     mode</a>.</p>
                   6882:    </dd>
                   6883: 
1.755     mike     6884:   </dl><h5 id="parsing-main-incolgroup"><span class="secno">8.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     6885: 
                   6886:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incolgroup" title="insertion
                   6887:   mode: in column group">in column group</a>", tokens must be handled as follows:</p>
                   6888: 
                   6889:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   6890:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   6891:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   6892:    <dd>
                   6893:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   6894:     the <a href="#current-node">current node</a>.</p>
                   6895:    </dd>
                   6896: 
                   6897:    <dt>A comment token</dt>
                   6898:    <dd>
                   6899:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   6900:     node</a> with the <code title="">data</code> attribute set to
                   6901:     the data given in the comment token.</p>
                   6902:    </dd>
                   6903: 
                   6904:    <dt>A DOCTYPE token</dt>
                   6905:    <dd>
                   6906:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6907:    </dd>
                   6908: 
                   6909:    <dt>A start tag whose tag name is "html"</dt>
                   6910:    <dd>
                   6911:     <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
                   6912:     mode</a>.</p>
                   6913:    </dd>
                   6914: 
                   6915:    <dt>A start tag whose tag name is "col"</dt>
                   6916:    <dd>
                   6917: 
                   6918:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   6919:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6920:     elements</a>.</p>
                   6921: 
                   6922:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   6923:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   6924: 
                   6925:    </dd>
                   6926: 
                   6927:    <dt>An end tag whose tag name is "colgroup"</dt>
                   6928:    <dd>
                   6929: 
                   6930:     <p>If the <a href="#current-node">current node</a> is the root
1.159     mike     6931:     <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     6932:     error</a>; ignore the token. (<a href="#fragment-case">fragment
                   6933:     case</a>)</p>
                   6934: 
                   6935:     <p>Otherwise, pop the <a href="#current-node">current node</a> (which will be
                   6936:     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
                   6937:     elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
                   6938:     "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
                   6939: 
                   6940:    </dd>
                   6941: 
                   6942:    <dt>An end tag whose tag name is "col"</dt>
                   6943:    <dd>
                   6944:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6945:    </dd>
                   6946: 
                   6947:    <dt>An end-of-file token</dt>
                   6948:    <dd>
                   6949: 
1.159     mike     6950:     <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     6951:     element, then <a href="#stop-parsing">stop parsing</a>. (<a href="#fragment-case">fragment
                   6952:     case</a>)</p>
                   6953: 
                   6954:     <p>Otherwise, act as described in the "anything else" entry
                   6955:     below.</p>
                   6956: 
                   6957:    </dd>
                   6958: 
                   6959:    <dt>Anything else</dt>
                   6960:    <dd>
                   6961: 
                   6962:     <p>Act as if an end tag with the tag name "colgroup" had been
                   6963:     seen, and then, if that token wasn't ignored, reprocess the
                   6964:     current token.</p>
                   6965: 
                   6966:     <p class="note">The fake end tag token here can only be
                   6967:     ignored in the <a href="#fragment-case">fragment case</a>.</p>
                   6968: 
                   6969:    </dd>
                   6970: 
1.755     mike     6971:   </dl><h5 id="parsing-main-intbody"><span class="secno">8.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     6972: 
                   6973:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion
                   6974:   mode: in table body">in table body</a>", tokens must be handled as follows:</p>
                   6975: 
                   6976:   <dl class="switch"><dt>A start tag whose tag name is "tr"</dt>
                   6977:    <dd>
                   6978: 
                   6979:     <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
                   6980:     context</a>. (See below.)</p>
                   6981: 
                   6982:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
                   6983:     the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion mode:
                   6984:     in row">in row</a>".</p>
                   6985: 
                   6986:    </dd>
                   6987: 
                   6988:    <dt>A start tag whose tag name is one of: "th", "td"</dt>
                   6989:    <dd>
                   6990:     <p><a href="#parse-error">Parse error</a>. Act as if a start tag with
                   6991:     the tag name "tr" had been seen, then reprocess the current
                   6992:     token.</p>
                   6993:    </dd>
                   6994: 
                   6995:    <dt>An end tag whose tag name is one of: "tbody", "tfoot",
                   6996:    "thead"</dt>
                   6997:    <dd>
                   6998: 
                   6999:     <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
                   7000:     scope</a> with the same tag name as the token, this is a
                   7001:     <a href="#parse-error">parse error</a>. Ignore the token.</p>
                   7002: 
                   7003:     <p>Otherwise:</p>
                   7004: 
                   7005:     <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
                   7006:     context</a>. (See below.)</p>
                   7007: 
                   7008:     <p>Pop the <a href="#current-node">current node</a> from the <a href="#stack-of-open-elements">stack of
                   7009:     open elements</a>. Switch the <a href="#insertion-mode">insertion mode</a>
                   7010:     to "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
                   7011: 
                   7012:    </dd>
                   7013: 
                   7014:    <dt>A start tag whose tag name is one of: "caption", "col",
                   7015:    "colgroup", "tbody", "tfoot", "thead"</dt>
                   7016:    <dt>An end tag whose tag name is "table"</dt>
                   7017:    <dd>
                   7018: 
                   7019:     <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
                   7020:     <code>tbody</code>, <code>thead</code>, or <code>tfoot</code>
                   7021:     element in table scope</a>, this is a <a href="#parse-error">parse
                   7022:     error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   7023:     case</a>)</p>
                   7024: 
                   7025:     <p>Otherwise:</p>
                   7026: 
                   7027:     <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
                   7028:     context</a>. (See below.)</p>
                   7029: 
                   7030:     <p>Act as if an end tag with the same tag name as the
                   7031:     <a href="#current-node">current node</a> ("tbody", "tfoot", or "thead") had
                   7032:     been seen, then reprocess the current token.</p>
                   7033: 
                   7034:    </dd>
                   7035: 
                   7036:    <dt>An end tag whose tag name is one of: "body", "caption",
                   7037:    "col", "colgroup", "html", "td", "th", "tr"</dt>
                   7038:    <dd>
                   7039:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7040:    </dd>
                   7041: 
                   7042:    <dt>Anything else</dt>
                   7043:    <dd>
                   7044:     <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
                   7045:     mode</a>.</p>
                   7046:    </dd>
                   7047: 
                   7048:   </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-body-context">clear the stack
                   7049:   back to a table body context</dfn>, it means that the UA must,
                   7050:   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     7051:   <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     7052:   element, pop elements from the <a href="#stack-of-open-elements">stack of open
                   7053:   elements</a>.</p>
                   7054: 
                   7055:   <p class="note">The <a href="#current-node">current node</a> being an
1.159     mike     7056:   <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     7057:   case</a>.</p>
                   7058: 
                   7059: 
1.755     mike     7060:   <h5 id="parsing-main-intr"><span class="secno">8.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     7061: 
                   7062:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
                   7063:   mode: in row">in row</a>", tokens must be handled as follows:</p>
                   7064: 
                   7065:   <dl class="switch"><dt>A start tag whose tag name is one of: "th", "td"</dt>
                   7066:    <dd>
                   7067: 
                   7068:     <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
                   7069:     context</a>. (See below.)</p>
                   7070: 
                   7071:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
                   7072:     the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion mode:
                   7073:     in cell">in cell</a>".</p>
                   7074: 
                   7075:     <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
                   7076:     formatting elements</a>.</p>
                   7077: 
                   7078:    </dd>
                   7079: 
                   7080:    <dt>An end tag whose tag name is "tr"</dt>
                   7081:    <dd>
                   7082: 
                   7083:     <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
                   7084:     scope</a> with the same tag name as the token, this is a
                   7085:     <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   7086:     case</a>)</p>
                   7087: 
                   7088:     <p>Otherwise:</p>
                   7089: 
                   7090:     <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
                   7091:     context</a>. (See below.)</p>
                   7092: 
                   7093:     <p>Pop the <a href="#current-node">current node</a> (which will be a
                   7094:     <code><a href="tabular-data.html#the-tr-element">tr</a></code> element) from the <a href="#stack-of-open-elements">stack of open
                   7095:     elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
                   7096:     "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   7097:     body</a>".</p>
                   7098: 
                   7099:    </dd>
                   7100: 
                   7101:    <dt>A start tag whose tag name is one of: "caption", "col",
                   7102:    "colgroup", "tbody", "tfoot", "thead", "tr"</dt>
                   7103:    <dt>An end tag whose tag name is "table"</dt>
                   7104:    <dd>
                   7105: 
                   7106:     <p>Act as if an end tag with the tag name "tr" had been seen,
                   7107:     then, if that token wasn't ignored, reprocess the current
                   7108:     token.</p>
                   7109: 
                   7110:     <p class="note">The fake end tag token here can only be
                   7111:     ignored in the <a href="#fragment-case">fragment case</a>.</p>
                   7112: 
                   7113:    </dd>
                   7114: 
                   7115:    <dt>An end tag whose tag name is one of: "tbody", "tfoot",
                   7116:    "thead"</dt>
                   7117:    <dd>
                   7118: 
                   7119:     <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
                   7120:     scope</a> with the same tag name as the token, this is a
                   7121:     <a href="#parse-error">parse error</a>. Ignore the token.</p>
                   7122: 
                   7123:     <p>Otherwise, act as if an end tag with the tag name "tr" had
                   7124:     been seen, then reprocess the current token.</p>
                   7125: 
                   7126:    </dd>
                   7127: 
                   7128:    <dt>An end tag whose tag name is one of: "body", "caption",
                   7129:    "col", "colgroup", "html", "td", "th"</dt>
                   7130:    <dd>
                   7131:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7132:    </dd>
                   7133: 
                   7134:    <dt>Anything else</dt>
                   7135:    <dd>
                   7136:     <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
                   7137:     mode</a>.</p>
                   7138:    </dd>
                   7139: 
                   7140:   </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-row-context">clear the stack
                   7141:   back to a table row context</dfn>, it means that the UA must,
                   7142:   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     7143:   element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1       mike     7144:   <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   7145: 
                   7146:   <p class="note">The <a href="#current-node">current node</a> being an
1.159     mike     7147:   <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     7148:   case</a>.</p>
                   7149: 
                   7150: 
1.755     mike     7151:   <h5 id="parsing-main-intd"><span class="secno">8.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     7152: 
                   7153:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intd" title="insertion
                   7154:   mode: in cell">in cell</a>", tokens must be handled as follows:</p>
                   7155: 
                   7156:   <dl class="switch"><dt>An end tag whose tag name is one of: "td", "th"</dt>
                   7157:    <dd>
                   7158: 
                   7159:     <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
                   7160:     scope</a> with the same tag name as that of the token, then
                   7161:     this is a <a href="#parse-error">parse error</a> and the token must be
                   7162:     ignored.</p>
                   7163: 
                   7164:     <p>Otherwise:</p>
                   7165: 
                   7166:     <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
                   7167: 
                   7168:     <p>Now, if the <a href="#current-node">current node</a> is not an element
                   7169:     with the same tag name as the token, then this is a
                   7170:     <a href="#parse-error">parse error</a>.</p>
                   7171: 
                   7172:     <p>Pop elements from this stack until an element with the same
                   7173:     tag name as the token has been popped from the stack.</p>
                   7174: 
                   7175:     <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
                   7176:     the last marker</a>.</p>
                   7177: 
                   7178:     <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
                   7179:     <a href="#current-node">current node</a> will be a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element at
                   7180:     this point.)</p>
                   7181: 
                   7182:    </dd>
                   7183: 
                   7184:    <dt>A start tag whose tag name is one of: "caption", "col",
                   7185:    "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
                   7186:    <dd>
                   7187: 
                   7188:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does
                   7189:     <em>not</em> <a href="#has-an-element-in-table-scope" title="has an element in table scope">have
                   7190:     a <code>td</code> or <code>th</code> element in table
                   7191:     scope</a>, then this is a <a href="#parse-error">parse error</a>; ignore
                   7192:     the token. (<a href="#fragment-case">fragment case</a>)</p>
                   7193: 
                   7194:     <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
                   7195:     reprocess the current token.</p>
                   7196: 
                   7197:    </dd>
                   7198: 
                   7199:    <dt>An end tag whose tag name is one of: "body", "caption",
                   7200:    "col", "colgroup", "html"</dt>
                   7201:    <dd>
                   7202:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7203:    </dd>
                   7204: 
                   7205:    <dt>An end tag whose tag name is one of: "table", "tbody",
                   7206:    "tfoot", "thead", "tr"</dt>
                   7207:    <dd>
                   7208: 
                   7209:     <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
                   7210:     scope</a> with the same tag name as that of the token
                   7211:     (which can only happen for "tbody", "tfoot" and "thead", or,
                   7212:     in the <a href="#fragment-case">fragment case</a>), then this is a <a href="#parse-error">parse
                   7213:     error</a> and the token must be ignored.</p>
                   7214: 
                   7215:     <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
                   7216:     reprocess the current token.</p>
                   7217: 
                   7218:    </dd>
                   7219: 
                   7220:    <dt>Anything else</dt>
                   7221:    <dd>
                   7222:     <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
                   7223:     mode</a>.</p>
                   7224:    </dd>
                   7225: 
                   7226:   </dl><p>Where the steps above say to <dfn id="close-the-cell">close the cell</dfn>, they
                   7227:   mean to run the following algorithm:</p>
                   7228: 
                   7229:   <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>
                   7230:    element in table scope</a>, then act as if an end tag token
                   7231:    with the tag name "td" had been seen.</p></li>
                   7232: 
                   7233:    <li><p>Otherwise, the <a href="#stack-of-open-elements">stack of open elements</a> will
                   7234:    <a href="#has-an-element-in-table-scope" title="has an element in table scope">have a
                   7235:    <code>th</code> element in table scope</a>; act as if an end
                   7236:    tag token with the tag name "th" had been seen.</p></li>
                   7237: 
                   7238:   </ol><p class="note">The <a href="#stack-of-open-elements">stack of open elements</a> cannot
                   7239:   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
                   7240:   the same time, nor can it have neither when the <a href="#insertion-mode">insertion
                   7241:   mode</a> is "<a href="#parsing-main-intd" title="insertion mode: in cell">in
                   7242:   cell</a>".</p>
                   7243: 
                   7244: 
1.755     mike     7245:   <h5 id="parsing-main-inselect"><span class="secno">8.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     7246: 
                   7247:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselect" title="insertion
                   7248:   mode: in select">in select</a>", tokens must be handled as follows:</p>
                   7249: 
                   7250:   <dl class="switch"><dt>A character token</dt>
                   7251:    <dd>
                   7252:     <p><a href="#insert-a-character" title="insert a character">Insert the token's
                   7253:     character</a> into the <a href="#current-node">current node</a>.</p>
                   7254:    </dd>
                   7255: 
                   7256:    <dt>A comment token</dt>
                   7257:    <dd>
                   7258:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   7259:     node</a> with the <code title="">data</code> attribute set to
                   7260:     the data given in the comment token.</p>
                   7261:    </dd>
                   7262: 
                   7263:    <dt>A DOCTYPE token</dt>
                   7264:    <dd>
                   7265:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7266:    </dd>
                   7267: 
                   7268:    <dt>A start tag whose tag name is "html"</dt>
                   7269:    <dd>
                   7270:     <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
                   7271:     mode</a>.</p>
                   7272:    </dd>
                   7273: 
                   7274:    <dt>A start tag whose tag name is "option"</dt>
                   7275:    <dd>
                   7276: 
                   7277:     <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
                   7278:     element, act as if an end tag with the tag name "option" had
                   7279:     been seen.</p>
                   7280: 
                   7281:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   7282: 
                   7283:    </dd>
                   7284: 
                   7285:    <dt>A start tag whose tag name is "optgroup"</dt>
                   7286:    <dd>
                   7287: 
                   7288:     <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
                   7289:     element, act as if an end tag with the tag name "option" had
                   7290:     been seen.</p>
                   7291: 
                   7292:     <p>If the <a href="#current-node">current node</a> is an
                   7293:     <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, act as if an end tag with the
                   7294:     tag name "optgroup" had been seen.</p>
                   7295: 
                   7296:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   7297: 
                   7298:    </dd>
                   7299: 
                   7300:    <dt>An end tag whose tag name is "optgroup"</dt>
                   7301:    <dd>
                   7302: 
                   7303:     <p>First, if the <a href="#current-node">current node</a> is an
                   7304:     <code><a href="forms.html#the-option-element">option</a></code> element, and the node immediately before
                   7305:     it in the <a href="#stack-of-open-elements">stack of open elements</a> is an
                   7306:     <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then act as if an end tag with
                   7307:     the tag name "option" had been seen.</p>
                   7308: 
                   7309:     <p>If the <a href="#current-node">current node</a> is an
                   7310:     <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then pop that node from the
                   7311:     <a href="#stack-of-open-elements">stack of open elements</a>. Otherwise, this is a
                   7312:     <a href="#parse-error">parse error</a>; ignore the token.</p>
                   7313: 
                   7314:    </dd>
                   7315: 
                   7316:    <dt>An end tag whose tag name is "option"</dt>
                   7317:    <dd>
                   7318: 
                   7319:     <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
                   7320:     element, then pop that node from the <a href="#stack-of-open-elements">stack of open
                   7321:     elements</a>. Otherwise, this is a <a href="#parse-error">parse
                   7322:     error</a>; ignore the token.</p>
                   7323: 
                   7324:    </dd>
                   7325: 
                   7326:    <dt>An end tag whose tag name is "select"</dt>
                   7327:    <dd>
                   7328: 
                   7329:     <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
                   7330:     scope</a> with the same tag name as the token, this is a
                   7331:     <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   7332:     case</a>)</p>
                   7333: 
                   7334:     <p>Otherwise:</p>
                   7335: 
                   7336:     <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   7337:     until a <code><a href="forms.html#the-select-element">select</a></code> element has been popped from the
                   7338:     stack.</p>
                   7339: 
                   7340:     <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
                   7341: 
                   7342:    </dd>
                   7343: 
                   7344:    <dt>A start tag whose tag name is "select"</dt>
                   7345:    <dd>
                   7346: 
                   7347:     <p><a href="#parse-error">Parse error</a>. Act as if the token had been
                   7348:     an end tag with the tag name "select" instead.</p>
                   7349: 
                   7350:    </dd>
                   7351: 
                   7352:    <dt>A start tag whose tag name is one of: "input", "keygen", "textarea"</dt>
                   7353:    <dd>
1.73      mike     7354: 
                   7355:     <p><a href="#parse-error">Parse error</a>.</p>
                   7356: 
1.124     mike     7357:     <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>
                   7358:     element in table scope</a>, ignore the token. (<a href="#fragment-case">fragment
                   7359:     case</a>)</p>
1.73      mike     7360: 
                   7361:     <p>Otherwise, act as if an end tag with the tag name "select" had
                   7362:     been seen, and reprocess the token.</p>
                   7363: 
1.1       mike     7364:    </dd>
                   7365: 
                   7366:    <dt>A start tag token whose tag name is "script"</dt>
                   7367:    <dd>
                   7368:     <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
                   7369:     mode</a>.</p>
                   7370:    </dd>
                   7371: 
                   7372:    <dt>An end-of-file token</dt>
                   7373:    <dd>
                   7374: 
                   7375:     <p>If the <a href="#current-node">current node</a> is not the root
1.159     mike     7376:     <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     7377:     error</a>.</p>
                   7378: 
                   7379:     <p class="note">It can only be the <a href="#current-node">current node</a> in
                   7380:     the <a href="#fragment-case">fragment case</a>.</p>
                   7381: 
                   7382:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7383: 
                   7384:    </dd>
                   7385: 
                   7386:    <dt>Anything else</dt>
                   7387:    <dd>
                   7388:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7389:    </dd>
                   7390: 
1.755     mike     7391:   </dl><h5 id="parsing-main-inselectintable"><span class="secno">8.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     7392: 
                   7393:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselectintable" title="insertion
                   7394:   mode: in select in table">in select in table</a>", tokens must be handled as follows:</p>
                   7395: 
                   7396:   <dl class="switch"><dt>A start tag whose tag name is one of: "caption", "table",
                   7397:    "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
                   7398:    <dd>
                   7399:     <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
                   7400:     name "select" had been seen, and reprocess the token.</p>
                   7401:    </dd>
                   7402: 
                   7403:    <dt>An end tag whose tag name is one of: "caption", "table",
                   7404:    "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
                   7405:    <dd>
                   7406: 
                   7407:     <p><a href="#parse-error">Parse error</a>.</p>
                   7408: 
                   7409:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-table-scope">has an
                   7410:     element in table scope</a> with the same tag name as that
                   7411:     of the token, then act as if an end tag with the tag name
                   7412:     "select" had been seen, and reprocess the token. Otherwise,
                   7413:     ignore the token.</p>
                   7414: 
                   7415:    </dd>
                   7416: 
                   7417:    <dt>Anything else</dt>
                   7418:    <dd>
                   7419:     <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
                   7420:     mode</a>.</p>
                   7421:    </dd>
                   7422: 
1.755     mike     7423:   </dl><h5 id="parsing-main-inforeign"><span class="secno">8.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     7424: 
                   7425:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inforeign" title="insertion
                   7426:   mode: in foreign content">in foreign content</a>", tokens must be
                   7427:   handled as follows:</p>
                   7428: 
                   7429:   <dl class="switch"><dt>A character token</dt>
                   7430:    <dd>
                   7431: 
                   7432:     <p><a href="#insert-a-character" title="insert a character">Insert the token's
                   7433:     character</a> into the <a href="#current-node">current node</a>.</p>
                   7434: 
                   7435:     <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
                   7436:     LINE FEED (LF), U+000C FORM FEED (FF), <!--U+000D CARRIAGE RETURN
                   7437:     (CR),--> or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
                   7438:     flag</a> to "not ok".</p>
                   7439: 
                   7440:    </dd>
                   7441: 
                   7442:    <dt>A comment token</dt>
                   7443:    <dd>
                   7444:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   7445:     node</a> with the <code title="">data</code> attribute set to
                   7446:     the data given in the comment token.</p>
                   7447:    </dd>
                   7448: 
                   7449:    <dt>A DOCTYPE token</dt>
                   7450:    <dd>
                   7451:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7452:    </dd>
                   7453: 
1.724     mike     7454:    <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     7455:    <dd>
                   7456: 
                   7457:     <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   7458:     elements</a>.</p>
                   7459: 
                   7460:     <p>Let the <var title="">old insertion point</var> have the
                   7461:     same value as the current <a href="#insertion-point">insertion point</a>. Let
                   7462:     the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
                   7463:     input character</a>.</p>
                   7464: 
                   7465:     <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
                   7466:     one. Set the <a href="#parser-pause-flag">parser pause flag</a> to true.</p>
                   7467: 
                   7468:     <p><a href="http://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing">Process
                   7469:     the <code title="">script</code> element</a> according to the SVG
1.187     mike     7470:     rules, if the user agent supports SVG. <a href="references.html#refsSVG">[SVG]</a></p>
1.1       mike     7471: 
1.159     mike     7472:     <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     7473:     tokenizer</a>, the parser will not be executed reentrantly,
                   7474:     since the <a href="#parser-pause-flag">parser pause flag</a> is true.</p>
                   7475: 
                   7476:     <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
                   7477:     one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
                   7478:     then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
                   7479: 
                   7480:     <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
                   7481:     <a href="#insertion-point">insertion point</a> to its previous value. This value
                   7482:     might be the "undefined" value.)</p>
                   7483: 
                   7484:    </dd>
                   7485: 
1.724     mike     7486:    <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>
                   7487:    <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>
                   7488:    <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>
                   7489:    <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>
                   7490:    <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>
                   7491:    <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>
                   7492:    <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>
                   7493:    <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>
                   7494:    <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>
                   7495:    <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     7496:    <dt>An end tag</dt>
                   7497:    <dd>
                   7498: 
                   7499:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the
                   7500:     <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
                   7501: 
                   7502:     <p>If, after doing so, the <a href="#insertion-mode">insertion mode</a> is still
                   7503:     "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
1.336     mike     7504:     content</a>", but there is no element <a href="#has-an-element-in-scope" title="has an
                   7505:     element in scope">in scope</a> that has a namespace other than
1.724     mike     7506:     the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, switch the <a href="#insertion-mode">insertion
1.1       mike     7507:     mode</a> to the <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
                   7508: 
                   7509:    </dd>
                   7510: 
                   7511:    <dt>A start tag whose tag name is one of: <!--"a",--> "b", "big",
                   7512:    "blockquote", "body"<!--by inspection-->, "br", "center", "code",
1.422     mike     7513:    "dd", "div", "dl", "dt"<!-- so that dd and dt can be handled
                   7514:    uniformly throughout the parser -->, "em", "embed", "h1", "h2",
                   7515:    "h3", "h4"<!--for completeness-->, "h5", "h6"<!--for
1.1       mike     7516:    completeness-->, "head"<!--by inspection-->, "hr", "i", "img",
                   7517:    "li", "listing"<!-- so that pre and listing can be handled
                   7518:    uniformly throughout the parser -->, "menu", "meta", "nobr",
                   7519:    "ol"<!-- so that dl, ul, and ol can be handled uniformly throughout
                   7520:    the parser -->, "p", "pre", "ruby", "s", <!--"script",--> "small",
                   7521:    "span", "strong", "strike"<!-- so that s and strike can be handled
                   7522:    uniformly throughout the parser -->, <!--"style",--> "sub", "sup",
1.305     mike     7523:    "table"<!--by inspection-->, "tt", "u", "ul", "var"</dt> <!-- this
                   7524:    list was determined empirically by studying over 6,000,000,000
1.422     mike     7525:    pages that were specifically not XML pages -->
                   7526:    <dt>A start tag whose tag name is "font", if the token has any
                   7527:    attributes named "color", "face", or "size"</dt> <!-- the
                   7528:    attributes here are required so that SVG <font> will go through as
                   7529:    SVG but legacy <font>s won't -->
                   7530:    <dt>An end-of-file token</dt> <dd>
1.1       mike     7531: 
                   7532:     <p><a href="#parse-error">Parse error</a>.</p>
                   7533: 
                   7534:     <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a> until
1.724     mike     7535:     the <a href="#current-node">current node</a> is in the <a href="infrastructure.html#html-namespace-0">HTML
1.1       mike     7536:     namespace</a>.</p>
                   7537: 
                   7538:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#secondary-insertion-mode">secondary
                   7539:     insertion mode</a>, and reprocess the token.</p>
                   7540: 
                   7541:    </dd>
                   7542: 
                   7543:    <dt>Any other start tag</dt>
                   7544:    <dd>
                   7545: 
                   7546:     <p>If the <a href="#current-node">current node</a> is an element in the
1.724     mike     7547:     <a href="infrastructure.html#mathml-namespace">MathML namespace</a>, <a href="#adjust-mathml-attributes">adjust MathML
1.1       mike     7548:     attributes</a> for the token. (This fixes the case of MathML
                   7549:     attributes that are not all lowercase.)</p>
                   7550: 
1.724     mike     7551:     <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     7552:     namespace</a>, and the token's tag name is one of the ones in
                   7553:     the first column of the following table, change the tag name to
                   7554:     the name given in the corresponding cell in the second
                   7555:     column. (This fixes the case of SVG elements that are not all
                   7556:     lowercase.)</p>
                   7557: 
                   7558:     <table><thead><tr><th> Tag name </th><th> Element name
                   7559:      </th></tr></thead><tbody><tr><td> <code title="">altglyph</code> </td><td> <code title="">altGlyph</code>
                   7560:       </td></tr><tr><td> <code title="">altglyphdef</code> </td><td> <code title="">altGlyphDef</code>
                   7561:       </td></tr><tr><td> <code title="">altglyphitem</code> </td><td> <code title="">altGlyphItem</code>
                   7562:       </td></tr><tr><td> <code title="">animatecolor</code> </td><td> <code title="">animateColor</code>
                   7563:       </td></tr><tr><td> <code title="">animatemotion</code> </td><td> <code title="">animateMotion</code>
                   7564:       </td></tr><tr><td> <code title="">animatetransform</code> </td><td> <code title="">animateTransform</code>
                   7565:       </td></tr><tr><td> <code title="">clippath</code> </td><td> <code title="">clipPath</code>
                   7566:       </td></tr><tr><td> <code title="">feblend</code> </td><td> <code title="">feBlend</code>
                   7567:       </td></tr><tr><td> <code title="">fecolormatrix</code> </td><td> <code title="">feColorMatrix</code>
                   7568:       </td></tr><tr><td> <code title="">fecomponenttransfer</code> </td><td> <code title="">feComponentTransfer</code>
                   7569:       </td></tr><tr><td> <code title="">fecomposite</code> </td><td> <code title="">feComposite</code>
                   7570:       </td></tr><tr><td> <code title="">feconvolvematrix</code> </td><td> <code title="">feConvolveMatrix</code>
                   7571:       </td></tr><tr><td> <code title="">fediffuselighting</code> </td><td> <code title="">feDiffuseLighting</code>
                   7572:       </td></tr><tr><td> <code title="">fedisplacementmap</code> </td><td> <code title="">feDisplacementMap</code>
                   7573:       </td></tr><tr><td> <code title="">fedistantlight</code> </td><td> <code title="">feDistantLight</code>
                   7574:       </td></tr><tr><td> <code title="">feflood</code> </td><td> <code title="">feFlood</code>
                   7575:       </td></tr><tr><td> <code title="">fefunca</code> </td><td> <code title="">feFuncA</code>
                   7576:       </td></tr><tr><td> <code title="">fefuncb</code> </td><td> <code title="">feFuncB</code>
                   7577:       </td></tr><tr><td> <code title="">fefuncg</code> </td><td> <code title="">feFuncG</code>
                   7578:       </td></tr><tr><td> <code title="">fefuncr</code> </td><td> <code title="">feFuncR</code>
                   7579:       </td></tr><tr><td> <code title="">fegaussianblur</code> </td><td> <code title="">feGaussianBlur</code>
                   7580:       </td></tr><tr><td> <code title="">feimage</code> </td><td> <code title="">feImage</code>
                   7581:       </td></tr><tr><td> <code title="">femerge</code> </td><td> <code title="">feMerge</code>
                   7582:       </td></tr><tr><td> <code title="">femergenode</code> </td><td> <code title="">feMergeNode</code>
                   7583:       </td></tr><tr><td> <code title="">femorphology</code> </td><td> <code title="">feMorphology</code>
                   7584:       </td></tr><tr><td> <code title="">feoffset</code> </td><td> <code title="">feOffset</code>
                   7585:       </td></tr><tr><td> <code title="">fepointlight</code> </td><td> <code title="">fePointLight</code>
                   7586:       </td></tr><tr><td> <code title="">fespecularlighting</code> </td><td> <code title="">feSpecularLighting</code>
                   7587:       </td></tr><tr><td> <code title="">fespotlight</code> </td><td> <code title="">feSpotLight</code>
                   7588:       </td></tr><tr><td> <code title="">fetile</code> </td><td> <code title="">feTile</code>
                   7589:       </td></tr><tr><td> <code title="">feturbulence</code> </td><td> <code title="">feTurbulence</code>
                   7590:       </td></tr><tr><td> <code title="">foreignobject</code> </td><td> <code title="">foreignObject</code>
                   7591:       </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
                   7592:       </td></tr><tr><td> <code title="">lineargradient</code> </td><td> <code title="">linearGradient</code>
                   7593:       </td></tr><tr><td> <code title="">radialgradient</code> </td><td> <code title="">radialGradient</code>
                   7594:       <!--<tr> <td> <code title="">solidcolor</code> <td> <code title="">solidColor</code> (SVG 1.2)-->
                   7595:       </td></tr><tr><td> <code title="">textpath</code> </td><td> <code title="">textPath</code>
1.724     mike     7596:     </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     7597:     namespace</a>, <a href="#adjust-svg-attributes">adjust SVG attributes</a> for the
                   7598:     token. (This fixes the case of SVG attributes that are not all
                   7599:     lowercase.)</p>
                   7600: 
                   7601:     <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
                   7602:     fixes the use of namespaced attributes, in particular XLink in
                   7603:     SVG.)</p>
                   7604: 
                   7605:     <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
                   7606:     same namespace as the <a href="#current-node">current node</a>.</p>
                   7607: 
                   7608:     <p>If the token has its <i>self-closing flag</i> set, pop the
                   7609:     <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   7610:     elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
                   7611:     flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
                   7612: 
                   7613:    </dd>
                   7614: 
1.755     mike     7615:   </dl><h5 id="parsing-main-afterbody"><span class="secno">8.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     7616: 
                   7617:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterbody" title="insertion
                   7618:   mode: after body">after body</a>", tokens must be handled as follows:</p>
                   7619: 
                   7620:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   7621:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   7622:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   7623:    <dd>
                   7624:     <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
                   7625:     mode</a>.</p>
                   7626:    </dd>
                   7627: 
                   7628:    <dt>A comment token</dt>
                   7629:    <dd>
                   7630:     <p>Append a <code>Comment</code> node to the first element in
1.159     mike     7631:     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     7632:     element), with the <code title="">data</code> attribute set to
                   7633:     the data given in the comment token.</p>
                   7634:    </dd>
                   7635: 
                   7636:    <dt>A DOCTYPE token</dt>
                   7637:    <dd>
                   7638:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7639:    </dd>
                   7640: 
                   7641:    <dt>A start tag whose tag name is "html"</dt>
                   7642:    <dd>
                   7643:     <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
                   7644:     mode</a>.</p>
                   7645:    </dd>
                   7646: 
                   7647:    <dt>An end tag whose tag name is "html"</dt>
                   7648:    <dd>
                   7649: 
                   7650:     <p>If the parser was originally created as part of the <a href="#html-fragment-parsing-algorithm">HTML
                   7651:     fragment parsing algorithm</a>, this is a <a href="#parse-error">parse
                   7652:     error</a>; ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
                   7653: 
                   7654:     <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
                   7655:     body</a>".</p>
                   7656: 
                   7657:    </dd>
                   7658: 
                   7659:    <dt>An end-of-file token</dt>
                   7660:    <dd>
                   7661:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7662:    </dd>
                   7663: 
                   7664:    <dt>Anything else</dt>
                   7665:    <dd>
                   7666: 
                   7667:     <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion
                   7668:     mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in body">in
                   7669:     body</a>" and reprocess the token.</p>
                   7670: 
                   7671:    </dd>
                   7672: 
1.755     mike     7673:   </dl><h5 id="parsing-main-inframeset"><span class="secno">8.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     7674: 
                   7675:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inframeset" title="insertion
                   7676:   mode: in frameset">in frameset</a>", tokens must be handled as follows:</p>
                   7677: 
                   7678:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   7679:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   7680:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   7681:    <dd>
                   7682:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   7683:     the <a href="#current-node">current node</a>.</p>
                   7684:    </dd>
                   7685: 
                   7686:    <dt>A comment token</dt>
                   7687:    <dd>
                   7688:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   7689:     node</a> with the <code title="">data</code> attribute set to
                   7690:     the data given in the comment token.</p>
                   7691:    </dd>
                   7692: 
                   7693:    <dt>A DOCTYPE token</dt>
                   7694:    <dd>
                   7695:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7696:    </dd>
                   7697: 
                   7698:    <dt>A start tag whose tag name is "html"</dt>
                   7699:    <dd>
                   7700:     <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
                   7701:     mode</a>.</p>
                   7702:    </dd>
                   7703: 
                   7704:    <dt>A start tag whose tag name is "frameset"</dt>
                   7705:    <dd>
                   7706:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   7707:    </dd>
                   7708: 
                   7709:    <dt>An end tag whose tag name is "frameset"</dt>
                   7710:    <dd>
                   7711: 
                   7712:     <p>If the <a href="#current-node">current node</a> is the root
1.159     mike     7713:     <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     7714:     error</a>; ignore the token. (<a href="#fragment-case">fragment
                   7715:     case</a>)</p>
                   7716: 
                   7717:     <p>Otherwise, pop the <a href="#current-node">current node</a> from the
                   7718:     <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   7719: 
                   7720:     <p>If the parser was <em>not</em> originally created as part
                   7721:     of the <a href="#html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>
                   7722:     (<a href="#fragment-case">fragment case</a>), and the <a href="#current-node">current
1.5       mike     7723:     node</a> is no longer a <code><a href="obsolete.html#frameset">frameset</a></code> element, then
1.1       mike     7724:     switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-afterframeset" title="insertion mode: after frameset">after
                   7725:     frameset</a>".</p>
                   7726: 
                   7727:    </dd>
                   7728: 
                   7729:    <dt>A start tag whose tag name is "frame"</dt>
                   7730:    <dd>
                   7731: 
                   7732:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.
                   7733:     Immediately pop the <a href="#current-node">current node</a> off the
                   7734:     <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   7735: 
                   7736:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   7737:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   7738: 
                   7739:    </dd>
                   7740: 
                   7741:    <dt>A start tag whose tag name is "noframes"</dt>
                   7742:    <dd>
                   7743:     <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
                   7744:     mode</a>.</p>
                   7745:    </dd>
                   7746: 
                   7747:    <dt>An end-of-file token</dt>
                   7748:    <dd>
                   7749: 
                   7750:     <p>If the <a href="#current-node">current node</a> is not the root
1.159     mike     7751:     <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     7752:     error</a>.</p>
                   7753: 
                   7754:     <p class="note">It can only be the <a href="#current-node">current node</a> in
                   7755:     the <a href="#fragment-case">fragment case</a>.</p>
                   7756: 
                   7757:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7758: 
                   7759:    </dd>
                   7760: 
                   7761:    <dt>Anything else</dt>
                   7762:    <dd>
                   7763:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7764:    </dd>
                   7765: 
1.755     mike     7766:   </dl><h5 id="parsing-main-afterframeset"><span class="secno">8.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     7767: 
                   7768:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterframeset" title="insertion
                   7769:   mode: after frameset">after frameset</a>", tokens must be handled as follows:</p>
                   7770: 
                   7771:   <!-- due to rules in the "in frameset" mode, this can't be entered in the fragment case -->
                   7772:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   7773:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   7774:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   7775:    <dd>
                   7776:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   7777:     the <a href="#current-node">current node</a>.</p>
                   7778:    </dd>
                   7779: 
                   7780:    <dt>A comment token</dt>
                   7781:    <dd>
                   7782:     <p>Append a <code>Comment</code> node to the <a href="#current-node">current
                   7783:     node</a> with the <code title="">data</code> attribute set to
                   7784:     the data given in the comment token.</p>
                   7785:    </dd>
                   7786: 
                   7787:    <dt>A DOCTYPE token</dt>
                   7788:    <dd>
                   7789:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7790:    </dd>
                   7791: 
                   7792:    <dt>A start tag whose tag name is "html"</dt>
                   7793:    <dd>
                   7794:     <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
                   7795:     mode</a>.</p>
                   7796:    </dd>
                   7797: 
                   7798:    <dt>An end tag whose tag name is "html"</dt>
                   7799:    <dd>
                   7800:     <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
                   7801:     frameset</a>".</p>
                   7802:    </dd>
                   7803: 
                   7804:    <dt>A start tag whose tag name is "noframes"</dt>
                   7805:    <dd>
                   7806:     <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
                   7807:     mode</a>.</p>
                   7808:    </dd>
                   7809: 
                   7810:    <dt>An end-of-file token</dt>
                   7811:    <dd>
                   7812:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7813:    </dd>
                   7814: 
                   7815:    <dt>Anything else</dt>
                   7816:    <dd>
                   7817:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7818:    </dd>
                   7819: 
1.755     mike     7820:   </dl><h5 id="the-after-after-body-insertion-mode"><span class="secno">8.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     7821: 
                   7822:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-body-insertion-mode" title="insertion
                   7823:   mode: after after body">after after body</a>", tokens must be handled as follows:</p>
                   7824: 
                   7825:   <dl class="switch"><dt>A comment token</dt>
                   7826:    <dd>
                   7827:     <p>Append a <code>Comment</code> node to the <code>Document</code>
                   7828:     object with the <code title="">data</code> attribute set to the
                   7829:     data given in the comment token.</p>
                   7830:    </dd>
                   7831: 
                   7832:    <dt>A DOCTYPE token</dt>
                   7833:    <dt>A character token that is one of U+0009 CHARACTER
                   7834:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   7835:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   7836:    <dt>A start tag whose tag name is "html"</dt>
                   7837:    <dd>
                   7838:     <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
                   7839:     mode</a>.</p>
                   7840:    </dd>
                   7841: 
                   7842:    <dt>An end-of-file token</dt>
                   7843:    <dd>
                   7844:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7845:    </dd>
                   7846: 
                   7847:    <dt>Anything else</dt>
                   7848:    <dd>
                   7849:     <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion mode</a>
                   7850:     to "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" and
                   7851:     reprocess the token.</p>
                   7852:    </dd>
                   7853: 
1.755     mike     7854:   </dl><h5 id="the-after-after-frameset-insertion-mode"><span class="secno">8.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     7855: 
                   7856:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-frameset-insertion-mode" title="insertion
                   7857:   mode: after after frameset">after after frameset</a>", tokens must be handled as follows:</p>
                   7858: 
                   7859:   <dl class="switch"><dt>A comment token</dt>
                   7860:    <dd>
                   7861:     <p>Append a <code>Comment</code> node to the <code>Document</code>
                   7862:     object with the <code title="">data</code> attribute set to the
                   7863:     data given in the comment token.</p>
                   7864:    </dd>
                   7865: 
                   7866:    <dt>A DOCTYPE token</dt>
                   7867:    <dt>A character token that is one of U+0009 CHARACTER
                   7868:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
                   7869:    <!--U+000D CARRIAGE RETURN (CR),--> or U+0020 SPACE</dt>
                   7870:    <dt>A start tag whose tag name is "html"</dt>
                   7871:    <dd>
                   7872:     <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
                   7873:     mode</a>.</p>
                   7874:    </dd>
                   7875: 
                   7876:    <dt>An end-of-file token</dt>
                   7877:    <dd>
                   7878:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7879:    </dd>
                   7880: 
                   7881:    <dt>A start tag whose tag name is "noframes"</dt>
                   7882:    <dd>
                   7883:     <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
                   7884:     mode</a>.</p>
                   7885:    </dd>
                   7886: 
                   7887:    <dt>Anything else</dt>
                   7888:    <dd>
                   7889:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7890:    </dd>
                   7891: 
1.266     mike     7892:   </dl></div><div class="impl">
                   7893: 
1.755     mike     7894:   <h4 id="the-end"><span class="secno">8.2.6 </span>The end</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     7895: 
                   7896:   <p>Once the user agent <dfn id="stop-parsing" title="stop parsing">stops parsing</dfn>
1.484     mike     7897:   the document, the user agent must run the following steps:</p>
1.1       mike     7898: 
1.484     mike     7899:   <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
                   7900:    "interactive" <!-- this also synchronously fires an event --> and
                   7901:    the <a href="#insertion-point">insertion point</a> to undefined.</p></li>
                   7902: 
                   7903:    <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
                   7904:    document has finished parsing</a> is not empty, run these
                   7905:    substeps:</p>
                   7906: 
1.755     mike     7907:     <ol><li><p><a href="web-application-apis.html#spin-the-event-loop">Spin the event loop</a> until the first
1.484     mike     7908:      <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
                   7909:      execute when the document has finished parsing</a> has its
                   7910:      <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag set <em>and</em> there
                   7911:      is no <a href="semantics.html#a-style-sheet-blocking-scripts" title="a style sheet blocking scripts">style sheet
                   7912:      blocking scripts</a>.</p></li>
                   7913: 
                   7914:      <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a> the
                   7915:      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
                   7916:      execute when the document has finished parsing</a>.</p></li>
                   7917: 
                   7918:      <li><p>Remove the first <code><a href="semantics.html#script">script</a></code> element from the
                   7919:      <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
                   7920:      finished parsing</a> (i.e. shift out the first entry in the
                   7921:      list).</p></li>
                   7922:  
                   7923:      <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
                   7924:      document has finished parsing</a> is still not empty, repeat
                   7925:      these substeps again from substep 1.</p>
                   7926: 
                   7927:     </li></ol></li>
                   7928: 
1.755     mike     7929:    <li><p><a href="web-application-apis.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     7930:    scripts that will execute as soon as possible</a> is
                   7931:    empty.</p></li>
                   7932: 
1.755     mike     7933:    <li><p><a href="web-application-apis.html#queue-a-task">Queue a task</a> to <a href="web-application-apis.html#fire-a-simple-event">fire a simple
1.484     mike     7934:    event</a> named <code title="event-DOMContentLoaded">DOMContentLoaded</code> at the
                   7935:    <code>Document</code>.</p></li>
                   7936: 
1.755     mike     7937:    <li><p><a href="web-application-apis.html#spin-the-event-loop">Spin the event loop</a> until there is nothing that
1.484     mike     7938:    <dfn id="delay-the-load-event" title="delay the load event">delays the load event</dfn> in
                   7939:    the <code>Document</code>.</p></li>
                   7940: 
1.755     mike     7941:    <li><p><a href="web-application-apis.html#queue-a-task">Queue a task</a> to set the <a href="dom.html#current-document-readiness">current document
1.484     mike     7942:    readiness</a> to "complete". <!-- this also fires an event
                   7943:    synchronously during the task --></p></li>
1.1       mike     7944: 
1.484     mike     7945:    <li><p>If the <code>Document</code> is in a <a href="browsers.html#browsing-context">browsing
1.755     mike     7946:    context</a>, then <a href="web-application-apis.html#queue-a-task">queue a task</a> to <a href="web-application-apis.html#fire-a-simple-event">fire a
1.460     mike     7947:    simple event</a> named <code title="event-load">load</code> at
1.1       mike     7948:    the <code>Document</code>'s <code><a href="browsers.html#window">Window</a></code> object, but with
                   7949:    its <code title="dom-event-target">target</code> set to the
                   7950:    <code>Document</code> object (and the <code title="dom-event-currentTarget">currentTarget</code> set to the
1.484     mike     7951:    <code><a href="browsers.html#window">Window</a></code> object).</p></li>
1.1       mike     7952: 
1.569     mike     7953:    <li><p>If the <code>Document</code> is in a <a href="browsers.html#browsing-context">browsing
1.755     mike     7954:    context</a>, then <a href="web-application-apis.html#queue-a-task">queue a task</a> to <a href="web-application-apis.html#fire-a-simple-event">fire a
1.569     mike     7955:    simple event</a> named <code title="event-pageshow">pageshow</code> at the
                   7956:    <code>Document</code>'s <code><a href="browsers.html#window">Window</a></code> object.</p></li>
                   7957: 
1.484     mike     7958:    <li><p>If the <code>Document</code> has a <a href="history.html#pending-state-object">pending state
1.755     mike     7959:    object</a>, then <a href="web-application-apis.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     7960:    <code>Document</code>'s <code><a href="browsers.html#window">Window</a></code> object using the
                   7961:    <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
                   7962:    current value of the <a href="history.html#pending-state-object">pending state object</a>. This event
1.484     mike     7963:    must bubble but not be cancelable and has no default
                   7964:    action.</p></li>
1.1       mike     7965: 
1.725     mike     7966:    <li><p>If the <code>Document</code> has any <a href="offline.html#pending-application-cache-download-process-tasks">pending
1.755     mike     7967:    application cache download process tasks</a>, then <a href="web-application-apis.html#queue-a-task" title="queue a task">queue</a> each such <a href="web-application-apis.html#concept-task" title="concept-task">task</a> in the order they were added to
1.725     mike     7968:    the list of <a href="offline.html#pending-application-cache-download-process-tasks">pending application cache download process
                   7969:    tasks</a>, and then empty the list of <a href="offline.html#pending-application-cache-download-process-tasks">pending application
1.755     mike     7970:    cache download process tasks</a>. The <a href="web-application-apis.html#task-source">task source</a>
                   7971:    for these <a href="web-application-apis.html#concept-task" title="concept-task">tasks</a> is the
                   7972:    <a href="web-application-apis.html#networking-task-source">networking task source</a>.</p></li>
1.725     mike     7973: 
                   7974:    <li><p>The <code>Document</code> is now <dfn id="completely-loaded">completely
                   7975:    loaded</dfn>.</p></li>
                   7976: 
1.755     mike     7977:   </ol><p>Except where otherwise specified, the <a href="web-application-apis.html#task-source">task source</a>
                   7978:   for the <a href="web-application-apis.html#concept-task" title="concept-task">tasks</a> mentioned in this
                   7979:   section is the <a href="web-application-apis.html#dom-manipulation-task-source">DOM manipulation task source</a>.</p>
1.1       mike     7980: 
1.266     mike     7981:   </div><div class="impl">
1.1       mike     7982: 
1.755     mike     7983:   <h4 id="coercing-an-html-dom-into-an-infoset"><span class="secno">8.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     7984: 
                   7985:   <p>When an application uses an <a href="#html-parser">HTML parser</a> in
                   7986:   conjunction with an XML pipeline, it is possible that the
                   7987:   constructed DOM is not compatible with the XML tool chain in certain
                   7988:   subtle ways. For example, an XML toolchain might not be able to
                   7989:   represent attributes with the name <code title="">xmlns</code>,
                   7990:   since they conflict with the Namespaces in XML syntax. There is also
                   7991:   some data that the <a href="#html-parser">HTML parser</a> generates that isn't
                   7992:   included in the DOM itself. This section specifies some rules for
                   7993:   handling these issues.</p>
                   7994: 
                   7995:   <p>If the XML API being used doesn't support DOCTYPEs, the tool may
                   7996:   drop DOCTYPEs altogether.</p>
                   7997: 
                   7998:   <p>If the XML API doesn't support attributes in no namespace that
                   7999:   are named "<code title="">xmlns</code>", attributes whose names
                   8000:   start with "<code title="">xmlns:</code>", or attributes in the
1.724     mike     8001:   <a href="infrastructure.html#xmlns-namespace">XMLNS namespace</a>, then the tool may drop such
1.1       mike     8002:   attributes.</p>
                   8003: 
                   8004:   <p>The tool may annotate the output with any namespace declarations
                   8005:   required for proper operation.</p>
                   8006: 
                   8007:   <p>If the XML API being used restricts the allowable characters in
                   8008:   the local names of elements and attributes, then the tool may map
                   8009:   all element and attribute local names that the API wouldn't support
                   8010:   to a set of names that <em>are</em> allowed, by replacing any
                   8011:   character that isn't supported with the uppercase letter U and the
                   8012:   six digits of the character's Unicode code point when expressed in
                   8013:   hexadecimal, using digits 0-9 and capital letters A-F as the
                   8014:   symbols, in increasing numeric order.</p>
                   8015: 
                   8016:   <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
                   8017:   parser</a>, though it is neither a legal HTML element name nor a
                   8018:   well-formed XML element name, would be converted into <code title="">fooU00003Cbar</code>, which <em>is</em> a well-formed XML
                   8019:   element name (though it's still not legal in HTML by any means).</p>
                   8020: 
                   8021:   <p class="example">As another example, consider the attribute
                   8022:   <code>xlink:href</code>. Used on a MathML element, it becomes, after
                   8023:   being <a href="#adjust-foreign-attributes" title="adjust foreign attributes">adjusted</a>, an
                   8024:   attribute with a prefix "<code title="">xlink</code>" and a local
                   8025:   name "<code title="">href</code>". However, used on an HTML element,
                   8026:   it becomes an attribute with no prefix and the local name "<code title="">xlink:href</code>", which is not a valid NCName, and thus
                   8027:   might not be accepted by an XML API. It could thus get converted,
                   8028:   becoming "<code title="">xlinkU00003Ahref</code>".</p>
                   8029: 
                   8030:   <p class="note">The resulting names from this conversion
                   8031:   conveniently can't clash with any attribute generated by the
                   8032:   <a href="#html-parser">HTML parser</a>, since those are all either lowercase or
                   8033:   those listed in the <a href="#adjust-foreign-attributes">adjust foreign attributes</a>
                   8034:   algorithm's table.</p>
                   8035: 
                   8036:   <p>If the XML API restricts comments from having two consecutive
                   8037:   U+002D HYPHEN-MINUS characters (--), the tool may insert a single
                   8038:   U+0020 SPACE character between any such offending characters.</p>
                   8039: 
                   8040:   <p>If the XML API restricts comments from ending in a
                   8041:   U+002D HYPHEN-MINUS character (-), the tool may insert a single
                   8042:   U+0020 SPACE character at the end of such comments.</p>
                   8043: 
                   8044:   <p>If the XML API restricts allowed characters in character data,
1.439     mike     8045:   attribute values, or comments, the tool may replace any U+000C FORM
                   8046:   FEED (FF) character with a U+0020 SPACE character, and any other
                   8047:   literal non-XML character with a U+FFFD REPLACEMENT CHARACTER.</p>
1.1       mike     8048: 
                   8049:   <p>If the tool has no way to convey out-of-band information, then
                   8050:   the tool may drop the following information:</p>
                   8051: 
                   8052:   <ul><li>Whether the document is set to <i><a href="dom.html#no-quirks-mode">no quirks mode</a></i>,
                   8053:    <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>
                   8054: 
                   8055:    <li>The association between form controls and forms that aren't
                   8056:    their nearest <code><a href="forms.html#the-form-element">form</a></code> element ancestor (use of the
                   8057:    <a href="#form-element-pointer"><code>form</code> element pointer</a> in the parser)</li>
                   8058: 
                   8059:   </ul><p class="note">The mutations allowed by this section apply
                   8060:   <em>after</em> the <a href="#html-parser">HTML parser</a>'s rules have been
                   8061:   applied. For example, a <code title="">&lt;a::&gt;</code> start tag
                   8062:   will be closed by a <code title="">&lt;/a::&gt;</code> end tag, and
                   8063:   never by a <code title="">&lt;/aU00003AU00003A&gt;</code> end tag, even
                   8064:   if the user agent is using the rules above to then generate an
                   8065:   actual element in the DOM with the name <code title="">aU00003AU00003A</code> for that start tag.</p>
                   8066: 
1.266     mike     8067:   </div><div class="impl">
1.1       mike     8068: 
1.755     mike     8069:   <h4 id="an-introduction-to-error-handling-and-strange-cases-in-the-parser"><span class="secno">8.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     8070: 
                   8071:   <p><i>This section is non-normative.</i></p>
                   8072: 
                   8073:   <p>This section examines some erroneous markup and discusses how
                   8074:   the <a href="#html-parser">HTML parser</a> handles these cases.</p>
                   8075: 
                   8076: 
1.755     mike     8077:   <h5 id="misnested-tags:-b-i-b-i"><span class="secno">8.2.8.1 </span>Misnested tags: &lt;b&gt;&lt;i&gt;&lt;/b&gt;&lt;/i&gt;</h5>
1.1       mike     8078: 
                   8079:   <p><i>This section is non-normative.</i></p>
                   8080: 
                   8081:   <p>The most-often discussed example of erroneous markup is as
                   8082:   follows:</p>
                   8083: 
                   8084:   <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>
                   8085: 
                   8086:   <p>The parsing of this markup is straightforward up to the "3". At
                   8087:   this point, the DOM looks like this:</p>
                   8088: 
1.159     mike     8089:   <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
                   8090:   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     8091:   <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
                   8092:   formatting elements</a> just has two: <code><a href="text-level-semantics.html#the-b-element">b</a></code> and
                   8093:   <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>
                   8094: 
                   8095:   <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is
                   8096:   invoked. This is a simple case, in that the <var title="">formatting
                   8097:   element</var> is the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element, and there is no
                   8098:   <var title="">furthest block</var>. Thus, the <a href="#stack-of-open-elements">stack of open
1.159     mike     8099:   elements</a> ends up with just three elements: <code><a href="semantics.html#the-html-element-0">html</a></code>,
                   8100:   <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     8101:   active formatting elements</a> has just one: <code><a href="text-level-semantics.html#the-i-element">i</a></code>. The
                   8102:   DOM tree is unmodified at this point.</p>
                   8103: 
                   8104:   <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
                   8105:   the active formatting elements</a>, in this case just the
                   8106:   <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
                   8107:   for the "4" text node. After the end tag token for the "i" is also
                   8108:   received, and the "5" text node is inserted, the DOM looks as
                   8109:   follows:</p>
                   8110: 
1.755     mike     8111:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="semantics.html#the-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">8.2.8.2 </span>Misnested tags: &lt;b&gt;&lt;p&gt;&lt;/b&gt;&lt;/p&gt;</h5>
1.1       mike     8112: 
                   8113:   <p><i>This section is non-normative.</i></p>
                   8114: 
                   8115:   <p>A case similar to the previous one is the following:</p>
                   8116: 
                   8117:   <pre>&lt;b&gt;1&lt;p&gt;2&lt;/b&gt;3&lt;/p&gt;</pre>
                   8118: 
                   8119:   <p>Up to the "2" the parsing here is straightforward:</p>
                   8120: 
1.159     mike     8121:   <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     8122:   "b" is parsed.</p>
                   8123: 
                   8124:   <p>Before that token is seen, the <a href="#stack-of-open-elements">stack of open
1.159     mike     8125:   elements</a> has four elements on it: <code><a href="semantics.html#the-html-element-0">html</a></code>,
                   8126:   <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     8127:   <a href="#list-of-active-formatting-elements">list of active formatting elements</a> just has the one:
                   8128:   <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>
                   8129: 
                   8130:   <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is invoked, as
                   8131:   in the previous example. However, in this case, there <em>is</em> a
                   8132:   <var title="">furthest block</var>, namely the <code><a href="semantics.html#the-p-element">p</a></code> element. Thus,
                   8133:   this time the adoption agency algorithm isn't skipped over.</p>
                   8134: 
1.159     mike     8135:   <p>The <var title="">common ancestor</var> is the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1       mike     8136:   element. A conceptual "bookmark" marks the position of the
                   8137:   <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
                   8138:   elements</a>, but since that list has only one element in it,
                   8139:   it won't have much effect.</p>
                   8140: 
                   8141:   <p>As the algorithm progresses, <var title="">node</var> ends up set
                   8142:   to the formatting element (<code><a href="text-level-semantics.html#the-b-element">b</a></code>), and <var title="">last
                   8143:   node</var> ends up set to the <var title="">furthest block</var>
                   8144:   (<code><a href="semantics.html#the-p-element">p</a></code>).</p>
                   8145: 
                   8146:   <p>The <var title="">last node</var> gets appended (moved) to the
                   8147:   <var title="">common ancestor</var>, so that the DOM looks like:</p>
                   8148: 
1.159     mike     8149:   <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     8150:   <code><a href="semantics.html#the-p-element">p</a></code> element are moved to it:</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="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     8153:   <code><a href="semantics.html#the-p-element">p</a></code> element, so that the DOM looks like:</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><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     8156:   active formatting elements</a> and the <a href="#stack-of-open-elements">stack of open
                   8157:   elements</a>, so that when the "3" is parsed, it is appended to
                   8158:   the <code><a href="semantics.html#the-p-element">p</a></code> element:</p>
                   8159: 
1.755     mike     8160:   <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">8.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     8161: 
                   8162:   <p><i>This section is non-normative.</i></p>
                   8163: 
                   8164:   <p>Error handling in tables is, for historical reasons, especially
                   8165:   strange. For example, consider the following markup:</p>
                   8166: 
                   8167:   <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>
                   8168: 
                   8169:   <p>The highlighted <code><a href="text-level-semantics.html#the-b-element">b</a></code> element start tag is not allowed
                   8170:   directly inside a table like that, and the parser handles this case
                   8171:   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
                   8172:   examining the DOM tree as it stands just after the
                   8173:   <code><a href="tabular-data.html#the-table-element">table</a></code> element's start tag has been seen:</p>
                   8174: 
1.159     mike     8175:   <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     8176:   tag has been seen:</p>
                   8177: 
1.159     mike     8178:   <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
                   8179:   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     8180:   <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
                   8181:   resulting DOM tree); the <a href="#list-of-active-formatting-elements">list of active formatting
                   8182:   elements</a> just has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it; and the
                   8183:   <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion mode: in
                   8184:   table">in table</a>".</p>
                   8185: 
                   8186:   <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
                   8187:   to be popped off the stack and a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> start tag to be
                   8188:   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
                   8189:   then handled in a rather straight-forward manner, taking the parser
                   8190:   through the "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   8191:   body</a>" and "<a href="#parsing-main-intr" title="insertion mode: in row">in
                   8192:   row</a>" insertion modes, after which the DOM looks as
                   8193:   follows:</p>
                   8194: 
1.159     mike     8195:   <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
                   8196:   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     8197:   <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
                   8198:   formatting elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in
                   8199:   it; and the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
                   8200:   mode: in row">in row</a>".</p>
                   8201: 
                   8202:   <p>The <code><a href="tabular-data.html#the-td-element">td</a></code> element start tag token, after putting a
                   8203:   <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
                   8204:   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
                   8205:   mode</a>).</p>
                   8206: 
1.159     mike     8207:   <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     8208:   no <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created to hold the resulting text
                   8209:   node:</p>
                   8210: 
1.159     mike     8211:   <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     8212:   handling them, the <a href="#stack-of-open-elements">stack of open elements</a> has on it the
1.159     mike     8213:   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     8214:   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
                   8215:   elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it (the
                   8216:   marker having been removed by the "td" end tag token); and the
                   8217:   <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion mode: in
                   8218:   table body">in table body</a>".</p>
                   8219: 
                   8220:   <p>Thus it is that the "bbb" character tokens are found. These
                   8221:   trigger the "<a href="#parsing-main-intabletext" title="insertion mode: in table text">in table
                   8222:   text</a>" insertion mode to be used (with the <a href="#original-insertion-mode">original
                   8223:   insertion mode</a> set to "<a href="#parsing-main-intbody" title="insertion mode: in table
                   8224:   body">in table body</a>"). The character tokens are collected,
                   8225:   and when the next token (the <code><a href="tabular-data.html#the-table-element">table</a></code> element end tag) is
                   8226:   seen, they are processed as a group. Since they are not all spaces,
                   8227:   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,
                   8228:   which defer to the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
                   8229:   body</a>" insertion mode but with <a href="#foster-parent" title="foster
                   8230:   parent">foster parenting</a>.</p>
                   8231: 
                   8232:   <p>When <a href="#reconstruct-the-active-formatting-elements" title="reconstruct the active formatting elements">the
                   8233:   active formatting elements are reconstructed</a>, a
                   8234:   <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created and <a href="#foster-parent" title="foster
                   8235:   parent">foster parented</a>, and then the "bbb" text node is
                   8236:   appended to it:</p>
                   8237: 
1.159     mike     8238:   <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
                   8239:   <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     8240:   <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
                   8241:   this doesn't match the resulting tree!); the <a href="#list-of-active-formatting-elements">list of active
                   8242:   formatting elements</a> has the new <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it;
                   8243:   and the <a href="#insertion-mode">insertion mode</a> is still "<a href="#parsing-main-intbody" title="insertion
                   8244:   mode: in table body">in table body</a>".</p>
                   8245: 
                   8246:   <p>Had the character tokens been only <a href="infrastructure.html#space-character" title="space
                   8247:   character">space characters</a> instead of "bbb", then those
                   8248:   <a href="infrastructure.html#space-character" title="space character">space characters</a> would just be
                   8249:   appended to the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element.</p>
                   8250: 
                   8251:   <p>Finally, the <code><a href="tabular-data.html#the-table-element">table</a></code> is closed by a "table" end
                   8252:   tag. This pops all the nodes from the <a href="#stack-of-open-elements">stack of open
                   8253:   elements</a> up to and including the <code><a href="tabular-data.html#the-table-element">table</a></code> element,
                   8254:   but it doesn't affect the <a href="#list-of-active-formatting-elements">list of active formatting
                   8255:   elements</a>, so the "ccc" character tokens after the table
                   8256:   result in yet another <code><a href="text-level-semantics.html#the-b-element">b</a></code> element being created, this
                   8257:   time after the table:</p>
                   8258: 
1.755     mike     8259:   <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">8.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     8260: 
                   8261:   <p><i>This section is non-normative.</i></p>
                   8262: 
                   8263:   <p>Consider the following markup, which for this example we will
                   8264:   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     8265:   content of an <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code> in another document with the
1.1       mike     8266:   <a href="infrastructure.html#url">URL</a> <code title="">http://example.com/outer</code>:</p>
                   8267: 
                   8268:   <pre>&lt;div id=a&gt;
                   8269:  &lt;script&gt;
                   8270:   var div = document.getElementById('a');
                   8271:   parent.document.body.appendChild(div);
                   8272:  &lt;/script&gt;
                   8273:  &lt;script&gt;
                   8274:   alert(document.URL);
                   8275:  &lt;/script&gt;
                   8276: &lt;/div&gt;
                   8277: &lt;script&gt;
                   8278:  alert(document.URL);
                   8279: &lt;/script&gt;</pre>
                   8280: 
                   8281:   <p>Up to the first "script" end tag, before the script is parsed,
                   8282:   the result is relatively straightforward:</p>
                   8283: 
1.306     mike     8284:   <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="">
                   8285:  </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     8286:   and its child <code><a href="semantics.html#script">script</a></code> element are gone:</p>
                   8287: 
1.159     mike     8288:   <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     8289:   aforementioned outer <a href="browsers.html#browsing-context">browsing context</a>. However, the
                   8290:   <a href="#stack-of-open-elements">stack of open elements</a> <em>still contains the
1.306     mike     8291:   <code><a href="semantics.html#the-div-element">div</a></code> element</em>.</p>
1.1       mike     8292: 
                   8293:   <p>Thus, when the second <code><a href="semantics.html#script">script</a></code> element is parsed, it
                   8294:   is inserted <em>into the outer <code>Document</code>
                   8295:   object</em>.</p>
                   8296: 
1.755     mike     8297:   <p>This also means that the <a href="web-application-apis.html#script-s-global-object">script's global object</a> is
1.1       mike     8298:   the outer <a href="browsers.html#browsing-context">browsing context</a>'s <code><a href="browsers.html#window">Window</a></code>
                   8299:   object, <em>not</em> the <code><a href="browsers.html#window">Window</a></code> object inside the
1.159     mike     8300:   <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code>.</p>
1.1       mike     8301: 
                   8302:   <p class="note">This isn't a security problem since the script that
1.306     mike     8303:   moves the <code><a href="semantics.html#the-div-element">div</a></code> into the outer <code>Document</code> can
1.714     mike     8304:   only do so because the two <code>Document</code> object have the
                   8305:   same <a href="browsers.html#origin">origin</a>.</p>
1.1       mike     8306: 
                   8307:   <p>Thus, the first alert says "http://example.com/outer".</p>
                   8308: 
1.306     mike     8309:   <p>Once the <code><a href="semantics.html#the-div-element">div</a></code> element's end tag is parsed, the
                   8310:   <code><a href="semantics.html#the-div-element">div</a></code> element is popped off the stack, and so the next
1.1       mike     8311:   <code><a href="semantics.html#script">script</a></code> element is in the inner <code>Document</code>:</p>
                   8312: 
1.159     mike     8313:   <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     8314: 
                   8315: 
                   8316: 
                   8317: 
1.755     mike     8318:   <h3 id="serializing-html-fragments"><span class="secno">8.3 </span>Serializing HTML fragments</h3><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     8319: 
                   8320:   <p>The following steps form the <dfn id="html-fragment-serialization-algorithm">HTML fragment serialization
                   8321:   algorithm</dfn>. The algorithm takes as input a DOM
                   8322:   <code>Element</code> or <code>Document</code>, referred to as <var title="">the node</var>, and either returns a string or raises an
                   8323:   exception.</p>
                   8324: 
                   8325:   <p class="note">This algorithm serializes the <em>children</em> of
                   8326:   the node being serialized, not the node itself.</p>
                   8327: 
                   8328:   <ol><li><p>Let <var title="">s</var> be a string, and initialize it to
                   8329:    the empty string.</p></li>
                   8330: 
                   8331:    <li>
                   8332: 
                   8333:     <p>For each child node of <var title="">the node</var>, in
                   8334:     <a href="infrastructure.html#tree-order">tree order</a>, run the following steps:
                   8335: 
                   8336:     </p><ol><li><p>Let <var title="">current node</var> be the child node
                   8337:      being processed.</p></li>
                   8338: 
                   8339:      <li>
                   8340: 
                   8341:       <p>Append the appropriate string from the following list to
                   8342:       <var title="">s</var>:</p>
                   8343: 
                   8344:       <dl class="switch"><dt>If <var title="">current node</var> is an <code title="">Element</code></dt>
                   8345: 
                   8346:        <dd>
                   8347: 
1.588     mike     8348:         <p>Append a U+003C LESS-THAN SIGN character character (&lt;),
                   8349:         followed by the element's tag name. (For nodes created by the
                   8350:         <a href="#html-parser">HTML parser</a> or <code title="">Document.createElement()</code>, the tag name will be
1.1       mike     8351:         lowercase.)</p>
                   8352: 
                   8353:         <p>For each attribute that the element has, append a U+0020
                   8354:         SPACE character, the attribute's name (which, for attributes
                   8355:         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     8356:         U+003D EQUALS SIGN character (=), a U+0022 QUOTATION MARK
                   8357:         character ("), the attribute's value, <a href="#escapingString" title="escaping a string">escaped as described below</a> in
                   8358:         <i>attribute mode</i>, and a second U+0022 QUOTATION MARK
                   8359:         character (").</p>
1.1       mike     8360: 
                   8361:         <p>While the exact order of attributes is UA-defined, and may
                   8362:         depend on factors such as the order that the attributes were
                   8363:         given in the original markup, the sort order must be stable,
                   8364:         such that consecutive invocations of this algorithm serialize an
                   8365:         element's attributes in the same order.</p>
                   8366: 
1.588     mike     8367:         <p>Append a U+003E GREATER-THAN SIGN character (&gt;).</p>
1.1       mike     8368: 
                   8369:         <p>If <var title="">current node</var> is an
1.5       mike     8370:         <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     8371:         <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     8372:         <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>,
                   8373:         <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     8374:         <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     8375:         <code><a href="obsolete.html#wbr">wbr</a></code> element, then continue on to the next child
1.589     mike     8376:         node at this point.</p> <!-- also, i guess: image and isindex,
                   8377:         but we don't list those because we don't consider those
                   8378:         "elements", more "macros", and thus we should never serialize
                   8379:         them -->
1.1       mike     8380: 
                   8381:         <p>If <var title="">current node</var> is a <code><a href="semantics.html#the-pre-element">pre</a></code>,
1.42      mike     8382:         <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     8383:         a U+000A LINE FEED (LF) character.</p>
                   8384: 
                   8385:         <p>Append the value of running the <a href="#html-fragment-serialization-algorithm">HTML fragment
                   8386:         serialization algorithm</a> on the <var title="">current
                   8387:         node</var> element (thus recursing into this algorithm for
1.588     mike     8388:         that element), followed by a U+003C LESS-THAN SIGN character
                   8389:         (&lt;), a U+002F SOLIDUS character (/), the element's tag name
                   8390:         again, and finally a U+003E GREATER-THAN SIGN character
                   8391:         (&gt;).</p>
1.1       mike     8392: 
                   8393:        </dd>
                   8394: 
                   8395: 
                   8396:        <dt>If <var title="">current node</var> is a <code title="">Text</code> or <code title="">CDATASection</code>
                   8397:        node</dt>
                   8398: 
                   8399:        <dd>
                   8400: 
1.19      mike     8401:         <p>If the parent of <var title="">current node</var> is a
1.42      mike     8402:         <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     8403:         <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     8404:         <code><a href="obsolete.html#noframes">noframes</a></code>, or <code><a href="obsolete.html#plaintext">plaintext</a></code> element, or
                   8405:         if the parent of <var title="">current node</var> is
1.755     mike     8406:         <code><a href="semantics.html#the-noscript-element">noscript</a></code> element and <a href="web-application-apis.html#concept-n-script" title="concept-n-script">scripting is enabled</a> for the
1.222     mike     8407:         node, then append the value of <var title="">current
                   8408:         node</var>'s <code title="">data</code> IDL attribute
                   8409:         literally.</p>
1.1       mike     8410: 
                   8411:         <p>Otherwise, append the value of <var title="">current
1.192     mike     8412:         node</var>'s <code title="">data</code> IDL attribute, <a href="#escapingString" title="escaping a string">escaped as described
1.1       mike     8413:         below</a>.</p>
                   8414: 
                   8415:        </dd>
                   8416: 
                   8417: 
                   8418:        <dt>If <var title="">current node</var> is a <code title="">Comment</code></dt>
                   8419: 
                   8420:        <dd>
                   8421: 
                   8422:         <p>Append the literal string <code>&lt;!--</code> (U+003C
                   8423:         LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS,
1.192     mike     8424:         U+002D HYPHEN-MINUS), followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1       mike     8425:         attribute, followed by the literal string <code>--&gt;</code>
                   8426:         (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN
                   8427:         SIGN).</p>
                   8428: 
                   8429:        </dd>
                   8430: 
                   8431: 
                   8432:        <dt>If <var title="">current node</var> is a <code title="">ProcessingInstruction</code></dt>
                   8433: 
                   8434:        <dd>
                   8435: 
                   8436:         <p>Append the literal string <code>&lt;?</code> (U+003C
                   8437:         LESS-THAN SIGN, U+003F QUESTION MARK), followed by the value
1.192     mike     8438:         of <var title="">current node</var>'s <code title="">target</code> IDL attribute, followed by a single
                   8439:         U+0020 SPACE character, followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1       mike     8440:         attribute, followed by a single U+003E GREATER-THAN SIGN
1.464     mike     8441:         character (&gt;).</p>
1.1       mike     8442: 
                   8443:        </dd>
                   8444: 
                   8445: 
                   8446:        <dt>If <var title="">current node</var> is a <code title="">DocumentType</code></dt>
                   8447: 
                   8448:        <dd>
                   8449: 
                   8450:         <p>Append the literal string <code>&lt;!DOCTYPE</code> (U+003C
                   8451:         LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+0044 LATIN CAPITAL
                   8452:         LETTER D, U+004F LATIN CAPITAL LETTER O, U+0043 LATIN CAPITAL
                   8453:         LETTER C, U+0054 LATIN CAPITAL LETTER T, U+0059 LATIN CAPITAL
                   8454:         LETTER Y, U+0050 LATIN CAPITAL LETTER P, U+0045 LATIN CAPITAL
                   8455:         LETTER E), followed by a space (U+0020 SPACE), followed by the
1.192     mike     8456:         value of <var title="">current node</var>'s <code title="">name</code> IDL attribute, followed by the literal
1.1       mike     8457:         string <code>&gt;</code> (U+003E GREATER-THAN SIGN).</p>
                   8458: 
                   8459:        </dd>
                   8460: 
                   8461: 
                   8462:       </dl><p>Other node types (e.g. <code title="">Attr</code>) cannot
                   8463:       occur as children of elements. If, despite this, they somehow do
                   8464:       occur, this algorithm must raise an
                   8465:       <code><a href="infrastructure.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception.</p>
                   8466: 
                   8467:      </li>
                   8468: 
                   8469:     </ol></li>
                   8470: 
                   8471:    <li><p>The result of the algorithm is the string <var title="">s</var>.</p></li>
                   8472: 
                   8473:   </ol><p><dfn id="escapingString">Escaping a string</dfn> (for the
                   8474:   purposes of the algorithm above) consists of replacing any
                   8475:   occurrences of the "<code title="">&amp;</code>" character by the
                   8476:   string "<code title="">&amp;amp;</code>", any occurrences of the
                   8477:   U+00A0 NO-BREAK SPACE character by the string "<code title="">&amp;nbsp;</code>", and, if the algorithm was invoked in
                   8478:   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
                   8479:   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>
                   8480: 
                   8481:   <p class="note">Entity reference nodes are <a href="infrastructure.html#entity-references">assumed to be expanded</a> by the user
                   8482:   agent, and are therefore not covered in the algorithm above.</p>
                   8483: 
                   8484:   <p class="note">It is possible that the output of this algorithm, if
                   8485:   parsed with an <a href="#html-parser">HTML parser</a>, will not return the
                   8486:   original tree structure. For instance, if a <code><a href="forms.html#the-textarea-element">textarea</a></code>
                   8487:   element to which a <code title="">Comment</code> node has been
                   8488:   appended is serialized and the output is then reparsed, the comment
                   8489:   will end up being displayed in the text field. Similarly, if, as a
                   8490:   result of DOM manipulation, an element contains a comment that
                   8491:   contains the literal string "<code title="">--&gt;</code>", then
                   8492:   when the result of serializing the element is parsed, the comment
                   8493:   will be truncated at that point and the rest of the comment will be
                   8494:   interpreted as markup. More examples would be making a
                   8495:   <code><a href="semantics.html#script">script</a></code> element contain a text node with the text string
                   8496:   "<code>&lt;/script&gt;</code>", or having a <code><a href="semantics.html#the-p-element">p</a></code> element that
                   8497:   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
                   8498:   <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> would imply the end
                   8499:   tag for the <code><a href="semantics.html#the-p-element">p</a></code>).</p>
                   8500: 
                   8501: 
1.755     mike     8502:   <h3 id="parsing-html-fragments"><span class="secno">8.4 </span>Parsing HTML fragments</h3><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1       mike     8503: 
                   8504:   <p>The following steps form the <dfn id="html-fragment-parsing-algorithm">HTML fragment parsing
                   8505:   algorithm</dfn>. The algorithm optionally takes as input an
                   8506:   <code>Element</code> node, referred to as the <var title="">context</var> element, which gives the context for the
                   8507:   parser, as well as <var title="">input</var>, a string to parse, and
                   8508:   returns a list of zero or more nodes.</p>
                   8509: 
                   8510:   <p class="note">Parts marked <dfn id="fragment-case">fragment case</dfn> in algorithms
                   8511:   in the parser section are parts that only occur if the parser was
                   8512:   created for the purposes of this algorithm (and with a <var title="">context</var> element). The algorithms have been annotated
                   8513:   with such markings for informational purposes only; such markings
                   8514:   have no normative weight. If it is possible for a condition
                   8515:   described as a <a href="#fragment-case">fragment case</a> to occur even when the
                   8516:   parser wasn't created for the purposes of handling this algorithm,
                   8517:   then that is an error in the specification.</p>
                   8518: 
                   8519:   <ol><li>
                   8520: 
                   8521:     <p>Create a new <code>Document</code> node, and mark it as being
                   8522:     an <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
                   8523: 
                   8524:    </li>
                   8525: 
                   8526:    <li>
                   8527: 
                   8528:     <p>If there is a <var title="">context</var> element, and the
                   8529:     <code>Document</code> of the <var title="">context</var> element
                   8530:     is in <a href="dom.html#quirks-mode">quirks mode</a>, then let the <code>Document</code>
                   8531:     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
                   8532:     the <var title="">context</var> element is in <a href="dom.html#limited-quirks-mode">limited quirks
                   8533:     mode</a>, then let the <code>Document</code> be in
                   8534:     <a href="dom.html#limited-quirks-mode">limited quirks mode</a>. Otherwise, leave the
                   8535:     <code>Document</code> in <a href="dom.html#no-quirks-mode">no quirks mode</a>.</p>
                   8536: 
                   8537:    </li>
                   8538: 
                   8539:    <li>
                   8540: 
                   8541:     <p>Create a new <a href="#html-parser">HTML parser</a>, and associate it with
                   8542:     the just created <code>Document</code> node.</p>
                   8543: 
                   8544:    </li>
                   8545: 
                   8546:    <li>
                   8547: 
                   8548:     <p>If there is a <var title="">context</var> element, run these
                   8549:     substeps:</p>
                   8550: 
                   8551:     <ol><li>
                   8552: 
1.541     mike     8553:       <p>Set the state of the <a href="#html-parser">HTML parser</a>'s
                   8554:       <a href="#tokenization">tokenization</a> stage as follows:</p>
1.1       mike     8555: 
1.159     mike     8556:       <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     8557:        element</dt>
                   8558: 
1.541     mike     8559:        <dd>Switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1       mike     8560: 
                   8561: 
1.672     mike     8562:        <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>,
                   8563:        <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     8564:        <code><a href="obsolete.html#noframes">noframes</a></code> element</dt>
1.1       mike     8565: 
1.541     mike     8566:        <dd>Switch the tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1       mike     8567: 
                   8568: 
1.672     mike     8569:        <dt>If it is a <code><a href="semantics.html#script">script</a></code> element</dt>
                   8570: 
                   8571:        <dd>Switch the tokenizer to the <a href="#script-data-state">script data state</a>.</dd>
                   8572: 
                   8573: 
1.1       mike     8574:        <dt>If it is a <code><a href="semantics.html#the-noscript-element">noscript</a></code> element</dt>
                   8575: 
1.541     mike     8576:        <dd>If the <a href="#scripting-flag">scripting flag</a> is enabled, switch the
                   8577:        tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>.  Otherwise,
                   8578:        leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1       mike     8579: 
                   8580: 
1.42      mike     8581:        <dt>If it is a <code><a href="obsolete.html#plaintext">plaintext</a></code> element</dt>
1.1       mike     8582: 
1.541     mike     8583:        <dd>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT
                   8584:        state</a>.</dd>
1.1       mike     8585: 
                   8586: 
                   8587:        <dt>Otherwise</dt>
                   8588: 
1.541     mike     8589:        <dd>Leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1       mike     8590: 
1.672     mike     8591:       </dl><p class="note">For performance reasons, an implementation that
1.756     mike     8592:       does not report errors and that uses the actual state machine
                   8593:       described in this specification directly could use the PLAINTEXT
                   8594:       state instead of the RAWTEXT and script data states where those
                   8595:       are mentioned in the list above. Except for rules regarding
                   8596:       parse errors, they are equivalent, since there is no
                   8597:       <a href="#appropriate-end-tag-token">appropriate end tag token</a> in the fragment case, yet
                   8598:       they involve far fewer state transitions.</p>
1.672     mike     8599: 
                   8600:      </li>
1.1       mike     8601: 
                   8602:      <li>
                   8603: 
1.159     mike     8604:       <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     8605:       with no attributes.</p>
                   8606: 
                   8607:      </li>
                   8608: 
                   8609:      <li>
                   8610: 
                   8611:       <p>Append the element <var title="">root</var> to the
                   8612:       <code>Document</code> node created above.</p>
                   8613: 
                   8614:      </li>
                   8615: 
                   8616:      <li>
                   8617: 
                   8618:       <p>Set up the parser's <a href="#stack-of-open-elements">stack of open elements</a> so that
                   8619:       it contains just the single element <var title="">root</var>.</p>
                   8620: 
                   8621:      </li>
                   8622: 
                   8623:      <li>
                   8624: 
                   8625:       <p><a href="#reset-the-insertion-mode-appropriately" title="reset the insertion mode appropriately">Reset the
                   8626:       parser's insertion mode appropriately</a>.</p>
                   8627: 
                   8628:       <p class="note">The parser will reference the <var title="">context</var> element as part of that algorithm.</p>
                   8629: 
                   8630:      </li>
                   8631: 
                   8632:      <li>
                   8633: 
                   8634:       <p>Set the parser's <a href="#form-element-pointer"><code>form</code> element pointer</a>
                   8635:       to the nearest node to the <var title="">context</var> element
                   8636:       that is a <code><a href="forms.html#the-form-element">form</a></code> element (going straight up the
                   8637:       ancestor chain, and including the element itself, if it is a
                   8638:       <code><a href="forms.html#the-form-element">form</a></code> element), or, if there is no such
                   8639:       <code><a href="forms.html#the-form-element">form</a></code> element, to null.</p>
                   8640: 
                   8641:      </li>
                   8642: 
                   8643:     </ol></li>
                   8644: 
                   8645:    <li>
                   8646: 
                   8647:     <p>Place into the <a href="#the-input-stream">input stream</a> for the <a href="#html-parser">HTML
                   8648:     parser</a> just created the <var title="">input</var>. The
                   8649:     encoding <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
                   8650:     <i>irrelevant</i>.</p>
                   8651: 
                   8652:    </li>
                   8653: 
                   8654:    <li>
                   8655: 
                   8656:     <p>Start the parser and let it run until it has consumed all the
                   8657:     characters just inserted into the input stream.</p>
                   8658: 
                   8659:    </li>
                   8660: 
                   8661:    <li>
                   8662: 
                   8663:     <p>If there is a <var title="">context</var> element, return the
                   8664:     child nodes of <var title="">root</var>, in <a href="infrastructure.html#tree-order">tree
                   8665:     order</a>.</p>
                   8666: 
                   8667:     <p>Otherwise, return the children of the <code>Document</code>
                   8668:     object, in <a href="infrastructure.html#tree-order">tree order</a>.</p>
                   8669: 
                   8670:    </li>
                   8671: 
1.123     mike     8672:   </ol></div></body></html>

Webmaster