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

1.872     mike        1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
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; }
1.840     mike       47:    dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
1.1       mike       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:    ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
                    146:    ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
                    147:    ul.domTree li li { list-style: none; }
                    148:    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; }
                    149:    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; }
                    150:    ul.domTree span { font-style: italic; font-family: serif; }
                    151:    ul.domTree .t1 code { color: purple; font-weight: bold; }
                    152:    ul.domTree .t2 { font-style: normal; font-family: monospace; }
                    153:    ul.domTree .t2 .name { color: black; font-weight: bold; }
                    154:    ul.domTree .t2 .value { color: blue; font-weight: normal; }
                    155:    ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
                    156:    ul.domTree .t7 code, .domTree .t8 code { color: green; }
                    157:    ul.domTree .t10 code { color: teal; }
                    158: 
1.736     mike      159:    body.dfnEnabled dfn { cursor: pointer; }
                    160:    .dfnPanel {
                    161:      display: inline;
                    162:      position: absolute;
                    163:      z-index: 10;
                    164:      height: auto;
                    165:      width: auto;
                    166:      padding: 0.5em 0.75em;
                    167:      font: small sans-serif, Droid Sans Fallback;
                    168:      background: #DDDDDD;
                    169:      color: black;
                    170:      border: outset 0.2em;
                    171:    }
                    172:    .dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
                    173:    .dfnPanel :link, .dfnPanel :visited { color: black; }
                    174:    .dfnPanel p { font-weight: bolder; }
                    175:    .dfnPanel * + p { margin-top: 0.25em; }
                    176:    .dfnPanel li { list-style-position: inside; }
                    177: 
1.671     mike      178:    #configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
                    179:    #configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
                    180:    #configUI p label { display: block; }
                    181:    #configUI #updateUI, #configUI .loginUI { text-align: center; }
                    182:    #configUI input[type=button] { display: block; margin: auto; }
1.267     mike      183:   </style><style type="text/css">
                    184: 
1.292     mike      185:    .applies thead th > * { display: block; }
                    186:    .applies thead code { display: block; }
                    187:    .applies tbody th { whitespace: nowrap; }
                    188:    .applies td { text-align: center; }
                    189:    .applies .yes { background: yellow; }
                    190: 
1.267     mike      191:    .matrix, .matrix td { border: none; text-align: right; }
                    192:    .matrix { margin-left: 2em; }
                    193: 
                    194:    .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
                    195:    .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
                    196:    .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
                    197: 
                    198:    #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
                    199:    #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
                    200:    #table-example-1 caption { padding-bottom: 0.5em; }
                    201:    #table-example-1 thead, #table-example-1 tbody { border: none; }
                    202:    #table-example-1 th, #table-example-1 td { border: solid thin; }
                    203:    #table-example-1 th { font-weight: normal; }
                    204:    #table-example-1 td { border-style: none solid; vertical-align: top; }
                    205:    #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
                    206:    #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
                    207:    #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
                    208:    #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
                    209:    #table-example-1 tbody td:first-child::after { content: leader(". "); }
                    210:    #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
                    211:    #table-example-1 tbody td:first-child + td { width: 10em; }
                    212:    #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
                    213:    #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
                    214: 
                    215:    .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
                    216:    .apple-table-examples * { font-family: "Times", serif; }
                    217:    .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
                    218:    .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
                    219:    .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
                    220:    .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
                    221:    .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
                    222:    .apple-table-examples td { text-align: right; vertical-align: top; }
                    223:    .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
                    224:    .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
                    225:    .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
                    226:    .apple-table-examples sup { line-height: 0; }
                    227: 
1.724     mike      228:    .details-example img { vertical-align: top; }
                    229: 
1.882     mike      230:    #named-character-references-table {
                    231:      font-size: 0.6em;
                    232:      column-width: 28em;
                    233:      column-gap: 1em;
                    234:      -moz-column-width: 28em;
                    235:      -moz-column-gap: 1em;
                    236:      -webkit-column-width: 28em;
                    237:      -webkit-column-gap: 1em;
                    238:    }
                    239:    #named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
                    240:    #named-character-references-table > table > tbody > tr > td:last-child:hover > span { position: absolute; top: auto; left: auto; margin-left: 0.5em; line-height: 1.2; font-size: 5em; border: outset; padding: 0.25em 0.5em; background: white; width: 1.25em; height: auto; text-align: center; }
                    241: 
1.872     mike      242:   </style><style type="text/css">
1.881     mike      243:    .domintro:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
                    244:   </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%0Ahtml%20%7B%20border:%20solid%20yellow;%20%7D%20.domintro:before%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%20.domintro:before%20%7B%20background:%20%23FFEEEE;%20%7D" id="highlight" rel="alternate stylesheet" title="Highlight implementation requirements"><script type="text/javascript">
1.671     mike      245:    function getCookie(name) {
                    246:      var params = location.search.substr(1).split("&");
                    247:      for (var index = 0; index < params.length; index++) {
                    248:        if (params[index] == name)
                    249:          return "1";
                    250:        var data = params[index].split("=");
                    251:        if (data[0] == name)
                    252:          return unescape(data[1]);
                    253:      }
                    254:      var cookies = document.cookie.split("; ");
                    255:      for (var index = 0; index < cookies.length; index++) {
                    256:        var data = cookies[index].split("=");
                    257:        if (data[0] == name)
                    258:          return unescape(data[1]);
                    259:      }
                    260:      return null;
                    261:    }
                    262:    function load(script) {
                    263:      var e = document.createElement('script');
                    264:      e.setAttribute('src', 'http://www.whatwg.org/specs/web-apps/current-work/' + script + '?' + encodeURIComponent(location) + '&' + encodeURIComponent(document.referrer));
                    265:      document.body.appendChild(e);
                    266:    }
                    267:    function init() {
                    268:      if (location.search == '?slow-browser')
                    269:        return;
                    270:      var configUI = document.createElement('div');
                    271:      configUI.id = 'configUI';
                    272:      document.body.appendChild(configUI);
                    273:      // load('reviewer.js'); // would need cross-site XHR
                    274:      if (document.getElementById('head'))
                    275:        load('toc.js');
                    276:      load('styler.js');
                    277:      // load('updater.js'); // would need cross-site XHR
1.724     mike      278:      load('dfn.js'); // doesn't support split-out specs, but, oh well.
1.671     mike      279:      // load('status.js'); // would need cross-site XHR
                    280:      if (getCookie('profile') == '1')
                    281:        document.getElementsByTagName('h2')[0].textContent += '; load: ' + (new Date() - loadTimer) + 'ms';
                    282:      fixBrokenLink();
                    283:    }
1.808     mike      284:   </script><link href="http://www.w3.org/StyleSheets/TR/W3C-WD" rel="stylesheet" type="text/css">
1.873     mike      285:   <script src="link-fixup.js" type="text/javascript"></script>
1.755     mike      286:   <link href="editing.html" title="7 User interaction" rel="prev">
1.2       mike      287:   <link href="spec.html#contents" title="Table of contents" rel="index">
1.755     mike      288:   <link href="named-character-references.html" title="8.5 Named character references" rel="next">
1.671     mike      289:   </head><body onload="fixBrokenLink(); init()"><div class="head" id="head">
1.1       mike      290:    <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      291:    <h1>HTML5</h1>
1.889   ! mike      292:    <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><p>This is revision 1.3973.</p>
1.885     mike      293: 
1.874     mike      294:    </div><div>
1.755     mike      295:    <a href="editing.html">&#8592; 7 User interaction</a> &#8211;
1.2       mike      296:    <a href="spec.html#contents">Table of contents</a> &#8211;
1.755     mike      297:    <a href="named-character-references.html">8.5 Named character references &#8594;</a>
1.874     mike      298:   </div>
1.1       mike      299: 
1.755     mike      300:   <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      301:   labeled with an <a href="infrastructure.html#html-mime-type">HTML MIME type</a>. Rules for XML resources
                    302:   are discussed in the section below entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
1.755     mike      303:   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      304: 
                    305:   <p><i>This section only applies to documents, authoring tools, and
                    306:   markup generators. In particular, it does not apply to conformance
                    307:   checkers; conformance checkers must use the requirements given in
                    308:   the next section ("parsing HTML documents").</i></p>
                    309: 
1.123     mike      310:   </div><p>Documents must consist of the following parts, in the given
                    311:   order:</p><ol><li>Optionally, a single U+FEFF BYTE ORDER MARK (BOM) character.</li>
1.1       mike      312: 
                    313:    <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
                    314:    <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    315: 
                    316:    <li>A <a href="#syntax-doctype" title="syntax-doctype">DOCTYPE</a>.
                    317: 
                    318:    </li><li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
                    319:    <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    320: 
1.159     mike      321:    <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      322: 
                    323:    <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
                    324:    <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    325: 
                    326:   </ol><p>The various types of content mentioned above are described in the
1.123     mike      327:   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      328:   declarations</a> are to be serialized, as discussed in the
1.123     mike      329:   section on that topic.</p><div class="note">
1.1       mike      330: 
1.159     mike      331:    <p>Space characters before the root <code><a href="semantics.html#the-html-element-0">html</a></code> element, and
                    332:    space characters at the start of the <code><a href="semantics.html#the-html-element-0">html</a></code> element and
                    333:    before the <code><a href="semantics.html#the-head-element-0">head</a></code> element, will be dropped when the
1.1       mike      334:    document is parsed; space characters <em>after</em> the root
1.159     mike      335:    <code><a href="semantics.html#the-html-element-0">html</a></code> element will be parsed as if they were at the end
                    336:    of the <code><a href="semantics.html#the-body-element-0">body</a></code> element. Thus, space characters around the
1.1       mike      337:    root element do not round-trip.</p>
                    338: 
                    339:    <p>It is suggested that newlines be inserted after the DOCTYPE,
                    340:    after any comments that are before the root element, after the
1.159     mike      341:    <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
                    342:    that are inside the <code><a href="semantics.html#the-html-element-0">html</a></code> element but before the
                    343:    <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1       mike      344: 
1.123     mike      345:   </div><p>Many strings in the HTML syntax (e.g. the names of elements and
1.1       mike      346:   their attributes) are case-insensitive, but only for characters in
1.547     mike      347:   the ranges U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL
                    348:   LETTER Z) and U+0061 to U+007A (LATIN SMALL LETTER A to LATIN SMALL
1.1       mike      349:   LETTER Z). For convenience, in this section this is just referred to
1.884     mike      350:   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) and <a href="http://www.w3.org/html/wg/tracker/issues/84">ISSUE-84</a> (legacy-doctypes) block progress to Last Call</span></p><p>A <dfn id="syntax-doctype" title="syntax-doctype">DOCTYPE</dfn> is a <!-- mostly
                    351:   useless but nonetheless --> required preamble.</p><p class="note">DOCTYPEs are required for legacy reasons. When
1.1       mike      352:   omitted, browsers tend to use a different rendering mode that is
                    353:   incompatible with some specifications. Including the DOCTYPE in a
                    354:   document ensures that the browser makes a best-effort attempt at
1.123     mike      355:   following the relevant specifications.</p><p>A DOCTYPE must consist of the following characters, in this
1.882     mike      356:   order:</p><ol class="brief"><li>A string that is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code title="">&lt;!DOCTYPE</code>".</li>
1.1       mike      357:    <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    358:    <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>
1.861     mike      359:    <li>Optionally, a <a href="#doctype-legacy-string">DOCTYPE legacy string</a> or an <a href="#obsolete-permitted-doctype-string">obsolete permitted DOCTYPE string</a> (defined below).</li>
1.1       mike      360:    <li>Zero or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
1.588     mike      361:    <li>A U+003E GREATER-THAN SIGN character (&gt;).</li>
1.1       mike      362:   </ol><p class="note">In other words, <code>&lt;!DOCTYPE HTML&gt;</code>,
1.861     mike      363:   case-insensitively.</p><hr><p>For the purposes of HTML generators that cannot output HTML
1.1       mike      364:   markup with the short DOCTYPE "<code title="">&lt;!DOCTYPE
                    365:   HTML&gt;</code>", a <dfn id="doctype-legacy-string">DOCTYPE legacy string</dfn> may be inserted
                    366:   into the DOCTYPE (in the position defined above). This string must
1.123     mike      367:   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      368:    <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      369:    <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
1.1       mike      370:    <li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>quote mark</i>).</li>
1.465     mike      371:    <li>The literal string "<code><a href="infrastructure.html#about:legacy-compat">about:legacy-compat</a></code>".</li>
1.856     mike      372:    <li>A matching U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (i.e. the same character as in the earlier step labeled <i>quote mark</i>).</li>
1.1       mike      373:   </ol><p class="note">In other words, <code>&lt;!DOCTYPE HTML SYSTEM
                    374:   "about:legacy-compat"&gt;</code> or <code>&lt;!DOCTYPE HTML SYSTEM
                    375:   'about:legacy-compat'&gt;</code>, case-insensitively except for the bit
1.724     mike      376:   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      377:   the document is generated from a system that cannot output the
1.861     mike      378:   shorter string.</p><hr><!-- see the parser section before changing this bit --><p>To help authors transition from HTML4 and XHTML1, an
                    379:   <dfn id="obsolete-permitted-doctype-string">obsolete permitted DOCTYPE string</dfn> can be inserted into
                    380:   the DOCTYPE (in the position defined above). This string must
                    381:   consist of:</p><ol class="brief"><li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    382:    <li>A string that is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code title="">PUBLIC</code>".</li>
                    383:    <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    384:    <li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>first quote mark</i>).</li>
                    385:    <li>The string from one of the cells in the first column of the table below. The row to which this cell belongs is the <i>selected row</i>.</li>
                    386:    <li>A matching U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (i.e. the same character as in the earlier step labeled <i>first quote mark</i>).</li>
                    387:    <li>If the cell in the second column of the <i>selected row</i> is not blank, one or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    388:    <li>If the cell in the second column of the <i>selected row</i> is not blank, a U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>third quote mark</i>).</li>
                    389:    <li>If the cell in the second column of the <i>selected row</i> is not blank, the string from the cell in the second column of the <i>selected row</i>.</li>
                    390:    <li>If the cell in the second column of the <i>selected row</i> is not blank, a matching U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (i.e. the same character as in the earlier step labeled <i>third quote mark</i>).</li>
                    391:   </ol><table><caption>
                    392:     Allowed values for public and system identifiers in an <a href="#obsolete-permitted-doctype-string">obsolete permitted DOCTYPE string</a>.
                    393:    </caption>
                    394:    <thead><tr><th> Public identifier
                    395:      </th><th> System identifier
                    396:    </th></tr></thead><tbody><tr><td> <code title="">-//W3C//DTD&#160;HTML&#160;4.0//EN</code>
                    397:      </td><td>
                    398:     </td></tr><tr><td> <code title="">-//W3C//DTD&#160;HTML&#160;4.0//EN</code>
                    399:      </td><td> <code title="">http://www.w3.org/TR/REC-html40/strict.dtd</code>
                    400:     </td></tr><tr><td> <code title="">-//W3C//DTD&#160;HTML&#160;4.01//EN</code>
                    401:      </td><td>
                    402:     </td></tr><tr><td> <code title="">-//W3C//DTD&#160;HTML&#160;4.01//EN</code>
                    403:      </td><td> <code title="">http://www.w3.org/TR/html4/strict.dtd</code>
                    404:     </td></tr><tr><td> <code title="">-//W3C//DTD&#160;XHTML&#160;1.0&#160;Strict//EN</code>
                    405:      </td><td> <code title="">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</code>
                    406:     </td></tr><tr><td> <code title="">-//W3C//DTD&#160;XHTML&#160;1.1//EN</code>
                    407:      </td><td> <code title="">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</code>
                    408:   </td></tr></tbody></table><p>A <a href="#syntax-doctype" title="syntax-doctype">DOCTYPE</a> containing an
                    409:   <a href="#obsolete-permitted-doctype-string">obsolete permitted DOCTYPE string</a> is an <dfn id="obsolete-permitted-doctype">obsolete
                    410:   permitted DOCTYPE</dfn>. Authors should not use <a href="#obsolete-permitted-doctype" title="obsolete permitted DOCTYPE">obsolete permitted
                    411:   DOCTYPEs</a>, as they are unnecessarily long.</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      412:   <a href="#raw-text-elements">raw text elements</a>, <a href="#rcdata-elements">RCDATA elements</a>,
                    413:   <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      414: 
                    415:    <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      416:    <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>,
                    417:    <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      418:    <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      419:    <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      420: 
1.373     mike      421:    <dt><dfn id="raw-text-elements">Raw text elements</dfn></dt>
1.1       mike      422: 
                    423:    <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      424:    noscript don't count as raw text for syntax purposes -->
1.1       mike      425: 
1.373     mike      426:    <dt><dfn id="rcdata-elements">RCDATA elements</dfn></dt>
1.1       mike      427: 
1.159     mike      428:    <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      429: 
1.373     mike      430:    <dt><dfn id="foreign-elements">Foreign elements</dfn></dt>
1.1       mike      431: 
1.724     mike      432:    <dd>Elements from the <a href="infrastructure.html#mathml-namespace">MathML namespace</a>
                    433:    and the <a href="infrastructure.html#svg-namespace">SVG namespace</a>.</dd>
1.1       mike      434: 
1.373     mike      435:    <dt><dfn id="normal-elements">Normal elements</dfn></dt>
1.1       mike      436: 
                    437:    <dd>All other allowed <a href="infrastructure.html#html-elements">HTML elements</a> are normal
                    438:    elements.</dd>
                    439: 
                    440:   </dl><p><dfn id="syntax-tags" title="syntax-tags">Tags</dfn> are used to delimit the start
1.373     mike      441:   and end of elements in the markup. <a href="#raw-text-elements" title="raw text
                    442:   elements">Raw text</a>, <a href="#rcdata-elements" title="RCDATA
                    443:   elements">RCDATA</a>, and <a href="#normal-elements" title="normal
                    444:   elements">normal</a> elements have a <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> to indicate where they
                    445:   begin, and an <a href="#syntax-end-tag" title="syntax-end-tag">end tag</a> to
                    446:   indicate where they end. The start and end tags of certain
                    447:   <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      448:   later. Those that cannot be omitted must not be omitted. <a href="#void-elements">Void
                    449:   elements</a> only have a start tag; end tags must not be
1.373     mike      450:   specified for <a href="#void-elements">void elements</a>. <a href="#foreign-elements">Foreign
                    451:   elements</a> must either have a start tag and an end tag, or a
                    452:   start tag that is marked as self-closing, in which case they must
                    453:   not have an end tag.</p><p>The contents of the element must be placed between just after the
1.1       mike      454:   start tag (which <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied,
                    455:   in certain cases</a>) and just before the end tag (which again,
                    456:   <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied in certain
                    457:   cases</a>). The exact allowed contents of each individual element
                    458:   depends on the content model of that element, as described earlier
                    459:   in this specification. Elements must not contain content that their
                    460:   content model disallows. In addition to the restrictions placed on
                    461:   the contents by those content models, however, the five types of
1.123     mike      462:   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      463:   no end tag, no content can be put between the start tag and the end
1.373     mike      464:   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
                    465:   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
                    466:   must not contain an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.
1.1       mike      467:   There are also <a href="#cdata-rcdata-restrictions">further
1.373     mike      468:   restrictions</a> described below.</p><p><a href="#foreign-elements">Foreign elements</a> whose start tag is marked as
                    469:   self-closing can't have any contents (since, again, as there's no
                    470:   end tag, no content can be put between the start tag and the end
                    471:   tag). <a href="#foreign-elements">Foreign elements</a> whose start tag is <em>not</em>
                    472:   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      473:   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      474: 
                    475:    <p>The HTML syntax does not support namespace
                    476:    declarations, even in <a href="#foreign-elements">foreign elements</a>.</p>
                    477: 
                    478:    <p>For instance, consider the following HTML fragment:</p>
                    479: 
                    480:    <pre>&lt;p&gt;
                    481:  &lt;svg&gt;
                    482:   &lt;metadata&gt;
                    483:    &lt;!-- this is invalid --&gt;
                    484:    &lt;cdr:license xmlns:cdr="http://www.example.com/cdr/metadata" name="MIT"/&gt;
                    485:   &lt;/metadata&gt;
                    486:  &lt;/svg&gt;
                    487: &lt;/p&gt;</pre>
                    488: 
                    489:    <p>The innermost element, <code title="">cdr:license</code>, is
                    490:    actually in the SVG namespace, as the "<code title="">xmlns:cdr</code>" attribute has no effect (unlike in
                    491:    XML). In fact, as the comment in the fragment above says, the
                    492:    fragment is actually non-conforming. This is because the SVG
                    493:    specification does not define any elements called "<code title="">cdr:license</code>" in the SVG namespace.</p>
                    494: 
                    495:   </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      496:   contain the character U+003C LESS-THAN SIGN (&lt;) or an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>. Some
                    497:   <a href="#normal-elements">normal elements</a> also have <a href="#element-restrictions">yet more restrictions</a> on what
1.1       mike      498:   content they are allowed to hold, beyond the restrictions imposed by
                    499:   the content model and those described in this paragraph. Those
1.123     mike      500:   restrictions are described below.</p><p>Tags contain a <dfn id="syntax-tag-name" title="syntax-tag-name">tag name</dfn>,
1.1       mike      501:   giving the element's name. HTML elements all have names that only
1.464     mike      502:   use characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
                    503:   NINE (9), U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER
                    504:   Z, and U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER
                    505:   Z. In the HTML syntax, tag names, even those for <a href="#foreign-elements">foreign
1.462     mike      506:   elements</a>, may be written with any mix of lower- and uppercase
                    507:   letters that, when converted to all-lowercase, matches the element's
1.755     mike      508:   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      509:   following format:</p><ol><li>The first character of a start tag must be a U+003C LESS-THAN
1.588     mike      510:    SIGN character (&lt;).</li>
1.1       mike      511: 
                    512:    <li>The next few characters of a start tag must be the element's
                    513:    <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
                    514: 
                    515:    <li>If there are to be any attributes in the next step, there must
                    516:    first be one or more <a href="infrastructure.html#space-character" title="space character">space
                    517:    characters</a>.</li>
                    518: 
                    519:    <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
                    520:    below. Attributes may be separated from each other by one or more
                    521:    <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
                    522: 
1.766     mike      523:    <li>After the attributes, or after the <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a> if there are no attributes,
                    524:    there may be one or more <a href="infrastructure.html#space-character" title="space character">space
                    525:    characters</a>. (Some attributes are required to be followed by
                    526:    a space. See the <a href="#syntax-attributes" title="syntax-attributes">attributes
                    527:    section</a> below.)</li>
1.1       mike      528: 
                    529:    <li>Then, if the element is one of the <a href="#void-elements">void elements</a>,
1.373     mike      530:    or if the element is a <a href="#foreign-elements" title="foreign elements">foreign
1.588     mike      531:    element</a>, then there may be a single U+002F SOLIDUS character
                    532:    (/). This character has no effect on <a href="#void-elements">void elements</a>,
                    533:    but on <a href="#foreign-elements">foreign elements</a> it marks the start tag as
                    534:    self-closing.</li>
1.1       mike      535: 
                    536:    <li>Finally, start tags must be closed by a U+003E GREATER-THAN
1.588     mike      537:    SIGN character (&gt;).</li>
1.1       mike      538: 
1.755     mike      539:   </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      540:   following format:</p><ol><li>The first character of an end tag must be a U+003C LESS-THAN
1.588     mike      541:    SIGN character (&lt;).</li>
1.1       mike      542: 
                    543:    <li>The second character of an end tag must be a U+002F SOLIDUS
1.588     mike      544:    character (/).</li>
1.1       mike      545: 
                    546:    <li>The next few characters of an end tag must be the element's
                    547:    <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
                    548: 
                    549:    <li>After the tag name, there may be one or more <a href="infrastructure.html#space-character" title="space
                    550:    character">space characters</a>.</li>
                    551: 
1.588     mike      552:    <li>Finally, end tags must be closed by a U+003E GREATER-THAN SIGN
                    553:    character (&gt;).</li>
1.1       mike      554: 
1.755     mike      555:   </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      556:   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      557:   one or more characters other than the <a href="infrastructure.html#space-character" title="space
                    558:   character">space characters</a>, U+0000 NULL, U+0022 QUOTATION
                    559:   MARK ("), U+0027 APOSTROPHE ('), U+003E GREATER-THAN SIGN
                    560:   (&gt;), U+002F SOLIDUS (/), and U+003D EQUALS SIGN (=) characters,
                    561:   the control characters, and any characters that are not defined by
1.462     mike      562:   Unicode. In the HTML syntax, attribute names, even those for
                    563:   <a href="#foreign-elements">foreign elements</a>, may be written with any mix of lower-
                    564:   and uppercase letters that are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.123     mike      565:   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      566:   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      567:   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      568: 
                    569:    <dd>
                    570: 
                    571:     <p>Just the <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute
1.837     mike      572:     name</a>. The value is implicitly the empty string.</p>
1.1       mike      573: 
                    574:     <div class="example">
                    575: 
                    576:      <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
                    577:      the empty attribute syntax:</p>
                    578: 
                    579:      <pre>&lt;input <em>disabled</em>&gt;</pre>
                    580: 
                    581:     </div>
                    582: 
                    583:     <p>If an attribute using the empty attribute syntax is to be
                    584:     followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
                    585:     character</a> separating the two.</p>
                    586: 
                    587:    </dd>
                    588: 
1.2       mike      589:    <dt id="unquoted">Unquoted attribute value syntax</dt>
1.1       mike      590: 
                    591:    <dd>
                    592: 
                    593:     <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
                    594:     followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
                    595:     characters</a>, followed by a single U+003D EQUALS SIGN
                    596:     character, followed by zero or more <a href="infrastructure.html#space-character" title="space
                    597:     character">space characters</a>, followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
                    598:     addition to the requirements given above for attribute values,
                    599:     must not contain any literal <a href="infrastructure.html#space-character" title="space character">space
1.588     mike      600:     characters</a>, any U+0022 QUOTATION MARK characters ("),
                    601:     U+0027 APOSTROPHE characters ('), U+003D EQUALS SIGN
                    602:     characters (=), U+003C LESS-THAN SIGN characters (&lt;), U+003E
                    603:     GREATER-THAN SIGN characters (&gt;), or U+0060 GRAVE ACCENT
                    604:     characters (`), and must not be the empty string.</p>
1.463     mike      605: 
                    606:     <!-- The ` character is in this list on a temporary basis, waiting
                    607:          for IE to fix it's parsing bug whereby it treats ` as an
                    608:          attribute value delimiter. Otherwise, escaping software that
                    609:          tries to be clever and not use quotes when it doesn't need to
                    610:          could be tricked by an attacker.
                    611: 
                    612:          Posit a site that allows the user to input text that is used
                    613:          verbatim in two attributes, such that the user can set the
                    614:          first attribute's value to:
                    615: 
                    616:             `
                    617: 
                    618:          ...and the second to:
                    619: 
                    620:             ` onload='...payload...' end=x
                    621: 
                    622:          ...with the assumption that the site is going to not quote
                    623:          the first one, and quote the second one with double quotes:
                    624: 
                    625:             <body title=` class="` onload='...payload...' end=x">
                    626: 
                    627:          In IE, this is treated as:
                    628: 
                    629:             <body title=' class="'
                    630:                   onload='...payload...'
                    631:                   end='x"'>
                    632: 
                    633:     -->
                    634: 
1.1       mike      635: 
                    636:     <div class="example">
                    637: 
                    638:      <p>In the following example, the <code title="attr-input-value"><a href="forms.html#attr-input-value">value</a></code> attribute is given
                    639:      with the unquoted attribute value syntax:</p>
                    640: 
                    641:      <pre>&lt;input <em>value=yes</em>&gt;</pre>
                    642: 
                    643:     </div>
                    644: 
                    645:     <p>If an attribute using the unquoted attribute syntax is to be
1.101     mike      646:     followed by another attribute or by the optional U+002F SOLIDUS
1.464     mike      647:     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      648:     must be a <a href="infrastructure.html#space-character">space character</a> separating the two.</p>
                    649: 
                    650:    </dd>
                    651: 
                    652:    <dt>Single-quoted attribute value syntax</dt>
                    653: 
                    654:    <dd>
                    655: 
                    656:     <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
                    657:     followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
                    658:     characters</a>, followed by a single U+003D EQUALS SIGN
                    659:     character, followed by zero or more <a href="infrastructure.html#space-character" title="space
                    660:     character">space characters</a>, followed by a single U+0027
1.588     mike      661:     APOSTROPHE character ('), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1       mike      662:     addition to the requirements given above for attribute values,
1.588     mike      663:     must not contain any literal U+0027 APOSTROPHE characters ('), and
                    664:     finally followed by a second single U+0027 APOSTROPHE character
                    665:     (').</p>
1.1       mike      666: 
                    667:     <div class="example">
                    668: 
                    669:      <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
                    670:      single-quoted attribute value syntax:</p>
                    671: 
                    672:      <pre>&lt;input <em>type='checkbox'</em>&gt;</pre>
                    673: 
                    674:     </div>
                    675: 
                    676:     <p>If an attribute using the single-quoted attribute syntax is to
                    677:     be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
                    678:     character</a> separating the two.</p>
                    679: 
                    680:    </dd>
                    681: 
                    682:    <dt>Double-quoted attribute value syntax</dt>
                    683: 
                    684:    <dd>
                    685: 
                    686:     <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
                    687:     followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
                    688:     characters</a>, followed by a single U+003D EQUALS SIGN
                    689:     character, followed by zero or more <a href="infrastructure.html#space-character" title="space
                    690:     character">space characters</a>, followed by a single U+0022
1.588     mike      691:     QUOTATION MARK character ("), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1       mike      692:     addition to the requirements given above for attribute values,
1.588     mike      693:     must not contain any literal U+0022 QUOTATION MARK characters ("),
                    694:     and finally followed by a second single U+0022 QUOTATION MARK
                    695:     character (").</p>
1.1       mike      696: 
                    697:     <div class="example">
                    698: 
                    699:      <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
                    700:      double-quoted attribute value syntax:</p>
                    701: 
                    702:      <pre>&lt;input <em>name="be evil"</em>&gt;</pre>
                    703: 
                    704:     </div>
                    705: 
                    706:     <p>If an attribute using the double-quoted attribute syntax is to
                    707:     be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
                    708:     character</a> separating the two.</p>
                    709: 
                    710:    </dd>
                    711: 
                    712:   </dl><p>There must never be two or more attributes on the same start tag
                    713:   whose names are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for
1.462     mike      714:   each other.</p><hr><p>When a <a href="#foreign-elements" title="foreign elements">foreign element</a> has
                    715:   one of the namespaced attributes given by the local name and
                    716:   namespace of the first and second cells of a row from the following
                    717:   table, it must be written using the name given by the third cell
                    718:   from the same row.</p><table><thead><tr><th> Local name </th><th> Namespace </th><th> Attribute name
1.724     mike      719:    </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>
                    720:     </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>
                    721:     </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>
                    722:     </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>
                    723:     </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>
                    724:     </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>
                    725:     </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>
                    726:     </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>
                    727:     </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>
                    728:     </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>
                    729:     </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>
                    730:     </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      731:   </td></tr></tbody></table><p>No other namespaced attribute can be expressed in <a href="#syntax">the
1.755     mike      732:   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      733:   is not present; it is implied, but it is still there. An HTML
1.159     mike      734:   document always has a root <code><a href="semantics.html#the-html-element-0">html</a></code> element, even if the
1.1       mike      735:   string <code title="">&lt;html&gt;</code> doesn't appear anywhere in
1.159     mike      736:   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
                    737:   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
                    738:   tag</a> may be omitted if the <code><a href="semantics.html#the-html-element-0">html</a></code> element is not
1.821     mike      739:   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
                    740:   element is empty, or if the first thing inside the
1.159     mike      741:   <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
                    742:   tag</a> may be omitted if the <code><a href="semantics.html#the-head-element-0">head</a></code> element is not
                    743:   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
                    744:   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      745:   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      746:   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      747:   <code><a href="semantics.html#the-style-element">style</a></code> element. <!-- Note that even if the </head> end
1.872     mike      748:   tag is present, the parser makes <style type="text/css"> and <script type="text/javascript"> elements
1.1       mike      749:   between </head> and <body> end up in the <head> instead of implying
1.159     mike      750:   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
                    751:   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      752:   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      753:   tag</a> may be omitted if the <code><a href="semantics.html#the-li-element">li</a></code> element is
                    754:   immediately followed by another <code><a href="semantics.html#the-li-element">li</a></code> element or if there
1.422     mike      755:   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      756:   tag</a> may be omitted if the <code><a href="semantics.html#the-dt-element">dt</a></code> element is
                    757:   immediately followed by another <code><a href="semantics.html#the-dt-element">dt</a></code> element or a
1.123     mike      758:   <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      759:   tag</a> may be omitted if the <code><a href="semantics.html#the-dd-element">dd</a></code> element is
                    760:   immediately followed by another <code><a href="semantics.html#the-dd-element">dd</a></code> element or a
                    761:   <code><a href="semantics.html#the-dt-element">dt</a></code> element, or if there is no more content in the
1.123     mike      762:   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      763:   tag</a> may be omitted if the <code><a href="semantics.html#the-p-element">p</a></code> element is
                    764:   immediately followed by an <code><a href="semantics.html#the-address-element">address</a></code>,
                    765:   <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      766:   <!--v2DATAGRID <code>datagrid</code>,--> <code><a href="obsolete.html#dir">dir</a></code>,
1.306     mike      767:   <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      768:   <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>,
                    769:   <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>,
                    770:   <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>,
                    771:   <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>,
                    772:   <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      773:   <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>,
                    774:   element, or if there is no more content in the parent element and
1.123     mike      775:   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      776:   tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rt-element">rt</a></code> element is
                    777:   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      778:   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      779:   tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rp-element">rp</a></code> element is
                    780:   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      781:   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      782:   <select>; commented out text below can handle the non-<select> case
1.123     mike      783:   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      784:   <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element <!--has an ancestor
                    785:   <code>select</code> element and--> is immediately followed by
                    786:   another <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or if <!--all of the elements
                    787:   that are ancestors of the <code>optgroup</code> element, up to and
                    788:   including the first ancestor element that is not an
                    789:   <code>optgroup</code> element, have no more content--> there is no
1.123     mike      790:   more content in the parent element.</p><!-- so e.g. the max number of </optgroup>s are omitted here:
1.1       mike      791:    <select><optgroup></select>
                    792:    <p id=x><optgroup></optgroup>x</p>
                    793:    <p id=x><optgroup><optgroup></optgroup></optgroup>x</p>
                    794:    <p><optgroup id=x><optgroup></optgroup>x</p>
                    795:    <p><optgroup><optgroup id=x>x</p>
1.123     mike      796:   --><!-- </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      797:   tag</a> may be omitted if the <code><a href="forms.html#the-option-element">option</a></code> element is
                    798:   immediately followed by another <code><a href="forms.html#the-option-element">option</a></code> element, or if
                    799:   it is immediately followed by an <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or
1.123     mike      800:   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      801:   first thing inside the <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is a
                    802:   <code><a href="tabular-data.html#the-col-element">col</a></code> element, and if the element is not immediately
                    803:   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      804:   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      805:   <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is not immediately followed by a
1.123     mike      806:   <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      807:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-thead-element">thead</a></code> element is
                    808:   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      809:   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      810:   first thing inside the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is a
                    811:   <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, and if the element is not immediately
                    812:   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
                    813:   <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element whose <a href="#syntax-end-tag" title="syntax-end-tag">end
                    814:   tag</a> has been omitted. (It can't be omitted if the element is
1.123     mike      815:   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      816:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is
                    817:   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      818:   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      819:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element is
                    820:   immediately followed by a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element, or if there is
1.123     mike      821:   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      822:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
                    823:   immediately followed by another <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, or if there
1.123     mike      824:   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      825:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-td-element">td</a></code> element is
                    826:   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      827:   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      828:   tag</a> may be omitted if the <code><a href="tabular-data.html#the-th-element">th</a></code> element is
                    829:   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      830:   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      831:   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      832:   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      833:   elements, even though these elements are technically allowed inside
                    834:   <code><a href="tabular-data.html#the-table-element">table</a></code> elements according to the content models
                    835:   described in this specification. (If a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
                    836:   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      837:   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
                    838:   placed immediately after the <a href="#syntax-start-tag" title="syntax-start-tag">start
1.1       mike      839:   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>
                    840:   elements. This does not affect the processing of the element. The
1.304     mike      841:   otherwise optional <a href="#syntax-newlines" title="syntax-newlines">newline</a>
1.381     mike      842:   <em>must</em> be included if the element's contents themselves start
                    843:   with a <a href="#syntax-newlines" title="syntax-newlines">newline</a> (because
                    844:   otherwise the leading newline in the contents would be treated like
                    845:   the optional newline, and ignored).</p><div class="example">
1.1       mike      846:    <p>The following two <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are equivalent:</p>
                    847:    <pre>&lt;pre&gt;Hello&lt;/pre&gt;</pre>
                    848:    <pre>&lt;pre&gt;<br>Hello&lt;/pre&gt;</pre>
1.755     mike      849:   </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.889   ! mike      850:   <a href="#rcdata-elements">RCDATA elements</a> must not contain any occurrences of the
        !           851:   string "<code title="">&lt;/</code>" (U+003C LESS-THAN SIGN, U+002F
        !           852:   SOLIDUS) followed by characters that case-insensitively match the
        !           853:   tag name of the element followed by one of U+0009 CHARACTER
        !           854:   TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D
        !           855:   CARRIAGE RETURN (CR), U+0020 SPACE, U+003E GREATER-THAN SIGN (&gt;), or
        !           856:   U+002F SOLIDUS (/).</p><h4 id="text-0"><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      857:   attributes, and comments. Text must consist of Unicode characters.
                    858:   Text must not contain U+0000 characters. Text must not contain
1.316     mike      859:   permanently undefined Unicode characters (noncharacters). Text must
                    860:   not contain control characters other than <a href="infrastructure.html#space-character" title="space
                    861:   character">space characters</a>. Extra constraints are placed on
                    862:   what is and what is not allowed in text based on where the text is
1.755     mike      863:   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      864:   represented either as U+000D CARRIAGE RETURN (CR) characters, U+000A
                    865:   LINE FEED (LF) characters, or pairs of U+000D CARRIAGE RETURN (CR),
1.882     mike      866:   U+000A LINE FEED (LF) characters in that order.</p><p>Where <a href="#syntax-charref" title="syntax-charref">character references</a>
                    867:   are allowed, a character reference of a U+000A LINE FEED (LF)
                    868:   character (but not a U+000D CARRIAGE RETURN (CR) character) also
                    869:   represents a <a href="#syntax-newlines" title="syntax-newlines">newline</a>.</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      870:   to escape characters that couldn't otherwise legally be included in
1.588     mike      871:   <a href="#syntax-text" title="syntax-text">text</a>.</p><p>Character references must start with a U+0026 AMPERSAND character
                    872:   (&amp;). Following this, there are three possible kinds of character
                    873:   references:</p><dl><dt>Named character references</dt>
1.1       mike      874: 
                    875:    <dd>The ampersand must be followed by one of the names given in the
                    876:    <a href="named-character-references.html#named-character-references">named character references</a> section, using the same
1.677     mike      877:    case. <span class="impl">The name must be one that is terminated by
                    878:    a U+003B SEMICOLON character (;).</span></dd>
1.1       mike      879: 
                    880: 
                    881:    <dt>Decimal numeric character reference</dt>
                    882: 
                    883:    <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588     mike      884:    character (#), followed by one or more digits in the range U+0030
                    885:    DIGIT ZERO (0) to U+0039 DIGIT NINE (9), representing a base-ten
                    886:    integer that corresponds to a Unicode code point that is allowed
                    887:    according to the definition below. The digits must then be followed
                    888:    by a U+003B SEMICOLON character (;).</dd>
1.1       mike      889: 
                    890: 
                    891:    <dt>Hexadecimal numeric character reference</dt>
                    892: 
                    893:    <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588     mike      894:    character (#), which must be followed by either a U+0078 LATIN
                    895:    SMALL LETTER X character (x) or a U+0058 LATIN CAPITAL LETTER X
                    896:    character (X), which must then be followed by one or more digits in
                    897:    the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061
                    898:    LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041
                    899:    LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F,
1.464     mike      900:    representing a base-sixteen integer that corresponds to a Unicode
                    901:    code point that is allowed according to the definition below. The
                    902:    digits must then be followed by a U+003B SEMICOLON character
                    903:    (;).</dd>
1.378     mike      904: 
                    905:   </dl><p>The numeric character reference forms described above are allowed
1.882     mike      906:   to reference any Unicode code point other than U+0000, U+000D,
                    907:   permanently undefined Unicode characters (noncharacters), and
                    908:   control characters other than <a href="infrastructure.html#space-character" title="space character">space
1.378     mike      909:   characters</a>.</p><p>An <dfn id="syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous
1.464     mike      910:   ampersand</dfn> is a U+0026 AMPERSAND character (&amp;) that is
                    911:   followed by some <a href="#syntax-text" title="syntax-text">text</a> other than a
                    912:   <a href="infrastructure.html#space-character">space character</a>, a U+003C LESS-THAN SIGN character
1.755     mike      913:   (&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      914:   the character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
                    915:   MARK, U+005B LEFT SQUARE BRACKET, U+0043 LATIN CAPITAL LETTER C,
                    916:   U+0044 LATIN CAPITAL LETTER D, U+0041 LATIN CAPITAL LETTER A, U+0054
                    917:   LATIN CAPITAL LETTER T, U+0041 LATIN CAPITAL LETTER A, U+005B LEFT
                    918:   SQUARE BRACKET (<code title="">&lt;![CDATA[</code>). Following this
                    919:   sequence, the CDATA section may have <a href="#syntax-text" title="syntax-text">text</a>, with the additional restriction
                    920:   that the text must not contain the three character sequence U+005D
                    921:   RIGHT SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E
                    922:   GREATER-THAN SIGN (<code title="">]]&gt;</code>). Finally, the CDATA
                    923:   section must be ended by the three character sequence U+005D RIGHT
                    924:   SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E GREATER-THAN
1.724     mike      925:   SIGN (<code title="">]]&gt;</code>).</p><div class="example">
                    926: 
                    927:    <p>CDATA sections can only be used in foreign content (MathML or
                    928:    SVG). In this example, a CDATA section is used to escape the
                    929:    contents of an <code>ms</code> element:</p>
                    930: 
                    931:    <pre>&lt;p&gt;You can add a string to a number, but this stringifies the number:&lt;/p&gt;
                    932: &lt;math&gt;
                    933:  &lt;ms&gt;&lt;![CDATA[x&lt;y]]&gt;&lt;/ms&gt;
                    934:  &lt;mo&gt;+&lt;/mo&gt;
                    935:  &lt;mn&gt;3&lt;/mn&gt;
                    936:  &lt;mo&gt;=&lt;/mo&gt;
                    937:  &lt;ms&gt;&lt;![CDATA[x&lt;y3]]&gt;&lt;/ms&gt;
                    938: &lt;/math&gt;</pre>
                    939: 
1.755     mike      940:   </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      941:   four character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
                    942:   MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS (<code title="">&lt;!--</code>). Following this sequence, the comment may
                    943:   have <a href="#syntax-text" title="syntax-text">text</a>, with the additional
                    944:   restriction that the text must not start with a single U+003E
1.588     mike      945:   GREATER-THAN SIGN character (&gt;), nor start with a U+002D
                    946:   HYPHEN-MINUS character (-) followed by a U+003E GREATER-THAN SIGN
                    947:   (&gt;) character, nor contain two consecutive U+002D HYPHEN-MINUS
                    948:   characters (<code title="">--</code>), nor end with a U+002D
                    949:   HYPHEN-MINUS character (-). Finally, the comment must be ended by
1.1       mike      950:   the three character sequence U+002D HYPHEN-MINUS, U+002D
1.123     mike      951:   HYPHEN-MINUS, U+003E GREATER-THAN SIGN (<code title="">--&gt;</code>).</p><div class="impl">
1.1       mike      952: 
1.755     mike      953:   <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      954: 
                    955:   <p><i>This section only applies to user agents, data mining tools,
                    956:   and conformance checkers.</i></p>
                    957: 
                    958:   <p class="note">The rules for parsing XML documents into DOM trees
                    959:   are covered by the next section, entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
                    960:   syntax</a>".</p>
                    961: 
                    962:   <p>For <a href="dom.html#html-documents">HTML documents</a>, user agents must use the parsing
                    963:   rules described in this section to generate the DOM trees. Together,
                    964:   these rules define what is referred to as the <dfn id="html-parser">HTML
                    965:   parser</dfn>.</p>
                    966: 
                    967:   <div class="note">
                    968: 
                    969:    <p>While the HTML syntax described in this specification bears a
                    970:    close resemblance to SGML and XML, it is a separate language with
                    971:    its own parsing rules.</p>
                    972: 
1.183     mike      973:    <p>Some earlier versions of HTML (in particular from HTML2 to
                    974:    HTML4) were based on SGML and used SGML parsing rules. However, few
1.1       mike      975:    (if any) web browsers ever implemented true SGML parsing for HTML
                    976:    documents; the only user agents to strictly handle HTML as an SGML
                    977:    application have historically been validators. The resulting
                    978:    confusion &#8212; with validators claiming documents to have one
                    979:    representation while widely deployed Web browsers interoperably
                    980:    implemented a different representation &#8212; has wasted decades
                    981:    of productivity. This version of HTML thus returns to a non-SGML
                    982:    basis.</p>
                    983: 
                    984:    <p>Authors interested in using SGML tools in their authoring
                    985:    pipeline are encouraged to use XML tools and the XML serialization
                    986:    of HTML.</p>
                    987: 
                    988:   </div>
                    989: 
                    990:   <p>This specification defines the parsing rules for HTML documents,
                    991:   whether they are syntactically correct or not. Certain points in the
                    992:   parsing algorithm are said to be <dfn id="parse-error" title="parse error">parse
                    993:   errors</dfn>. The error handling for parse errors is well-defined:
                    994:   user agents must either act as described below when encountering
                    995:   such problems, or must abort processing at the first error that they
                    996:   encounter for which they do not wish to apply the rules described
                    997:   below.</p>
                    998: 
                    999:   <p>Conformance checkers must report at least one parse error
                   1000:   condition to the user if one or more parse error conditions exist in
                   1001:   the document and must not report parse error conditions if none
                   1002:   exist in the document. Conformance checkers may report more than one
1.174     mike     1003:   parse error condition if more than one parse error condition exists
1.1       mike     1004:   in the document. Conformance checkers are not required to recover
                   1005:   from parse errors.</p>
                   1006: 
                   1007:   <p class="note">Parse errors are only errors with the
                   1008:   <em>syntax</em> of HTML. In addition to checking for parse errors,
                   1009:   conformance checkers will also verify that the document obeys all
                   1010:   the other conformance requirements described in this
                   1011:   specification.</p>
                   1012: 
                   1013:   <p>For the purposes of conformance checkers, if a resource is
                   1014:   determined to be in <a href="#syntax">the HTML syntax</a>, then it is an
                   1015:   <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
                   1016: 
1.266     mike     1017:   </div><div class="impl">
1.1       mike     1018: 
1.755     mike     1019:   <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     1020: 
                   1021:   <p>The input to the HTML parsing process consists of a stream of
                   1022:   Unicode characters, which is passed through a
                   1023:   <a href="#tokenization">tokenization</a> stage followed by a <a href="#tree-construction">tree
1.810     mike     1024:   construction</a> stage. The output is a <code><a href="infrastructure.html#document">Document</a></code>
1.1       mike     1025:   object.</p>
                   1026: 
                   1027:   <p class="note">Implementations that <a href="infrastructure.html#non-scripted">do not
                   1028:   support scripting</a> do not have to actually create a DOM
1.810     mike     1029:   <code><a href="infrastructure.html#document">Document</a></code> object, but the DOM tree in such cases is
1.1       mike     1030:   still used as the model for the rest of the specification.</p>
                   1031: 
                   1032:   <p>In the common case, the data handled by the tokenization stage
1.159     mike     1033:   comes from the network, but <a href="embedded-content-0.html#dynamic-markup-insertion" title="dynamic markup
                   1034:   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     1035: 
1.724     mike     1036:   <p><img alt="" src="http://dev.w3.org/html5/spec/images/parsing-model-overview.png"></p>
1.1       mike     1037: 
                   1038:   <p id="nestedParsing">There is only one set of states for the
                   1039:   tokenizer stage and the tree construction stage, but the tree
                   1040:   construction stage is reentrant, meaning that while the tree
                   1041:   construction stage is handling one token, the tokenizer might be
                   1042:   resumed, causing further tokens to be emitted and processed before
                   1043:   the first token's processing is complete.</p>
                   1044: 
                   1045:   <div class="example">
                   1046: 
                   1047:    <p>In the following example, the tree construction stage will be
                   1048:    called upon to handle a "p" start tag token while handling the
                   1049:    "script" start tag token:</p>
                   1050: 
                   1051:    <pre>...
                   1052: &lt;script&gt;
                   1053:  document.write('&lt;p&gt;');
                   1054: &lt;/script&gt;
                   1055: ...</pre>
                   1056: 
                   1057:   </div>
                   1058: 
                   1059:   <p>To handle these cases, parsers have a <dfn id="script-nesting-level">script nesting
                   1060:   level</dfn>, which must be initially set to zero, and a <dfn id="parser-pause-flag">parser
                   1061:   pause flag</dfn>, which must be initially set to false.</p>
                   1062: 
1.266     mike     1063:   </div><div class="impl">
1.1       mike     1064: 
1.755     mike     1065:   <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     1066: 
                   1067:   <p>The stream of Unicode characters that comprises the input to the
                   1068:   tokenization stage will be initially seen by the user agent as a
                   1069:   stream of bytes (typically coming over the network or from the local
                   1070:   file system). The bytes encode the actual characters according to a
                   1071:   particular <em>character encoding</em>, which the user agent must
                   1072:   use to decode the bytes into characters.</p>
                   1073: 
                   1074:   <p class="note">For XML documents, the algorithm user agents must
                   1075:   use to determine the character encoding is given by the XML
1.104     mike     1076:   specification. This section does not apply to XML documents. <a href="references.html#refsXML">[XML]</a></p>
1.1       mike     1077: 
                   1078: 
1.755     mike     1079:   <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     1080: 
                   1081:   <p>In some cases, it might be impractical to unambiguously determine
                   1082:   the encoding before parsing the document. Because of this, this
                   1083:   specification provides for a two-pass mechanism with an optional
                   1084:   pre-scan. Implementations are allowed, as described below, to apply
                   1085:   a simplified parsing algorithm to whatever bytes they have available
                   1086:   before beginning to parse the document. Then, the real parser is
                   1087:   started, using a tentative encoding derived from this pre-parse and
                   1088:   other out-of-band metadata. If, while the document is being loaded,
                   1089:   the user agent discovers an encoding declaration that conflicts with
                   1090:   this information, then the parser can get reinvoked to perform a
                   1091:   parse of the document with the real encoding.</p>
                   1092: 
                   1093:   <p id="documentEncoding">User agents must use the following
                   1094:   algorithm (the <dfn id="encoding-sniffing-algorithm">encoding sniffing algorithm</dfn>) to determine
                   1095:   the character encoding to use when decoding a document in the first
                   1096:   pass. This algorithm takes as input any out-of-band metadata
                   1097:   available to the user agent (e.g. the <a href="infrastructure.html#content-type" title="Content-Type">Content-Type metadata</a> of the document)
                   1098:   and all the bytes available so far, and returns an encoding and a
                   1099:   <dfn id="concept-encoding-confidence" title="concept-encoding-confidence">confidence</dfn>. The
                   1100:   confidence is either <i>tentative</i>, <i>certain</i>, or
                   1101:   <i>irrelevant</i>. The encoding used, and whether the confidence in
                   1102:   that encoding is <i>tentative</i> or <i>certain</i>, is <a href="#meta-charset-during-parse">used during the parsing</a> to
                   1103:   determine whether to <a href="#change-the-encoding">change the encoding</a>. If no
                   1104:   encoding is necessary, e.g. because the parser is operating on a
                   1105:   stream of Unicode characters and doesn't have to use an encoding at
                   1106:   all, then the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
                   1107:   <i>irrelevant</i>.</p>
                   1108: 
                   1109:   <ol><li><p>If the transport layer specifies an encoding, and it is
                   1110:    supported, return that encoding with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1111:    <i>certain</i>, and abort these steps.</p></li>
                   1112: 
                   1113:    <li><p>The user agent may wait for more bytes of the resource to be
                   1114:    available, either in this step or at any later step in this
                   1115:    algorithm. For instance, a user agent might wait 500ms or 512
                   1116:    bytes, whichever came first. In general preparsing the source to
                   1117:    find the encoding improves performance, as it reduces the need to
                   1118:    throw away the data structures used when parsing upon finding the
                   1119:    encoding information. However, if the user agent delays too long to
                   1120:    obtain data to determine the encoding, then the cost of the delay
                   1121:    could outweigh any performance improvements from the
                   1122:    preparse.</p></li>
                   1123: 
                   1124:    <li><p>For each of the rows in the following table, starting with
                   1125:    the first one and going down, if there are as many or more bytes
                   1126:    available than the number of bytes in the first column, and the
                   1127:    first bytes of the file match the bytes given in the first column,
                   1128:    then return the encoding given in the cell in the second column of
                   1129:    that row, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1130:    <i>certain</i>, and abort these steps:</p>
                   1131: 
                   1132:     <!-- this table is present in several forms in this file; keep them in sync -->
                   1133:     <table><thead><tr><th>Bytes in Hexadecimal
                   1134:        </th><th>Encoding
                   1135:      </th></tr></thead><tbody><!-- nobody uses this
                   1136:       <tr>
                   1137:        <td>00 00 FE FF
                   1138:        <td>UTF-32BE
                   1139:       <tr>
                   1140:        <td>FF FE 00 00
                   1141:        <td>UTF-32LE
                   1142: --><tr><td>FE FF
                   1143:        </td><td>UTF-16BE
                   1144:       </td></tr><tr><td>FF FE
                   1145:        </td><td>UTF-16LE
                   1146:       </td></tr><tr><td>EF BB BF
                   1147:        </td><td>UTF-8
                   1148: <!-- nobody uses this
                   1149:       <tr>
                   1150:        <td>DD 73 66 73
                   1151:        <td>UTF-EBCDIC
                   1152: -->
                   1153:     </td></tr></tbody></table><p class="note">This step looks for Unicode Byte Order Marks
                   1154:    (BOMs).</p></li>
                   1155: 
                   1156:    <li><p>Otherwise, the user agent will have to search for explicit
                   1157:    character encoding information in the file itself. This should
                   1158:    proceed as follows:
                   1159: 
                   1160:     </p><p>Let <var title="">position</var> be a pointer to a byte in the
                   1161:     input stream, initially pointing at the first byte. If at any
                   1162:     point during these substeps the user agent either runs out of
                   1163:     bytes or decides that scanning further bytes would not be
                   1164:     efficient, then skip to the next step of the overall character
                   1165:     encoding detection algorithm. User agents may decide that scanning
                   1166:     <em>any</em> bytes is not efficient, in which case these substeps
                   1167:     are entirely skipped.</p>
                   1168: 
                   1169:     <p>Now, repeat the following "two" steps until the algorithm
                   1170:     aborts (either because user agent aborts, as described above, or
                   1171:     because a character encoding is found):</p>
                   1172: 
                   1173:     <ol><li><p>If <var title="">position</var> points to:</p>
                   1174: 
                   1175:       <dl class="switch"><dt>A sequence of bytes starting with: 0x3C 0x21 0x2D 0x2D (ASCII '&lt;!--')</dt>
                   1176:        <dd>
                   1177: 
                   1178:         <p>Advance the <var title="">position</var> pointer so that it
                   1179:         points at the first 0x3E byte which is preceded by two 0x2D
                   1180:         bytes (i.e. at the end of an ASCII '--&gt;' sequence) and comes
                   1181:         after the 0x3C byte that was found. (The two 0x2D bytes can be
                   1182:         the same as the those in the '&lt;!--' sequence.)</p>
                   1183: 
                   1184:        </dd>
                   1185: 
                   1186:        <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>
                   1187:        <dd>
                   1188: 
                   1189:         <ol><li><p>Advance the <var title="">position</var> pointer so
                   1190:          that it points at the next 0x09, 0x0A, 0x0C, 0x0D, 0x20, or
                   1191:          0x2F byte (the one in sequence of characters matched
                   1192:          above).</p></li>
                   1193: 
                   1194:          <li><p><a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">Get
                   1195:          an attribute</a> and its value. If no attribute was
                   1196:          sniffed, then skip this inner set of steps, and jump to the
                   1197:          second step in the overall "two step" algorithm.</p></li>
                   1198: 
                   1199:          <li><p>If the attribute's name is neither "<code title="">charset</code>" nor "<code title="">content</code>",
                   1200:          then return to step 2 in these inner steps.</p></li>
                   1201: 
                   1202:          <li><p>If the attribute's name is "<code title="">charset</code>", let <var title="">charset</var> be
                   1203:          the attribute's value, interpreted as a character
                   1204:          encoding.</p></li>
                   1205: 
                   1206:          <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
                   1207:          extracting an encoding from a Content-Type</a>, giving the
                   1208:          attribute's value as the string to parse. If an encoding is
                   1209:          returned, let <var title="">charset</var> be that
                   1210:          encoding. Otherwise, return to step 2 in these inner
                   1211:          steps.</p></li>
                   1212: 
                   1213:          <li><p>If <var title="">charset</var> is a UTF-16 encoding,
                   1214:          change the value of <var title="">charset</var> to
                   1215:          UTF-8.</p></li>
                   1216: 
                   1217:          <li><p>If <var title="">charset</var> is a supported
                   1218:          character encoding, then return the given encoding, with
                   1219:          <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1220:          <i>tentative</i>, and abort all these steps.</p></li>
                   1221: 
                   1222:          <li><p>Otherwise, return to step 2 in these inner
                   1223:          steps.</p></li>
                   1224: 
                   1225:         </ol></dd>
                   1226: 
1.464     mike     1227:        <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     1228:        <dd>
                   1229: 
                   1230:         <ol><li><p>Advance the <var title="">position</var> pointer so
                   1231:          that it points at the next 0x09 (ASCII TAB), 0x0A (ASCII LF),
                   1232:          0x0C (ASCII FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E
1.464     mike     1233:          (ASCII &gt;) byte.</p></li>
1.1       mike     1234: 
                   1235:          <li><p>Repeatedly <a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">get an
                   1236:          attribute</a> until no further attributes can be found,
                   1237:          then jump to the second step in the overall "two step"
                   1238:          algorithm.</p></li>
                   1239: 
                   1240:         </ol></dd>
                   1241: 
                   1242:        <dt>A sequence of bytes starting with: 0x3C 0x21 (ASCII '&lt;!')</dt>
                   1243:        <dt>A sequence of bytes starting with: 0x3C 0x2F (ASCII '&lt;/')</dt>
                   1244:        <dt>A sequence of bytes starting with: 0x3C 0x3F (ASCII '&lt;?')</dt>
                   1245:        <dd>
                   1246: 
                   1247:         <p>Advance the <var title="">position</var> pointer so that it
1.464     mike     1248:         points at the first 0x3E byte (ASCII &gt;) that comes after the
1.1       mike     1249:         0x3C byte that was found.</p>
                   1250: 
                   1251:        </dd>
                   1252: 
                   1253:        <dt>Any other byte</dt>
                   1254:        <dd>
                   1255: 
                   1256:         <p>Do nothing with that byte.</p>
                   1257: 
                   1258:        </dd>
                   1259: 
                   1260:       </dl></li>
                   1261: 
                   1262:      <li>Move <var title="">position</var> so it points at the next
                   1263:      byte in the input stream, and return to the first step of this
                   1264:      "two step" algorithm.</li>
                   1265: 
                   1266:     </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
                   1267:     attribute</dfn>, it means doing this:</p>
                   1268: 
                   1269:     <ol><li><p>If the byte at <var title="">position</var> is one of 0x09
                   1270:      (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR),
1.464     mike     1271:      0x20 (ASCII space), or 0x2F (ASCII /) then advance <var title="">position</var> to the next byte and redo this
1.1       mike     1272:      substep.</p></li>
                   1273: 
                   1274:      <li><p>If the byte at <var title="">position</var> is 0x3E (ASCII
1.464     mike     1275:      &gt;), then abort the "get an attribute" algorithm. There isn't
1.1       mike     1276:      one.</p></li>
                   1277: 
                   1278:      <li><p>Otherwise, the byte at <var title="">position</var> is the
                   1279:      start of the attribute name. Let <var title="">attribute
                   1280:      name</var> and <var title="">attribute value</var> be the empty
                   1281:      string.</p></li>
                   1282: 
                   1283:      <li><p><i>Attribute name</i>: Process the byte at <var title="">position</var> as follows:</p>
                   1284: 
1.464     mike     1285:       <dl class="switch"><dt>If it is 0x3D (ASCII =), and the <var title="">attribute
1.1       mike     1286:        name</var> is longer than the empty string</dt>
                   1287: 
                   1288:        <dd>Advance <var title="">position</var> to the next byte and
                   1289:        jump to the step below labeled <i>value</i>.</dd>
                   1290: 
                   1291:        <dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
                   1292:        FF), 0x0D (ASCII CR), or 0x20 (ASCII space)</dt>
                   1293: 
                   1294:        <dd>Jump to the step below labeled <i>spaces</i>.</dd>
                   1295: 
1.464     mike     1296:        <dt>If it is 0x2F (ASCII /) or 0x3E (ASCII &gt;)</dt>
1.1       mike     1297: 
                   1298:        <dd>Abort the "get an attribute" algorithm. The attribute's
                   1299:        name is the value of <var title="">attribute name</var>, its
                   1300:        value is the empty string.</dd>
                   1301: 
1.464     mike     1302:        <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
                   1303:        Z)</dt>
1.1       mike     1304: 
                   1305:        <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
                   1306:        name</var> (where <var title="">b</var> is the value of the
                   1307:        byte at <var title="">position</var>).</dd>
                   1308: 
                   1309:        <dt>Anything else</dt>
                   1310: 
                   1311:        <dd>Append the Unicode character with the same code point as the
                   1312:        value of the byte at <var title="">position</var>) to <var title="">attribute name</var>. (It doesn't actually matter how
                   1313:        bytes outside the ASCII range are handled here, since only
                   1314:        ASCII characters can contribute to the detection of a character
                   1315:        encoding.)</dd>
                   1316: 
                   1317:       </dl></li>
                   1318: 
                   1319:      <li><p>Advance <var title="">position</var> to the next byte and
                   1320:      return to the previous step.</p></li>
                   1321: 
                   1322:      <li><p><i>Spaces</i>: If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
                   1323:      LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
                   1324:      advance <var title="">position</var> to the next byte, then,
                   1325:      repeat this step.</p></li>
                   1326: 
                   1327:      <li><p>If the byte at <var title="">position</var> is
1.464     mike     1328:      <em>not</em> 0x3D (ASCII =), abort the "get an attribute"
1.1       mike     1329:      algorithm. The attribute's name is the value of <var title="">attribute name</var>, its value is the empty
                   1330:      string.</p></li>
                   1331: 
                   1332:      <li><p>Advance <var title="">position</var> past the 0x3D (ASCII
1.464     mike     1333:      =) byte.</p></li>
1.1       mike     1334: 
                   1335:      <li><p><i>Value:</i> If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
                   1336:      LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
                   1337:      advance <var title="">position</var> to the next byte, then,
                   1338:      repeat this step.</p></li>
                   1339: 
                   1340:      <li><p>Process the byte at <var title="">position</var> as
                   1341:      follows:</p>
                   1342: 
1.464     mike     1343:       <dl class="switch"><dt>If it is 0x22 (ASCII ") or 0x27 (ASCII ')</dt>
1.1       mike     1344: 
                   1345:        <dd>
                   1346: 
                   1347:         <ol><li>Let <var title="">b</var> be the value of the byte at
                   1348:          <var title="">position</var>.</li>
                   1349: 
                   1350:          <li>Advance <var title="">position</var> to the next
                   1351:          byte.</li>
                   1352: 
                   1353:          <li>If the value of the byte at <var title="">position</var>
                   1354:          is the value of <var title="">b</var>, then advance <var title="">position</var> to the next byte and abort the "get
                   1355:          an attribute" algorithm. The attribute's name is the value of
                   1356:          <var title="">attribute name</var>, and its value is the
                   1357:          value of <var title="">attribute value</var>.</li>
                   1358: 
1.464     mike     1359:          <li>Otherwise, if the value of the byte at <var title="">position</var> is in the range 0x41 (ASCII A) to
                   1360:          0x5A (ASCII Z), then append a Unicode character to <var title="">attribute value</var> whose code point is 0x20 more
1.1       mike     1361:          than the value of the byte at <var title="">position</var>.</li>
                   1362: 
                   1363:          <li>Otherwise, append a Unicode character to <var title="">attribute value</var> whose code point is the same as
                   1364:          the value of the byte at <var title="">position</var>.</li>
                   1365: 
                   1366:          <li>Return to the second step in these substeps.</li>
                   1367: 
                   1368:         </ol></dd>
                   1369: 
1.464     mike     1370:        <dt>If it is 0x3E (ASCII &gt;)</dt>
1.1       mike     1371: 
                   1372:        <dd>Abort the "get an attribute" algorithm. The attribute's
                   1373:        name is the value of <var title="">attribute name</var>, its
                   1374:        value is the empty string.</dd>
                   1375: 
                   1376: 
1.464     mike     1377:        <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
                   1378:        Z)</dt>
1.1       mike     1379: 
                   1380:        <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
                   1381:        value</var> (where <var title="">b</var> is the value of the
                   1382:        byte at <var title="">position</var>). Advance <var title="">position</var> to the next byte.</dd>
                   1383: 
                   1384:        <dt>Anything else</dt>
                   1385: 
                   1386:        <dd>Append the Unicode character with the same code point as the
                   1387:        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>
                   1388: 
                   1389:       </dl></li>
                   1390: 
                   1391:      <li><p>Process the byte at <var title="">position</var> as
                   1392:      follows:</p>
                   1393: 
                   1394:       <dl class="switch"><dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
                   1395:        FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E (ASCII
1.464     mike     1396:        &gt;)</dt>
1.1       mike     1397: 
                   1398:        <dd>Abort the "get an attribute" algorithm. The attribute's
                   1399:        name is the value of <var title="">attribute name</var> and its
                   1400:        value is the value of <var title="">attribute value</var>.</dd>
                   1401: 
1.464     mike     1402:        <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
                   1403:        Z)</dt>
1.1       mike     1404: 
                   1405:        <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
                   1406:        value</var> (where <var title="">b</var> is the value of the
                   1407:        byte at <var title="">position</var>).</dd>
                   1408: 
                   1409:        <dt>Anything else</dt>
                   1410: 
                   1411:        <dd>Append the Unicode character with the same code point as the
                   1412:        value of the byte at <var title="">position</var>) to <var title="">attribute value</var>.</dd>
                   1413: 
                   1414:       </dl></li>
                   1415: 
                   1416:      <li><p>Advance <var title="">position</var> to the next byte and
                   1417:      return to the previous step.</p></li>
                   1418: 
                   1419:     </ol><p>For the sake of interoperability, user agents should not use a
                   1420:     pre-scan algorithm that returns different results than the one
                   1421:     described above. (But, if you do, please at least let us know, so
                   1422:     that we can improve this algorithm and benefit everyone...)</p>
                   1423: 
                   1424:    </li>
                   1425: 
                   1426:    <li><p>If the user agent has information on the likely encoding for
                   1427:    this page, e.g. based on the encoding of the page when it was last
                   1428:    visited, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1429:    <i>tentative</i>, and abort these steps.</p></li>
                   1430: 
1.322     mike     1431:    <li>
                   1432: 
                   1433:     <p>The user agent may attempt to autodetect the character encoding
                   1434:     from applying frequency analysis or other algorithms to the data
1.568     mike     1435:     stream. Such algorithms may use information about the resource
                   1436:     other than the resource's contents, including the address of the
                   1437:     resource. If autodetection succeeds in determining a character
1.322     mike     1438:     encoding, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1439:     <i>tentative</i>, and abort these steps. <a href="references.html#refsUNIVCHARDET">[UNIVCHARDET]</a></p>
                   1440: 
                   1441:     <p class="note">The UTF-8 encoding has a highly detectable bit
                   1442:     pattern. Documents that contain bytes with values greater than
                   1443:     0x7F which match the UTF-8 pattern are very likely to be UTF-8,
                   1444:     while documents with byte sequences that do not match it are very
                   1445:     likely not. User-agents are therefore encouraged to search for
1.485     mike     1446:     this common encoding. <a href="references.html#refsPPUTF8">[PPUTF8]</a> <a href="references.html#refsUTF8DET">[UTF8DET]</a></p>
1.322     mike     1447: 
                   1448:    </li>
1.1       mike     1449: 
1.501     mike     1450:    <li>
                   1451: 
                   1452:     <p>Otherwise, return an implementation-defined or user-specified
                   1453:     default character encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
                   1454:     <i>tentative</i>.</p>
                   1455: 
                   1456:     <p>In controlled environments or in environments where the
                   1457:     encoding of documents can be prescribed (for example, for user
                   1458:     agents intended for dedicated use in new networks), the
                   1459:     comprehensive <code title="">UTF-8</code> encoding is
                   1460:     suggested.</p>
                   1461: 
                   1462:     <p>In other environments, the default encoding is typically
                   1463:     dependent on the user's locale (an approximation of the languages,
1.760     mike     1464:     and thus often encodings, of the pages that the user is likely to
                   1465:     frequent). The following table gives suggested defaults based on
                   1466:     the user's locale, for compatibility with legacy content. Locales
                   1467:     are identified by BCP 47 language codes. <a href="references.html#refsBCP47">[BCP47]</a></p>
1.501     mike     1468: 
                   1469:     <!-- based on mozilla 1.9.1 localizations: 
                   1470:          http://mxr.mozilla.org/l10n-mozilla1.9.1/find?string=global%2Fintl.properties&tree=l10n-mozilla1.9.1&hint= -->
                   1471: 
1.504     mike     1472:     <table><thead><tr><th>Locale language
1.501     mike     1473:        </th><th>Suggested default encoding
                   1474:      </th></tr></thead><tbody><tr><td>ar
                   1475:        </td><td>UTF-8
                   1476: 
                   1477:       </td></tr><tr><td>be
                   1478:        </td><td>ISO-8859-5
                   1479: 
                   1480:       </td></tr><tr><td>bg
                   1481:        </td><td>windows-1251
                   1482: 
                   1483:       </td></tr><tr><td>cs<!-- -CZ -->
                   1484:        </td><td>ISO-8859-2
                   1485: 
                   1486:       </td></tr><tr><td>cy
                   1487:        </td><td>UTF-8
                   1488: 
                   1489:       </td></tr><tr><td>fa<!-- -IR -->
                   1490:        </td><td>UTF-8
                   1491: 
                   1492:       </td></tr><tr><td>he<!-- -IL -->
                   1493:        </td><td>windows-1255
                   1494: 
                   1495:       </td></tr><tr><td>hr
                   1496:        </td><td>UTF-8
                   1497: 
                   1498:       </td></tr><tr><td>hu<!-- -HU -->
                   1499:        </td><td>ISO-8859-2
                   1500: 
                   1501:       </td></tr><tr><td>ja <!-- and ja-JP-mac -->
1.863     mike     1502:        </td><td>Windows-31J <!-- Shift_JIS -->
1.501     mike     1503: 
                   1504:       </td></tr><tr><td>kk
                   1505:        </td><td>UTF-8
                   1506: 
                   1507:       </td></tr><tr><td>ko<!-- -KR -->
                   1508:        </td><td>windows-949 <!-- EUC-KR -->
                   1509: 
                   1510:       </td></tr><tr><td>ku
                   1511:        </td><td>windows-1254 <!-- ISO-8859-9 -->
                   1512: 
                   1513:       </td></tr><tr><td>lt
                   1514:        </td><td>windows-1257
                   1515: 
                   1516:       </td></tr><tr><td>lv<!-- -LV -->
                   1517:        </td><td>ISO-8859-13
                   1518: 
                   1519:       </td></tr><tr><td>mk<!-- -MK -->
                   1520:        </td><td>UTF-8
                   1521: 
                   1522:       </td></tr><tr><td>or
                   1523:        </td><td>UTF-8
                   1524: 
                   1525:       </td></tr><tr><td>pl<!-- -PL -->
                   1526:        </td><td>ISO-8859-2
                   1527: 
                   1528:       </td></tr><tr><td>ro
                   1529:        </td><td>UTF-8
                   1530: 
                   1531:       </td></tr><tr><td>ru
                   1532:        </td><td>windows-1251
                   1533: 
                   1534:       </td></tr><tr><td>sk
                   1535:        </td><td>windows-1250
                   1536: 
                   1537:       </td></tr><tr><td>sl
                   1538:        </td><td>ISO-8859-2
                   1539: 
                   1540:       </td></tr><tr><td>sr
                   1541:        </td><td>UTF-8
                   1542: 
                   1543:       </td></tr><tr><td>th
                   1544:        </td><td>windows-874 <!-- TIS-620 -->
                   1545: 
                   1546:       </td></tr><tr><td>tr<!-- -TR -->
                   1547:        </td><td>windows-1254 <!-- ISO-8859-9 -->
                   1548: 
1.503     mike     1549:       </td></tr><tr><td>uk
1.501     mike     1550:        </td><td>windows-1251
                   1551: 
                   1552:       </td></tr><tr><td>vi
                   1553:        </td><td>UTF-8
                   1554: 
                   1555:       </td></tr><tr><td>zh-CN
                   1556:        </td><td>GB18030
                   1557: 
                   1558:       </td></tr><tr><td>zh-TW
                   1559:        </td><td>Big5
                   1560: 
                   1561:       </td></tr><tr><td>All other locales
                   1562:        </td><td>windows-1252
                   1563: 
                   1564:     </td></tr></tbody></table></li>
1.1       mike     1565: 
                   1566:   </ol><p>The <a href="dom.html#document-s-character-encoding">document's character encoding</a> must immediately
                   1567:   be set to the value returned from this algorithm, at the same time
                   1568:   as the user agent uses the returned value to select the decoder to
                   1569:   use for the input stream.</p>
                   1570: 
1.582     mike     1571:   <p class="note">This algorithm is a <a href="introduction.html#willful-violation">willful violation</a>
                   1572:   of the HTTP specification, which requires that the encoding be
                   1573:   assumed to be ISO-8859-1 in the absence of a <a href="semantics.html#character-encoding-declaration">character
1.647     mike     1574:   encoding declaration</a> to the contrary, and of RFC 2046,
1.582     mike     1575:   which requires that the encoding be assumed to be US-ASCII in the
                   1576:   absence of a <a href="semantics.html#character-encoding-declaration">character encoding declaration</a> to the
                   1577:   contrary. This specification's third approach is motivated by a
                   1578:   desire to be maximally compatible with legacy content. <a href="references.html#refsHTTP">[HTTP]</a> <a href="references.html#refsRFC2046">[RFC2046]</a></p>
                   1579: 
1.1       mike     1580: 
1.755     mike     1581:   <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     1582: 
1.237     mike     1583:   <p>User agents must at a minimum support the UTF-8 and Windows-1252
                   1584:   encodings, but may support more.</p>
                   1585: 
                   1586:   <p class="note">It is not unusual for Web browsers to support dozens
                   1587:   if not upwards of a hundred distinct character encodings.</p>
                   1588: 
1.365     mike     1589:   <p>User agents must support the <a href="infrastructure.html#preferred-mime-name">preferred MIME name</a> of
                   1590:   every character encoding they support, and should support all the
                   1591:   IANA-registered names and aliases of every character encoding they
                   1592:   support. <a href="references.html#refsIANACHARSET">[IANACHARSET]</a></p>
1.237     mike     1593: 
                   1594:   <p>When comparing a string specifying a character encoding with the
                   1595:   name or alias of a character encoding to determine if they are
                   1596:   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
                   1597:   then perform the comparison in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   1598:   case-insensitive</a> manner.</p>
                   1599: 
1.539     mike     1600:   <hr><p>When a user agent would otherwise use an encoding given in the
1.237     mike     1601:   first column of the following table to either convert content to
                   1602:   Unicode characters or convert Unicode characters to bytes, it must
                   1603:   instead use the encoding given in the cell in the second column of
                   1604:   the same row. When a byte or sequence of bytes is treated
                   1605:   differently due to this encoding aliasing, it is said to have been
                   1606:   <dfn id="misinterpreted-for-compatibility">misinterpreted for compatibility</dfn>.</p>
                   1607: 
                   1608:   <table><caption>Character encoding overrides</caption>
                   1609:    <thead><tr><th> Input encoding </th><th> Replacement encoding </th><th> References
                   1610:    </th></tr></thead><tbody><!-- how about EUC-JP? --><tr><td> EUC-KR </td><td> windows-949 </td><td>
                   1611:          <a href="references.html#refsEUCKR">[EUCKR]</a>
                   1612:          <a href="references.html#refsWIN949">[WIN949]</a>
                   1613:     </td></tr><tr><td> GB2312 </td><td> GBK </td><td>
                   1614:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1615:          <a href="references.html#refsGBK">[GBK]</a>
                   1616:     </td></tr><tr><td> GB_2312-80 </td><td> GBK </td><td>
                   1617:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1618:          <a href="references.html#refsGBK">[GBK]</a>
                   1619:     </td></tr><tr><td> ISO-8859-1 </td><td> windows-1252 </td><td>
                   1620:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1621:          <a href="references.html#refsWIN1252">[WIN1252]</a>
                   1622:     </td></tr><tr><td> ISO-8859-9 </td><td> windows-1254 </td><td>
                   1623:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1624:          <a href="references.html#refsWIN1254">[WIN1254]</a>
                   1625:     </td></tr><tr><td> ISO-8859-11 </td><td> windows-874 </td><td>
                   1626:          <a href="references.html#refsISO885911">[ISO885911]</a>
                   1627:          <a href="references.html#refsWIN874">[WIN874]</a>
                   1628:     </td></tr><tr><td> KS_C_5601-1987 </td><td> windows-949 </td><td>
                   1629:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1630:          <a href="references.html#refsWIN949">[WIN949]</a>
1.863     mike     1631:     </td></tr><tr><td> Shift_JIS </td><td> Windows-31J </td><td>
1.237     mike     1632:          <a href="references.html#refsSHIFTJIS">[SHIFTJIS]</a>
                   1633:          <a href="references.html#refsWIN31J">[WIN31J]</a>
                   1634:     </td></tr><tr><td> TIS-620 </td><td> windows-874 </td><td>
                   1635:          <a href="references.html#refsTIS620">[TIS620]</a>
                   1636:          <a href="references.html#refsWIN874">[WIN874]</a>
                   1637:     </td></tr><tr><td> US-ASCII </td><td> windows-1252 </td><td>
                   1638:          <a href="references.html#refsRFC1345">[RFC1345]</a>
                   1639:          <a href="references.html#refsWIN1252">[WIN1252]</a>
                   1640:    </td></tr></tbody></table><p class="note">The requirement to treat certain encodings as other
                   1641:   encodings according to the table above is a <a href="introduction.html#willful-violation">willful
                   1642:   violation</a> of the W3C Character Model specification, motivated
                   1643:   by a desire for compatibility with legacy content. <a href="references.html#refsCHARMOD">[CHARMOD]</a></p>
                   1644: 
                   1645:   <p>When a user agent is to use the UTF-16 encoding but no BOM has
                   1646:   been found, user agents must default to UTF-16LE.</p>
                   1647: 
                   1648:   <p class="note">The requirement to default UTF-16 to LE rather than
                   1649:   BE is a <a href="introduction.html#willful-violation">willful violation</a> of RFC 2781, motivated by a
1.581     mike     1650:   desire for compatibility with legacy content. <a href="references.html#refsRFC2781">[RFC2781]</a></p>
1.237     mike     1651: 
                   1652:   <hr><p>User agents must not support the CESU-8, UTF-7, BOCU-1 and SCSU
                   1653:   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>
                   1654: 
                   1655:   <p>Support for encodings based on EBCDIC is not recommended. This
                   1656:   encoding is rarely used for publicly-facing Web content.</p>
                   1657: 
                   1658:   <p>Support for UTF-32 is not recommended. This encoding is rarely
                   1659:   used, and frequently implemented incorrectly.</p>
                   1660: 
                   1661:   <p class="note">This specification does not make any attempt to
                   1662:   support EBCDIC-based encodings and UTF-32 in its algorithms; support
                   1663:   and use of these encodings can thus lead to unexpected behavior in
                   1664:   implementations of this specification.</p>
                   1665: 
                   1666: 
                   1667: 
1.755     mike     1668:   <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     1669: 
                   1670:   <p>Given an encoding, the bytes in the input stream must be
                   1671:   converted to Unicode characters for the tokenizer, as described by
                   1672:   the rules for that encoding, except that the leading U+FEFF BYTE
                   1673:   ORDER MARK character, if any, must not be stripped by the encoding
                   1674:   layer (it is stripped by the rule below).</p> <!-- this is to
                   1675:   prevent two leading BOMs from being both stripped, once by the
                   1676:   decoder, and once by the parser -->
                   1677: 
                   1678:   <p>Bytes or sequences of bytes in the original byte stream that
1.393     mike     1679:   could not be converted to Unicode code points must be converted to
                   1680:   U+FFFD REPLACEMENT CHARACTERs.</p>
1.1       mike     1681: 
                   1682:   <p class="note">Bytes or sequences of bytes in the original byte
                   1683:   stream that did not conform to the encoding specification
                   1684:   (e.g. invalid UTF-8 byte sequences in a UTF-8 input stream) are
                   1685:   errors that conformance checkers are expected to report.</p>
                   1686: 
1.438     mike     1687:   <p>Any byte or sequence of bytes in the original byte stream that is
                   1688:   <a href="#misinterpreted-for-compatibility">misinterpreted for compatibility</a> is a <a href="#parse-error">parse
1.1       mike     1689:   error</a>.</p>
                   1690: 
                   1691:   <p>One leading U+FEFF BYTE ORDER MARK character must be ignored if
                   1692:   any are present.</p>
                   1693: 
1.300     mike     1694:   <p class="note">The requirement to strip a U+FEFF BYTE ORDER MARK
                   1695:   character regardless of whether that character was used to determine
                   1696:   the byte order is a <a href="introduction.html#willful-violation">willful violation</a> of Unicode,
                   1697:   motivated by a desire to increase the resilience of user agents in
                   1698:   the face of na&#239;ve transcoders.</p>
                   1699: 
1.316     mike     1700:   <p>All U+0000 NULL characters and code points in the range U+D800 to
1.315     mike     1701:   U+DFFF<!-- surrogates not allowed e.g. in UTF-8, and we don't want
                   1702:   them to suddenly turn into codepoints when they go through a UTF-16
                   1703:   pipe --> in the input must be replaced by U+FFFD REPLACEMENT
1.316     mike     1704:   CHARACTERs. Any occurrences of such characters and code points are
                   1705:   <a href="#parse-error" title="parse error">parse errors</a>.</p>
1.1       mike     1706: 
                   1707:   <p>Any occurrences of any characters in the ranges U+0001 to U+0008,
                   1708:   <!-- HT, LF allowed --> <!-- U+000B is in the next list --> <!-- FF,
                   1709:   CR allowed --> U+000E to U+001F, <!-- ASCII allowed --> U+007F
1.315     mike     1710:   <!--to U+0084, (U+0085 NEL not allowed), U+0086--> to U+009F, U+FDD0
                   1711:   to U+FDEF, and characters U+000B, U+FFFE, U+FFFF, U+1FFFE, U+1FFFF,
                   1712:   U+2FFFE, U+2FFFF, U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE,
                   1713:   U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF,
                   1714:   U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE,
                   1715:   U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF,
                   1716:   U+10FFFE, and U+10FFFF are <a href="#parse-error" title="parse error">parse
1.316     mike     1717:   errors</a>. These are all control characters or permanently
                   1718:   undefined Unicode characters (noncharacters).</p>
1.1       mike     1719: 
                   1720:   <p>U+000D CARRIAGE RETURN (CR) characters and U+000A LINE FEED (LF)
                   1721:   characters are treated specially. Any CR characters that are
                   1722:   followed by LF characters must be removed, and any CR characters not
                   1723:   followed by LF characters must be converted to LF characters. Thus,
                   1724:   newlines in HTML DOMs are represented by LF characters, and there
                   1725:   are never any CR characters in the input to the
                   1726:   <a href="#tokenization">tokenization</a> stage.</p>
                   1727: 
                   1728:   <p>The <dfn id="next-input-character">next input character</dfn> is the first character in the
                   1729:   input stream that has not yet been <dfn id="consumed">consumed</dfn>. Initially,
                   1730:   the <i><a href="#next-input-character">next input character</a></i> is the first character in the
                   1731:   input. The <dfn id="current-input-character">current input character</dfn> is the last character
                   1732:   to have been <i><a href="#consumed">consumed</a></i>.</p>
                   1733: 
                   1734:   <p>The <dfn id="insertion-point">insertion point</dfn> is the position (just before a
                   1735:   character or just before the end of the input stream) where content
1.159     mike     1736:   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     1737:   inserted. The insertion point is relative to the position of the
                   1738:   character immediately after it, it is not an absolute offset into
                   1739:   the input stream. Initially, the insertion point is
1.10      mike     1740:   undefined.</p>
1.1       mike     1741: 
                   1742:   <p>The "EOF" character in the tables below is a conceptual character
                   1743:   representing the end of the <a href="#the-input-stream">input stream</a>. If the parser
1.159     mike     1744:   is a <a href="embedded-content-0.html#script-created-parser">script-created parser</a>, then the end of the
1.1       mike     1745:   <a href="#the-input-stream">input stream</a> is reached when an <dfn id="explicit-eof-character">explicit "EOF"
1.159     mike     1746:   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     1747:   consumed. Otherwise, the "EOF" character is not a real character in
                   1748:   the stream, but rather the lack of any further characters.</p>
                   1749: 
                   1750: 
1.755     mike     1751:   <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     1752: 
                   1753:   <p>When the parser requires the user agent to <dfn id="change-the-encoding">change the
                   1754:   encoding</dfn>, it must run the following steps. This might happen
                   1755:   if the <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> described above
                   1756:   failed to find an encoding, or if it found an encoding that was not
                   1757:   the actual encoding of the file.</p>
                   1758: 
                   1759:   <ol><li>If the new encoding is identical or equivalent to the encoding
                   1760:    that is already being used to interpret the input stream, then set
                   1761:    the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1762:    <i>certain</i> and abort these steps. This happens when the
                   1763:    encoding information found in the file matches what the
                   1764:    <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> determined to be the
                   1765:    encoding, and in the second pass through the parser if the first
                   1766:    pass found that the encoding sniffing algorithm described in the
                   1767:    earlier section failed to find the right encoding.</li>
                   1768: 
                   1769:    <li>If the encoding that is already being used to interpret the
                   1770:    input stream is a UTF-16 encoding, then set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1771:    <i>certain</i> and abort these steps. The new encoding is ignored;
                   1772:    if it was anything but the same encoding, then it would be clearly
                   1773:    incorrect.</li>
                   1774: 
                   1775:    <li>If the new encoding is a UTF-16 encoding, change it to
                   1776:    UTF-8.</li>
                   1777: 
                   1778:    <li>If all the bytes up to the last byte converted by the current
                   1779:    decoder have the same Unicode interpretations in both the current
                   1780:    encoding and the new encoding, and if the user agent supports
                   1781:    changing the converter on the fly, then the user agent may change
                   1782:    to the new converter for the encoding on the fly. Set the
                   1783:    <a href="dom.html#document-s-character-encoding">document's character encoding</a> and the encoding used to
                   1784:    convert the input stream to the new encoding, set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1785:    <i>certain</i>, and abort these steps.</li>
                   1786: 
                   1787:    <li>Otherwise, <a href="history.html#navigate">navigate</a> to the document again, with
                   1788:    <a href="history.html#replacement-enabled">replacement enabled</a>, and using the same <a href="history.html#source-browsing-context">source
                   1789:    browsing context</a>, but this time skip the <a href="#encoding-sniffing-algorithm">encoding
                   1790:    sniffing algorithm</a> and instead just set the encoding to the
                   1791:    new encoding and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1792:    <i>certain</i>. Whenever possible, this should be done without
                   1793:    actually contacting the network layer (the bytes should be
                   1794:    re-parsed from memory), even if, e.g., the document is marked as
                   1795:    not being cacheable. If this is not possible and contacting the
                   1796:    network layer would involve repeating a request that uses a method
                   1797:    other than HTTP GET (<a href="infrastructure.html#concept-http-equivalent-get" title="concept-http-equivalent-get">or
                   1798:    equivalent</a> for non-HTTP URLs), then instead set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
                   1799:    <i>certain</i> and ignore the new encoding. The resource will be
                   1800:    misinterpreted. User agents may notify the user of the situation,
                   1801:    to aid in application development.</li>
                   1802: 
1.266     mike     1803:   </ol></div><div class="impl">
                   1804: 
1.755     mike     1805:   <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     1806: 
1.755     mike     1807:   <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     1808: 
                   1809:   <p>The <dfn id="insertion-mode">insertion mode</dfn> is a state variable that controls
                   1810:   the primary operation of the tree construction stage.</p>
                   1811: 
                   1812:   <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
                   1813:   "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before html</a>",
                   1814:   "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before head</a>",
                   1815:   "<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     1816:   "<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     1817:   "<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>",
                   1818:   "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table body</a>",
                   1819:   "<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
                   1820:   table</a>", "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in
                   1821:   foreign content</a>", "<a href="#parsing-main-afterbody" title="insertion mode: after
                   1822:   body">after body</a>", "<a href="#parsing-main-inframeset" title="insertion mode: in
                   1823:   frameset">in frameset</a>", "<a href="#parsing-main-afterframeset" title="insertion mode: after
                   1824:   frameset">after frameset</a>", "<a href="#the-after-after-body-insertion-mode" title="insertion mode:
                   1825:   after after body">after after body</a>", and "<a href="#the-after-after-frameset-insertion-mode" title="insertion mode: after after frameset">after after
                   1826:   frameset</a>" during the course of the parsing, as described in
                   1827:   the <a href="#tree-construction">tree construction</a> stage. The insertion mode affects
                   1828:   how tokens are processed and whether CDATA sections are
                   1829:   supported.</p>
                   1830: 
                   1831:   <p>Seven of these modes, namely "<a href="#parsing-main-inhead" title="insertion mode: in
                   1832:   head">in head</a>", "<a href="#parsing-main-inbody" title="insertion mode: in body">in
                   1833:   body</a>", "<a href="#parsing-main-intable" title="insertion mode: in table">in
                   1834:   table</a>", "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   1835:   body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in row</a>",
                   1836:   "<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
                   1837:   that the other modes defer to them at various times. When the
                   1838:   algorithm below says that the user agent is to do something
                   1839:   "<dfn id="using-the-rules-for">using the rules for</dfn> the <var title="">m</var> insertion
                   1840:   mode", where <var title="">m</var> is one of these modes, the user
                   1841:   agent must use the rules described under the <var title="">m</var>
                   1842:   <a href="#insertion-mode">insertion mode</a>'s section, but must leave the
                   1843:   <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>
                   1844:   to a new value.</p>
                   1845: 
                   1846:   <p>When the insertion mode is switched to "<a href="#parsing-main-incdata" title="insertion
1.540     mike     1847:   mode: text">text</a>" or "<a href="#parsing-main-intabletext" title="insertion mode: in table
                   1848:   text">in table text</a>", the <dfn id="original-insertion-mode">original insertion mode</dfn>
                   1849:   is also set. This is the insertion mode to which the tree
                   1850:   construction stage will return.</p>
1.1       mike     1851: 
                   1852:   <p>When the insertion mode is switched to "<a href="#parsing-main-inforeign" title="insertion
                   1853:   mode: in foreign content">in foreign content</a>", the
                   1854:   <dfn id="secondary-insertion-mode">secondary insertion mode</dfn> is also set. This secondary mode
                   1855:   is used within the rules for the "<a href="#parsing-main-inforeign" title="insertion mode: in
                   1856:   foreign content">in foreign content</a>" mode to handle HTML
                   1857:   (i.e. not foreign) content.</p>
                   1858: 
                   1859:   <hr><p>When the steps below require the UA to <dfn id="reset-the-insertion-mode-appropriately">reset the insertion
                   1860:   mode appropriately</dfn>, it means the UA must follow these
                   1861:   steps:</p>
                   1862: 
                   1863:   <ol><li>Let <var title="">last</var> be false.</li>
                   1864: 
1.604     mike     1865:    <li>Let <var title="">foreign</var> be false.</li>
                   1866: 
1.1       mike     1867:    <li>Let <var title="">node</var> be the last node in the
                   1868:    <a href="#stack-of-open-elements">stack of open elements</a>.</li>
                   1869: 
1.604     mike     1870:    <li><i>Loop</i>: If <var title="">node</var> is the first node in
                   1871:    the stack of open elements, then set <var title="">last</var> to
                   1872:    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     1873: 
                   1874:    <li>If <var title="">node</var> is a <code><a href="forms.html#the-select-element">select</a></code> element,
1.604     mike     1875:    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
1.856     mike     1876:    step labeled <i title="">end</i>. (<a href="#fragment-case">fragment case</a>)</li>
1.1       mike     1877: 
                   1878:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-td-element">td</a></code> or
                   1879:    <code><a href="tabular-data.html#the-th-element">th</a></code> element and <var title="">last</var> is false, then
                   1880:    switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion
1.856     mike     1881:    mode: in cell">in cell</a>" and jump to the step labeled <i title="">end</i>.</li>
1.1       mike     1882: 
                   1883:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then
                   1884:    switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion
1.856     mike     1885:    mode: in row">in row</a>" and jump to the step labeled <i title="">end</i>.</li>
1.1       mike     1886: 
                   1887:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>,
                   1888:    <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
                   1889:    <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in
1.856     mike     1890:    table body">in table body</a>" and jump to the step labeled <i title="">end</i>.</li>
1.1       mike     1891: 
                   1892:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-caption-element">caption</a></code> element,
1.604     mike     1893:    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
1.856     mike     1894:    the step labeled <i title="">end</i>.</li>
1.1       mike     1895: 
                   1896:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element,
                   1897:    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.856     mike     1898:    jump to the step labeled <i title="">end</i>. (<a href="#fragment-case">fragment
1.604     mike     1899:    case</a>)</li>
1.1       mike     1900: 
                   1901:    <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-table-element">table</a></code> element,
1.604     mike     1902:    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
1.856     mike     1903:    step labeled <i title="">end</i>.</li>
1.1       mike     1904: 
1.159     mike     1905:    <li>If <var title="">node</var> is a <code><a href="semantics.html#the-head-element-0">head</a></code> element,
1.604     mike     1906:    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
1.856     mike     1907:    the step labeled <i title="">end</i>. (<a href="#fragment-case">fragment
1.604     mike     1908:    case</a>)</li> <!-- This is only here for now in case people
                   1909:    think that the spec accidentally omitted it and try to "fix"
                   1910:    it. Note that noscript-in-head is also handled this way. This is
                   1911:    all intentional. The only thing it doesn't handle is the
                   1912:    scripting-disabled fragment parsing case for a <head> element
                   1913:    containing a <noscript> which itself contains something other than
1.872     mike     1914:    a <link> or a <style type="text/css"> element; you'd expect that to break out of
1.604     mike     1915:    the <noscript> but it doesn't. This is an edge case that doesn't
                   1916:    affect the spec, since the algorithm for fragment parsing is only
                   1917:    used for innerHTML/outerHTML/insertAdjacentHTML(), where we know
                   1918:    scripting is enabled. -->
1.1       mike     1919: 
1.159     mike     1920:    <li>If <var title="">node</var> is a <code><a href="semantics.html#the-body-element-0">body</a></code> element,
1.604     mike     1921:    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
1.856     mike     1922:    step labeled <i title="">end</i>.</li>
1.1       mike     1923: 
1.5       mike     1924:    <li>If <var title="">node</var> is a <code><a href="obsolete.html#frameset">frameset</a></code> element,
1.604     mike     1925:    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
1.856     mike     1926:    the step labeled <i title="">end</i>. (<a href="#fragment-case">fragment
1.604     mike     1927:    case</a>)</li>
1.1       mike     1928: 
1.159     mike     1929:    <li>If <var title="">node</var> is an <code><a href="semantics.html#the-html-element-0">html</a></code> element,
1.333     mike     1930:    then <!--: if the <span><code title="">head</code> element
                   1931:    pointer</span> is null,--> switch the <a href="#insertion-mode">insertion mode</a>
                   1932:    to "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before
                   1933:    head</a>"<!--, otherwise, switch the <span>insertion mode</span>
                   1934:    to "<span title="insertion mode: after head">after head</span>".-->
1.856     mike     1935:    Then, <!-- in either case, --> jump to the step labeled <i title="">end</i>. (<a href="#fragment-case">fragment case</a>)</li> <!-- if the
1.604     mike     1936:    head element pointer can ever be non-null when we're going through
                   1937:    these steps, we'll need to uncomment out the commented-out bits -->
                   1938: 
1.724     mike     1939:    <li>If <var title="">node</var> is an element from the <a href="infrastructure.html#mathml-namespace">MathML
                   1940:    namespace</a> or the <a href="infrastructure.html#svg-namespace">SVG namespace</a>, then set the
1.604     mike     1941:    <var title="">foreign</var> flag to true.</li>
1.1       mike     1942: 
                   1943:    <li>If <var title="">last</var> is true, then switch the
                   1944:    <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in
1.856     mike     1945:    body">in body</a>" and jump to the step labeled <i title="">end</i>. (<a href="#fragment-case">fragment case</a>)</li>
1.1       mike     1946: 
                   1947:    <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
                   1948:    elements</a>.</li>
                   1949: 
1.856     mike     1950:    <li>Return to the step labeled <i>loop</i>.</li>
1.604     mike     1951: 
                   1952:    <li><i>End</i>: If <var title="">foreign</var> is true, switch the
                   1953:    <a href="#secondary-insertion-mode">secondary insertion mode</a> to whatever the
                   1954:    <a href="#insertion-mode">insertion mode</a> is set to, and switch the
                   1955:    <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
                   1956:    foreign content">in foreign content</a>".</li>
1.1       mike     1957: 
1.755     mike     1958:   </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     1959: 
                   1960:   <p>Initially, the <dfn id="stack-of-open-elements">stack of open elements</dfn> is empty. The
                   1961:   stack grows downwards; the topmost node on the stack is the first
                   1962:   one added to the stack, and the bottommost node of the stack is the
                   1963:   most recently added node in the stack (notwithstanding when the
                   1964:   stack is manipulated in a random access fashion as part of <a href="#adoptionAgency">the handling for misnested tags</a>).</p>
                   1965: 
                   1966:   <p>The "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before
                   1967:   html</a>" <a href="#insertion-mode">insertion mode</a> creates the
1.159     mike     1968:   <code><a href="semantics.html#the-html-element-0">html</a></code> root element node, which is then added to the
1.1       mike     1969:   stack.</p>
                   1970: 
                   1971:   <p>In the <a href="#fragment-case">fragment case</a>, the <a href="#stack-of-open-elements">stack of open
1.159     mike     1972:   elements</a> is initialized to contain an <code><a href="semantics.html#the-html-element-0">html</a></code>
1.1       mike     1973:   element that is created as part of <a href="#html-fragment-parsing-algorithm" title="html fragment
                   1974:   parsing algorithm">that algorithm</a>. (The <a href="#fragment-case">fragment
                   1975:   case</a> skips the "<a href="#the-before-html-insertion-mode" title="insertion mode: before
                   1976:   html">before html</a>" <a href="#insertion-mode">insertion mode</a>.)</p>
                   1977: 
1.159     mike     1978:   <p>The <code><a href="semantics.html#the-html-element-0">html</a></code> node, however it is created, is the topmost
1.838     mike     1979:   node of the stack. It only gets popped off the stack when the parser
                   1980:   <a href="#stop-parsing" title="stop parsing">finishes</a>.</p>
1.1       mike     1981: 
                   1982:   <p>The <dfn id="current-node">current node</dfn> is the bottommost node in this
                   1983:   stack.</p>
                   1984: 
                   1985:   <p>The <dfn id="current-table">current table</dfn> is the last <code><a href="tabular-data.html#the-table-element">table</a></code>
                   1986:   element in the <a href="#stack-of-open-elements">stack of open elements</a>, if there is
                   1987:   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
                   1988:   open elements</a> (<a href="#fragment-case">fragment case</a>), then the
                   1989:   <a href="#current-table">current table</a> is the first element in the <a href="#stack-of-open-elements">stack
1.159     mike     1990:   of open elements</a> (the <code><a href="semantics.html#the-html-element-0">html</a></code> element).</p>
1.1       mike     1991: 
                   1992:   <p>Elements in the stack fall into the following categories:</p>
                   1993: 
                   1994:   <dl><dt><dfn id="special">Special</dfn></dt>
                   1995: 
                   1996:    <dd><p>The following HTML elements have varying levels of special
                   1997:    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>,
                   1998:    <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     1999:    <code><a href="obsolete.html#basefont">basefont</a></code>, <code><a href="obsolete.html#bgsound">bgsound</a></code>,
1.159     mike     2000:    <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     2001:    <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     2002:    <code><a href="interactive-elements.html#the-command">command</a></code>, <!--v2DDATAGRID <code>datagrid</code>-->,
1.422     mike     2003:    <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>,
                   2004:    <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     2005:    <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     2006:    <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>,
                   2007:    <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>,
                   2008:    <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>,
                   2009:    <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>,
                   2010:    <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>,
                   2011:    (commented out because this isn't an element that can end up on the
                   2012:    stack, so it doesn't matter) --> <code><a href="text-level-semantics.html#the-img-element">img</a></code>,
                   2013:    <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>,
                   2014:    <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>,
                   2015:    <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>,
                   2016:    <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>,
                   2017:    <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>,
                   2018:    <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     2019:    <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>,
                   2020:    <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>,
                   2021:    <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     2022:    <code><a href="obsolete.html#wbr">wbr</a></code>, and <code><a href="obsolete.html#xmp">xmp</a></code>.</p></dd>
1.1       mike     2023: 
                   2024:    <dt><dfn id="scoping">Scoping</dfn></dt>
                   2025:    <dd><p>The following HTML elements introduce new <a href="#has-an-element-in-scope" title="has
                   2026:    an element in scope">scopes</a> for various parts of the
1.5       mike     2027:    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     2028:    <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>,
                   2029:    <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     2030:    <code><a href="tabular-data.html#the-th-element">th</a></code>, and SVG's <code>foreignObject</code>.</p></dd>
                   2031: 
                   2032:    <dt><dfn id="formatting">Formatting</dfn></dt>
                   2033:    <dd><p>The following HTML elements are those that end up in the
                   2034:    <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     2035:    <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>,
                   2036:    <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     2037:    <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     2038:    <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
                   2039:    <code><a href="obsolete.html#u">u</a></code>.</p></dd>
1.1       mike     2040: 
                   2041:    <dt><dfn id="phrasing">Phrasing</dfn></dt>
                   2042:    <dd><p>All other elements found while parsing an HTML
                   2043:    document.</p></dd>
                   2044: 
1.234     mike     2045:   </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
                   2046:   specific scope</dfn> consisting of a list of element types <var title="">list</var> when the following algorithm terminates in a
                   2047:   match state:</p>
1.1       mike     2048: 
                   2049:   <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
                   2050:    node</a> (the bottommost node of the stack).</p></li>
                   2051: 
                   2052:    <li><p>If <var title="">node</var> is the target node, terminate in
                   2053:    a match state.</p></li>
                   2054: 
1.234     mike     2055:    <li><p>Otherwise, if <var title="">node</var> is one of the element
                   2056:    types in <var title="">list</var>, terminate in a failure
                   2057:    state.</p></li>
1.1       mike     2058: 
                   2059:    <li><p>Otherwise, set <var title="">node</var> to the previous
                   2060:    entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to step
                   2061:    2. (This will never fail, since the loop will always terminate in
                   2062:    the previous step if the top of the stack &#8212; an
1.159     mike     2063:    <code><a href="semantics.html#the-html-element-0">html</a></code> element &#8212; is reached.)</p></li>
1.1       mike     2064: 
1.234     mike     2065:   </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
                   2066:   it <a href="#has-an-element-in-the-specific-scope">has an element in the specific scope</a> consisting
                   2067:   of the following element types:</p>
                   2068: 
                   2069:   <ul class="brief"><li><code><a href="obsolete.html#the-applet-element">applet</a></code> in the HTML namespace</li>
                   2070:    <li><code><a href="tabular-data.html#the-caption-element">caption</a></code> in the HTML namespace</li>
                   2071:    <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.) -->
                   2072:    <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
                   2073:    <li><code><a href="tabular-data.html#the-td-element">td</a></code> in the HTML namespace</li>
                   2074:    <li><code><a href="tabular-data.html#the-th-element">th</a></code> in the HTML namespace</li>
                   2075:    <li><code><a href="forms.html#the-button-element">button</a></code> in the HTML namespace</li>
                   2076:    <li><code><a href="obsolete.html#the-marquee-element">marquee</a></code> in the HTML namespace</li>
                   2077:    <li><code><a href="text-level-semantics.html#the-object-element">object</a></code> in the HTML namespace</li>
                   2078:    <li><code title="">foreignObject</code> in the SVG namespace</li>
                   2079:   </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
                   2080:   item scope</dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
                   2081:   scope</a> consisting of the following element types:</p>
                   2082: 
                   2083:   <ul class="brief"><li>All the element types listed above for the <i><a href="#has-an-element-in-scope">has an element
                   2084:    in scope</a></i> algorithm.</li>
                   2085:    <li><code><a href="semantics.html#the-ol-element">ol</a></code> in the HTML namespace</li>
                   2086:    <li><code><a href="semantics.html#the-ul-element">ul</a></code> in the HTML namespace</li>
                   2087:   </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
                   2088:   scope</em></dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
                   2089:   scope</a> consisting of the following element types:</p>
                   2090: 
                   2091:   <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.) -->
                   2092:    <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
                   2093:   </ul><p>Nothing happens if at any time any of the elements in the
1.1       mike     2094:   <a href="#stack-of-open-elements">stack of open elements</a> are moved to a new location in,
1.810     mike     2095:   or removed from, the <code><a href="infrastructure.html#document">Document</a></code> tree. In particular, the
1.1       mike     2096:   stack is not changed in this situation. This can cause, amongst
                   2097:   other strange effects, content to be appended to nodes that are no
                   2098:   longer in the DOM.</p>
                   2099: 
                   2100:   <p class="note">In some cases (namely, when <a href="#adoptionAgency">closing misnested formatting elements</a>),
                   2101:   the stack is manipulated in a random-access fashion.</p>
                   2102: 
                   2103: 
1.755     mike     2104:   <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     2105: 
                   2106:   <p>Initially, the <dfn id="list-of-active-formatting-elements">list of active formatting elements</dfn> is
                   2107:   empty. It is used to handle mis-nested <a href="#formatting" title="formatting">formatting element tags</a>.</p>
                   2108: 
                   2109:   <p>The list contains elements in the <a href="#formatting">formatting</a>
                   2110:   category, and scope markers. The scope markers are inserted when
1.159     mike     2111:   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     2112:   elements, marquees, table cells, and table captions, and are used to
1.5       mike     2113:   prevent formatting from "leaking" <em>into</em> <code><a href="obsolete.html#the-applet-element">applet</a></code>
1.159     mike     2114:   elements, buttons, <code><a href="text-level-semantics.html#the-object-element">object</a></code> elements, marquees, and
1.1       mike     2115:   tables.</p>
                   2116: 
                   2117:   <p class="note">The scope markers are unrelated to the concept of an
                   2118:   element being <a href="#has-an-element-in-scope" title="has an element in scope">in
                   2119:   scope</a>.</p>
                   2120: 
                   2121:   <p>In addition, each element in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2122:   elements</a> is associated with the token for which it was
                   2123:   created, so that further elements can be created for that token if
                   2124:   necessary.</p>
                   2125: 
                   2126:   <p>When the steps below require the UA to <dfn id="reconstruct-the-active-formatting-elements">reconstruct the
                   2127:   active formatting elements</dfn>, the UA must perform the following
                   2128:   steps:</p>
                   2129: 
                   2130:   <ol><li>If there are no entries in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2131:    elements</a>, then there is nothing to reconstruct; stop this
                   2132:    algorithm.</li>
                   2133: 
                   2134:    <li>If the last (most recently added) entry in the <a href="#list-of-active-formatting-elements">list of
                   2135:    active formatting elements</a> is a marker, or if it is an
                   2136:    element that is in the <a href="#stack-of-open-elements">stack of open elements</a>, then
                   2137:    there is nothing to reconstruct; stop this algorithm.</li>
                   2138: 
                   2139:    <li>Let <var title="">entry</var> be the last (most recently added)
                   2140:    element in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2141:    elements</a>.</li>
                   2142: 
                   2143:    <li>If there are no entries before <var title="">entry</var> in the
                   2144:    <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, then jump to step
                   2145:    8.</li>
                   2146: 
                   2147:    <li>Let <var title="">entry</var> be the entry one earlier than
                   2148:    <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2149:    elements</a>.</li>
                   2150: 
                   2151:    <li>If <var title="">entry</var> is neither a marker nor an element
                   2152:    that is also in the <a href="#stack-of-open-elements">stack of open elements</a>, go to step
                   2153:    4.</li>
                   2154: 
                   2155:    <li>Let <var title="">entry</var> be the element one later than
                   2156:    <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
                   2157:    elements</a>.</li>
                   2158: 
                   2159:    <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
                   2160:    element <var title="">entry</var> was created, to obtain <var title="">new element</var>.</li>
                   2161: 
                   2162:    <li>Append <var title="">new element</var> to the <a href="#current-node">current
                   2163:    node</a> and push it onto the <a href="#stack-of-open-elements">stack of open
                   2164:    elements</a> so that it is the new <a href="#current-node">current
                   2165:    node</a>.</li>
                   2166: 
                   2167:    <li>Replace the entry for <var title="">entry</var> in the list
                   2168:    with an entry for <var title="">new element</var>.</li>
                   2169: 
                   2170:    <li>If the entry for <var title="">new element</var> in the
                   2171:    <a href="#list-of-active-formatting-elements">list of active formatting elements</a> is not the last
                   2172:    entry in the list, return to step 7.</li>
                   2173: 
                   2174:   </ol><p>This has the effect of reopening all the formatting elements that
                   2175:   were opened in the current body, cell, or caption (whichever is
                   2176:   youngest) that haven't been explicitly closed.</p>
                   2177: 
                   2178:   <p class="note">The way this specification is written, the
                   2179:   <a href="#list-of-active-formatting-elements">list of active formatting elements</a> always consists of
                   2180:   elements in chronological order with the least recently added
                   2181:   element first and the most recently added element last (except for
                   2182:   while steps 8 to 11 of the above algorithm are being executed, of
                   2183:   course).</p>
                   2184: 
                   2185:   <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
                   2186:   active formatting elements up to the last marker</dfn>, the UA must
                   2187:   perform the following steps:</p>
                   2188: 
                   2189:   <ol><li>Let <var title="">entry</var> be the last (most recently added)
                   2190:    entry in the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</li>
                   2191: 
                   2192:    <li>Remove <var title="">entry</var> from the <a href="#list-of-active-formatting-elements">list of active
                   2193:    formatting elements</a>.</li>
                   2194: 
                   2195:    <li>If <var title="">entry</var> was a marker, then stop the
                   2196:    algorithm at this point. The list has been cleared up to the last
                   2197:    marker.</li>
                   2198: 
                   2199:    <li>Go to step 1.</li>
                   2200: 
1.755     mike     2201:   </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     2202: 
                   2203:   <p>Initially, the <dfn id="head-element-pointer"><code title="">head</code> element
                   2204:   pointer</dfn> and the <dfn id="form-element-pointer"><code title="">form</code> element
                   2205:   pointer</dfn> are both null.</p>
                   2206: 
1.159     mike     2207:   <p>Once a <code><a href="semantics.html#the-head-element-0">head</a></code> element has been parsed (whether
1.1       mike     2208:   implicitly or explicitly) the <a href="#head-element-pointer"><code title="">head</code>
                   2209:   element pointer</a> gets set to point to this node.</p>
                   2210: 
                   2211:   <p>The <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
                   2212:   points to the last <code><a href="forms.html#the-form-element">form</a></code> element that was opened and
                   2213:   whose end tag has not yet been seen. It is used to make form
                   2214:   controls associate with forms in the face of dramatically bad
                   2215:   markup, for historical reasons.</p>
                   2216: 
                   2217: 
1.755     mike     2218:   <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     2219: 
1.794     mike     2220:   <p>The <dfn id="scripting-flag">scripting flag</dfn> is set to "enabled" if <a href="webappapis.html#concept-n-script" title="concept-n-script">scripting was enabled</a> for the
1.810     mike     2221:   <code><a href="infrastructure.html#document">Document</a></code> with which the parser is associated when the
1.1       mike     2222:   parser was created, and "disabled" otherwise.</p>
                   2223: 
                   2224:   <p class="note">The <a href="#scripting-flag">scripting flag</a> can be enabled even
                   2225:   when the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML fragment
                   2226:   parsing algorithm</a>, even though <code><a href="semantics.html#script">script</a></code> elements
                   2227:   don't execute in that case.</p>
                   2228: 
                   2229:   <p>The <dfn id="frameset-ok-flag">frameset-ok flag</dfn> is set to "ok" when the parser is
                   2230:   created. It is set to "not ok" after certain tokens are seen.</p>
                   2231: 
1.266     mike     2232:   </div><div class="impl">
1.1       mike     2233: 
1.755     mike     2234:   <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     2235: 
                   2236:   <p>Implementations must act as if they used the following state
                   2237:   machine to tokenize HTML. The state machine must start in the
                   2238:   <a href="#data-state">data state</a>. Most states consume a single character,
                   2239:   which may have various side-effects, and either switches the state
                   2240:   machine to a new state to <em>reconsume</em> the same character, or
                   2241:   switches it to a new state (to consume the next character), or
                   2242:   repeats the same state (to consume the next character). Some states
                   2243:   have more complicated behavior and can consume several characters
1.541     mike     2244:   before switching to another state. In some cases, the tokenizer
                   2245:   state is also changed by the tree construction stage.</p>
1.1       mike     2246: 
1.541     mike     2247:   <p>The exact behavior of certain states depends on the
                   2248:   <a href="#insertion-mode">insertion mode</a> and the <a href="#stack-of-open-elements">stack of open
                   2249:   elements</a>. Certain states also use a <dfn id="temporary-buffer"><var>temporary
                   2250:   buffer</var></dfn> to track progress.</p>
1.1       mike     2251: 
                   2252:   <p>The output of the tokenization step is a series of zero or more
                   2253:   of the following tokens: DOCTYPE, start tag, end tag, comment,
                   2254:   character, end-of-file. DOCTYPE tokens have a name, a public
                   2255:   identifier, a system identifier, and a <i>force-quirks
                   2256:   flag</i>. When a DOCTYPE token is created, its name, public
                   2257:   identifier, and system identifier must be marked as missing (which
                   2258:   is a distinct state from the empty string), and the <i>force-quirks
                   2259:   flag</i> must be set to <i>off</i> (its other state is
                   2260:   <i>on</i>). Start and end tag tokens have a tag name, a
                   2261:   <i>self-closing flag</i>, and a list of attributes, each of which
                   2262:   has a name and a value. When a start or end tag token is created,
                   2263:   its <i>self-closing flag</i> must be unset (its other state is that
                   2264:   it be set), and its attributes list must be empty. Comment and
                   2265:   character tokens have data.</p>
                   2266: 
                   2267:   <p>When a token is emitted, it must immediately be handled by the
                   2268:   <a href="#tree-construction">tree construction</a> stage. The tree construction stage
1.541     mike     2269:   can affect the state of the tokenization stage, and can insert
                   2270:   additional characters into the stream. (For example, the
1.1       mike     2271:   <code><a href="semantics.html#script">script</a></code> element can result in scripts executing and
1.159     mike     2272:   using the <a href="embedded-content-0.html#dynamic-markup-insertion">dynamic markup insertion</a> APIs to insert
1.1       mike     2273:   characters into the stream being tokenized.)</p>
                   2274: 
                   2275:   <p>When a start tag token is emitted with its <i>self-closing
                   2276:   flag</i> set, if the flag is not <dfn id="acknowledge-self-closing-flag" title="acknowledge
                   2277:   self-closing flag">acknowledged</dfn> when it is processed by the
                   2278:   tree construction stage, that is a <a href="#parse-error">parse error</a>.</p>
                   2279: 
                   2280:   <p>When an end tag token is emitted with attributes, that is a
                   2281:   <a href="#parse-error">parse error</a>.</p>
                   2282: 
                   2283:   <p>When an end tag token is emitted with its <i>self-closing
                   2284:   flag</i> set, that is a <a href="#parse-error">parse error</a>.</p>
                   2285: 
1.541     mike     2286:   <p>An <dfn id="appropriate-end-tag-token">appropriate end tag token</dfn> is an end tag token whose
                   2287:   tag name matches the tag name of the last start tag to have been
                   2288:   emitted from this tokenizer, if any. If no start tag has been
                   2289:   emitted from this tokenizer, then no end tag token is
                   2290:   appropriate.</p>
                   2291: 
1.1       mike     2292:   <p>Before each step of the tokenizer, the user agent must first
                   2293:   check the <a href="#parser-pause-flag">parser pause flag</a>. If it is true, then the
                   2294:   tokenizer must abort the processing of any nested invocations of the
1.479     mike     2295:   tokenizer, yielding control back to the caller.</p>
1.1       mike     2296: 
                   2297:   <p>The tokenizer state machine consists of the states defined in the
                   2298:   following subsections.</p>
                   2299: 
1.541     mike     2300: 
1.333     mike     2301:   <!-- Order of the lists below is supposed to be non-error then
                   2302:   error, by unicode, then EOF, ending with "anything else" -->
1.1       mike     2303: 
1.541     mike     2304: 
1.755     mike     2305:   <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     2306: 
                   2307:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2308: 
                   2309:   <dl class="switch"><dt>U+0026 AMPERSAND (&amp;)</dt>
1.541     mike     2310:    <dd>Switch to the <a href="#character-reference-in-data-state">character reference in data
1.56      mike     2311:    state</a>.</dd>
1.1       mike     2312: 
1.541     mike     2313:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2314:    <dd>Switch to the <a href="#tag-open-state">tag open state</a>.</dd>
                   2315: 
                   2316:    <dt>EOF</dt>
                   2317:    <dd>Emit an end-of-file token.</dd>
                   2318: 
                   2319:    <dt>Anything else</dt>
                   2320:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2321:    token. Stay in the <a href="#data-state">data state</a>.</dd>
1.1       mike     2322: 
1.755     mike     2323:   </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     2324: 
                   2325:   <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>, with no
                   2326:   <a href="#additional-allowed-character">additional allowed character</a>.</p>
                   2327: 
                   2328:   <p>If nothing is returned, emit a U+0026 AMPERSAND character
                   2329:   token.</p>
                   2330: 
                   2331:   <p>Otherwise, emit the character token that was returned.</p>
                   2332: 
                   2333:   <p>Finally, switch to the <a href="#data-state">data state</a>.</p>
                   2334: 
                   2335: 
1.755     mike     2336:   <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     2337: 
1.541     mike     2338:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2339: 
1.541     mike     2340:   <dl class="switch"><dt>U+0026 AMPERSAND (&amp;)</dt>
1.618     mike     2341:    <dd>Switch to the <a href="#character-reference-in-rcdata-state">character reference in RCDATA
1.541     mike     2342:    state</a>.</dd>
1.1       mike     2343: 
                   2344:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
1.541     mike     2345:    <dd>Switch to the <a href="#rcdata-less-than-sign-state">RCDATA less-than sign state</a>.</dd>
                   2346: 
                   2347:    <dt>EOF</dt>
                   2348:    <dd>Emit an end-of-file token.</dd>
1.1       mike     2349: 
1.541     mike     2350:    <dt>Anything else</dt>
                   2351:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2352:    token. Stay in the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1       mike     2353: 
1.755     mike     2354:   </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     2355: 
                   2356:   <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>, with no
                   2357:   <a href="#additional-allowed-character">additional allowed character</a>.</p>
                   2358: 
                   2359:   <p>If nothing is returned, emit a U+0026 AMPERSAND character
                   2360:   token.</p>
                   2361: 
                   2362:   <p>Otherwise, emit the character token that was returned.</p>
                   2363: 
                   2364:   <p>Finally, switch to the <a href="#rcdata-state">RCDATA state</a>.</p>
                   2365: 
                   2366: 
1.755     mike     2367:   <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     2368: 
1.541     mike     2369:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2370: 
1.541     mike     2371:   <dl class="switch"><dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2372:    <dd>Switch to the <a href="#rawtext-less-than-sign-state">RAWTEXT less-than sign state</a>.</dd>
1.1       mike     2373: 
                   2374:    <dt>EOF</dt>
                   2375:    <dd>Emit an end-of-file token.</dd>
                   2376: 
                   2377:    <dt>Anything else</dt>
1.541     mike     2378:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2379:    token. Stay in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1       mike     2380: 
1.755     mike     2381:   </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     2382: 
1.541     mike     2383:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2384: 
1.541     mike     2385:   <dl class="switch"><dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2386:    <dd>Switch to the <a href="#script-data-less-than-sign-state">script data less-than sign state</a>.</dd>
1.1       mike     2387: 
1.541     mike     2388:    <dt>EOF</dt>
                   2389:    <dd>Emit an end-of-file token.</dd>
1.1       mike     2390: 
1.541     mike     2391:    <dt>Anything else</dt>
                   2392:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2393:    token. Stay in the <a href="#script-data-state">script data state</a>.</dd>
1.1       mike     2394: 
1.755     mike     2395:   </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     2396: 
1.541     mike     2397:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2398: 
1.541     mike     2399:   <dl class="switch"><dt>EOF</dt>
                   2400:    <dd>Emit an end-of-file token.</dd>
1.1       mike     2401: 
1.541     mike     2402:    <dt>Anything else</dt>
                   2403:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2404:    token. Stay in the <a href="#plaintext-state">PLAINTEXT state</a>.</dd>
1.1       mike     2405: 
1.755     mike     2406:   </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     2407: 
1.541     mike     2408:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2409: 
1.541     mike     2410:   <dl class="switch"><dt>U+0021 EXCLAMATION MARK (!)</dt>
                   2411:    <dd>Switch to the <a href="#markup-declaration-open-state">markup declaration open state</a>.</dd>
1.1       mike     2412: 
1.541     mike     2413:    <dt>U+002F SOLIDUS (/)</dt>
1.755     mike     2414:    <dd>Switch to the <a href="#end-tag-open-state">end tag open state</a>.</dd>
1.1       mike     2415: 
1.541     mike     2416:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2417:    <dd>Create a new start tag token, set its tag name to the
                   2418:    lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
                   2419:    character's code point), then switch to the <a href="#tag-name-state">tag name
                   2420:    state</a>. (Don't emit the token yet; further details will
                   2421:    be filled in before it is emitted.)</dd>
1.1       mike     2422: 
1.541     mike     2423:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2424:    <dd>Create a new start tag token, set its tag name to the
                   2425:    <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
                   2426:    name state</a>. (Don't emit the token yet; further details will
                   2427:    be filled in before it is emitted.)</dd>
1.1       mike     2428: 
1.541     mike     2429:    <dt>U+003F QUESTION MARK (?)</dt>
                   2430:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
                   2431:    comment state</a>.</dd>
1.1       mike     2432: 
1.541     mike     2433:    <dt>Anything else</dt>
                   2434:    <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
                   2435:    character token and reconsume the <a href="#current-input-character">current input
                   2436:    character</a> in the <a href="#data-state">data state</a>.</dd>
1.1       mike     2437: 
1.755     mike     2438:   </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     2439: 
1.541     mike     2440:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1       mike     2441: 
                   2442:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2443:    <dd>Create a new end tag token, set its tag name to the lowercase
1.541     mike     2444:    version of the <a href="#current-input-character">current input character</a> (add 0x0020 to
                   2445:    the character's code point), then switch to the <a href="#tag-name-state">tag name
1.1       mike     2446:    state</a>. (Don't emit the token yet; further details will be
                   2447:    filled in before it is emitted.)</dd>
                   2448: 
                   2449:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
1.541     mike     2450:    <dd>Create a new end tag token, set its tag name to the
                   2451:    <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
                   2452:    name state</a>. (Don't emit the token yet; further details will
                   2453:    be filled in before it is emitted.)</dd>
1.1       mike     2454: 
                   2455:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2456:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#data-state">data
                   2457:    state</a>.</dd>
                   2458: 
                   2459:    <dt>EOF</dt>
                   2460:    <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
                   2461:    character token and a U+002F SOLIDUS character token. Reconsume
                   2462:    the EOF character in the <a href="#data-state">data state</a>.</dd>
                   2463: 
                   2464:    <dt>Anything else</dt>
                   2465:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
                   2466:    comment state</a>.</dd>
                   2467: 
1.755     mike     2468:   </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     2469: 
                   2470:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2471: 
                   2472:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2473:    <dt>U+000A LINE FEED (LF)</dt>
                   2474:    <dt>U+000C FORM FEED (FF)</dt>
                   2475:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2476:    <dt>U+0020 SPACE</dt>
                   2477:    <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   2478: 
                   2479:    <dt>U+002F SOLIDUS (/)</dt>
                   2480:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   2481: 
                   2482:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2483:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   2484:    state</a>.</dd>
                   2485: 
                   2486:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541     mike     2487:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2488:    character</a> (add 0x0020 to the character's code point) to the
                   2489:    current tag token's tag name. Stay in the <a href="#tag-name-state">tag name
                   2490:    state</a>.</dd>
                   2491: 
                   2492:    <dt>EOF</dt>
                   2493:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2494:    <a href="#data-state">data state</a>.</dd>
                   2495: 
                   2496:    <dt>Anything else</dt>
                   2497:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2498:    tag token's tag name. Stay in the <a href="#tag-name-state">tag name state</a>.</dd>
                   2499: 
1.755     mike     2500:   </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     2501:   <!-- identical to the RAWTEXT less-than sign state, except s/RAWTEXT/RCDATA/g -->
                   2502: 
                   2503:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2504: 
                   2505:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   2506:    <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
                   2507:    to the <a href="#rcdata-end-tag-open-state">RCDATA end tag open state</a>.</dd>
                   2508: 
                   2509:    <dt>Anything else</dt>
                   2510:    <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
                   2511:    <a href="#current-input-character">current input character</a> in the <a href="#rcdata-state">RCDATA
                   2512:    state</a>.</dd>
                   2513: 
1.755     mike     2514:   </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     2515:   <!-- identical to the RAWTEXT (and Script data) end tag open state, except s/RAWTEXT/RCDATA/g -->
                   2516: 
                   2517:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2518: 
                   2519:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2520:    <dd>Create a new end tag token, and set its tag name to the
                   2521:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2522:    0x0020 to the character's code point). Append the <a href="#current-input-character">current
                   2523:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2524:    switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
                   2525:    the token yet; further details will be filled in before it is
                   2526:    emitted.)</dd>
                   2527: 
                   2528:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2529:    <dd>Create a new end tag token, and set its tag name to the
                   2530:    <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
                   2531:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2532:    switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
                   2533:    the token yet; further details will be filled in before it is
                   2534:    emitted.)</dd>
                   2535: 
                   2536:    <dt>Anything else</dt>
                   2537:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2538:    character token, and reconsume the <a href="#current-input-character">current input
                   2539:    character</a> in the <a href="#rcdata-state">RCDATA state</a>.</dd>
                   2540: 
1.755     mike     2541:   </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     2542:   <!-- identical to the RAWTEXT (and Script data) end tag name state, except s/RAWTEXT/RCDATA/g -->
                   2543: 
                   2544:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2545: 
                   2546:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2547:    <dt>U+000A LINE FEED (LF)</dt>
                   2548:    <dt>U+000C FORM FEED (FF)</dt>
                   2549:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2550:    <dt>U+0020 SPACE</dt>
                   2551:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2552:    token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
                   2553:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2554:    below.</dd>
                   2555: 
                   2556:    <dt>U+002F SOLIDUS (/)</dt>
                   2557:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2558:    token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
                   2559:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2560:    below.</dd>
                   2561: 
                   2562:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2563:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2564:    token</a>, then emit the current tag token and switch to the
                   2565:    <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
                   2566:    else" entry below.</dd>
                   2567: 
                   2568:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2569:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2570:    character</a> (add 0x0020 to the character's code point) to the
                   2571:    current tag token's tag name. Append the <a href="#current-input-character">current input
                   2572:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2573:    <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
                   2574: 
                   2575:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2576:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2577:    tag token's tag name. Append the <a href="#current-input-character">current input
                   2578:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2579:    <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
                   2580: 
                   2581:    <dt>Anything else</dt>
                   2582:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2583:    character token, a character token for each of the characters in
                   2584:    the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
                   2585:    the buffer), and reconsume the <a href="#current-input-character">current input character</a>
                   2586:    in the <a href="#rcdata-state">RCDATA state</a>.</dd>
                   2587: 
1.755     mike     2588:   </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     2589:   <!-- identical to the RCDATA less-than sign state, except s/RCDATA/RAWTEXT/g -->
                   2590: 
                   2591:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2592: 
                   2593:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   2594:    <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
                   2595:    to the <a href="#rawtext-end-tag-open-state">RAWTEXT end tag open state</a>.</dd>
                   2596: 
                   2597:    <dt>Anything else</dt>
                   2598:    <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
                   2599:    <a href="#current-input-character">current input character</a> in the <a href="#rawtext-state">RAWTEXT
                   2600:    state</a>.</dd>
                   2601: 
1.755     mike     2602:   </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     2603:   <!-- identical to the RCDATA (and Script data) end tag open state, except s/RCDATA/RAWTEXT/g -->
                   2604: 
                   2605:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2606: 
                   2607:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2608:    <dd>Create a new end tag token, and set its tag name to the
                   2609:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2610:    0x0020 to the character's code point). Append the <a href="#current-input-character">current
                   2611:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2612:    switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
                   2613:    the token yet; further details will be filled in before it is
                   2614:    emitted.)</dd>
                   2615: 
                   2616:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2617:    <dd>Create a new end tag token, and set its tag name to the
                   2618:    <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
                   2619:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2620:    switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
                   2621:    the token yet; further details will be filled in before it is
                   2622:    emitted.)</dd>
                   2623: 
                   2624:    <dt>Anything else</dt>
                   2625:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2626:    character token, and reconsume the <a href="#current-input-character">current input
                   2627:    character</a> in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
                   2628: 
1.755     mike     2629:   </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     2630:   <!-- identical to the RCDATA (and Script data) end tag name state, except s/RCDATA/RAWTEXT/g -->
                   2631: 
                   2632:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2633: 
                   2634:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2635:    <dt>U+000A LINE FEED (LF)</dt>
                   2636:    <dt>U+000C FORM FEED (FF)</dt>
                   2637:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2638:    <dt>U+0020 SPACE</dt>
                   2639:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2640:    token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
                   2641:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2642:    below.</dd>
                   2643: 
                   2644:    <dt>U+002F SOLIDUS (/)</dt>
                   2645:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2646:    token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
                   2647:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2648:    below.</dd>
                   2649: 
                   2650:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2651:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2652:    token</a>, then emit the current tag token and switch to the
                   2653:    <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
                   2654:    else" entry below.</dd>
                   2655: 
                   2656:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2657:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2658:    character</a> (add 0x0020 to the character's code point) to the
                   2659:    current tag token's tag name. Append the <a href="#current-input-character">current input
                   2660:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2661:    <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
                   2662: 
                   2663:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2664:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2665:    tag token's tag name. Append the <a href="#current-input-character">current input
                   2666:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2667:    <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
                   2668: 
                   2669:    <dt>Anything else</dt>
                   2670:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2671:    character token, a character token for each of the characters in
                   2672:    the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
                   2673:    the buffer), and reconsume the <a href="#current-input-character">current input character</a>
                   2674:    in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
                   2675: 
1.755     mike     2676:   </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     2677: 
                   2678:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2679: 
                   2680:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   2681:    <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
                   2682:    to the <a href="#script-data-end-tag-open-state">script data end tag open state</a>.</dd>
                   2683: 
                   2684:    <dt>U+0021 EXCLAMATION MARK (!)</dt>
                   2685:    <dd>Emit a U+003C LESS-THAN SIGN character token and a U+0021
                   2686:    EXCLAMATION MARK character token. Switch to the <a href="#script-data-escape-start-state">script data
                   2687:    escape start state</a>.</dd>
                   2688: 
                   2689:    <dt>Anything else</dt>
                   2690:    <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
                   2691:    <a href="#current-input-character">current input character</a> in the <a href="#script-data-state">script data
                   2692:    state</a>.</dd>
                   2693: 
1.755     mike     2694:   </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     2695:   <!-- identical to the RCDATA (and RAWTEXT) end tag open state, except s/RCDATA/Script data/g -->
                   2696: 
                   2697:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2698: 
                   2699:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2700:    <dd>Create a new end tag token, and set its tag name to the
                   2701:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2702:    0x0020 to the character's code point). Append the <a href="#current-input-character">current
                   2703:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2704:    switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
                   2705:    the token yet; further details will be filled in before it is
                   2706:    emitted.)</dd>
                   2707: 
                   2708:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2709:    <dd>Create a new end tag token, and set its tag name to the
                   2710:    <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
                   2711:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2712:    switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
                   2713:    the token yet; further details will be filled in before it is
                   2714:    emitted.)</dd>
                   2715: 
                   2716:    <dt>Anything else</dt>
                   2717:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2718:    character token, and reconsume the <a href="#current-input-character">current input
                   2719:    character</a> in the <a href="#script-data-state">script data state</a>.</dd>
                   2720: 
1.755     mike     2721:   </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     2722:   <!-- identical to the RCDATA (and RAWTEXT) end tag name state, except s/RCDATA/Script data/g -->
                   2723: 
                   2724:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2725: 
                   2726:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2727:    <dt>U+000A LINE FEED (LF)</dt>
                   2728:    <dt>U+000C FORM FEED (FF)</dt>
                   2729:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2730:    <dt>U+0020 SPACE</dt>
                   2731:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2732:    token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
                   2733:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2734:    below.</dd>
                   2735: 
                   2736:    <dt>U+002F SOLIDUS (/)</dt>
                   2737:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2738:    token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
                   2739:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2740:    below.</dd>
                   2741: 
                   2742:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2743:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2744:    token</a>, then emit the current tag token and switch to the
                   2745:    <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
                   2746:    else" entry below.</dd>
                   2747: 
                   2748:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2749:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2750:    character</a> (add 0x0020 to the character's code point) to the
                   2751:    current tag token's tag name. Append the <a href="#current-input-character">current input
                   2752:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542     mike     2753:    <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541     mike     2754: 
                   2755:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2756:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2757:    tag token's tag name. Append the <a href="#current-input-character">current input
                   2758:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542     mike     2759:    <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541     mike     2760: 
                   2761:    <dt>Anything else</dt>
                   2762:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2763:    character token, a character token for each of the characters in
                   2764:    the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
                   2765:    the buffer), and reconsume the <a href="#current-input-character">current input character</a>
                   2766:    in the <a href="#script-data-state">script data state</a>.</dd>
                   2767: 
1.755     mike     2768:   </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     2769: 
                   2770:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2771: 
                   2772:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2773:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2774:    <a href="#script-data-escape-start-dash-state">script data escape start dash state</a>.</dd>
                   2775: 
                   2776:    <dt>Anything else</dt>
                   2777:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   2778:    <a href="#script-data-state">script data state</a>.</dd>
                   2779: 
1.755     mike     2780:   </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     2781: 
                   2782:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2783: 
                   2784:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2785:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2786:    <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
                   2787: 
                   2788:    <dt>Anything else</dt>
                   2789:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   2790:    <a href="#script-data-state">script data state</a>.</dd>
                   2791: 
1.755     mike     2792:   </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     2793: 
                   2794:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2795: 
                   2796:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2797:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2798:    <a href="#script-data-escaped-dash-state">script data escaped dash state</a>.</dd>
                   2799: 
1.542     mike     2800:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2801:    <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
                   2802:    state</a>.</p></dd>
                   2803: 
1.541     mike     2804:    <dt>EOF</dt>
                   2805:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2806:    <a href="#data-state">data state</a>.</dd>
                   2807: 
                   2808:    <dt>Anything else</dt>
1.542     mike     2809:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2810:    token. Stay in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541     mike     2811: 
1.755     mike     2812:   </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     2813: 
                   2814:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2815: 
                   2816:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2817:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2818:    <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
                   2819: 
1.542     mike     2820:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2821:    <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
                   2822:    state</a>.</p></dd>
                   2823: 
1.541     mike     2824:    <dt>EOF</dt>
                   2825:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2826:    <a href="#data-state">data state</a>.</dd>
                   2827: 
                   2828:    <dt>Anything else</dt>
1.542     mike     2829:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2830:    token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541     mike     2831: 
1.755     mike     2832:   </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     2833: 
                   2834:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2835: 
                   2836:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2837:    <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
                   2838:    <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
                   2839: 
1.542     mike     2840:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   2841:    <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
                   2842:    state</a>.</p></dd>
                   2843: 
1.541     mike     2844:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2845:    <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
                   2846:    <a href="#script-data-state">script data state</a>.</dd>
1.1       mike     2847: 
                   2848:    <dt>EOF</dt>
                   2849:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   2850:    <a href="#data-state">data state</a>.</dd>
                   2851: 
                   2852:    <dt>Anything else</dt>
1.542     mike     2853:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2854:    token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
                   2855: 
1.755     mike     2856:   </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     2857: 
                   2858:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2859: 
                   2860:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   2861:    <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
                   2862:    to the <a href="#script-data-escaped-end-tag-open-state">script data escaped end tag open state</a>.</dd>
                   2863: 
                   2864:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2865:    <dd>Emit a U+003C LESS-THAN SIGN character token and the
                   2866:    <a href="#current-input-character">current input character</a> as a character token. Set the
                   2867:    <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
                   2868:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2869:    0x0020 to the character's code point) to the <var><a href="#temporary-buffer">temporary
                   2870:    buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
                   2871:    state</a>.</dd>
                   2872: 
                   2873:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2874:    <dd>Emit a U+003C LESS-THAN SIGN character token and the
                   2875:    <a href="#current-input-character">current input character</a> as a character token. Set the
                   2876:    <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
                   2877:    <a href="#current-input-character">current input character</a> to the <var><a href="#temporary-buffer">temporary
                   2878:    buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
                   2879:    state</a>.</dd>
                   2880: 
                   2881:    <dt>Anything else</dt>
                   2882:    <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
                   2883:    <a href="#current-input-character">current input character</a> in the <a href="#script-data-escaped-state">script data
                   2884:    escaped state</a>.</dd>
                   2885: 
1.755     mike     2886:   </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     2887: 
                   2888:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2889: 
                   2890:   <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2891:    <dd>Create a new end tag token, and set its tag name to the
                   2892:    lowercase version of the <a href="#current-input-character">current input character</a> (add
                   2893:    0x0020 to the character's code point). Append the <a href="#current-input-character">current
                   2894:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2895:    switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
                   2896:    state</a>. (Don't emit the token yet; further details will be
                   2897:    filled in before it is emitted.)</dd>
                   2898: 
                   2899:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2900:    <dd>Create a new end tag token, and set its tag name to the
                   2901:    <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
                   2902:    input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
                   2903:    switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
                   2904:    state</a>. (Don't emit the token yet; further details will be
                   2905:    filled in before it is emitted.)</dd>
                   2906: 
                   2907:    <dt>Anything else</dt>
                   2908:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2909:    character token, and reconsume the <a href="#current-input-character">current input
                   2910:    character</a> in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
                   2911: 
1.755     mike     2912:   </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     2913: 
                   2914:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2915: 
                   2916:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2917:    <dt>U+000A LINE FEED (LF)</dt>
                   2918:    <dt>U+000C FORM FEED (FF)</dt>
                   2919:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2920:    <dt>U+0020 SPACE</dt>
                   2921:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2922:    token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
                   2923:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2924:    below.</dd>
                   2925: 
                   2926:    <dt>U+002F SOLIDUS (/)</dt>
                   2927:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2928:    token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
                   2929:    state</a>. Otherwise, treat it as per the "anything else" entry
                   2930:    below.</dd>
                   2931: 
                   2932:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2933:    <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
                   2934:    token</a>, then emit the current tag token and switch to the
                   2935:    <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
                   2936:    else" entry below.</dd>
                   2937: 
                   2938:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2939:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   2940:    character</a> (add 0x0020 to the character's code point) to the
                   2941:    current tag token's tag name. Append the <a href="#current-input-character">current input
                   2942:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2943:    <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
                   2944: 
                   2945:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2946:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   2947:    tag token's tag name. Append the <a href="#current-input-character">current input
                   2948:    character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
                   2949:    <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
                   2950: 
                   2951:    <dt>Anything else</dt>
                   2952:    <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
                   2953:    character token, a character token for each of the characters in
                   2954:    the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
                   2955:    the buffer), and reconsume the <a href="#current-input-character">current input character</a>
                   2956:    in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
                   2957: 
1.755     mike     2958:   </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     2959: 
                   2960:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2961: 
                   2962:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   2963:    <dt>U+000A LINE FEED (LF)</dt>
                   2964:    <dt>U+000C FORM FEED (FF)</dt>
                   2965:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   2966:    <dt>U+0020 SPACE</dt>
                   2967:    <dt>U+002F SOLIDUS (/)</dt>
                   2968:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   2969:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2970:    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
                   2971:    double escaped state</a>. Otherwise, switch to the <a href="#script-data-escaped-state">script
                   2972:    data escaped state</a>.</dd>
                   2973: 
                   2974:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   2975:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2976:    token. Append the lowercase version of the <a href="#current-input-character">current input
                   2977:    character</a> (add 0x0020 to the character's code point) to the
                   2978:    <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
                   2979:    escape start state</a>.</dd>
                   2980: 
                   2981:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   2982:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   2983:    token. Append the <a href="#current-input-character">current input character</a> to the
                   2984:    <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
                   2985:    escape start state</a>.</dd>
                   2986: 
                   2987:    <dt>Anything else</dt>
                   2988:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   2989:    <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
                   2990: 
1.755     mike     2991:   </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     2992: 
                   2993:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   2994: 
                   2995:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   2996:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   2997:    <a href="#script-data-double-escaped-dash-state">script data double escaped dash state</a>.</dd>
                   2998: 
                   2999:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3000:    <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
                   3001:    <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
                   3002:    state</a>.</p></dd>
                   3003: 
                   3004:    <dt>EOF</dt>
                   3005:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3006:    <a href="#data-state">data state</a>.</dd>
                   3007: 
                   3008:    <dt>Anything else</dt>
                   3009:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   3010:    token. Stay in the <a href="#script-data-double-escaped-state">script data double escaped
                   3011:    state</a>.</dd>
                   3012: 
1.755     mike     3013:   </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     3014: 
                   3015:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3016: 
                   3017:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3018:    <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
                   3019:    <a href="#script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>.</dd>
                   3020: 
                   3021:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3022:    <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
                   3023:    <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
                   3024:    state</a>.</p></dd>
                   3025: 
                   3026:    <dt>EOF</dt>
                   3027:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3028:    <a href="#data-state">data state</a>.</dd>
                   3029: 
                   3030:    <dt>Anything else</dt>
                   3031:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   3032:    token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
                   3033:    state</a>.</dd>
                   3034: 
1.755     mike     3035:   </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     3036: 
                   3037:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3038: 
                   3039:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3040:    <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
                   3041:    <a href="#script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>.</dd>
                   3042: 
                   3043:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3044:    <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
                   3045:    <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
                   3046:    state</a>.</p></dd>
                   3047: 
                   3048:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3049:    <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
                   3050:    <a href="#script-data-state">script data state</a>.</dd>
                   3051: 
                   3052:    <dt>EOF</dt>
                   3053:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3054:    <a href="#data-state">data state</a>.</dd>
                   3055: 
                   3056:    <dt>Anything else</dt>
                   3057:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   3058:    token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
                   3059:    state</a>.</dd>
                   3060: 
1.755     mike     3061:   </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     3062: 
                   3063:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3064: 
                   3065:   <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
                   3066:    <dd>Emit a U+002F SOLIDUS character token. Set the <var><a href="#temporary-buffer">temporary
                   3067:    buffer</a></var> to the empty string. Switch to the <a href="#script-data-double-escape-end-state">script data
                   3068:    double escape end state</a>.</dd>
                   3069: 
                   3070:    <dt>Anything else</dt>
                   3071:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   3072:    <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
                   3073: 
1.755     mike     3074:   </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     3075: 
                   3076:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3077: 
                   3078:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3079:    <dt>U+000A LINE FEED (LF)</dt>
                   3080:    <dt>U+000C FORM FEED (FF)</dt>
                   3081:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3082:    <dt>U+0020 SPACE</dt>
                   3083:    <dt>U+002F SOLIDUS (/)</dt>
                   3084:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3085:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   3086:    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
                   3087:    escaped state</a>. Otherwise, switch to the <a href="#script-data-double-escaped-state">script data
                   3088:    double escaped state</a>.</dd>
                   3089: 
                   3090:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   3091:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   3092:    token. Append the lowercase version of the <a href="#current-input-character">current input
                   3093:    character</a> (add 0x0020 to the character's code point) to the
                   3094:    <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
                   3095:    escape end state</a>.</dd>
                   3096: 
                   3097:    <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
                   3098:    <dd>Emit the <a href="#current-input-character">current input character</a> as a character
                   3099:    token. Append the <a href="#current-input-character">current input character</a> to the
                   3100:    <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
                   3101:    escape end state</a>.</dd>
                   3102: 
                   3103:    <dt>Anything else</dt>
                   3104:    <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
                   3105:    <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
1.1       mike     3106: 
1.755     mike     3107:   </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     3108: 
                   3109:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3110: 
                   3111:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3112:    <dt>U+000A LINE FEED (LF)</dt>
                   3113:    <dt>U+000C FORM FEED (FF)</dt>
                   3114:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3115:    <dt>U+0020 SPACE</dt>
                   3116:    <dd>Stay in the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3117: 
                   3118:    <dt>U+002F SOLIDUS (/)</dt>
                   3119:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   3120: 
                   3121:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3122:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3123:    state</a>.</dd>
                   3124: 
                   3125:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   3126:    <dd>Start a new attribute in the current tag token. Set that
                   3127:    attribute's name to the lowercase version of the <a href="#current-input-character">current input
                   3128:    character</a> (add 0x0020 to the character's code point), and its
                   3129:    value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
                   3130:    state</a>.</dd>
                   3131: 
                   3132:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3133:    <dt>U+0027 APOSTROPHE (')</dt>
                   3134:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3135:    <dt>U+003D EQUALS SIGN (=)</dt>
                   3136:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3137:    entry below.</dd>
                   3138: 
                   3139:    <dt>EOF</dt>
                   3140:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3141:    <a href="#data-state">data state</a>.</dd>
                   3142: 
                   3143:    <dt>Anything else</dt>
                   3144:    <dd>Start a new attribute in the current tag token. Set that
                   3145:    attribute's name to the <a href="#current-input-character">current input character</a>, and its value to
                   3146:    the empty string. Switch to the <a href="#attribute-name-state">attribute name
                   3147:    state</a>.</dd>
                   3148: 
1.755     mike     3149:   </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     3150: 
                   3151:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3152: 
                   3153:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3154:    <dt>U+000A LINE FEED (LF)</dt>
                   3155:    <dt>U+000C FORM FEED (FF)</dt>
                   3156:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3157:    <dt>U+0020 SPACE</dt>
                   3158:    <dd>Switch to the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
                   3159: 
                   3160:    <dt>U+002F SOLIDUS (/)</dt>
                   3161:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   3162: 
                   3163:    <dt>U+003D EQUALS SIGN (=)</dt>
                   3164:    <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
                   3165: 
                   3166:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3167:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3168:    state</a>.</dd>
                   3169: 
                   3170:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541     mike     3171:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   3172:    character</a> (add 0x0020 to the character's code point) to the
                   3173:    current attribute's name. Stay in the <a href="#attribute-name-state">attribute name
1.1       mike     3174:    state</a>.</dd>
                   3175: 
                   3176:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3177:    <dt>U+0027 APOSTROPHE (')</dt>
                   3178:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3179:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3180:    entry below.</dd>
                   3181: 
                   3182:    <dt>EOF</dt>
                   3183:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3184:    <a href="#data-state">data state</a>.</dd>
                   3185: 
                   3186:    <dt>Anything else</dt>
1.541     mike     3187:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3188:    attribute's name. Stay in the <a href="#attribute-name-state">attribute name
                   3189:    state</a>.</dd>
1.1       mike     3190: 
                   3191:   </dl><p>When the user agent leaves the attribute name state (and before
                   3192:   emitting the tag token, if appropriate), the complete attribute's
                   3193:   name must be compared to the other attributes on the same token;
                   3194:   if there is already an attribute on the token with the exact same
                   3195:   name, then this is a <a href="#parse-error">parse error</a> and the new
                   3196:   attribute must be dropped, along with the value that gets
                   3197:   associated with it (if any).</p>
                   3198: 
                   3199: 
1.755     mike     3200:   <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     3201: 
                   3202:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3203: 
                   3204:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3205:    <dt>U+000A LINE FEED (LF)</dt>
                   3206:    <dt>U+000C FORM FEED (FF)</dt>
                   3207:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3208:    <dt>U+0020 SPACE</dt>
                   3209:    <dd>Stay in the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
                   3210: 
                   3211:    <dt>U+002F SOLIDUS (/)</dt>
                   3212:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   3213: 
                   3214:    <dt>U+003D EQUALS SIGN (=)</dt>
                   3215:    <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
                   3216: 
                   3217:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3218:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3219:    state</a>.</dd>
                   3220: 
                   3221:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   3222:    <dd>Start a new attribute in the current tag token. Set that
1.541     mike     3223:    attribute's name to the lowercase version of the <a href="#current-input-character">current
                   3224:    input character</a> (add 0x0020 to the character's code point),
                   3225:    and its value to the empty string. Switch to the <a href="#attribute-name-state">attribute
                   3226:    name state</a>.</dd>
1.1       mike     3227: 
                   3228:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3229:    <dt>U+0027 APOSTROPHE (')</dt>
                   3230:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3231:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3232:    entry below.</dd>
                   3233: 
                   3234:    <dt>EOF</dt>
                   3235:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3236:    <a href="#data-state">data state</a>.</dd>
                   3237: 
                   3238:    <dt>Anything else</dt>
                   3239:    <dd>Start a new attribute in the current tag token. Set that
1.541     mike     3240:    attribute's name to the <a href="#current-input-character">current input character</a>, and
                   3241:    its value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
1.1       mike     3242:    state</a>.</dd>
                   3243: 
1.755     mike     3244:   </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     3245: 
                   3246:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3247: 
                   3248:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3249:    <dt>U+000A LINE FEED (LF)</dt>
                   3250:    <dt>U+000C FORM FEED (FF)</dt>
                   3251:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3252:    <dt>U+0020 SPACE</dt>
                   3253:    <dd>Stay in the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
                   3254: 
                   3255:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3256:    <dd>Switch to the <a href="#attribute-value-double-quoted-state">attribute value (double-quoted) state</a>.</dd>
                   3257: 
                   3258:    <dt>U+0026 AMPERSAND (&amp;)</dt>
                   3259:    <dd>Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted) state</a>
1.541     mike     3260:    and reconsume this <a href="#current-input-character">current input character</a>.</dd>
1.1       mike     3261: 
                   3262:    <dt>U+0027 APOSTROPHE (')</dt>
                   3263:    <dd>Switch to the <a href="#attribute-value-single-quoted-state">attribute value (single-quoted) state</a>.</dd>
                   3264: 
                   3265:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3266:    <dd><a href="#parse-error">Parse error</a>. Emit the current tag token. Switch to
                   3267:    the <a href="#data-state">data state</a>.</dd>
                   3268: 
                   3269:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3270:    <dt>U+003D EQUALS SIGN (=)</dt>
1.463     mike     3271:    <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1       mike     3272:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3273:    entry below.</dd>
                   3274: 
                   3275:    <dt>EOF</dt>
                   3276:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3277:    <a href="#data-state">data state</a>.</dd>
                   3278: 
                   3279:    <dt>Anything else</dt>
                   3280:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3281:    attribute's value. Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
                   3282:    state</a>.</dd>
                   3283: 
1.755     mike     3284:   </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     3285: 
                   3286:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3287: 
                   3288:   <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
                   3289:    <dd>Switch to the <a href="#after-attribute-value-quoted-state">after attribute value (quoted)
                   3290:    state</a>.</dd>
                   3291: 
                   3292:    <dt>U+0026 AMPERSAND (&amp;)</dt>
                   3293:    <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
                   3294:    state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
                   3295:    being U+0022 QUOTATION MARK (").</dd>
                   3296: 
                   3297:    <dt>EOF</dt>
                   3298:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3299:    <a href="#data-state">data state</a>.</dd>
                   3300: 
                   3301:    <dt>Anything else</dt>
1.541     mike     3302:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3303:    attribute's value. Stay in the <a href="#attribute-value-double-quoted-state">attribute value
                   3304:    (double-quoted) state</a>.</dd>
1.1       mike     3305: 
1.755     mike     3306:   </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     3307: 
                   3308:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3309: 
                   3310:   <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
                   3311:    <dd>Switch to the <a href="#after-attribute-value-quoted-state">after attribute value (quoted)
                   3312:    state</a>.</dd>
                   3313: 
                   3314:    <dt>U+0026 AMPERSAND (&amp;)</dt>
                   3315:    <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
                   3316:    state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
                   3317:    being U+0027 APOSTROPHE (').</dd>
                   3318: 
                   3319:    <dt>EOF</dt>
                   3320:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3321:    <a href="#data-state">data state</a>.</dd>
                   3322: 
                   3323:    <dt>Anything else</dt>
1.541     mike     3324:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3325:    attribute's value. Stay in the <a href="#attribute-value-single-quoted-state">attribute value
                   3326:    (single-quoted) state</a>.</dd>
1.1       mike     3327: 
1.755     mike     3328:   </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     3329: 
                   3330:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3331: 
                   3332:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3333:    <dt>U+000A LINE FEED (LF)</dt>
                   3334:    <dt>U+000C FORM FEED (FF)</dt>
                   3335:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3336:    <dt>U+0020 SPACE</dt>
                   3337:    <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3338: 
                   3339:    <dt>U+0026 AMPERSAND (&amp;)</dt>
                   3340:    <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
1.299     mike     3341:    state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
                   3342:    being U+003E GREATER-THAN SIGN (&gt;).</dd>
1.1       mike     3343: 
                   3344:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3345:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3346:    state</a>.</dd>
                   3347: 
                   3348:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3349:    <dt>U+0027 APOSTROPHE (')</dt>
                   3350:    <dt>U+003C LESS-THAN SIGN (&lt;)</dt>
                   3351:    <dt>U+003D EQUALS SIGN (=)</dt>
1.463     mike     3352:    <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1       mike     3353:    <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
                   3354:    entry below.</dd>
                   3355: 
                   3356:    <dt>EOF</dt>
                   3357:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3358:    <a href="#data-state">data state</a>.</dd>
                   3359: 
                   3360:    <dt>Anything else</dt>
1.541     mike     3361:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3362:    attribute's value. Stay in the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
1.1       mike     3363:    state</a>.</dd>
                   3364: 
1.755     mike     3365:   </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     3366: 
                   3367:   <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>.</p>
                   3368: 
                   3369:   <p>If nothing is returned, append a U+0026 AMPERSAND character to
                   3370:   the current attribute's value.</p>
                   3371: 
                   3372:   <p>Otherwise, append the returned character token to the current
                   3373:   attribute's value.</p>
                   3374: 
                   3375:   <p>Finally, switch back to the attribute value state that you were
                   3376:   in when were switched into this state.</p>
                   3377: 
                   3378: 
1.755     mike     3379:   <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     3380: 
                   3381:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3382: 
                   3383:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3384:    <dt>U+000A LINE FEED (LF)</dt>
                   3385:    <dt>U+000C FORM FEED (FF)</dt>
                   3386:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3387:    <dt>U+0020 SPACE</dt>
                   3388:    <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3389: 
                   3390:    <dt>U+002F SOLIDUS (/)</dt>
                   3391:    <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
                   3392: 
                   3393:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3394:    <dd>Emit the current tag token. Switch to the <a href="#data-state">data
                   3395:    state</a>.</dd>
                   3396: 
                   3397:    <dt>EOF</dt>
                   3398:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3399:    <a href="#data-state">data state</a>.</dd>
                   3400: 
                   3401:    <dt>Anything else</dt>
                   3402:    <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
                   3403:    the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3404: 
1.755     mike     3405:   </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     3406: 
                   3407:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3408: 
                   3409:   <dl class="switch"><dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3410:    <dd>Set the <i>self-closing flag</i> of the current tag
                   3411:    token. Emit the current tag token. Switch to the <a href="#data-state">data
                   3412:    state</a>.</dd>
                   3413: 
                   3414:    <dt>EOF</dt>
                   3415:    <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
                   3416:    <a href="#data-state">data state</a>.</dd>
                   3417: 
                   3418:    <dt>Anything else</dt>
                   3419:    <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
                   3420:    the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
                   3421: 
1.755     mike     3422:   </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     3423: 
                   3424:   <p>Consume every character up to and including the first U+003E
                   3425:   GREATER-THAN SIGN character (&gt;) or the end of the file (EOF),
                   3426:   whichever comes first. Emit a comment token whose data is the
                   3427:   concatenation of all the characters starting from and including
                   3428:   the character that caused the state machine to switch into the
                   3429:   bogus comment state, up to and including the character immediately
                   3430:   before the last consumed character (i.e. up to the character just
                   3431:   before the U+003E or EOF character). (If the comment was started
                   3432:   by the end of the file (EOF), the token is empty.)</p>
                   3433: 
                   3434:   <p>Switch to the <a href="#data-state">data state</a>.</p>
                   3435: 
                   3436:   <p>If the end of the file was reached, reconsume the EOF
                   3437:   character.</p>
                   3438: 
                   3439: 
1.755     mike     3440:   <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     3441: 
1.588     mike     3442:   <p>If the next two characters are both U+002D HYPHEN-MINUS
                   3443:   characters (-), consume those two characters, create a comment token
1.1       mike     3444:   whose data is the empty string, and switch to the <a href="#comment-start-state">comment
                   3445:   start state</a>.</p>
                   3446: 
                   3447:   <p>Otherwise, if the next seven characters are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   3448:   case-insensitive</a> match for the word "DOCTYPE", then consume
                   3449:   those characters and switch to the <a href="#doctype-state">DOCTYPE state</a>.</p>
                   3450: 
                   3451:   <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
                   3452:   content</a>" and the <a href="#current-node">current node</a> is not an element
1.724     mike     3453:   in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a> and the next seven characters are
1.585     mike     3454:   an <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string "[CDATA[" (the
                   3455:   five uppercase letters "CDATA" with a U+005B LEFT SQUARE BRACKET
                   3456:   character before and after), then consume those characters and
                   3457:   switch to the <a href="#cdata-section-state">CDATA section state</a>.</p>
1.1       mike     3458: 
                   3459:   <p>Otherwise, this is a <a href="#parse-error">parse error</a>. Switch to the
                   3460:   <a href="#bogus-comment-state">bogus comment state</a>. The next character that is
                   3461:   consumed, if any, is the first character that will be in the
                   3462:   comment.</p>
                   3463: 
                   3464: 
1.755     mike     3465:   <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     3466: 
                   3467:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3468: 
                   3469:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3470:    <dd>Switch to the <a href="#comment-start-dash-state">comment start dash state</a>.</dd>
                   3471: 
                   3472:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3473:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to the
                   3474:    <a href="#data-state">data state</a>.</dd> <!-- see comment in comment end state
                   3475:    -->
                   3476: 
                   3477:    <dt>EOF</dt>
                   3478:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
                   3479:    the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3480: 
                   3481:    <dt>Anything else</dt>
1.541     mike     3482:    <dd>Append the <a href="#current-input-character">current input character</a> to the comment
                   3483:    token's data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3484: 
1.755     mike     3485:   </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     3486: 
                   3487:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3488: 
                   3489:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3490:    <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
                   3491: 
                   3492:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3493:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to
                   3494:    the <a href="#data-state">data state</a>.</dd>
                   3495: 
                   3496:    <dt>EOF</dt>
                   3497:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
                   3498:    EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
                   3499:    in comment end state -->
                   3500: 
                   3501:    <dt>Anything else</dt>
1.541     mike     3502:    <dd>Append a U+002D HYPHEN-MINUS character (-) and the
                   3503:    <a href="#current-input-character">current input character</a> to the comment token's
                   3504:    data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3505: 
1.755     mike     3506:   </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     3507: 
                   3508:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3509: 
                   3510:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3511:    <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a></dd>
                   3512: 
                   3513:    <dt>EOF</dt>
                   3514:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
                   3515:    EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
                   3516:    in comment end state -->
                   3517: 
                   3518:    <dt>Anything else</dt>
1.541     mike     3519:    <dd>Append the <a href="#current-input-character">current input character</a> to the comment
                   3520:    token's data. Stay in the <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3521: 
1.755     mike     3522:   </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     3523: 
                   3524:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3525: 
                   3526:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
                   3527:    <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
                   3528: 
                   3529:    <dt>EOF</dt>
                   3530:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
                   3531:    EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
                   3532:    in comment end state -->
                   3533: 
                   3534:    <dt>Anything else</dt>
1.541     mike     3535:    <dd>Append a U+002D HYPHEN-MINUS character (-) and the
                   3536:    <a href="#current-input-character">current input character</a> to the comment token's
                   3537:    data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3538: 
1.755     mike     3539:   </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     3540: 
                   3541:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3542: 
                   3543:   <dl class="switch"><dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3544:    <dd>Emit the comment token. Switch to the <a href="#data-state">data
                   3545:    state</a>.</dd>
                   3546: 
                   3547:    <dt>U+0009 CHARACTER TABULATION</dt>
                   3548:    <dt>U+000A LINE FEED (LF)</dt>
                   3549:    <dt>U+000C FORM FEED (FF)</dt>
                   3550:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3551:    <dt>U+0020 SPACE</dt>
1.588     mike     3552:    <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS
                   3553:    characters (-) and the <a href="#current-input-character">current input character</a> to the
1.541     mike     3554:    comment token's data. Switch to the <a href="#comment-end-space-state">comment end space
                   3555:    state</a>.</dd>
1.1       mike     3556: 
                   3557:    <dt>U+0021 EXCLAMATION MARK (!)</dt>
                   3558:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#comment-end-bang-state">comment end bang
                   3559:    state</a>.</dd>
                   3560: 
1.333     mike     3561:    <dt>U+002D HYPHEN-MINUS (-)</dt>
                   3562:    <dd><a href="#parse-error">Parse error</a>. Append a U+002D HYPHEN-MINUS
1.464     mike     3563:    character (-) to the comment token's data. Stay in the
1.333     mike     3564:    <a href="#comment-end-state">comment end state</a>.</dd>
                   3565: 
1.1       mike     3566:    <dt>EOF</dt>
                   3567:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
                   3568:    the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- For
1.724     mike     3569:    security reasons: otherwise, hostile user could put a <script type="text/javascript"> in
1.1       mike     3570:    a comment e.g. in a blog comment and then DOS the server so that
1.724     mike     3571:    the end tag isn't read, and then the commented <script type="text/javascript"> tag would
1.1       mike     3572:    be treated as live code -->
                   3573: 
                   3574:    <dt>Anything else</dt>
1.588     mike     3575:    <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS
                   3576:    characters (-) and the <a href="#current-input-character">current input character</a> to the
1.541     mike     3577:    comment token's data. Switch to the <a href="#comment-state">comment
                   3578:    state</a>.</dd>
1.1       mike     3579: 
1.755     mike     3580:   </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     3581: 
                   3582:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3583: 
1.333     mike     3584:   <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
1.588     mike     3585:    <dd>Append two U+002D HYPHEN-MINUS characters (-) and a U+0021
1.464     mike     3586:    EXCLAMATION MARK character (!) to the comment token's data. Switch
1.1       mike     3587:    to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
                   3588: 
1.333     mike     3589:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3590:    <dd>Emit the comment token. Switch to the <a href="#data-state">data
                   3591:    state</a>.</dd>
                   3592: 
1.1       mike     3593:    <dt>EOF</dt>
                   3594:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
                   3595:    the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
                   3596:    comment in comment end state -->
                   3597: 
                   3598:    <dt>Anything else</dt>
1.588     mike     3599:    <dd>Append two U+002D HYPHEN-MINUS characters (-), a U+0021
1.541     mike     3600:    EXCLAMATION MARK character (!), and the <a href="#current-input-character">current input
                   3601:    character</a> to the comment token's data. Switch to the
                   3602:    <a href="#comment-state">comment state</a>.</dd>
1.1       mike     3603: 
1.755     mike     3604:   </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     3605: 
                   3606:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3607: 
1.333     mike     3608:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
1.1       mike     3609:    <dt>U+000A LINE FEED (LF)</dt>
                   3610:    <dt>U+000C FORM FEED (FF)</dt>
                   3611:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3612:    <dt>U+0020 SPACE</dt>
1.541     mike     3613:    <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Stay in
1.1       mike     3614:    the <a href="#comment-end-space-state">comment end space state</a>.</dd>
                   3615: 
1.333     mike     3616:    <dt>U+002D HYPHEN-MINUS (-)</dt>
                   3617:    <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
                   3618: 
                   3619:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3620:    <dd>Emit the comment token. Switch to the <a href="#data-state">data
                   3621:    state</a>.</dd>
                   3622: 
1.1       mike     3623:    <dt>EOF</dt>
                   3624:    <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
                   3625:    the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
                   3626:    comment in comment end state -->
                   3627: 
                   3628:    <dt>Anything else</dt>
1.541     mike     3629:    <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Switch
1.1       mike     3630:    to the <a href="#comment-state">comment state</a>.</dd>
                   3631: 
1.755     mike     3632:   </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     3633: 
                   3634:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3635: 
                   3636:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3637:    <dt>U+000A LINE FEED (LF)</dt>
                   3638:    <dt>U+000C FORM FEED (FF)</dt>
                   3639:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3640:    <dt>U+0020 SPACE</dt>
                   3641:    <dd>Switch to the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
                   3642: 
                   3643:    <dt>EOF</dt>
                   3644:    <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
                   3645:    <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
                   3646:    the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3647: 
                   3648:    <dt>Anything else</dt>
1.608     mike     3649:    <dd><a href="#parse-error">Parse error</a>. Reconsume the character in the
                   3650:    <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
1.1       mike     3651: 
1.755     mike     3652:   </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     3653: 
                   3654:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3655: 
                   3656:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3657:    <dt>U+000A LINE FEED (LF)</dt>
                   3658:    <dt>U+000C FORM FEED (FF)</dt>
                   3659:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3660:    <dt>U+0020 SPACE</dt>
                   3661:    <dd>Stay in the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
                   3662: 
                   3663:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
                   3664:    <dd>Create a new DOCTYPE token. Set the token's name to the
1.541     mike     3665:    lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
1.1       mike     3666:    character's code point). Switch to the <a href="#doctype-name-state">DOCTYPE name
                   3667:    state</a>.</dd>
                   3668: 
1.333     mike     3669:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3670:    <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
                   3671:    <i>force-quirks flag</i> to <i>on</i>. Emit the token. Switch to
                   3672:    the <a href="#data-state">data state</a>.</dd>
                   3673: 
1.1       mike     3674:    <dt>EOF</dt>
                   3675:    <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
                   3676:    <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
                   3677:    the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3678: 
                   3679:    <dt>Anything else</dt>
                   3680:    <dd>Create a new DOCTYPE token. Set the token's name to the
                   3681:    <a href="#current-input-character">current input character</a>. Switch to the <a href="#doctype-name-state">DOCTYPE name
                   3682:    state</a>.</dd>
                   3683: 
1.755     mike     3684:   </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     3685: 
                   3686:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3687: 
                   3688:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3689:    <dt>U+000A LINE FEED (LF)</dt>
                   3690:    <dt>U+000C FORM FEED (FF)</dt>
                   3691:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3692:    <dt>U+0020 SPACE</dt>
                   3693:    <dd>Switch to the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
                   3694: 
                   3695:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3696:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   3697:    state</a>.</dd>
                   3698: 
                   3699:    <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541     mike     3700:    <dd>Append the lowercase version of the <a href="#current-input-character">current input
                   3701:    character</a> (add 0x0020 to the character's code point) to the
                   3702:    current DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
                   3703:    state</a>.</dd>
1.1       mike     3704: 
                   3705:    <dt>EOF</dt>
                   3706:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3707:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3708:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3709: 
                   3710:    <dt>Anything else</dt>
1.541     mike     3711:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   3712:    DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
                   3713:    state</a>.</dd>
1.1       mike     3714: 
1.755     mike     3715:   </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     3716: 
                   3717:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3718: 
                   3719:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3720:    <dt>U+000A LINE FEED (LF)</dt>
                   3721:    <dt>U+000C FORM FEED (FF)</dt>
                   3722:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3723:    <dt>U+0020 SPACE</dt>
                   3724:    <dd>Stay in the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
                   3725: 
                   3726:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3727:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   3728:    state</a>.</dd>
                   3729: 
                   3730:    <dt>EOF</dt>
                   3731:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3732:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3733:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3734: 
                   3735:    <dt>Anything else</dt>
                   3736:    <dd>
                   3737: 
                   3738:     <p>If the six characters starting from the <a href="#current-input-character">current input
                   3739:     character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match
                   3740:     for the word "PUBLIC", then consume those characters and switch to
1.444     mike     3741:     the <a href="#after-doctype-public-keyword-state">after DOCTYPE public keyword state</a>.</p>
1.1       mike     3742: 
                   3743:     <p>Otherwise, if the six characters starting from the
                   3744:     <a href="#current-input-character">current input character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   3745:     case-insensitive</a> match for the word "SYSTEM", then consume
1.444     mike     3746:     those characters and switch to the <a href="#after-doctype-system-keyword-state">after DOCTYPE system
                   3747:     keyword state</a>.</p>
1.1       mike     3748: 
                   3749:     <p>Otherwise, this is the <a href="#parse-error">parse error</a>. Set the
                   3750:     DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to
                   3751:     the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</p>
                   3752: 
                   3753:    </dd>
                   3754: 
1.755     mike     3755:   </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     3756: 
                   3757:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3758: 
                   3759:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3760:    <dt>U+000A LINE FEED (LF)</dt>
                   3761:    <dt>U+000C FORM FEED (FF)</dt>
                   3762:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3763:    <dt>U+0020 SPACE</dt>
                   3764:    <dd>Switch to the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier
                   3765:    state</a>.</dd>
                   3766: 
1.620     mike     3767:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3768:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's public
                   3769:    identifier to the empty string (not missing), then switch to the
                   3770:    <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public identifier (double-quoted) state</a>.</dd>
                   3771: 
                   3772:    <dt>U+0027 APOSTROPHE (')</dt>
                   3773:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's public
                   3774:    identifier to the empty string (not missing), then switch to the
                   3775:    <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public identifier (single-quoted) state</a>.</dd>
                   3776: 
                   3777:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3778:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3779:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3780:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3781: 
1.444     mike     3782:    <dt>EOF</dt>
                   3783:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3784:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3785:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3786: 
                   3787:    <dt>Anything else</dt>
1.620     mike     3788:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3789:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3790:    DOCTYPE state</a>.</dd>
1.444     mike     3791: 
1.755     mike     3792:   </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     3793: 
                   3794:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3795: 
                   3796:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3797:    <dt>U+000A LINE FEED (LF)</dt>
                   3798:    <dt>U+000C FORM FEED (FF)</dt>
                   3799:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3800:    <dt>U+0020 SPACE</dt>
                   3801:    <dd>Stay in the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier state</a>.</dd>
                   3802: 
                   3803:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3804:    <dd>Set the DOCTYPE token's public identifier to the empty string
                   3805:    (not missing), then switch to the <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public identifier
                   3806:    (double-quoted) state</a>.</dd>
                   3807: 
                   3808:    <dt>U+0027 APOSTROPHE (')</dt>
                   3809:    <dd>Set the DOCTYPE token's public identifier to the empty string
                   3810:    (not missing), then switch to the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public identifier
                   3811:    (single-quoted) state</a>.</dd>
                   3812: 
                   3813:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3814:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3815:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3816:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3817: 
                   3818:    <dt>EOF</dt>
                   3819:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3820:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3821:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3822: 
                   3823:    <dt>Anything else</dt>
                   3824:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3825:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3826:    DOCTYPE state</a>.</dd>
                   3827: 
1.755     mike     3828:   </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     3829: 
                   3830:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3831: 
                   3832:   <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
                   3833:    <dd>Switch to the <a href="#after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd>
                   3834: 
                   3835:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3836:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3837:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3838:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3839: 
                   3840:    <dt>EOF</dt>
                   3841:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3842:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3843:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3844: 
                   3845:    <dt>Anything else</dt>
                   3846:    <dd>Append the <a href="#current-input-character">current input character</a> to the current DOCTYPE
                   3847:    token's public identifier. Stay in the <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public
                   3848:    identifier (double-quoted) state</a>.</dd>
                   3849: 
1.755     mike     3850:   </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     3851: 
                   3852:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3853: 
                   3854:   <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
                   3855:    <dd>Switch to the <a href="#after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd>
                   3856: 
                   3857:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3858:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3859:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3860:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3861: 
                   3862:    <dt>EOF</dt>
                   3863:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3864:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3865:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3866: 
                   3867:    <dt>Anything else</dt>
                   3868:    <dd>Append the <a href="#current-input-character">current input character</a> to the current DOCTYPE
                   3869:    token's public identifier. Stay in the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public
                   3870:    identifier (single-quoted) state</a>.</dd>
                   3871: 
1.755     mike     3872:   </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     3873: 
                   3874:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3875: 
                   3876:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3877:    <dt>U+000A LINE FEED (LF)</dt>
                   3878:    <dt>U+000C FORM FEED (FF)</dt>
                   3879:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3880:    <dt>U+0020 SPACE</dt>
1.541     mike     3881:    <dd>Switch to the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system
                   3882:    identifiers state</a>.</dd>
1.444     mike     3883: 
                   3884:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3885:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   3886:    state</a>.</dd>
                   3887: 
                   3888:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3889:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
                   3890:    identifier to the empty string (not missing), then switch to the
                   3891:    <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier (double-quoted) state</a>.</dd>
                   3892: 
                   3893:    <dt>U+0027 APOSTROPHE (')</dt>
                   3894:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
                   3895:    identifier to the empty string (not missing), then switch to the
                   3896:    <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier (single-quoted) state</a>.</dd>
                   3897: 
                   3898:    <dt>EOF</dt>
                   3899:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3900:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3901:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3902: 
                   3903:    <dt>Anything else</dt>
                   3904:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3905:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3906:    DOCTYPE state</a>.</dd>
                   3907: 
1.755     mike     3908:   </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     3909: 
                   3910:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3911: 
                   3912:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3913:    <dt>U+000A LINE FEED (LF)</dt>
                   3914:    <dt>U+000C FORM FEED (FF)</dt>
                   3915:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3916:    <dt>U+0020 SPACE</dt>
1.541     mike     3917:    <dd>Stay in the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system identifiers
                   3918:    state</a>.</dd>
1.444     mike     3919: 
                   3920:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3921:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   3922:    state</a>.</dd>
1.1       mike     3923: 
                   3924:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3925:    <dd>Set the DOCTYPE token's system identifier to the empty string
                   3926:    (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
                   3927:    (double-quoted) state</a>.</dd>
                   3928: 
                   3929:    <dt>U+0027 APOSTROPHE (')</dt>
                   3930:    <dd>Set the DOCTYPE token's system identifier to the empty string
                   3931:    (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
                   3932:    (single-quoted) state</a>.</dd>
                   3933: 
                   3934:    <dt>EOF</dt>
                   3935:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3936:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3937:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3938: 
                   3939:    <dt>Anything else</dt>
                   3940:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3941:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3942:    DOCTYPE state</a>.</dd>
                   3943: 
1.755     mike     3944:   </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     3945: 
                   3946:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3947: 
                   3948:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3949:    <dt>U+000A LINE FEED (LF)</dt>
                   3950:    <dt>U+000C FORM FEED (FF)</dt>
                   3951:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3952:    <dt>U+0020 SPACE</dt>
                   3953:    <dd>Switch to the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier
                   3954:    state</a>.</dd>
                   3955: 
1.620     mike     3956:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3957:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
                   3958:    identifier to the empty string (not missing), then switch to the
                   3959:    <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier (double-quoted) state</a>.</dd>
                   3960: 
                   3961:    <dt>U+0027 APOSTROPHE (')</dt>
                   3962:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
                   3963:    identifier to the empty string (not missing), then switch to the
                   3964:    <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier (single-quoted) state</a>.</dd>
                   3965: 
                   3966:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   3967:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3968:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   3969:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   3970: 
1.444     mike     3971:    <dt>EOF</dt>
                   3972:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3973:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   3974:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   3975: 
                   3976:    <dt>Anything else</dt>
1.620     mike     3977:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   3978:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   3979:    DOCTYPE state</a>.</dd>
1.444     mike     3980: 
1.755     mike     3981:   </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     3982: 
                   3983:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   3984: 
                   3985:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   3986:    <dt>U+000A LINE FEED (LF)</dt>
                   3987:    <dt>U+000C FORM FEED (FF)</dt>
                   3988:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   3989:    <dt>U+0020 SPACE</dt>
                   3990:    <dd>Stay in the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier state</a>.</dd>
                   3991: 
                   3992:    <dt>U+0022 QUOTATION MARK (")</dt>
                   3993:    <dd>Set the DOCTYPE token's system identifier to the empty string
                   3994:    (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
                   3995:    (double-quoted) state</a>.</dd>
                   3996: 
                   3997:    <dt>U+0027 APOSTROPHE (')</dt>
                   3998:    <dd>Set the DOCTYPE token's system identifier to the empty string
                   3999:    (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
                   4000:    (single-quoted) state</a>.</dd>
                   4001: 
                   4002:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   4003:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   4004:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   4005:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   4006: 
                   4007:    <dt>EOF</dt>
                   4008:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   4009:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   4010:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   4011: 
                   4012:    <dt>Anything else</dt>
                   4013:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   4014:    <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
                   4015:    DOCTYPE state</a>.</dd>
                   4016: 
1.755     mike     4017:   </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     4018: 
                   4019:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   4020: 
                   4021:   <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
1.541     mike     4022:    <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
                   4023:    state</a>.</dd>
1.1       mike     4024: 
                   4025:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   4026:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   4027:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   4028:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   4029: 
                   4030:    <dt>EOF</dt>
                   4031:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   4032:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   4033:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   4034: 
                   4035:    <dt>Anything else</dt>
1.541     mike     4036:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   4037:    DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system
1.1       mike     4038:    identifier (double-quoted) state</a>.</dd>
                   4039: 
1.755     mike     4040:   </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     4041: 
                   4042:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   4043: 
                   4044:   <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
1.541     mike     4045:    <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
                   4046:    state</a>.</dd>
1.1       mike     4047: 
                   4048:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   4049:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   4050:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
                   4051:    token. Switch to the <a href="#data-state">data state</a>.</dd>
                   4052: 
                   4053:    <dt>EOF</dt>
                   4054:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   4055:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   4056:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   4057: 
                   4058:    <dt>Anything else</dt>
1.541     mike     4059:    <dd>Append the <a href="#current-input-character">current input character</a> to the current
                   4060:    DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system
1.1       mike     4061:    identifier (single-quoted) state</a>.</dd>
                   4062: 
1.755     mike     4063:   </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     4064: 
                   4065:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   4066: 
                   4067:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   4068:    <dt>U+000A LINE FEED (LF)</dt>
                   4069:    <dt>U+000C FORM FEED (FF)</dt>
                   4070:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   4071:    <dt>U+0020 SPACE</dt>
1.541     mike     4072:    <dd>Stay in the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
                   4073:    state</a>.</dd>
1.1       mike     4074: 
                   4075:    <dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   4076:    <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
                   4077:    state</a>.</dd>
                   4078: 
                   4079:    <dt>EOF</dt>
                   4080:    <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
                   4081:    <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
                   4082:    Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
                   4083: 
                   4084:    <dt>Anything else</dt>
                   4085:    <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-doctype-state">bogus DOCTYPE
                   4086:    state</a>. (This does <em>not</em> set the DOCTYPE token's
                   4087:    <i>force-quirks flag</i> to <i>on</i>.)</dd>
                   4088: 
1.755     mike     4089:   </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     4090: 
                   4091:   <p>Consume the <a href="#next-input-character">next input character</a>:</p>
                   4092: 
                   4093:   <dl class="switch"><dt>U+003E GREATER-THAN SIGN (&gt;)</dt>
                   4094:    <dd>Emit the DOCTYPE token. Switch to the <a href="#data-state">data
                   4095:    state</a>.</dd>
                   4096: 
                   4097:    <dt>EOF</dt>
                   4098:    <dd>Emit the DOCTYPE token. Reconsume the EOF character in the
                   4099:    <a href="#data-state">data state</a>.</dd>
                   4100: 
                   4101:    <dt>Anything else</dt>
                   4102:    <dd>Stay in the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</dd>
                   4103: 
1.755     mike     4104:   </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     4105: 
                   4106:   <p>Consume every character up to the next occurrence of the three
                   4107:   character sequence U+005D RIGHT SQUARE BRACKET U+005D RIGHT SQUARE
                   4108:   BRACKET U+003E GREATER-THAN SIGN (<code title="">]]&gt;</code>), or the
                   4109:   end of the file (EOF), whichever comes first. Emit a series of
                   4110:   character tokens consisting of all the characters consumed except
                   4111:   the matching three character sequence at the end (if one was found
                   4112:   before the end of the file).</p>
                   4113: 
                   4114:   <p>Switch to the <a href="#data-state">data state</a>.</p>
                   4115: 
                   4116:   <p>If the end of the file was reached, reconsume the EOF
                   4117:   character.</p>
                   4118: 
                   4119: 
                   4120: 
1.755     mike     4121:   <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     4122: 
                   4123:   <p>This section defines how to <dfn id="consume-a-character-reference">consume a character
                   4124:   reference</dfn>. This definition is used when parsing character
1.299     mike     4125:   references <a href="#character-reference-in-data-state" title="character reference in data state">in
1.1       mike     4126:   text</a> and <a href="#character-reference-in-attribute-value-state" title="character reference in attribute value
                   4127:   state">in attributes</a>.</p>
                   4128: 
                   4129:   <p>The behavior depends on the identity of the next character (the
                   4130:   one immediately after the U+0026 AMPERSAND character):</p>
                   4131: 
                   4132:   <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
                   4133:    <dt>U+000A LINE FEED (LF)</dt>
                   4134:    <dt>U+000C FORM FEED (FF)</dt>
                   4135:    <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
                   4136:    <dt>U+0020 SPACE</dt>
                   4137:    <dt>U+003C LESS-THAN SIGN</dt>
                   4138:    <dt>U+0026 AMPERSAND</dt>
                   4139:    <dt>EOF</dt>
                   4140:    <dt>The <dfn id="additional-allowed-character">additional allowed character</dfn>, if there is one</dt>
                   4141: 
                   4142:    <dd>Not a character reference. No characters are consumed, and
                   4143:    nothing is returned. (This is not an error, either.)</dd>
                   4144: 
                   4145: 
                   4146:    <dt>U+0023 NUMBER SIGN (#)</dt>
                   4147: 
                   4148:    <dd>
                   4149: 
                   4150:     <p>Consume the U+0023 NUMBER SIGN.</p>
                   4151: 
                   4152:     <p>The behavior further depends on the character after the U+0023
                   4153:     NUMBER SIGN:</p>
                   4154: 
                   4155:     <dl class="switch"><dt>U+0078 LATIN SMALL LETTER X</dt>
                   4156:      <dt>U+0058 LATIN CAPITAL LETTER X</dt>
                   4157: 
                   4158:      <dd>
                   4159: 
                   4160:       <p>Consume the X.</p>
                   4161: 
                   4162:       <p>Follow the steps below, but using the range of characters
1.464     mike     4163:       U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061 LATIN
                   4164:       SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041 LATIN
                   4165:       CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F (in other
                   4166:       words, 0-9, A-F, a-f).</p>
1.1       mike     4167: 
                   4168:       <p>When it comes to interpreting the number, interpret it as a
                   4169:       hexadecimal number.</p>
                   4170: 
                   4171:      </dd>
                   4172: 
                   4173: 
                   4174:      <dt>Anything else</dt>
                   4175: 
                   4176:      <dd>
                   4177: 
                   4178:       <p>Follow the steps below, but using the range of characters
1.464     mike     4179:       U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</p>
1.1       mike     4180: 
                   4181:       <p>When it comes to interpreting the number, interpret it as a
                   4182:       decimal number.</p>
                   4183: 
                   4184:      </dd>
                   4185: 
                   4186:     </dl><p>Consume as many characters as match the range of characters
                   4187:     given above.</p>
                   4188: 
                   4189:     <p>If no characters match the range, then don't consume any
                   4190:     characters (and unconsume the U+0023 NUMBER SIGN character and, if
                   4191:     appropriate, the X character). This is a <a href="#parse-error">parse
                   4192:     error</a>; nothing is returned.</p>
                   4193: 
                   4194:     <p>Otherwise, if the next character is a U+003B SEMICOLON, consume
                   4195:     that too. If it isn't, there is a <a href="#parse-error">parse
                   4196:     error</a>.</p>
                   4197: 
                   4198:     <p>If one or more characters match the range, then take them all
                   4199:     and interpret the string of characters as a number (either
                   4200:     hexadecimal or decimal as appropriate).</p>
                   4201: 
                   4202:     <p>If that number is one of the numbers in the first column of the
                   4203:     following table, then this is a <a href="#parse-error">parse error</a>. Find the
                   4204:     row with that number in the first column, and return a character
                   4205:     token for the Unicode character given in the second column of that
                   4206:     row.</p>
                   4207: 
                   4208:     <table><thead><tr><th>Number </th><th colspan="2">Unicode character
                   4209:      </th></tr></thead><tbody><tr><td>0x00 </td><td>U+FFFD </td><td>REPLACEMENT CHARACTER
1.882     mike     4210:       </td></tr><tr><td>0x0D </td><td>U+000D </td><td>CARRIAGE RETURN (CR)
1.464     mike     4211:       </td></tr><tr><td>0x80 </td><td>U+20AC </td><td>EURO SIGN (&#8364;)
1.1       mike     4212:       </td></tr><tr><td>0x81 </td><td>U+0081 </td><td>&lt;control&gt;
1.464     mike     4213:       </td></tr><tr><td>0x82 </td><td>U+201A </td><td>SINGLE LOW-9 QUOTATION MARK (&#8218;)
                   4214:       </td></tr><tr><td>0x83 </td><td>U+0192 </td><td>LATIN SMALL LETTER F WITH HOOK (&#402;)
                   4215:       </td></tr><tr><td>0x84 </td><td>U+201E </td><td>DOUBLE LOW-9 QUOTATION MARK (&#8222;)
                   4216:       </td></tr><tr><td>0x85 </td><td>U+2026 </td><td>HORIZONTAL ELLIPSIS (&#8230;)
                   4217:       </td></tr><tr><td>0x86 </td><td>U+2020 </td><td>DAGGER (&#8224;)
                   4218:       </td></tr><tr><td>0x87 </td><td>U+2021 </td><td>DOUBLE DAGGER (&#8225;)
                   4219:       </td></tr><tr><td>0x88 </td><td>U+02C6 </td><td>MODIFIER LETTER CIRCUMFLEX ACCENT (&#710;)
                   4220:       </td></tr><tr><td>0x89 </td><td>U+2030 </td><td>PER MILLE SIGN (&#8240;)
                   4221:       </td></tr><tr><td>0x8A </td><td>U+0160 </td><td>LATIN CAPITAL LETTER S WITH CARON (&#352;)
                   4222:       </td></tr><tr><td>0x8B </td><td>U+2039 </td><td>SINGLE LEFT-POINTING ANGLE QUOTATION MARK (&#8249;)
                   4223:       </td></tr><tr><td>0x8C </td><td>U+0152 </td><td>LATIN CAPITAL LIGATURE OE (&#338;)
1.1       mike     4224:       </td></tr><tr><td>0x8D </td><td>U+008D </td><td>&lt;control&gt;
1.464     mike     4225:       </td></tr><tr><td>0x8E </td><td>U+017D </td><td>LATIN CAPITAL LETTER Z WITH CARON (&#381;)
1.1       mike     4226:       </td></tr><tr><td>0x8F </td><td>U+008F </td><td>&lt;control&gt;
                   4227:       </td></tr><tr><td>0x90 </td><td>U+0090 </td><td>&lt;control&gt;
1.464     mike     4228:       </td></tr><tr><td>0x91 </td><td>U+2018 </td><td>LEFT SINGLE QUOTATION MARK (&#8216;)
                   4229:       </td></tr><tr><td>0x92 </td><td>U+2019 </td><td>RIGHT SINGLE QUOTATION MARK (&#8217;)
                   4230:       </td></tr><tr><td>0x93 </td><td>U+201C </td><td>LEFT DOUBLE QUOTATION MARK (&#8220;)
                   4231:       </td></tr><tr><td>0x94 </td><td>U+201D </td><td>RIGHT DOUBLE QUOTATION MARK (&#8221;)
                   4232:       </td></tr><tr><td>0x95 </td><td>U+2022 </td><td>BULLET (&#8226;)
                   4233:       </td></tr><tr><td>0x96 </td><td>U+2013 </td><td>EN DASH (&#8211;)
                   4234:       </td></tr><tr><td>0x97 </td><td>U+2014 </td><td>EM DASH (&#8212;)
                   4235:       </td></tr><tr><td>0x98 </td><td>U+02DC </td><td>SMALL TILDE (&#732;)
                   4236:       </td></tr><tr><td>0x99 </td><td>U+2122 </td><td>TRADE MARK SIGN (&#8482;)
                   4237:       </td></tr><tr><td>0x9A </td><td>U+0161 </td><td>LATIN SMALL LETTER S WITH CARON (&#353;)
                   4238:       </td></tr><tr><td>0x9B </td><td>U+203A </td><td>SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (&#8250;)
                   4239:       </td></tr><tr><td>0x9C </td><td>U+0153 </td><td>LATIN SMALL LIGATURE OE (&#339;)
1.1       mike     4240:       </td></tr><tr><td>0x9D </td><td>U+009D </td><td>&lt;control&gt;
1.464     mike     4241:       </td></tr><tr><td>0x9E </td><td>U+017E </td><td>LATIN SMALL LETTER Z WITH CARON (&#382;)
                   4242:       </td></tr><tr><td>0x9F </td><td>U+0178 </td><td>LATIN CAPITAL LETTER Y WITH DIAERESIS (&#376;)
1.315     mike     4243:     </td></tr></tbody></table><p>Otherwise, if the number is in the range 0xD800 to 0xDFFF<!--
                   4244:     surrogates not allowed; see the comment in the "preprocessing the
                   4245:     input stream" section for details --> or is greater than 0x10FFFF,
                   4246:     then this is a <a href="#parse-error">parse error</a>. Return a U+FFFD
                   4247:     REPLACEMENT CHARACTER.</p>
1.18      mike     4248: 
                   4249:     <p>Otherwise, return a character token for the Unicode character
1.1       mike     4250:     whose code point is that number.
                   4251: 
                   4252:     <!-- this is the same as the equivalent list in the input stream
                   4253:     section -->
                   4254:     If the number is in the range 0x0001 to 0x0008, <!-- HT, LF
                   4255:     allowed --> <!-- U+000B is in the next list --> <!-- FF, CR
                   4256:     allowed --> 0x000E to 0x001F, <!-- ASCII allowed --> 0x007F <!--to
1.315     mike     4257:     0x0084, (0x0085 NEL not allowed), 0x0086--> to 0x009F, 0xFDD0 to
                   4258:     0xFDEF, or is one of 0x000B, 0xFFFE, 0xFFFF, 0x1FFFE, 0x1FFFF,
                   4259:     0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE,
                   4260:     0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF,
                   4261:     0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF, 0xCFFFE,
                   4262:     0xCFFFF, 0xDFFFE, 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF,
                   4263:     0x10FFFE, or 0x10FFFF, then this is a <a href="#parse-error">parse
                   4264:     error</a>.</p>
1.1       mike     4265: 
                   4266:    </dd>
                   4267: 
                   4268: 
                   4269:    <dt>Anything else</dt>
                   4270: 
                   4271:    <dd>
                   4272: 
                   4273:     <p>Consume the maximum number of characters possible, with the
                   4274:     consumed characters matching one of the identifiers in the first
                   4275:     column of the <a href="named-character-references.html#named-character-references">named character references</a> table (in a
                   4276:     <a href="infrastructure.html#case-sensitive">case-sensitive</a> manner).</p>
                   4277: 
                   4278:     <p>If no match can be made, then this is a <a href="#parse-error">parse
                   4279:     error</a>. No characters are consumed, and nothing is
                   4280:     returned.</p>
                   4281: 
1.588     mike     4282:     <p>If the last character matched is not a U+003B SEMICOLON
                   4283:     character (;), there is a <a href="#parse-error">parse error</a>.</p>
1.1       mike     4284: 
                   4285:     <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
                   4286:     attribute</a>, and the last character matched is not a U+003B
1.588     mike     4287:     SEMICOLON character (;), and the next character is in the range
                   4288:     U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0041 LATIN
                   4289:     CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z, or U+0061 LATIN
                   4290:     SMALL LETTER A to U+007A LATIN SMALL LETTER Z, then, for
                   4291:     historical reasons, all the characters that were matched after the
                   4292:     U+0026 AMPERSAND character (&amp;) must be unconsumed, and nothing
                   4293:     is returned.</p>
1.1       mike     4294: 
                   4295:     <p>Otherwise, return a character token for the character
                   4296:     corresponding to the character reference name (as given by the
                   4297:     second column of the <a href="named-character-references.html#named-character-references">named character references</a>
                   4298:     table).</p>
                   4299: 
                   4300:     <div class="example">
                   4301: 
                   4302:      <p>If the markup contains <code title="">I'm &amp;notit; I tell
                   4303:      you</code>, the character reference is parsed as "not", as in,
                   4304:      <code title="">I'm &#172;it; I tell you</code>. But if the markup
                   4305:      was <code title="">I'm &amp;notin; I tell you</code>, the
                   4306:      character reference would be parsed as "notin;", resulting in
                   4307:      <code title="">I'm &#8713; I tell you</code>.</p>
                   4308: 
                   4309:     </div>
                   4310: 
                   4311:    </dd>
                   4312: 
1.266     mike     4313:   </dl></div><div class="impl">
                   4314: 
1.363     mike     4315:   <!-- v2: One thing that this doesn't define is handling deeply
                   4316:   nested documents. There are compatibility requirements around that:
                   4317:   you can't throw away the elements altogether, consider Tux made only
                   4318:   with opening <font> elements, one per character. Seems that the best
                   4319:   thing to do is to close some formatting elements from the middle of
                   4320:   the stack when you hit a limit, or something. -->
                   4321: 
1.755     mike     4322:   <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     4323: 
                   4324:   <p>The input to the tree construction stage is a sequence of tokens
                   4325:   from the <a href="#tokenization">tokenization</a> stage. The tree construction
1.810     mike     4326:   stage is associated with a DOM <code><a href="infrastructure.html#document">Document</a></code> object when a
1.1       mike     4327:   parser is created. The "output" of this stage consists of
                   4328:   dynamically modifying or extending that document's DOM tree.</p>
                   4329: 
                   4330:   <p>This specification does not define when an interactive user agent
1.810     mike     4331:   has to render the <code><a href="infrastructure.html#document">Document</a></code> so that it is available to
1.1       mike     4332:   the user, or when it has to begin accepting user input.</p>
                   4333: 
                   4334:   <p>As each token is emitted from the tokenizer, the user agent must
                   4335:   process the token according to the rules given in the section
                   4336:   corresponding to the current <a href="#insertion-mode">insertion mode</a>.</p>
                   4337: 
                   4338:   <p>When the steps below require the UA to <dfn id="insert-a-character">insert a
                   4339:   character</dfn> into a node, if that node has a child immediately
                   4340:   before where the character is to be inserted, and that child is a
1.882     mike     4341:   <code><a href="infrastructure.html#text">Text</a></code> node, and that <code><a href="infrastructure.html#text">Text</a></code> node was the last
1.1       mike     4342:   node that the parser inserted into the document, then the character
1.882     mike     4343:   must be appended to that <code><a href="infrastructure.html#text">Text</a></code> node; otherwise, a new
                   4344:   <code><a href="infrastructure.html#text">Text</a></code> node whose data is just that character must be
1.1       mike     4345:   inserted in the appropriate place.</p>
                   4346: 
                   4347:   <div class="example">
                   4348: 
                   4349:    <p>Here are some sample inputs to the parser and the corresponding
                   4350:    number of text nodes that they result in, assuming a user agent
                   4351:    that executes scripts.</p>
                   4352: 
                   4353:    <table><thead><tr><th>Input </th><th>Number of text nodes
                   4354:     </th></tr></thead><tbody><tr><td><pre>A&lt;script&gt;
                   4355: var&#160;script&#160;=&#160;document.getElementsByTagName('script')[0];
                   4356: document.body.removeChild(script);
                   4357: &lt;/script&gt;B</pre>
                   4358:       </td><td>Two adjacent text nodes in the document, containing "A" and "B".
                   4359:      </td></tr><tr><td><pre>A&lt;script&gt;
                   4360: var&#160;text&#160;=&#160;document.createTextNode('B');
                   4361: document.body.appendChild(text);
                   4362: &lt;/script&gt;C</pre>
                   4363:       </td><td>Four text nodes; "A" before the script, the script's contents, "B" after the script, and then, immediately after that, "C".
                   4364:      </td></tr><tr><td><pre>A&lt;script&gt;
                   4365: var&#160;text&#160;=&#160;document.getElementsByTagName('script')[0].firstChild;
                   4366: text.data&#160;=&#160;'B';
                   4367: document.body.appendChild(text);
                   4368: &lt;/script&gt;B</pre>
                   4369:       </td><td>Two adjacent text nodes in the document, containing "A" and "BB".
                   4370:      </td></tr><tr><td><pre>A&lt;table&gt;B&lt;tr&gt;C&lt;/tr&gt;C&lt;/table&gt;</pre>
                   4371:       </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>.)
                   4372:      </td></tr><tr><td><pre>A&lt;table&gt;&lt;tr&gt;&#160;B&lt;/tr&gt;&#160;B&lt;/table&gt;</pre>
                   4373:       </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>.)
                   4374:      </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>
                   4375:       </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.)
                   4376:    </td></tr></tbody></table></div>
                   4377: 
                   4378:   <p id="mutation-during-parsing">DOM mutation events must not fire
                   4379:   for changes caused by the UA parsing the document. (Conceptually,
                   4380:   the parser is not mutating the DOM, it is constructing it.) This
1.159     mike     4381:   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     4382: 
                   4383:   <p class="note">Not all of the tag names mentioned below are
                   4384:   conformant tag names in this specification; many are included to
                   4385:   handle legacy content. They still form part of the algorithm that
                   4386:   implementations are required to implement to claim conformance.</p>
                   4387: 
                   4388:   <p class="note">The algorithm described below places no limit on the
                   4389:   depth of the DOM tree generated, or on the length of tag names,
                   4390:   attribute names, attribute values, text nodes, etc. While
                   4391:   implementors are encouraged to avoid arbitrary limits, it is
                   4392:   recognized that <a href="infrastructure.html#hardwareLimitations">practical
1.445     mike     4393:   concerns</a> will likely force user agents to impose nesting depth
                   4394:   constraints.</p>
1.1       mike     4395: 
                   4396: 
1.755     mike     4397:   <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     4398: 
                   4399:   <p>When the steps below require the UA to <dfn id="create-an-element-for-the-token" title="create an
                   4400:   element for the token">create an element for a token</dfn> in a
                   4401:   particular namespace, the UA must create a node implementing the
                   4402:   interface appropriate for the element type corresponding to the tag
                   4403:   name of the token in the given namespace (as given in the
                   4404:   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     4405:   element in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, this specification
1.1       mike     4406:   defines it to be the <code><a href="text-level-semantics.html#htmlanchorelement">HTMLAnchorElement</a></code> interface), with
                   4407:   the tag name being the name of that element, with the node being in
                   4408:   the given namespace, and with the attributes on the node being those
                   4409:   given in the given token.</p>
                   4410: 
1.724     mike     4411:   <p>The interface appropriate for an element in the <a href="infrastructure.html#html-namespace-0">HTML
1.426     mike     4412:   namespace</a> that is not defined in this specification (or
                   4413:   <a href="infrastructure.html#other-applicable-specifications">other applicable specifications</a>) is
1.44      mike     4414:   <code><a href="dom.html#htmlunknownelement">HTMLUnknownElement</a></code>. Element in other namespaces whose
1.1       mike     4415:   interface is not defined by that namespace's specification must use
1.810     mike     4416:   the interface <code><a href="infrastructure.html#element">Element</a></code>.</p>
1.1       mike     4417: 
1.882     mike     4418:   <p>When a <a href="forms.html#category-reset" title="category-reset">resettable element</a> is
1.1       mike     4419:   created in this manner, its <a href="forms.html#concept-form-reset-control" title="concept-form-reset-control">reset algorithm</a> must be
                   4420:   invoked once the attributes are set. (This initializes the element's
                   4421:   <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
                   4422:   attributes.)</p>
                   4423: 
                   4424:   <hr><p>When the steps below require the UA to <dfn id="insert-an-html-element">insert an HTML
                   4425:   element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
1.724     mike     4426:   for the token</a> in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, and then
1.1       mike     4427:   append this node to the <a href="#current-node">current node</a>, and push it onto
                   4428:   the <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
                   4429:   <a href="#current-node">current node</a>.</p>
                   4430: 
                   4431:   <p>The steps below may also require that the UA insert an HTML
                   4432:   element in a particular place, in which case the UA must follow the
                   4433:   same steps except that it must insert or append the new node in the
                   4434:   location specified instead of appending it to the <a href="#current-node">current
                   4435:   node</a>. (This happens in particular during the parsing of
                   4436:   tables with invalid content.)</p>
                   4437: 
                   4438:   <p>If an element created by the <a href="#insert-an-html-element">insert an HTML element</a>
                   4439:   algorithm is a <a href="forms.html#form-associated-element">form-associated element</a>, and the
                   4440:   <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is not null,
                   4441:   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
                   4442:   <a href="forms.html#concept-form-association" title="concept-form-association">associate</a> the newly
                   4443:   created element with the <code><a href="forms.html#the-form-element">form</a></code> element pointed to by the
                   4444:   <a href="#form-element-pointer"><code title="">form</code> element pointer</a> before
                   4445:   inserting it wherever it is to be inserted.</p>
                   4446: 
                   4447:   <hr><p>When the steps below require the UA to <dfn id="insert-a-foreign-element">insert a foreign
                   4448:   element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
                   4449:   for the token</a> in the given namespace, and then append this
                   4450:   node to the <a href="#current-node">current node</a>, and push it onto the
                   4451:   <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
1.724     mike     4452:   <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     4453:   whose value is not exactly the same as the element's namespace, that
                   4454:   is a <a href="#parse-error">parse error</a>. Similarly, if the newly created
                   4455:   element has an <code title="">xmlns:xlink</code> attribute in the
1.724     mike     4456:   <a href="infrastructure.html#xmlns-namespace">XMLNS namespace</a> whose value is not the <a href="infrastructure.html#xlink-namespace">XLink
1.1       mike     4457:   Namespace</a>, that is a <a href="#parse-error">parse error</a>.</p>
                   4458: 
                   4459:   <p>When the steps below require the user agent to <dfn id="adjust-mathml-attributes">adjust MathML
                   4460:   attributes</dfn> for a token, then, if the token has an attribute
                   4461:   named <code title="">definitionurl</code>, change its name to <code title="">definitionURL</code> (note the case difference).</p>
                   4462: 
                   4463:   <p>When the steps below require the user agent to <dfn id="adjust-svg-attributes">adjust SVG
                   4464:   attributes</dfn> for a token, then, for each attribute on the token
                   4465:   whose attribute name is one of the ones in the first column of the
                   4466:   following table, change the attribute's name to the name given in
                   4467:   the corresponding cell in the second column. (This fixes the case of
                   4468:   SVG attributes that are not all lowercase.)</p>
                   4469: 
                   4470:   <table><thead><tr><th> Attribute name on token </th><th> Attribute name on element
                   4471:    </th></tr></thead><tbody><tr><td> <code title="">attributename</code> </td><td> <code title="">attributeName</code>
                   4472:     </td></tr><tr><td> <code title="">attributetype</code> </td><td> <code title="">attributeType</code>
                   4473:     </td></tr><tr><td> <code title="">basefrequency</code> </td><td> <code title="">baseFrequency</code>
                   4474:     </td></tr><tr><td> <code title="">baseprofile</code> </td><td> <code title="">baseProfile</code>
                   4475:     </td></tr><tr><td> <code title="">calcmode</code> </td><td> <code title="">calcMode</code>
                   4476:     </td></tr><tr><td> <code title="">clippathunits</code> </td><td> <code title="">clipPathUnits</code>
                   4477:     </td></tr><tr><td> <code title="">contentscripttype</code> </td><td> <code title="">contentScriptType</code>
                   4478:     </td></tr><tr><td> <code title="">contentstyletype</code> </td><td> <code title="">contentStyleType</code>
                   4479:     </td></tr><tr><td> <code title="">diffuseconstant</code> </td><td> <code title="">diffuseConstant</code>
                   4480:     </td></tr><tr><td> <code title="">edgemode</code> </td><td> <code title="">edgeMode</code>
                   4481:     </td></tr><tr><td> <code title="">externalresourcesrequired</code> </td><td> <code title="">externalResourcesRequired</code>
                   4482:     </td></tr><tr><td> <code title="">filterres</code> </td><td> <code title="">filterRes</code>
                   4483:     </td></tr><tr><td> <code title="">filterunits</code> </td><td> <code title="">filterUnits</code>
                   4484:     </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
                   4485:     </td></tr><tr><td> <code title="">gradienttransform</code> </td><td> <code title="">gradientTransform</code>
                   4486:     </td></tr><tr><td> <code title="">gradientunits</code> </td><td> <code title="">gradientUnits</code>
                   4487:     </td></tr><tr><td> <code title="">kernelmatrix</code> </td><td> <code title="">kernelMatrix</code>
                   4488:     </td></tr><tr><td> <code title="">kernelunitlength</code> </td><td> <code title="">kernelUnitLength</code>
                   4489:     </td></tr><tr><td> <code title="">keypoints</code> </td><td> <code title="">keyPoints</code>
                   4490:     </td></tr><tr><td> <code title="">keysplines</code> </td><td> <code title="">keySplines</code>
                   4491:     </td></tr><tr><td> <code title="">keytimes</code> </td><td> <code title="">keyTimes</code>
                   4492:     </td></tr><tr><td> <code title="">lengthadjust</code> </td><td> <code title="">lengthAdjust</code>
                   4493:     </td></tr><tr><td> <code title="">limitingconeangle</code> </td><td> <code title="">limitingConeAngle</code>
                   4494:     </td></tr><tr><td> <code title="">markerheight</code> </td><td> <code title="">markerHeight</code>
                   4495:     </td></tr><tr><td> <code title="">markerunits</code> </td><td> <code title="">markerUnits</code>
                   4496:     </td></tr><tr><td> <code title="">markerwidth</code> </td><td> <code title="">markerWidth</code>
                   4497:     </td></tr><tr><td> <code title="">maskcontentunits</code> </td><td> <code title="">maskContentUnits</code>
                   4498:     </td></tr><tr><td> <code title="">maskunits</code> </td><td> <code title="">maskUnits</code>
                   4499:     </td></tr><tr><td> <code title="">numoctaves</code> </td><td> <code title="">numOctaves</code>
                   4500:     </td></tr><tr><td> <code title="">pathlength</code> </td><td> <code title="">pathLength</code>
                   4501:     </td></tr><tr><td> <code title="">patterncontentunits</code> </td><td> <code title="">patternContentUnits</code>
                   4502:     </td></tr><tr><td> <code title="">patterntransform</code> </td><td> <code title="">patternTransform</code>
                   4503:     </td></tr><tr><td> <code title="">patternunits</code> </td><td> <code title="">patternUnits</code>
                   4504:     </td></tr><tr><td> <code title="">pointsatx</code> </td><td> <code title="">pointsAtX</code>
                   4505:     </td></tr><tr><td> <code title="">pointsaty</code> </td><td> <code title="">pointsAtY</code>
                   4506:     </td></tr><tr><td> <code title="">pointsatz</code> </td><td> <code title="">pointsAtZ</code>
                   4507:     </td></tr><tr><td> <code title="">preservealpha</code> </td><td> <code title="">preserveAlpha</code>
                   4508:     </td></tr><tr><td> <code title="">preserveaspectratio</code> </td><td> <code title="">preserveAspectRatio</code>
                   4509:     </td></tr><tr><td> <code title="">primitiveunits</code> </td><td> <code title="">primitiveUnits</code>
                   4510:     </td></tr><tr><td> <code title="">refx</code> </td><td> <code title="">refX</code>
                   4511:     </td></tr><tr><td> <code title="">refy</code> </td><td> <code title="">refY</code>
                   4512:     </td></tr><tr><td> <code title="">repeatcount</code> </td><td> <code title="">repeatCount</code>
                   4513:     </td></tr><tr><td> <code title="">repeatdur</code> </td><td> <code title="">repeatDur</code>
                   4514:     </td></tr><tr><td> <code title="">requiredextensions</code> </td><td> <code title="">requiredExtensions</code>
                   4515:     </td></tr><tr><td> <code title="">requiredfeatures</code> </td><td> <code title="">requiredFeatures</code>
                   4516:     </td></tr><tr><td> <code title="">specularconstant</code> </td><td> <code title="">specularConstant</code>
                   4517:     </td></tr><tr><td> <code title="">specularexponent</code> </td><td> <code title="">specularExponent</code>
                   4518:     </td></tr><tr><td> <code title="">spreadmethod</code> </td><td> <code title="">spreadMethod</code>
                   4519:     </td></tr><tr><td> <code title="">startoffset</code> </td><td> <code title="">startOffset</code>
                   4520:     </td></tr><tr><td> <code title="">stddeviation</code> </td><td> <code title="">stdDeviation</code>
                   4521:     </td></tr><tr><td> <code title="">stitchtiles</code> </td><td> <code title="">stitchTiles</code>
                   4522:     </td></tr><tr><td> <code title="">surfacescale</code> </td><td> <code title="">surfaceScale</code>
                   4523:     </td></tr><tr><td> <code title="">systemlanguage</code> </td><td> <code title="">systemLanguage</code>
                   4524:     </td></tr><tr><td> <code title="">tablevalues</code> </td><td> <code title="">tableValues</code>
                   4525:     </td></tr><tr><td> <code title="">targetx</code> </td><td> <code title="">targetX</code>
                   4526:     </td></tr><tr><td> <code title="">targety</code> </td><td> <code title="">targetY</code>
                   4527:     </td></tr><tr><td> <code title="">textlength</code> </td><td> <code title="">textLength</code>
                   4528:     </td></tr><tr><td> <code title="">viewbox</code> </td><td> <code title="">viewBox</code>
                   4529:     </td></tr><tr><td> <code title="">viewtarget</code> </td><td> <code title="">viewTarget</code>
                   4530:     </td></tr><tr><td> <code title="">xchannelselector</code> </td><td> <code title="">xChannelSelector</code>
                   4531:     </td></tr><tr><td> <code title="">ychannelselector</code> </td><td> <code title="">yChannelSelector</code>
                   4532:     </td></tr><tr><td> <code title="">zoomandpan</code> </td><td> <code title="">zoomAndPan</code>
                   4533:   </td></tr></tbody></table><p>When the steps below require the user agent to <dfn id="adjust-foreign-attributes">adjust
                   4534:   foreign attributes</dfn> for a token, then, if any of the attributes
                   4535:   on the token match the strings given in the first column of the
                   4536:   following table, let the attribute be a namespaced attribute, with
                   4537:   the prefix being the string given in the corresponding cell in the
                   4538:   second column, the local name being the string given in the
                   4539:   corresponding cell in the third column, and the namespace being the
                   4540:   namespace given in the corresponding cell in the fourth
                   4541:   column. (This fixes the use of namespaced attributes, in particular
                   4542:   <a href="dom.html#attr-xml-lang" title="attr-xml-lang"><code title="">lang</code> attributes in
                   4543:   the <span>XML namespace</span></a>.)</p>
                   4544: 
                   4545:   <table><thead><tr><th> Attribute name </th><th> Prefix </th><th> Local name </th><th> Namespace
1.724     mike     4546:    </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>
                   4547:     </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>
                   4548:     </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>
                   4549:     </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>
                   4550:     </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>
                   4551:     </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>
                   4552:     </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>
                   4553:     </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 -->
                   4554:     </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>
                   4555:     </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>
                   4556:     </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>
                   4557:     </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     4558:   </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     4559:   <dfn id="generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</dfn> consist of the
                   4560:   following steps. These algorithms are always invoked in response to
                   4561:   a start tag token.</p>
                   4562: 
                   4563:   <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p></li>
                   4564: 
1.91      mike     4565:    <li><p>If the algorithm that was invoked is the <a href="#generic-raw-text-element-parsing-algorithm">generic raw
1.541     mike     4566:    text element parsing algorithm</a>, switch the tokenizer to the
                   4567:    <a href="#rawtext-state">RAWTEXT state</a>; otherwise the algorithm invoked
                   4568:    was the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>,
                   4569:    switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</p></li>
1.1       mike     4570: 
                   4571:    <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
                   4572:    <a href="#insertion-mode">insertion mode</a>.</p>
                   4573: 
1.540     mike     4574:    </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     4575: 
1.755     mike     4576:   </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     4577: 
                   4578:   <p>When the steps below require the UA to <dfn id="generate-implied-end-tags">generate implied end
                   4579:   tags</dfn>, then, while the <a href="#current-node">current node</a> is a
1.422     mike     4580:   <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     4581:   <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
                   4582:   <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
                   4583:   <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
                   4584:   pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   4585:   elements</a>.</p>
                   4586: 
                   4587:   <p>If a step requires the UA to generate implied end tags but lists
                   4588:   an element to exclude from the process, then the UA must perform the
                   4589:   above steps as if that element was not in the above list.</p>
                   4590: 
                   4591: 
1.755     mike     4592:   <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     4593: 
                   4594:   <p>Foster parenting happens when content is misnested in tables.</p>
                   4595: 
                   4596:   <p>When a node <var title="">node</var> is to be <dfn id="foster-parent" title="foster
                   4597:   parent">foster parented</dfn>, the node <var title="">node</var>
                   4598:   must be inserted into the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
                   4599: 
                   4600:   <p>The <dfn id="foster-parent-element">foster parent element</dfn> is the parent element of the
                   4601:   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
                   4602:   elements</a>, if there is a <code><a href="tabular-data.html#the-table-element">table</a></code> element and it has
                   4603:   such a parent element. If there is no <code><a href="tabular-data.html#the-table-element">table</a></code> element in
                   4604:   the <a href="#stack-of-open-elements">stack of open elements</a> (<a href="#fragment-case">fragment
                   4605:   case</a>), then the <i><a href="#foster-parent-element">foster parent element</a></i> is the first
                   4606:   element in the <a href="#stack-of-open-elements">stack of open elements</a> (the
1.159     mike     4607:   <code><a href="semantics.html#the-html-element-0">html</a></code> element). Otherwise, if there is a
1.1       mike     4608:   <code><a href="tabular-data.html#the-table-element">table</a></code> element in the <a href="#stack-of-open-elements">stack of open
                   4609:   elements</a>, but the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
                   4610:   <a href="#stack-of-open-elements">stack of open elements</a> has no parent, or its parent
                   4611:   node is not an element, then the <i><a href="#foster-parent-element">foster parent element</a></i> is
                   4612:   the element before the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
                   4613:   <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   4614: 
                   4615:   <p>If the <i><a href="#foster-parent-element">foster parent element</a></i> is the parent element of the
                   4616:   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
                   4617:   elements</a>, then <var title="">node</var> must be inserted
                   4618:   immediately <em>before</em> the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in
                   4619:   the <a href="#stack-of-open-elements">stack of open elements</a> in the <i><a href="#foster-parent-element">foster parent
                   4620:   element</a></i>; otherwise, <var title="">node</var> must be
                   4621:   <em>appended</em> to the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
                   4622: 
                   4623: 
                   4624: 
1.755     mike     4625:   <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     4626: 
                   4627:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-initial-insertion-mode" title="insertion
                   4628:   mode: initial">initial</a>", tokens must be handled as follows:</p>
                   4629: 
                   4630:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   4631:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882     mike     4632:    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1       mike     4633:    <dd>
                   4634:     <p>Ignore the token.</p>
                   4635:    </dd>
                   4636: 
                   4637:    <dt>A comment token</dt>
                   4638:    <dd>
1.882     mike     4639:     <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <code><a href="infrastructure.html#document">Document</a></code>
1.1       mike     4640:     object with the <code title="">data</code> attribute set to the
                   4641:     data given in the comment token.</p>
                   4642:    </dd>
                   4643: 
                   4644:    <dt>A DOCTYPE token</dt>
                   4645:    <dd>
                   4646: 
                   4647:     <p>If the DOCTYPE token's name is not a
                   4648:     <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
                   4649:     missing, or the token's system identifier is neither missing nor a
                   4650:     <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string
1.465     mike     4651:     "<code><a href="infrastructure.html#about:legacy-compat">about:legacy-compat</a></code>", and none of the sets of
1.1       mike     4652:     conditions in the following list are matched, then there is a
1.861     mike     4653:     <a href="#parse-error">parse error</a>.</p>
1.1       mike     4654: 
                   4655:     <ul><!-- only things that trigger no-quirks mode and were valid in
1.688     mike     4656:      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>
                   4657:      match for the string "<code title="">html</code>", the token's
                   4658:      public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
                   4659:      "<code title="">-//W3C//DTD&#160;HTML&#160;4.0//EN</code>", and
                   4660:      the token's system identifier is either missing or the
1.1       mike     4661:      <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/REC-html40/strict.dtd</code>".</li>
                   4662: 
1.688     mike     4663:      <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
                   4664:      match for the string "<code title="">html</code>", the token's
                   4665:      public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
                   4666:      "<code title="">-//W3C//DTD&#160;HTML&#160;4.01//EN</code>", and
                   4667:      the token's system identifier is either missing or the
1.1       mike     4668:      <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/html4/strict.dtd</code>".</li>
                   4669: 
1.688     mike     4670:      <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
                   4671:      match for the string "<code title="">html</code>", the token's
                   4672:      public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
                   4673:      "<code title="">-//W3C//DTD&#160;XHTML&#160;1.0&#160;Strict//EN</code>",
1.1       mike     4674:      and the token's system identifier is the
                   4675:      <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</code>".</li>
                   4676: 
1.688     mike     4677:      <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
                   4678:      match for the string "<code title="">html</code>", the token's
                   4679:      public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
                   4680:      "<code title="">-//W3C//DTD&#160;XHTML&#160;1.1//EN</code>", and
                   4681:      the token's system identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a>
1.1       mike     4682:      string "<code title="">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</code>".</li>
                   4683: 
                   4684:     </ul><p>Conformance checkers may, based on the values (including
                   4685:     presence or lack thereof) of the DOCTYPE token's name, public
                   4686:     identifier, or system identifier, switch to a conformance checking
                   4687:     mode for another language (e.g. based on the DOCTYPE token a
                   4688:     conformance checker could recognize that the document is an
1.183     mike     4689:     HTML4-era document, and defer to an HTML4 conformance
1.1       mike     4690:     checker.)</p>
                   4691: 
1.882     mike     4692:     <p>Append a <code><a href="infrastructure.html#documenttype">DocumentType</a></code> node to the
1.810     mike     4693:     <code><a href="infrastructure.html#document">Document</a></code> node, with the <code title="">name</code>
1.1       mike     4694:     attribute set to the name given in the DOCTYPE token, or the empty
                   4695:     string if the name was missing; the <code title="">publicId</code>
                   4696:     attribute set to the public identifier given in the DOCTYPE token,
                   4697:     or the empty string if the public identifier was missing; the
                   4698:     <code title="">systemId</code> attribute set to the system
                   4699:     identifier given in the DOCTYPE token, or the empty string if the
                   4700:     system identifier was missing; and the other attributes specific
1.882     mike     4701:     to <code><a href="infrastructure.html#documenttype">DocumentType</a></code> objects set to null and empty lists
                   4702:     as appropriate. Associate the <code><a href="infrastructure.html#documenttype">DocumentType</a></code> node with
1.810     mike     4703:     the <code><a href="infrastructure.html#document">Document</a></code> object so that it is returned as the
1.1       mike     4704:     value of the <code title="">doctype</code> attribute of the
1.810     mike     4705:     <code><a href="infrastructure.html#document">Document</a></code> object.</p>
1.1       mike     4706: 
                   4707:     <p id="quirks-mode-doctypes">Then, if the DOCTYPE token matches
                   4708:     one of the conditions in the following list, then set the
1.810     mike     4709:     <code><a href="infrastructure.html#document">Document</a></code> to <a href="dom.html#quirks-mode">quirks mode</a>:</p>
1.1       mike     4710: 
                   4711:     <ul class="brief"><li> The <i>force-quirks flag</i> is set to <i>on</i>. </li>
1.688     mike     4712:      <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     4713:      <li> The public identifier starts with: "<code title="">+//Silmaril//dtd html Pro v0r11 19970101//<!--EN--></code>" </li>
                   4714:      <li> The public identifier starts with: "<code title="">-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
                   4715:      <li> The public identifier starts with: "<code title="">-//AS//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
                   4716:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 1//<!--EN--></code>" </li>
                   4717:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 2//<!--EN--></code>" </li>
                   4718:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 1//<!--EN--></code>" </li>
                   4719:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 2//<!--EN--></code>" </li>
                   4720:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict//<!--EN--></code>" </li>
                   4721:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0//<!--EN--></code>" </li>
                   4722:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.1E//<!--EN--></code>" </li>
                   4723:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.0//<!--EN--></code>" </li>
                   4724:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML 3.0//EN//</code>" </li>-->
                   4725:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2 Final//<!--EN--></code>" </li>
                   4726:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2//<!--EN--></code>" </li>
                   4727:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3//<!--EN--></code>" </li>
                   4728:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 0//<!--EN--></code>" </li>
                   4729:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 0//EN//2.0</code>" </li>-->
                   4730:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 1//<!--EN--></code>" </li>
                   4731:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 1//EN//2.0</code>" </li>-->
                   4732:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 2//<!--EN--></code>" </li>
                   4733:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 2//EN//2.0</code>" </li>-->
                   4734:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 3//<!--EN--></code>" </li>
                   4735:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 3//EN//3.0</code>" </li>-->
                   4736:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 0//<!--EN--></code>" </li>
                   4737:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 0//EN//2.0</code>" </li>-->
                   4738:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 1//<!--EN--></code>" </li>
                   4739:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 1//EN//2.0</code>" </li>-->
                   4740:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 2//<!--EN--></code>" </li>
                   4741:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 2//EN//2.0</code>" </li>-->
                   4742:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 3//<!--EN--></code>" </li>
                   4743:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 3//EN//3.0</code>" </li>-->
                   4744:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict//<!--EN--></code>" </li>
                   4745:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//2.0</code>" </li>-->
                   4746:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//3.0</code>" </li>-->
                   4747:      <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML//<!--EN--></code>" </li>
                   4748:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//2.0</code>" </li>-->
                   4749:    <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//3.0</code>" </li>-->
                   4750:      <li> The public identifier starts with: "<code title="">-//Metrius//DTD Metrius Presentational//<!--EN--></code>" </li>
                   4751:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//<!--EN--></code>" </li>
                   4752:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML//<!--EN--></code>" </li>
                   4753:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 Tables//<!--EN--></code>" </li>
                   4754:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//<!--EN--></code>" </li>
                   4755:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML//<!--EN--></code>" </li>
                   4756:      <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 Tables//<!--EN--></code>" </li>
                   4757:      <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD HTML//<!--EN--></code>" </li>
                   4758:      <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD Strict HTML//<!--EN--></code>" </li>
                   4759:      <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML 2.0//<!--EN--></code>" </li>
                   4760:      <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended 1.0//<!--EN--></code>" </li>
                   4761:      <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//<!--EN--></code>" </li>
                   4762:      <li> The public identifier starts with: "<code title="">-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//<!--EN--></code>" </li>
                   4763:      <li> The public identifier starts with: "<code title="">-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//<!--EN--></code>" </li>
                   4764:      <li> The public identifier starts with: "<code title="">-//Spyglass//DTD HTML 2.0 Extended//<!--EN--></code>" </li>
                   4765:      <li> The public identifier starts with: "<code title="">-//SQ//DTD HTML 2.0 HoTMetaL + extensions//<!--EN--></code>" </li>
                   4766:      <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava HTML//<!--EN--></code>" </li>
                   4767:      <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava Strict HTML//<!--EN--></code>" </li>
                   4768:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3 1995-03-24//<!--EN--></code>" </li>
                   4769:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Draft//<!--EN--></code>" </li>
                   4770:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Final//<!--EN--></code>" </li>
                   4771:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2//<!--EN--></code>" </li>
                   4772:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2S Draft//<!--EN--></code>" </li>
                   4773:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Frameset//<!--EN--></code>" </li>
                   4774:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Transitional//<!--EN--></code>" </li>
                   4775:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 19960712//<!--EN--></code>" </li>
                   4776:      <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 970421//<!--EN--></code>" </li>
                   4777:      <li> The public identifier starts with: "<code title="">-//W3C//DTD W3 HTML//<!--EN--></code>" </li>
                   4778:      <li> The public identifier starts with: "<code title="">-//W3O//DTD W3 HTML 3.0//<!--EN--></code>" </li>
                   4779:    <!--<li> The public identifier is set to: "<code title="">-//W3O//DTD W3 HTML 3.0//EN//</code>" </li>-->
                   4780:      <li> The public identifier is set to: "<code title="">-//W3O//DTD W3 HTML Strict 3.0//EN//</code>" </li>
                   4781:      <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML 2.0//<!--EN--></code>" </li>
                   4782:      <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML//<!--EN--></code>" </li>
                   4783:      <li> The public identifier is set to: "<code title="">-/W3C/DTD HTML 4.0 Transitional/EN</code>" </li>
                   4784:      <li> The public identifier is set to: "<code title="">HTML</code>" </li>
                   4785:      <li> The system identifier is set to: "<code title="">http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd</code>" </li>
                   4786:      <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
                   4787:      <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Transitional//<!--EN--></code>" </li>
                   4788:     </ul><p>Otherwise, if the DOCTYPE token matches one of the conditions
1.810     mike     4789:     in the following list, then set the <code><a href="infrastructure.html#document">Document</a></code> to
1.880     mike     4790:     <a href="dom.html#limited-quirks-mode">limited-quirks mode</a>:</p>
1.1       mike     4791: 
                   4792:     <ul class="brief"><li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Frameset//<!--EN--></code>" </li>
                   4793:      <li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Transitional//<!--EN--></code>" </li>
                   4794:      <li> The system identifier is not missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
                   4795:      <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     4796:     </ul><p>The system identifier and public identifier strings must be
                   4797:     compared to the values given in the lists above in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   4798:     case-insensitive</a> manner. A system identifier whose value is
                   4799:     the empty string is not considered missing for the purposes of the
                   4800:     conditions above.</p>
1.1       mike     4801: 
                   4802:     <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>
                   4803: 
                   4804:    </dd>
                   4805: 
                   4806:    <dt>Anything else</dt>
                   4807:    <dd>
                   4808: 
1.727     mike     4809:     <p>If the document is <em>not</em> <a href="text-level-semantics.html#an-iframe-srcdoc-document">an <code>iframe</code>
                   4810:     <code title="attr-iframe-srcdoc">srcdoc</code> document</a>,
                   4811:     then this is a <a href="#parse-error">parse error</a>; set the
1.810     mike     4812:     <code><a href="infrastructure.html#document">Document</a></code> to <a href="dom.html#quirks-mode">quirks mode</a>.</p>
1.1       mike     4813: 
1.727     mike     4814:     <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     4815:     reprocess the current token.</p>
                   4816: 
                   4817:    </dd>
                   4818: 
1.755     mike     4819:   </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     4820: 
                   4821:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-html-insertion-mode" title="insertion
                   4822:   mode: before html">before html</a>", tokens must be handled as follows:</p>
                   4823: 
                   4824:   <dl class="switch"><dt>A DOCTYPE token</dt>
                   4825:    <dd>
                   4826:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4827:    </dd>
                   4828: 
                   4829:    <dt>A comment token</dt>
                   4830:    <dd>
1.882     mike     4831:     <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <code><a href="infrastructure.html#document">Document</a></code>
1.1       mike     4832:     object with the <code title="">data</code> attribute set to the
                   4833:     data given in the comment token.</p>
                   4834:    </dd>
                   4835: 
                   4836:    <dt>A character token that is one of U+0009 CHARACTER
                   4837:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882     mike     4838:    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1       mike     4839:    <dd>
                   4840:     <p>Ignore the token.</p>
                   4841:    </dd>
                   4842: 
                   4843:    <dt>A start tag whose tag name is "html"</dt>
                   4844:    <dd>
                   4845: 
1.724     mike     4846:     <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.810     mike     4847:     namespace</a>. Append it to the <code><a href="infrastructure.html#document">Document</a></code>
1.1       mike     4848:     object. Put this element in the <a href="#stack-of-open-elements">stack of open
                   4849:     elements</a>.</p>
                   4850: 
1.810     mike     4851:     <p id="parser-appcache">If the <code><a href="infrastructure.html#document">Document</a></code> is being
1.1       mike     4852:     loaded as part of <a href="history.html#navigate" title="navigate">navigation</a> of a
                   4853:     <a href="browsers.html#browsing-context">browsing context</a>, then: if the newly created element
1.875     mike     4854:     has a <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code> attribute
                   4855:     whose value is not the empty string, then <a href="infrastructure.html#resolve-a-url" title="resolve a
                   4856:     url">resolve</a> the value of that attribute to an
                   4857:     <a href="infrastructure.html#absolute-url">absolute URL</a>, relative to the newly created element,
                   4858:     and if that is successful, run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application cache selection
1.29      mike     4859:     algorithm</a> with the resulting <a href="infrastructure.html#absolute-url">absolute URL</a> with
                   4860:     any <a href="infrastructure.html#url-fragment" title="url-fragment">&lt;fragment&gt;</a> component
1.875     mike     4861:     removed; otherwise, if there is no such attribute, or its value is
                   4862:     the empty string, or resolving its value fails, run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application cache selection
                   4863:     algorithm</a> with no manifest. The algorithm must be passed
                   4864:     the <code><a href="infrastructure.html#document">Document</a></code> object.</p>
1.1       mike     4865: 
                   4866:     <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>
                   4867: 
                   4868:    </dd>
                   4869: 
1.334     mike     4870:    <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
                   4871:    <dd>
                   4872:     <p>Act as described in the "anything else" entry below.</p>
                   4873:    </dd>
                   4874: 
                   4875:    <dt>Any other end tag</dt>
                   4876:    <dd>
                   4877:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4878:    </dd>
                   4879: 
1.1       mike     4880:    <dt>Anything else</dt>
                   4881:    <dd>
                   4882: 
1.159     mike     4883:     <p>Create an <code><a href="semantics.html#the-html-element-0">html</a></code> element. Append it to the
1.810     mike     4884:     <code><a href="infrastructure.html#document">Document</a></code> object. Put this element in the <a href="#stack-of-open-elements">stack
1.1       mike     4885:     of open elements</a>.</p>
                   4886: 
1.810     mike     4887:     <p>If the <code><a href="infrastructure.html#document">Document</a></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
1.1       mike     4888:     context</a>, then: run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application cache selection
                   4889:     algorithm</a> with no manifest, passing it the
1.810     mike     4890:     <code><a href="infrastructure.html#document">Document</a></code> object.</p>
1.1       mike     4891: 
                   4892:     <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
                   4893:     reprocess the current token.</p>
                   4894: 
                   4895:    </dd>
                   4896: 
                   4897:   </dl><p>The root element can end up being removed from the
1.810     mike     4898:   <code><a href="infrastructure.html#document">Document</a></code> object, e.g. by scripts; nothing in particular
1.1       mike     4899:   happens in such cases, content continues being appended to the nodes
                   4900:   as described in the next section.</p>
                   4901: 
                   4902: 
1.755     mike     4903:   <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     4904: 
                   4905:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-head-insertion-mode" title="insertion
                   4906:   mode: before head">before head</a>", tokens must be handled as follows:</p>
                   4907: 
                   4908:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   4909:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882     mike     4910:    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1       mike     4911:    <dd>
                   4912:     <p>Ignore the token.</p> <!-- :-( -->
                   4913:    </dd>
                   4914: 
                   4915:    <dt>A comment token</dt>
                   4916:    <dd>
1.882     mike     4917:     <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1       mike     4918:     node</a> with the <code title="">data</code> attribute set to
                   4919:     the data given in the comment token.</p>
                   4920:    </dd>
                   4921: 
                   4922:    <dt>A DOCTYPE token</dt>
                   4923:    <dd>
                   4924:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4925:    </dd>
                   4926: 
                   4927:    <dt>A start tag whose tag name is "html"</dt>
                   4928:    <dd>
                   4929:     <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
                   4930:     mode</a>.</p>
                   4931:    </dd>
                   4932: 
                   4933:    <dt>A start tag whose tag name is "head"</dt>
                   4934:    <dd>
                   4935: 
                   4936:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   4937: 
                   4938:     <p>Set the <a href="#head-element-pointer"><code title="">head</code> element pointer</a>
1.159     mike     4939:     to the newly created <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1       mike     4940: 
                   4941:     <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>
                   4942: 
                   4943:    </dd>
                   4944: 
                   4945:    <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
                   4946:    <dd>
                   4947: 
                   4948:     <p>Act as if a start tag token with the tag name "head" and no
                   4949:     attributes had been seen, then reprocess the current token.</p>
                   4950: 
                   4951:    </dd>
                   4952: 
                   4953:    <dt>Any other end tag</dt>
                   4954:    <dd>
                   4955: 
                   4956:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4957: 
                   4958:    </dd>
                   4959: 
                   4960:    <dt>Anything else</dt>
                   4961:    <dd>
                   4962: 
                   4963:     <p>Act as if a start tag token with the tag name "head" and no
                   4964:     attributes had been seen, then reprocess the current
                   4965:     token.</p>
                   4966: 
                   4967:    </dd>
                   4968: 
1.755     mike     4969:   </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     4970: 
                   4971:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inhead" title="insertion
                   4972:   mode: in head">in head</a>", tokens must be handled as follows:</p>
                   4973: 
                   4974:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   4975:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882     mike     4976:    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1       mike     4977:    <dd>
                   4978:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   4979:     the <a href="#current-node">current node</a>.</p>
                   4980:    </dd>
                   4981: 
                   4982:    <dt>A comment token</dt>
                   4983:    <dd>
1.882     mike     4984:     <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1       mike     4985:     node</a> with the <code title="">data</code> attribute set to
                   4986:     the data given in the comment token.</p>
                   4987:    </dd>
                   4988: 
                   4989:    <dt>A DOCTYPE token</dt>
                   4990:    <dd>
                   4991:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   4992:    </dd>
                   4993: 
                   4994:    <dt>A start tag whose tag name is "html"</dt>
                   4995:    <dd>
                   4996:     <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
                   4997:     mode</a>.</p>
                   4998:    </dd>
                   4999: 
                   5000:    <dt>A start tag whose tag name is one of: "base", "command",
                   5001:    "link"</dt>
                   5002:    <dd>
                   5003: 
                   5004:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   5005:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   5006:     elements</a>.</p>
                   5007: 
                   5008:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   5009:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   5010: 
                   5011:    </dd>
                   5012: 
                   5013:    <dt>A start tag whose tag name is "meta"</dt>
                   5014:    <dd>
                   5015: 
                   5016:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   5017:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   5018:     elements</a>.</p>
                   5019: 
                   5020:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   5021:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   5022: 
                   5023:     <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
                   5024:     value is a supported encoding, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
                   5025:     currently <i>tentative</i>, then <a href="#change-the-encoding">change the
                   5026:     encoding</a> to the encoding given by the value of the
                   5027:     <code title="attr-meta-charset"><a href="semantics.html#attr-meta-charset">charset</a></code> attribute.</p>
                   5028: 
                   5029:     <p>Otherwise, if the element has a <code title="attr-meta-charset"><a href="semantics.html#attr-meta-charset">content</a></code> attribute, and
                   5030:     applying the <a href="infrastructure.html#algorithm-for-extracting-an-encoding-from-a-content-type">algorithm for extracting an encoding from a
                   5031:     Content-Type</a> to its value returns a supported encoding
                   5032:     <var title="">encoding</var>, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
                   5033:     currently <i>tentative</i>, then <a href="#change-the-encoding">change the
                   5034:     encoding</a> to the encoding <var title="">encoding</var>.</p>
                   5035: 
                   5036:    </dd>
                   5037: 
                   5038:    <dt>A start tag whose tag name is "title"</dt>
                   5039:    <dd>
                   5040:     <p>Follow the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>.</p>
                   5041:    </dd>
                   5042: 
                   5043:    <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
                   5044:    <dt>A start tag whose tag name is one of: "noframes", "style"</dt>
                   5045:    <dd>
1.91      mike     5046:     <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1       mike     5047:    </dd>
                   5048: 
                   5049:    <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is disabled</dt>
                   5050:    <dd>
                   5051: 
                   5052:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5053: 
                   5054:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inheadnoscript" title="insertion mode: in head noscript">in head
                   5055:     noscript</a>".</p>
                   5056: 
                   5057:    </dd>
                   5058: 
                   5059:    <dt id="scriptTag">A start tag whose tag name is "script"</dt>
                   5060:    <dd>
                   5061: 
1.854     mike     5062:     <p>Run these steps:</p>
                   5063: 
1.1       mike     5064:     <ol><li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> in the
1.724     mike     5065:      <a href="infrastructure.html#html-namespace-0">HTML namespace</a>.</p></li>
1.1       mike     5066: 
                   5067:      <li>
                   5068: 
                   5069:       <p>Mark the element as being <a href="semantics.html#parser-inserted">"parser-inserted"</a>.</p>
                   5070: 
                   5071:       <p class="note">This ensures that, if the script is external,
1.159     mike     5072:       any <code title="dom-document-write"><a href="embedded-content-0.html#dom-document-write">document.write()</a></code>
1.1       mike     5073:       calls in the script will execute in-line, instead of blowing the
                   5074:       document away, as would happen in most other cases. It also
                   5075:       prevents the script from executing until the end tag is
                   5076:       seen.</p>
                   5077: 
                   5078:      </li>
                   5079: 
                   5080:      <li><p>If the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML
                   5081:      fragment parsing algorithm</a>, then mark the
1.484     mike     5082:      <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
                   5083:      started"</a>. (<a href="#fragment-case">fragment case</a>)</p></li>
1.1       mike     5084: 
                   5085:      <li><p>Append the new element to the <a href="#current-node">current node</a>
                   5086:      and push it onto the <a href="#stack-of-open-elements">stack of open
                   5087:      elements</a>.</p></li>
                   5088: 
1.541     mike     5089:      <li><p>Switch the tokenizer to the <a href="#script-data-state">script data
                   5090:      state</a>.</p></li>
1.1       mike     5091: 
                   5092:      <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
                   5093:      <a href="#insertion-mode">insertion mode</a>.</p>
                   5094: 
1.540     mike     5095:      </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     5096: 
                   5097:     </ol></dd>
                   5098: 
                   5099:    <dt>An end tag whose tag name is "head"</dt>
                   5100:    <dd>
                   5101: 
                   5102:     <p>Pop the <a href="#current-node">current node</a> (which will be the
1.159     mike     5103:     <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     5104:     elements</a>.</p>
                   5105: 
                   5106:     <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>
                   5107: 
                   5108:    </dd>
                   5109: 
                   5110:    <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
                   5111:    <dd>
                   5112:     <p>Act as described in the "anything else" entry below.</p>
                   5113:    </dd>
                   5114: 
                   5115:    <dt>A start tag whose tag name is "head"</dt>
                   5116:    <dt>Any other end tag</dt>
                   5117:    <dd>
                   5118:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5119:    </dd>
                   5120: 
                   5121:    <dt>Anything else</dt>
                   5122:    <dd>
                   5123: 
                   5124:     <!-- can't get here with an EOF and a fragment case -->
                   5125: 
                   5126:     <p>Act as if an end tag token with the tag name "head" had
                   5127:     been seen, and reprocess the current token.</p>
                   5128: 
                   5129:    </dd>
                   5130: 
1.755     mike     5131:   </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     5132: 
                   5133:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inheadnoscript" title="insertion
                   5134:   mode: in head noscript">in head noscript</a>", tokens must be handled as follows:</p>
                   5135: 
                   5136:   <dl class="switch"><dt>A DOCTYPE token</dt>
                   5137:    <dd>
                   5138:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5139:    </dd>
                   5140: 
                   5141:    <dt>A start tag whose tag name is "html"</dt>
                   5142:    <dd>
                   5143:     <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
                   5144:     mode</a>.</p>
                   5145:    </dd>
                   5146: 
                   5147:    <dt>An end tag whose tag name is "noscript"</dt>
                   5148:    <dd>
                   5149: 
                   5150:     <p>Pop the <a href="#current-node">current node</a> (which will be a
                   5151:     <code><a href="semantics.html#the-noscript-element">noscript</a></code> element) from the <a href="#stack-of-open-elements">stack of open
                   5152:     elements</a>; the new <a href="#current-node">current node</a> will be a
1.159     mike     5153:     <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1       mike     5154: 
                   5155:     <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>
                   5156: 
                   5157:    </dd>
                   5158: 
                   5159:    <dt>A character token that is one of U+0009 CHARACTER
                   5160:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882     mike     5161:    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1       mike     5162:    <dt>A comment token</dt>
                   5163:    <dt>A start tag whose tag name is one of: "link", "meta", "noframes", "style"</dt>
                   5164:    <dd>
                   5165:     <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
                   5166:     mode</a>.</p>
                   5167:    </dd>
                   5168: 
                   5169:    <dt>An end tag whose tag name is "br"</dt>
                   5170:    <dd>
                   5171:     <p>Act as described in the "anything else" entry below.</p>
                   5172:    </dd>
                   5173: 
                   5174:    <dt>A start tag whose tag name is one of: "head", "noscript"</dt>
                   5175:    <dt>Any other end tag</dt>
                   5176:    <dd>
                   5177:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5178:    </dd>
                   5179: 
                   5180:    <dt>Anything else</dt>
                   5181:    <dd>
                   5182: 
                   5183:     <!-- can't get here with an EOF and a fragment case -->
                   5184: 
                   5185:     <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
                   5186:     name "noscript" had been seen and reprocess the current
                   5187:     token.</p>
                   5188: 
                   5189:    </dd>
                   5190: 
1.755     mike     5191:   </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     5192: 
                   5193:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-head-insertion-mode" title="insertion
                   5194:   mode: after head">after head</a>", tokens must be handled as follows:</p>
                   5195: 
                   5196:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   5197:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882     mike     5198:    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1       mike     5199:    <dd>
                   5200:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   5201:     the <a href="#current-node">current node</a>.</p>
                   5202:    </dd>
                   5203: 
                   5204:    <dt>A comment token</dt>
                   5205:    <dd>
1.882     mike     5206:     <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1       mike     5207:     node</a> with the <code title="">data</code> attribute set to
                   5208:     the data given in the comment token.</p>
                   5209:    </dd>
                   5210: 
                   5211:    <dt>A DOCTYPE token</dt>
                   5212:    <dd>
                   5213:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5214:    </dd>
                   5215: 
                   5216:    <dt>A start tag whose tag name is "html"</dt>
                   5217:    <dd>
                   5218:     <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
                   5219:     mode</a>.</p>
                   5220:    </dd>
                   5221: 
                   5222:    <dt>A start tag whose tag name is "body"</dt>
                   5223:    <dd>
                   5224: 
                   5225:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5226: 
                   5227:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   5228: 
                   5229:     <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>
                   5230: 
                   5231:    </dd>
                   5232: 
                   5233:    <dt>A start tag whose tag name is "frameset"</dt>
                   5234:    <dd>
                   5235: 
                   5236:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5237: 
                   5238:     <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>
                   5239: 
                   5240:    </dd>
                   5241: 
                   5242:    <dt>A start tag token whose tag name is one of: "base", "link",
                   5243:    "meta", "noframes", "script", "style", "title"</dt>
                   5244:    <dd>
                   5245: 
                   5246:     <p><a href="#parse-error">Parse error</a>.</p>
                   5247: 
                   5248:     <p>Push the node pointed to by the <a href="#head-element-pointer"><code title="">head</code> element pointer</a> onto the
                   5249:     <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   5250: 
                   5251:     <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
                   5252:     mode</a>.</p>
                   5253: 
                   5254:     <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
                   5255:     of open elements</a>.</p>
                   5256: 
                   5257:     <p class="note">The <a href="#head-element-pointer"><code title="">head</code> element
                   5258:     pointer</a> cannot be null at this point.</p>
                   5259: 
                   5260:    </dd>
                   5261: 
                   5262:    <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
                   5263:    <dd>
                   5264:     <p>Act as described in the "anything else" entry below.</p>
                   5265:    </dd>
                   5266: 
                   5267:    <dt>A start tag whose tag name is "head"</dt>
                   5268:    <dt>Any other end tag</dt>
                   5269:    <dd>
                   5270:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5271:    </dd>
                   5272: 
                   5273:    <dt>Anything else</dt>
                   5274:    <dd>
                   5275:     <p>Act as if a start tag token with the tag name "body" and no
                   5276:     attributes had been seen, then set the <a href="#frameset-ok-flag">frameset-ok
                   5277:     flag</a> back to "ok", and then reprocess the current
                   5278:     token.</p>
                   5279:    </dd>
                   5280: 
1.755     mike     5281:   </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     5282: 
                   5283:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inbody" title="insertion
                   5284:   mode: in body">in body</a>", tokens must be handled as follows:</p>
                   5285: 
                   5286:   <dl class="switch"><dt>A character token</dt>
                   5287:    <dd>
                   5288: 
                   5289:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5290:     any.</p>
                   5291: 
                   5292:     <p><a href="#insert-a-character" title="insert a character">Insert the token's
                   5293:     character</a> into the <a href="#current-node">current node</a>.</p>
                   5294: 
                   5295:     <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
1.882     mike     5296:     LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN
                   5297:     (CR), or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
1.1       mike     5298:     flag</a> to "not ok".</p>
                   5299: 
                   5300:    </dd>
                   5301: 
                   5302:    <dt>A comment token</dt>
                   5303:    <dd>
1.882     mike     5304:     <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1       mike     5305:     node</a> with the <code title="">data</code> attribute set to
                   5306:     the data given in the comment token.</p>
                   5307:    </dd>
                   5308: 
                   5309:    <dt>A DOCTYPE token</dt>
                   5310:    <dd>
                   5311:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   5312:    </dd>
                   5313: 
                   5314:    <dt>A start tag whose tag name is "html"</dt>
                   5315:    <dd>
                   5316:     <p><a href="#parse-error">Parse error</a>. For each attribute on the token,
                   5317:     check to see if the attribute is already present on the top
                   5318:     element of the <a href="#stack-of-open-elements">stack of open elements</a>. If it is not,
                   5319:     add the attribute and its corresponding value to that element.</p>
                   5320:    </dd>
                   5321: 
                   5322:    <dt>A start tag token whose tag name is one of: "base", "command",
                   5323:    "link", "meta", "noframes", "script", "style", "title"</dt>
                   5324:    <dd>
                   5325:     <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
                   5326:     mode</a>.</p>
                   5327:    </dd>
                   5328: 
                   5329:    <dt>A start tag whose tag name is "body"</dt>
                   5330:    <dd>
                   5331: 
                   5332:     <p><a href="#parse-error">Parse error</a>.</p>
                   5333: 
                   5334:     <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159     mike     5335:     elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1       mike     5336:     <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
                   5337:     then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
                   5338: 
                   5339:     <p>Otherwise, for each attribute on the token, check to see if
1.159     mike     5340:     the attribute is already present on the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1       mike     5341:     element (the second element) on the <a href="#stack-of-open-elements">stack of open
                   5342:     elements</a>. If it is not, add the attribute and its
                   5343:     corresponding value to that element.</p>
                   5344: 
                   5345:    </dd>
                   5346: 
                   5347:    <dt>A start tag whose tag name is "frameset"</dt>
                   5348:    <dd>
                   5349: 
                   5350:     <p><a href="#parse-error">Parse error</a>.</p>
                   5351: 
                   5352:     <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159     mike     5353:     elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1       mike     5354:     <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
                   5355:     then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
                   5356: 
                   5357:     <p>If the <a href="#frameset-ok-flag">frameset-ok flag</a> is set to "not ok", ignore
                   5358:     the token.</p>
                   5359: 
                   5360:     <p>Otherwise, run the following steps:</p>
                   5361: 
                   5362:     <ol><li><p>Remove the second element on the <a href="#stack-of-open-elements">stack of open
                   5363:      elements</a> from its parent node, if it has one.</p></li>
                   5364: 
                   5365:      <li><p>Pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of
                   5366:      open elements</a>, from the <a href="#current-node">current node</a> up to,
1.159     mike     5367:      but not including, the root <code><a href="semantics.html#the-html-element-0">html</a></code> element.</p>
1.1       mike     5368: 
                   5369:      </li><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
                   5370:      token.</p></li>
                   5371: 
                   5372:      <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>
                   5373: 
                   5374:     </li></ol></dd>
                   5375: 
                   5376:    <dt>An end-of-file token</dt>
                   5377:    <dd>
                   5378: 
                   5379:     <p>If there is a node in the <a href="#stack-of-open-elements">stack of open elements</a>
1.422     mike     5380:     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>
                   5381:     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     5382:     <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
                   5383:     <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
                   5384:     <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     5385:     <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     5386:     this is a <a href="#parse-error">parse error</a>.</p> <!-- (some of those are
1.422     mike     5387:     fragment cases) -->
1.1       mike     5388: 
                   5389:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   5390: 
                   5391:    </dd>
                   5392: 
                   5393:    <dt>An end tag whose tag name is "body"</dt>
                   5394:    <dd>
                   5395: 
                   5396:     <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
                   5397:     in scope</a>, this is a <a href="#parse-error">parse error</a>; ignore the
                   5398:     token.</p>
                   5399: 
                   5400:     <!-- if we get here, the insertion mode here is forcibly "in
                   5401:     body". -->
                   5402: 
                   5403:     <p>Otherwise, if there is a node in the <a href="#stack-of-open-elements">stack of open
1.422     mike     5404:     elements</a> that is not either a <code><a href="semantics.html#the-dd-element">dd</a></code> element, a
1.1       mike     5405:     <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
                   5406:     <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
                   5407:     <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
                   5408:     <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
                   5409:     <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
                   5410:     <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     5411:     <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
                   5412:     <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     5413:     error</a>.</p> <!-- (some of those are fragment cases, e.g. for
                   5414:     <tbody> you'd have hit the first paragraph since the <body>
1.422     mike     5415:     wouldn't be in scope, unless it was a fragment case) -->
1.1       mike     5416: 
                   5417:     <!-- If we ever change the frameset-ok flag to an insertion mode,
                   5418:     then we'd have to somehow keep track of its state when we switch
                   5419:     to after-body. -->
                   5420: 
                   5421:     <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>
                   5422: 
                   5423:    </dd>
                   5424: 
                   5425:    <dt>An end tag whose tag name is "html"</dt>
                   5426:    <dd>
                   5427: 
                   5428:     <p>Act as if an end tag with tag name "body" had been seen,
                   5429:     then, if that token wasn't ignored, reprocess the current
                   5430:     token.</p>
                   5431: 
                   5432:    </dd>
                   5433: 
                   5434:    <!-- start tags for non-phrasing flow content elements -->
                   5435: 
                   5436:    <!-- the normal ones -->
                   5437:    <dt>A start tag whose tag name is one of: "address", "article",
1.683     mike     5438:    "aside", "blockquote", "center", <!--v2DATAGRID"datagrid",-->
1.305     mike     5439:    "details", "dir", "div", "dl", "fieldset", "figure", "footer",
                   5440:    "header", "hgroup", "menu", "nav", "ol", "p", "section", "ul"</dt>
1.1       mike     5441:    <dd>
                   5442: 
                   5443:     <!-- As of May 2008 this doesn't match any browser exactly, but is
                   5444:     as close to what IE does as I can get without doing the non-tree
                   5445:     DOM nonsense, and thus should actually afford better compatibility
                   5446:     when implemented by the other browsers. -->
                   5447: 
                   5448:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5449:     an element in scope">has a <code>p</code> element in
                   5450:     scope</a>, then act as if an end tag with the tag name
                   5451:     "p" had been seen.</p>
                   5452: 
                   5453:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5454: 
                   5455:    </dd>
                   5456: 
                   5457:    <!-- as normal, but close h1-h6 if it's the current node -->
                   5458:    <dt>A start tag whose tag name is one of: "h1", "h2", "h3", "h4",
                   5459:    "h5", "h6"</dt>
                   5460:    <dd>
                   5461: 
                   5462:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5463:     an element in scope">has a <code>p</code> element in
                   5464:     scope</a>, then act as if an end tag with the tag name
                   5465:     "p" had been seen.</p>
                   5466: 
                   5467:     <p>If the <a href="#current-node">current node</a> is an element whose tag name
                   5468:     is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is a
                   5469:     <a href="#parse-error">parse error</a>; pop the <a href="#current-node">current node</a> off
                   5470:     the <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   5471:     <!-- See https://bugs.webkit.org/show_bug.cgi?id=12646 -->
                   5472: 
                   5473:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5474: 
                   5475:    </dd>
                   5476: 
                   5477:    <!-- as normal, but drops leading newline -->
                   5478:    <dt>A start tag whose tag name is one of: "pre", "listing"</dt>
                   5479:    <dd>
                   5480: 
                   5481:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5482:     an element in scope">has a <code>p</code> element in
                   5483:     scope</a>, then act as if an end tag with the tag name
                   5484:     "p" had been seen.</p>
                   5485: 
                   5486:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5487: 
                   5488:     <p>If the next token is a U+000A LINE FEED (LF) character
                   5489:     token, then ignore that token and move on to the next
                   5490:     one. (Newlines at the start of <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are
                   5491:     ignored as an authoring convenience.)</p>
                   5492: 
1.882     mike     5493:     <!-- <pre>[CR]X will eat the [CR], <pre>&#x10;X will eat the
                   5494:     &#x10;, but <pre>&#x13;X will not eat the &#x13;. -->
                   5495: 
1.1       mike     5496:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   5497: 
                   5498:    </dd>
                   5499: 
                   5500:    <!-- as normal, but interacts with the form element pointer -->
                   5501:    <dt>A start tag whose tag name is "form"</dt>
                   5502:    <dd>
                   5503: 
                   5504:     <p>If the <a href="#form-element-pointer"><code title="form">form</code> element
                   5505:     pointer</a> is not null, then this is a <a href="#parse-error">parse
                   5506:     error</a>; ignore the token.</p>
                   5507: 
                   5508:     <p>Otherwise:</p>
                   5509: 
                   5510:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5511:     an element in scope">has a <code>p</code> element in
                   5512:     scope</a>, then act as if an end tag with the tag name
                   5513:     "p" had been seen.</p>
                   5514: 
                   5515:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, and set the
                   5516:     <a href="#form-element-pointer"><code title="form">form</code> element pointer</a> to
                   5517:     point to the element created.</p>
                   5518: 
                   5519:    </dd>
                   5520: 
                   5521:    <!-- as normal, but imply </li> when there's another <li> open in weird cases -->
                   5522:    <dt>A start tag whose tag name is "li"</dt>
                   5523:    <dd>
                   5524: 
1.864     mike     5525:     <p>Run these steps:</p>
1.1       mike     5526: 
                   5527:     <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
                   5528: 
                   5529:      <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
                   5530:      node</a> (the bottommost node of the stack).</p></li>
                   5531: 
1.578     mike     5532:      <li><p><i>Loop</i>: If <var title="">node</var> is an
                   5533:      <code><a href="semantics.html#the-li-element">li</a></code> element, then act as if an end tag with the tag
                   5534:      name "li" had been seen, then jump to the last step.</p></li>
1.1       mike     5535: 
1.578     mike     5536:      <li><p>If <var title="">node</var> is not in the
1.1       mike     5537:      <a href="#formatting">formatting</a> category, and is not in the
                   5538:      <a href="#phrasing">phrasing</a> category, and is not an
1.306     mike     5539:      <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     5540:      element, then jump to the last step.</p></li> <!-- an element
                   5541:      <foo> is in this list if the following markup:
                   5542: 
                   5543:          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><ol><li><foo><li>
                   5544: 
                   5545:      ...results in the second <li> not being (in any way) a descendant
                   5546:      of the first <li>, or if <foo> is a formatting element that gets
                   5547:      reopened later. -->
                   5548: 
                   5549:      <li><p>Otherwise, set <var title="">node</var> to the previous
                   5550:      entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
                   5551:      the step labeled <i>loop</i>.</p></li>
                   5552: 
                   5553:      <li>
                   5554: 
                   5555:       <p>This is the last step.</p>
                   5556: 
                   5557:       <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5558:       an element in scope">has a <code>p</code> element in
                   5559:       scope</a>, then act as if an end tag with the tag name
                   5560:       "p" had been seen.</p>
                   5561: 
                   5562:       <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
                   5563:       token.</p>
                   5564: 
                   5565:      </li>
                   5566: 
                   5567:     </ol></dd>
                   5568: 
                   5569:    <!-- as normal, but imply </dt> or </dd> when there's another <dt> or <dd> open in weird cases  -->
1.422     mike     5570:    <dt>A start tag whose tag name is one of: "dd", "dt"</dt>
1.1       mike     5571:    <dd>
                   5572: 
1.854     mike     5573:     <p>Run these steps:</p>
1.1       mike     5574: 
                   5575:     <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
                   5576: 
                   5577:      <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
                   5578:      node</a> (the bottommost node of the stack).</p></li>
                   5579: 
                   5580:      <li><p><i>Loop</i>: If <var title="">node</var> is a
1.422     mike     5581:      <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
                   5582:      tag with the same tag name as <var title="">node</var> had been
                   5583:      seen, then jump to the last step.</p></li>
1.1       mike     5584: 
                   5585:      <li><p>If <var title="">node</var> is not in the
                   5586:      <a href="#formatting">formatting</a> category, and is not in the
                   5587:      <a href="#phrasing">phrasing</a> category, and is not an
1.306     mike     5588:      <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     5589:      element, then jump to the last step.</p></li> <!-- an element
                   5590:      <foo> is in this list if the following markup:
                   5591: 
                   5592:          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><dl><dt><foo><dt>
                   5593: 
                   5594:      ...results in the second <dt> not being (in any way) a descendant
                   5595:      of the first <dt>, or if <foo> is a formatting element that gets
                   5596:      reopened later. -->
                   5597: 
                   5598:      <li><p>Otherwise, set <var title="">node</var> to the previous
                   5599:      entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
                   5600:      the step labeled <i>loop</i>.</p></li>
                   5601: 
                   5602:      <li>
                   5603: 
                   5604:       <p>This is the last step.</p>
                   5605: 
                   5606:       <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5607:       an element in scope">has a <code>p</code> element in
                   5608:       scope</a>, then act as if an end tag with the tag name
                   5609:       "p" had been seen.</p>
                   5610: 
                   5611:       <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
                   5612:       token.</p>
                   5613: 
                   5614:      </li>
                   5615: 
                   5616:     </ol></dd>
                   5617: 
                   5618:    <!-- same as normal, but effectively ends parsing -->
                   5619:    <dt>A start tag whose tag name is "plaintext"</dt>
                   5620:    <dd>
                   5621: 
                   5622:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   5623:     an element in scope">has a <code>p</code> element in
                   5624:     scope</a>, then act as if an end tag with the tag name
                   5625:     "p" had been seen.</p>
                   5626: 
                   5627:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   5628: 
1.541     mike     5629:     <p>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1       mike     5630: 
1.541     mike     5631:     <p class="note">Once a start tag with the tag name "plaintext" has
                   5632:     been seen, that will be the last token ever seen other than
                   5633:     character tokens (and the end-of-file token), because there is no
                   5634:     way to switch out of the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1       mike     5635: 
                   5636:    </dd>
                   5637: 
                   5638:    <!-- end tags for non-phrasing flow content elements -->
                   5639: 
                   5640:    <!-- the normal ones -->
                   5641:    <dt>An end tag whose tag name is one of: "address", "article",
1.683     mike     5642:    "aside", "blockquote", "center", <!--v2DATAGRID"datagrid",-->
1.305     mike     5643:    "details", "dir", "div", "dl", "fieldset", "figure", "footer",
                   5644:    "header", "hgroup", "listing", "menu", "nav", "ol", "pre",
                   5645:    "section", "ul"</dt>
1.1       mike     5646:    <dd>
                   5647: 
                   5648:     <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>
                   5649:     with the same tag name as that of the token, then this is a
                   5650:     <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5651: 
                   5652:     <p>Otherwise, run these steps:</p>
                   5653: 
                   5654:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   5655: 
                   5656:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5657:      the same tag name as that of the token, then this is a
                   5658:      <a href="#parse-error">parse error</a>.</p></li>
                   5659: 
                   5660:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5661:      until an element with the same tag name as the token has been
                   5662:      popped from the stack.</p></li>
                   5663: 
                   5664:     </ol></dd>
                   5665: 
                   5666:    <!-- removes the form element pointer instead of the matching node -->
                   5667:    <dt>An end tag whose tag name is "form"</dt>
                   5668:    <dd>
                   5669: 
                   5670:     <p>Let <var title="">node</var> be the element that the
                   5671:     <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is set
                   5672:     to.</p>
                   5673: 
                   5674:     <p>Set the <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
                   5675:     to null.</p>
                   5676: 
                   5677:     <p>If <var title="">node</var> is null or the <a href="#stack-of-open-elements">stack of open
                   5678:     elements</a> does not <a href="#has-an-element-in-scope" title="has an element in
                   5679:     scope">have <var title="">node</var> in scope</a>, then this is
                   5680:     a <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5681: 
                   5682:     <p>Otherwise, run these steps:</p>
                   5683: 
                   5684:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   5685: 
                   5686:      <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
                   5687:      error</a>.</p></li>
                   5688: 
                   5689:      <li><p>Remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of
                   5690:      open elements</a>.</p></li>
                   5691: 
                   5692:     </ol></dd>
                   5693: 
                   5694:    <!-- as normal, except </p> implies <p> if there's no <p> in scope, and needs care as the elements have optional tags -->
                   5695:    <dt>An end tag whose tag name is "p"</dt>
                   5696:    <dd>
                   5697: 
                   5698:     <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>
                   5699:     with the same tag name as that of the token, then this is a
                   5700:     <a href="#parse-error">parse error</a>; act as if a start tag with the tag name
                   5701:     "p" had been seen, then reprocess the current token.</p>
                   5702: 
                   5703:     <p>Otherwise, run these steps:</p>
                   5704: 
                   5705:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
                   5706:      for elements with the same tag name as the token.</p></li>
                   5707: 
                   5708:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5709:      the same tag name as that of the token, then this is a
                   5710:      <a href="#parse-error">parse error</a>.</p></li>
                   5711: 
                   5712:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5713:      until an element with the same tag name as the token has been
                   5714:      popped from the stack.</p></li>
                   5715: 
                   5716:     </ol></dd>
                   5717: 
1.234     mike     5718:    <!-- as normal, but needs care as the elements have optional tags, and are further scoped by <ol>/<ul> -->
                   5719:    <dt>An end tag whose tag name is "li"</dt>
                   5720:    <dd>
                   5721: 
                   5722:     <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
                   5723:     item scope</a> with the same tag name as that of the token,
                   5724:     then this is a <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5725: 
                   5726:     <p>Otherwise, run these steps:</p>
                   5727: 
                   5728:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
                   5729:      for elements with the same tag name as the token.</p></li>
                   5730: 
                   5731:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5732:      the same tag name as that of the token, then this is a
                   5733:      <a href="#parse-error">parse error</a>.</p></li>
                   5734: 
                   5735:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5736:      until an element with the same tag name as the token has been
                   5737:      popped from the stack.</p></li>
                   5738: 
                   5739:     </ol></dd>
                   5740: 
1.1       mike     5741:    <!-- as normal, but needs care as the elements have optional tags -->
1.422     mike     5742:    <dt>An end tag whose tag name is one of: "dd", "dt"</dt>
1.1       mike     5743:    <dd>
                   5744: 
                   5745:     <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>
                   5746:     with the same tag name as that of the token, then this is a
                   5747:     <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5748: 
                   5749:     <p>Otherwise, run these steps:</p>
                   5750: 
                   5751:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
                   5752:      for elements with the same tag name as the token.</p></li>
                   5753: 
                   5754:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5755:      the same tag name as that of the token, then this is a
                   5756:      <a href="#parse-error">parse error</a>.</p></li>
                   5757: 
                   5758:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5759:      until an element with the same tag name as the token has been
                   5760:      popped from the stack.</p></li>
                   5761: 
                   5762:     </ol></dd>
                   5763: 
                   5764:    <!-- as normal, except acts as a closer for any of the h1-h6 elements -->
                   5765:    <dt>An end tag whose tag name is one of: "h1", "h2", "h3", "h4", "h5", "h6"</dt>
                   5766:    <dd>
                   5767: 
                   5768:     <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>
                   5769:     whose tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6",
                   5770:     then this is a <a href="#parse-error">parse error</a>; ignore the token.</p>
                   5771: 
                   5772:     <p>Otherwise, run these steps:</p>
                   5773: 
                   5774:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   5775: 
                   5776:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   5777:      the same tag name as that of the token, then this is a
                   5778:      <a href="#parse-error">parse error</a>.</p></li>
                   5779: 
                   5780:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   5781:      until an element whose tag name is one of "h1", "h2", "h3", "h4",
                   5782:      "h5", or "h6" has been popped from the stack.</p></li>
                   5783: 
                   5784:     </ol></dd>
                   5785: 
                   5786:    <dt>An end tag whose tag name is "sarcasm"</dt>
                   5787:    <dd>
                   5788:     <p>Take a deep breath, then act as described in the "any other end
                   5789:     tag" entry below.</p>
                   5790:    </dd>
                   5791: 
                   5792:    <!-- ADOPTION AGENCY ELEMENTS
                   5793:         Mozilla-only: bdo blink del ins sub sup q
                   5794:         Safari-only: code dfn kbd nobr samp var wbr
                   5795:         Both: a b big em font i s small strike strong tt u -->
                   5796: 
                   5797:    <dt>A start tag whose tag name is "a"</dt>
                   5798:    <dd>
                   5799: 
                   5800:     <p>If the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>
                   5801:     contains an element whose tag name is "a" between the end of
                   5802:     the list and the last marker on the list (or the start of the
                   5803:     list if there is no marker on the list), then this is a
                   5804:     <a href="#parse-error">parse error</a>; act as if an end tag with the tag
                   5805:     name "a" had been seen, then remove that element from the
                   5806:     <a href="#list-of-active-formatting-elements">list of active formatting elements</a> and the
                   5807:     <a href="#stack-of-open-elements">stack of open elements</a> if the end tag didn't
                   5808:     already remove it (it might not have if the element is not
                   5809:     <a href="#has-an-element-in-table-scope" title="has an element in table scope">in table
                   5810:     scope</a>).</p>
                   5811: 
                   5812:     <p class="example">In the non-conforming stream
                   5813:     <code>&lt;a&#160;href="a"&gt;a&lt;table&gt;&lt;a&#160;href="b"&gt;b&lt;/table&gt;x</code>,
1.876     mike     5814:     the first <code><a href="text-level-semantics.html#the-a-element">a</a></code> element would be closed upon seeing the
                   5815:     second one, and the "x" character would be inside a link to "b",
                   5816:     not to "a". This is despite the fact that the outer <code><a href="text-level-semantics.html#the-a-element">a</a></code>
                   5817:     element is not in table scope (meaning that a regular
                   5818:     <code>&lt;/a&gt;</code> end tag at the start of the table wouldn't
                   5819:     close the outer <code><a href="text-level-semantics.html#the-a-element">a</a></code> element). The result is that the
                   5820:     two <code><a href="text-level-semantics.html#the-a-element">a</a></code> elements are indirectly nested inside each
                   5821:     other &#8212; non-conforming markup will often result in
                   5822:     non-conforming DOMs when parsed.</p>
1.1       mike     5823: 
                   5824:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5825:     any.</p>
                   5826: 
                   5827:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
                   5828:     element to the <a href="#list-of-active-formatting-elements">list of active formatting
                   5829:     elements</a>.</p>
                   5830: 
                   5831:    </dd>
                   5832: 
                   5833:    <dt>A start tag whose tag name is one of: "b", "big", "code", "em",
                   5834:    "font", "i", "s", "small", "strike", "strong", "tt", "u"</dt>
                   5835:    <dd>
                   5836: 
                   5837:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5838:     any.</p>
                   5839: 
                   5840:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
                   5841:     element to the <a href="#list-of-active-formatting-elements">list of active formatting
                   5842:     elements</a>.</p>
                   5843: 
                   5844:    </dd>
                   5845: 
                   5846:    <dt>A start tag whose tag name is "nobr"</dt>
                   5847:    <dd>
                   5848: 
                   5849:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   5850:     any.</p>
                   5851: 
                   5852:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
                   5853:     element in scope">has a <code>nobr</code> element in scope</a>,
                   5854:     then this is a <a href="#parse-error">parse error</a>; act as if an end tag with
                   5855:     the tag name "nobr" had been seen, then once again
                   5856:     <a href="#reconstruct-the-active-formatting-elements">reconstruct the active formatting elements</a>, if
                   5857:     any.</p>
                   5858: 
                   5859:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
                   5860:     element to the <a href="#list-of-active-formatting-elements">list of active formatting
                   5861:     elements</a>.</p>
                   5862: 
                   5863:    </dd>
                   5864: 
                   5865:    <dt id="adoptionAgency">An end tag whose tag name is one of: "a",
                   5866:    "b", "big", "code", "em", "font", "i", "nobr", "s", "small",
                   5867:    "strike", "strong", "tt", "u"</dt>
                   5868:    <dd>
                   5869: 
1.854     mike     5870:     <p>Run these steps:</p>
1.1       mike     5871: 
                   5872:     <ol><li>
                   5873: 
                   5874:       <p>Let the <var title="">formatting element</var> be the
                   5875:       last element in the <a href="#list-of-active-formatting-elements">list of active formatting
                   5876:       elements</a> that:</p>
                   5877: 
                   5878:       <ul><li>is between the end of the list and the last scope
                   5879:        marker in the list, if any, or the start of the list
                   5880:        otherwise, and</li>
                   5881: 
                   5882:        <li>has the same tag name as the token.</li>
                   5883: 
                   5884:       </ul><p>If there is no such node, or, if that node is also in the
                   5885:       <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
                   5886:       <a href="#parse-error">parse error</a>; ignore the token, and abort these
                   5887:       steps.</p>
                   5888: 
                   5889:       <p>Otherwise, if there is such a node, but that node is not
                   5890:       in the <a href="#stack-of-open-elements">stack of open elements</a>, then this is a
                   5891:       <a href="#parse-error">parse error</a>; remove the element from the list,
                   5892:       and abort these steps.</p>
                   5893: 
                   5894:       <p>Otherwise, there is a <var title="">formatting
                   5895:       element</var> and that element is in <a href="#stack-of-open-elements" title="stack of
                   5896:       open elements">the stack</a> and is <a href="#has-an-element-in-scope" title="has an
                   5897:       element in scope">in scope</a>. If the element is not the
                   5898:       <a href="#current-node">current node</a>, this is a <a href="#parse-error">parse
                   5899:       error</a>. In any case, proceed with the algorithm as
                   5900:       written in the following steps.</p>
                   5901: 
                   5902:      </li>
                   5903: 
                   5904:      <li><p>Let the <var title="">furthest block</var> be the
                   5905:      topmost node in the <a href="#stack-of-open-elements">stack of open elements</a> that
                   5906:      is lower in the stack than the <var title="">formatting
                   5907:      element</var>, and is not an element in the
                   5908:      <a href="#phrasing">phrasing</a> or <a href="#formatting">formatting</a>
                   5909:      categories. There might not be one.</p></li>
                   5910: 
                   5911:      <li><p>If there is no <var title="">furthest block</var>,
                   5912:      then the UA must skip the subsequent steps and instead just
                   5913:      pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of open
                   5914:      elements</a>, from the <a href="#current-node">current node</a> up to and
                   5915:      including the <var title="">formatting element</var>, and
                   5916:      remove the <var title="">formatting element</var> from the
                   5917:      <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</p></li>
                   5918: 
                   5919:      <li><p>Let the <var title="">common ancestor</var> be the element
                   5920:      immediately above the <var title="">formatting element</var> in the
                   5921:      <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
                   5922: 
                   5923:      <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
                   5924:      formatting elements</a> relative to the elements on either
                   5925:      side of it in the list.</p></li>
                   5926: 
                   5927:      <li>
                   5928: 
                   5929:       <p>Let <var title="">node</var> and <var title="">last node</var> be the
                   5930:       <var title="">furthest block</var>. Follow these steps:</p>
                   5931: 
                   5932:       <ol><li>Let <var title="">node</var> be the element immediately
                   5933:        above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
1.436     mike     5934:        elements</a>, or if <var title="">node</var> is no longer in
                   5935:        the <a href="#stack-of-open-elements">stack of open elements</a> (e.g. because it got
                   5936:        removed by the next step), the element that was immediately
                   5937:        above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
                   5938:        elements</a> before <var title="">node</var> was
                   5939:        removed.</li>
1.1       mike     5940: 
                   5941:        <li>If <var title="">node</var> is not in the <a href="#list-of-active-formatting-elements">list of
                   5942:        active formatting elements</a>, then remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of open
                   5943:        elements</a> and then go back to step 1.</li>
                   5944: 
                   5945:        <li>Otherwise, if <var title="">node</var> is the <var title="">formatting element</var>, then go to the next step
                   5946:        in the overall algorithm.</li>
                   5947: 
                   5948:        <li>Otherwise, if <var title="">last node</var> is the <var title="">furthest block</var>, then move the aforementioned
                   5949:        bookmark to be immediately after the <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
                   5950:        elements</a>.</li>
                   5951: 
                   5952:        <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
                   5953:        element <var title="">node</var> was created, replace the entry
                   5954:        for <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active
                   5955:        formatting elements</a> with an entry for the new element,
                   5956:        replace the entry for <var title="">node</var> in the
                   5957:        <a href="#stack-of-open-elements">stack of open elements</a> with an entry for the new
                   5958:        element, and let <var title="">node</var> be the new
                   5959:        element.</li>
                   5960: 
                   5961:        <li>Insert <var title="">last node</var> into <var title="">node</var>, first removing it from its previous
                   5962:        parent node if any.</li>
                   5963: 
                   5964:        <li>Let <var title="">last node</var> be <var title="">node</var>.</li>
                   5965: 
                   5966:        <li>Return to step 1 of this inner set of steps.</li>
                   5967: 
                   5968:       </ol></li>
                   5969: 
                   5970:      <li>
                   5971: 
                   5972:       <p>If the <var title="">common ancestor</var> node is a
                   5973:       <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>,
                   5974:       <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,
                   5975:       <a href="#foster-parent">foster parent</a> whatever <var title="">last
                   5976:       node</var> ended up being in the previous step, first removing
                   5977:       it from its previous parent node if any.</p>
                   5978: 
                   5979:       <p>Otherwise, append whatever <var title="">last node</var>
                   5980:       ended up being in the previous step to the <var title="">common
                   5981:       ancestor</var> node, first removing it from its previous parent
                   5982:       node if any.</p>
                   5983: 
                   5984:      </li>
                   5985: 
                   5986:      <li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
                   5987:      <var title="">formatting element</var> was created.</p></li>
                   5988: 
                   5989:      <li><p>Take all of the child nodes of the <var title="">furthest
                   5990:      block</var> and append them to the element created in the last
                   5991:      step.</p></li>
                   5992: 
                   5993:      <li><p>Append that new element to the <var title="">furthest
                   5994:      block</var>.</p></li>
                   5995: 
                   5996:      <li><p>Remove the <var title="">formatting element</var> from the
                   5997:      <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, and insert the
                   5998:      new element into the <a href="#list-of-active-formatting-elements">list of active formatting
                   5999:      elements</a> at the position of the aforementioned
                   6000:      bookmark.</p></li>
                   6001: 
                   6002:      <li><p>Remove the <var title="">formatting element</var> from the
                   6003:      <a href="#stack-of-open-elements">stack of open elements</a>, and insert the new element
                   6004:      into the <a href="#stack-of-open-elements">stack of open elements</a> immediately below
                   6005:      the position of the <var title="">furthest block</var> in that
                   6006:      stack.</p></li>
                   6007: 
                   6008:      <li><p>Jump back to step 1 in this series of steps.</p></li>
                   6009: 
1.334     mike     6010:     </ol><p class="note">Because of the way this algorithm causes elements
1.304     mike     6011:     to change parents, it has been dubbed the "adoption agency
                   6012:     algorithm" (in contrast with other possible algorithms for dealing
                   6013:     with misnested content, which included the "incest algorithm", the
1.1       mike     6014:     "secret affair algorithm", and the "Heisenberg algorithm").</p>
                   6015: 
                   6016:    </dd>
                   6017: 
                   6018:    <dt>A start tag whose tag name is "button"</dt>
                   6019:    <dd>
                   6020: 
                   6021:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   6022:     an element in scope">has a <code>button</code> element in
                   6023:     scope</a>, then this is a <a href="#parse-error">parse error</a>;
                   6024:     act as if an end tag with the tag name "button" had been seen,
                   6025:     then reprocess the token.</p>
                   6026: 
                   6027:     <p>Otherwise:</p>
                   6028: 
                   6029:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6030:     any.</p>
                   6031: 
                   6032:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6033: 
                   6034:     <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
                   6035:     formatting elements</a>.</p>
                   6036: 
                   6037:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6038: 
                   6039:    </dd>
                   6040: 
                   6041:    <dt>A start tag token whose tag name is one of: "applet",
                   6042:    "marquee", "object"</dt>
                   6043:    <dd>
                   6044: 
                   6045:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6046:     any.</p>
                   6047: 
                   6048:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6049: 
                   6050:     <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
                   6051:     formatting elements</a>.</p>
                   6052: 
                   6053:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6054: 
                   6055:    </dd>
                   6056: 
                   6057:    <dt>An end tag token whose tag name is one of: "applet", "button",
                   6058:    "marquee", "object"</dt>
                   6059:    <dd>
                   6060: 
                   6061:     <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>
                   6062:     with the same tag name as that of the token, then this is a
                   6063:     <a href="#parse-error">parse error</a>; ignore the token.</p>
                   6064: 
                   6065:     <p>Otherwise, run these steps:</p>
                   6066: 
                   6067:     <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   6068: 
                   6069:      <li><p>If the <a href="#current-node">current node</a> is not an element with
                   6070:      the same tag name as that of the token, then this is a
                   6071:      <a href="#parse-error">parse error</a>.</p></li>
                   6072: 
                   6073:      <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   6074:      until an element with the same tag name as the token has been
                   6075:      popped from the stack.</p></li>
                   6076: 
                   6077:      <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
                   6078:      last marker</a>.</li>
                   6079: 
                   6080:     </ol></dd>
                   6081: 
                   6082:    <dt>A start tag whose tag name is "table"</dt>
                   6083:    <dd>
                   6084: 
1.810     mike     6085:     <p>If the <code><a href="infrastructure.html#document">Document</a></code> is <em>not</em> set to
1.1       mike     6086:     <a href="dom.html#quirks-mode">quirks mode</a>, and the <a href="#stack-of-open-elements">stack of open
                   6087:     elements</a> <a href="#has-an-element-in-scope" title="has an element in scope">has a
                   6088:     <code>p</code> element in scope</a>, then act as if an end tag
                   6089:     with the tag name "p" had been seen.</p> <!-- i hate myself (this
                   6090:     quirk was basically caused by acid2; if i'd realised we could
                   6091:     change the specs when i wrote acid2, we could have avoided having
                   6092:     any parsing-mode quirks) -Hixie -->
                   6093: 
                   6094:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6095: 
                   6096:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6097: 
                   6098:     <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>
                   6099: 
                   6100:    </dd>
                   6101: 
                   6102:    <dt>A start tag whose tag name is one of: "area", "basefont",
1.589     mike     6103:    "bgsound", "br", "embed", "img", "input", "keygen", "wbr"</dt>
1.1       mike     6104:    <dd>
                   6105: 
                   6106:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6107:     any.</p>
                   6108: 
                   6109:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   6110:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6111:     elements</a>.</p>
                   6112: 
                   6113:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   6114:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   6115: 
                   6116:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p> <!--
1.589     mike     6117:     shouldn't really do it for <area>, <basefont>, and <bgsound> -->
1.1       mike     6118: 
                   6119:    </dd>
                   6120: 
                   6121:    <dt>A start tag whose tag name is one of: "param", "source"</dt>
                   6122:    <dd>
                   6123: 
                   6124:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   6125:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6126:     elements</a>.</p>
                   6127: 
                   6128:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   6129:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   6130: 
                   6131:    </dd>
                   6132: 
                   6133:    <dt>A start tag whose tag name is "hr"</dt>
                   6134:    <dd>
                   6135: 
                   6136:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   6137:     an element in scope">has a <code>p</code> element in
                   6138:     scope</a>, then act as if an end tag with the tag name
                   6139:     "p" had been seen.</p>
                   6140: 
                   6141:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   6142:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6143:     elements</a>.</p>
                   6144: 
                   6145:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   6146:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   6147: 
                   6148:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6149: 
                   6150:    </dd>
                   6151: 
                   6152:    <dt>A start tag whose tag name is "image"</dt>
                   6153:    <dd>
                   6154:     <p><a href="#parse-error">Parse error</a>. Change the token's tag name
                   6155:     to "img" and reprocess it. (Don't ask.)</p> <!-- As of
                   6156:     2005-12, studies showed that around 0.2% of pages used the
                   6157:     <image> element. -->
                   6158:    </dd>
                   6159: 
                   6160:    <dt id="isindex">A start tag whose tag name is "isindex"</dt>
                   6161:    <dd>
                   6162: 
                   6163:     <p><a href="#parse-error">Parse error</a>.</p>
                   6164: 
                   6165:     <p>If the <a href="#form-element-pointer"><code title="">form</code> element
                   6166:     pointer</a> is not null, then ignore the token.</p>
                   6167: 
                   6168:     <p>Otherwise:</p>
                   6169: 
                   6170:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   6171:     token's <i>self-closing flag</i></a>, if it is set.</p> <!--
                   6172:     purely to reduce the number of errors (we don't care if they
                   6173:     included the /, they're not supposed to be including the tag at
                   6174:     all! -->
                   6175: 
                   6176:     <p>Act as if a start tag token with the tag name "form" had been seen.</p>
                   6177: 
                   6178:     <p>If the token has an attribute called "action", set the
                   6179:     <code title="attr-form-action">action</code> attribute on the
                   6180:     resulting <code><a href="forms.html#the-form-element">form</a></code> element to the value of the
                   6181:     "action" attribute of the token.</p>
                   6182: 
                   6183:     <p>Act as if a start tag token with the tag name "hr" had been
                   6184:     seen.</p>
                   6185: 
                   6186:     <p>Act as if a start tag token with the tag name "label" had been
                   6187:     seen.</p>
                   6188: 
                   6189:     <p>Act as if a stream of character tokens had been seen (see below
                   6190:     for what they should say).</p>
                   6191: 
                   6192:     <p>Act as if a start tag token with the tag name "input" had been
                   6193:     seen, with all the attributes from the "isindex" token except
                   6194:     "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
                   6195:     <code><a href="forms.html#the-input-element">input</a></code> element to the value "<code title="">isindex</code>".</p>
                   6196: 
                   6197:     <p>Act as if a stream of character tokens had been seen (see
                   6198:     below for what they should say).</p>
                   6199: 
                   6200:     <p>Act as if an end tag token with the tag name "label" had been
                   6201:     seen.</p>
                   6202: 
                   6203:     <p>Act as if a start tag token with the tag name "hr" had been
                   6204:     seen.</p>
                   6205: 
                   6206:     <p>Act as if an end tag token with the tag name "form" had been
                   6207:     seen.</p>
                   6208: 
                   6209:     <p>If the token has an attribute with the name "prompt", then the
                   6210:     first stream of characters must be the same string as given in
                   6211:     that attribute, and the second stream of characters must be
                   6212:     empty. Otherwise, the two streams of character tokens together
                   6213:     should, together with the <code><a href="forms.html#the-input-element">input</a></code> element, express the
1.883     mike     6214:     equivalent of "This is a searchable index. Enter search keywords:
                   6215:     (input field)" in the user's preferred language.</p>
1.1       mike     6216: 
                   6217:    </dd>
                   6218: 
                   6219:    <dt>A start tag whose tag name is "textarea"</dt>
                   6220:    <dd>
                   6221: 
1.854     mike     6222:     <p>Run these steps:</p>
                   6223: 
1.1       mike     6224:     <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
                   6225:      token.</p></li>
                   6226: 
                   6227:      <li><p>If the next token is a U+000A LINE FEED (LF) character
                   6228:      token, then ignore that token and move on to the next
                   6229:      one. (Newlines at the start of <code><a href="forms.html#the-textarea-element">textarea</a></code> elements are
                   6230:      ignored as an authoring convenience.)</p></li>
1.882     mike     6231:      
                   6232:      <!-- see comment in <pre> start tag bit -->
1.1       mike     6233: 
1.671     mike     6234:      <li><p>Switch the tokenizer to the <a href="#rcdata-state">RCDATA
1.541     mike     6235:      state</a>.</p></li>
1.1       mike     6236: 
                   6237:      <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the
                   6238:      current <a href="#insertion-mode">insertion mode</a>.</p>
                   6239: 
                   6240:      </li><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not
                   6241:      ok".</p></li>
                   6242: 
1.540     mike     6243:      <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     6244: 
                   6245:     </ol></dd>
                   6246: 
                   6247:    <dt>A start tag whose tag name is "xmp"</dt>
                   6248:    <dd>
                   6249: 
1.233     mike     6250:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
                   6251:     an element in scope">has a <code>p</code> element in
                   6252:     scope</a>, then act as if an end tag with the tag name
                   6253:     "p" had been seen.</p>
                   6254: 
1.1       mike     6255:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6256:     any.</p>
                   6257: 
                   6258:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6259: 
1.91      mike     6260:     <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1       mike     6261: 
                   6262:    </dd>
                   6263: 
                   6264:    <dt>A start tag whose tag name is "iframe"</dt>
                   6265:    <dd>
                   6266: 
                   6267:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6268: 
1.91      mike     6269:     <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1       mike     6270: 
                   6271:    </dd>
                   6272: 
                   6273:    <dt>A start tag whose tag name is "noembed"</dt>
                   6274:    <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
                   6275:    <dd>
                   6276: 
1.91      mike     6277:     <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1       mike     6278: 
                   6279:    </dd>
                   6280: 
                   6281:    <dt>A start tag whose tag name is "select"</dt>
                   6282:    <dd>
                   6283: 
                   6284:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6285:     any.</p>
                   6286: 
                   6287:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6288: 
                   6289:     <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
                   6290: 
                   6291:     <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>",
                   6292:     "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   6293:     body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in
                   6294:     row</a>", or "<a href="#parsing-main-intd" title="insertion mode: in cell">in
                   6295:     cell</a>", then switch the <a href="#insertion-mode">insertion mode</a> to
                   6296:     "<a href="#parsing-main-inselectintable" title="insertion mode: in select in table">in select in
                   6297:     table</a>". Otherwise, switch the <a href="#insertion-mode">insertion mode</a>
                   6298:     to "<a href="#parsing-main-inselect" title="insertion mode: in select">in select</a>".</p>
                   6299: 
                   6300:    </dd>
                   6301: 
                   6302:    <dt>A start tag whose tag name is one of: "optgroup", "option"</dt>
                   6303:    <dd>
                   6304: 
                   6305:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
                   6306:     element in scope">has an <code>option</code> element in
                   6307:     scope</a>, then act as if an end tag with the tag name "option"
                   6308:     had been seen.</p>
                   6309: 
                   6310:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6311:     any.</p>
                   6312: 
                   6313:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6314: 
                   6315:    </dd>
                   6316: 
                   6317:    <dt>A start tag whose tag name is one of: "rp", "rt"</dt>
                   6318:    <dd>
                   6319: 
                   6320:     <!-- the parsing rules for ruby really don't match IE much at all,
                   6321:          but in practice the markup used is very simple and so strict
                   6322:          compatibility with IE isn't required. For example, as defined
                   6323:          here we get very, very different behaviour than IE for
                   6324:          pathological cases like:
                   6325: 
                   6326:            <ruby><ol><li><p>a<rt>b
                   6327:            <ruby>a<rt>b<p>c
                   6328: 
                   6329:          But in practice most ruby markup falls into these cases:
                   6330: 
                   6331:            <ruby>a<rt>b</ruby>
                   6332:            <ruby>a<rp>b<rt>c<rp>d</ruby>
                   6333:            <ruby>a<rt>b</rt></ruby>
                   6334:            <ruby>a<rp>b</rp><rt>c</rt><rp>d</rp></ruby>
                   6335: 
                   6336:     -->
                   6337: 
                   6338:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
                   6339:     element in scope">has a <code>ruby</code> element in scope</a>,
                   6340:     then <a href="#generate-implied-end-tags">generate implied end tags</a>. If the <a href="#current-node">current
                   6341:     node</a> is not then a <code><a href="text-level-semantics.html#the-ruby-element">ruby</a></code> element, this is a
                   6342:     <a href="#parse-error">parse error</a>; pop all the nodes from the <a href="#current-node">current
                   6343:     node</a> up to the node immediately before the bottommost
                   6344:     <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
                   6345:     elements</a>.</p>
                   6346: 
                   6347:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6348: 
                   6349:    </dd>
                   6350: 
                   6351:    <dt>An end tag whose tag name is "br"</dt>
                   6352:    <dd>
                   6353:     <p><a href="#parse-error">Parse error</a>. Act as if a start tag token with
                   6354:     the tag name "br" had been seen. Ignore the end tag token.</p>
                   6355:    </dd>
                   6356: 
                   6357:    <dt>A start tag whose tag name is "math"</dt>
                   6358:    <dd>
                   6359: 
                   6360:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6361:     any.</p>
                   6362: 
                   6363:     <p><a href="#adjust-mathml-attributes">Adjust MathML attributes</a> for the token. (This
                   6364:     fixes the case of MathML attributes that are not all
                   6365:     lowercase.)</p>
                   6366: 
                   6367:     <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
                   6368:     fixes the use of namespaced attributes, in particular XLink.)</p>
                   6369: 
                   6370:     <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
1.724     mike     6371:     <a href="infrastructure.html#mathml-namespace">MathML namespace</a>.</p>
1.1       mike     6372: 
                   6373:     <!-- If we ever change the frameset-ok flag to an insertion mode,
                   6374:     the following change would be implied, except we'd have to do it
                   6375:     even in the face of a self-closed tag:
                   6376:     <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
                   6377:     -->
                   6378: 
                   6379:     <p>If the token has its <i>self-closing flag</i> set, pop the
                   6380:     <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6381:     elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
                   6382:     flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
                   6383: 
                   6384:     <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
                   6385:     "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
                   6386:     content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
                   6387:     the current <a href="#insertion-mode">insertion mode</a>, and then switch the
                   6388:     <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
                   6389:     foreign content">in foreign content</a>".</p>
                   6390: 
                   6391:    </dd>
                   6392: 
                   6393:    <dt>A start tag whose tag name is "svg"</dt>
                   6394:    <dd>
                   6395: 
                   6396:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6397:     any.</p>
                   6398: 
                   6399:     <p><a href="#adjust-svg-attributes">Adjust SVG attributes</a> for the token. (This fixes
                   6400:     the case of SVG attributes that are not all lowercase.)</p>
                   6401: 
                   6402:     <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
                   6403:     fixes the use of namespaced attributes, in particular XLink in
                   6404:     SVG.)</p>
                   6405: 
                   6406:     <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
1.724     mike     6407:     <a href="infrastructure.html#svg-namespace">SVG namespace</a>.</p>
1.1       mike     6408: 
                   6409:     <!-- If we ever change the frameset-ok flag to an insertion mode,
                   6410:     the following change would be implied, except we'd have to do it
                   6411:     even in the face of a self-closed tag:
                   6412:     <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
                   6413:     -->
                   6414: 
                   6415:     <p>If the token has its <i>self-closing flag</i> set, pop the
                   6416:     <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6417:     elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
                   6418:     flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
                   6419: 
                   6420:     <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
                   6421:     "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
                   6422:     content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
                   6423:     the current <a href="#insertion-mode">insertion mode</a>, and then switch the
                   6424:     <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
                   6425:     foreign content">in foreign content</a>".</p>
                   6426: 
                   6427:    </dd>
                   6428: 
                   6429:    <dt>A start <!--or end--> tag whose tag name is one of: "caption",
                   6430:    "col", "colgroup", "frame", "head", "tbody", "td", "tfoot", "th",
                   6431:    "thead", "tr"</dt>
                   6432:    <!--<dt>An end tag whose tag name is one of: "area", "base",
                   6433:    "basefont", "bgsound", "command", "embed", "hr", "iframe", "image",
                   6434:    "img", "input", "isindex", "keygen", "link", "meta", "noembed",
1.589     mike     6435:    "noframes", "param", "script", "select", "source", "style",
                   6436:    "table", "textarea", "title", "wbr"</dt>-->
1.1       mike     6437:    <!--<dt>An end tag whose tag name is "noscript", if the
                   6438:    <span>scripting flag</span> is enabled</dt>-->
                   6439:    <dd>
                   6440:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6441:     <!-- end tags are commented out because since they can never end
                   6442:     up on the stack anyway, the default end tag clause will
                   6443:     automatically handle them. we don't want to have text in the spec
                   6444:     that is just an optimisation, as that detracts from the spec
                   6445:     itself -->
                   6446:    </dd>
                   6447: 
                   6448:    <dt>Any other start tag</dt>
                   6449:    <dd>
                   6450: 
                   6451:     <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
                   6452:     any.</p>
                   6453: 
                   6454:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6455: 
                   6456:     <p class="note">This element will be a <a href="#phrasing">phrasing</a>
                   6457:     element.</p>
                   6458: 
                   6459:    </dd>
                   6460: 
                   6461:    <dt>Any other end tag</dt>
                   6462:    <dd>
                   6463: 
1.854     mike     6464:     <p>Run these steps:</p>
1.1       mike     6465: 
                   6466:     <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
                   6467:      node</a> (the bottommost node of the stack).</p></li>
                   6468: 
                   6469:      <li><p>If <var title="">node</var> has the same tag name as
1.856     mike     6470:      the token, then:</p>
1.1       mike     6471: 
                   6472:       <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
                   6473: 
                   6474:        <li><p>If the tag name of the end tag token does not match
                   6475:        the tag name of the <a href="#current-node">current node</a>, this is a
                   6476:        <a href="#parse-error">parse error</a>.</p></li>
                   6477: 
                   6478:        <li><p>Pop all the nodes from the <a href="#current-node">current node</a> up
                   6479:        to <var title="">node</var>, including <var title="">node</var>, then stop these steps.</p></li>
                   6480: 
                   6481:       </ol></li>
                   6482: 
                   6483:      <li><p>Otherwise, if <var title="">node</var> is in neither the
                   6484:      <a href="#formatting">formatting</a> category nor the <a href="#phrasing">phrasing</a>
                   6485:      category, then this is a <a href="#parse-error">parse error</a>; ignore the
                   6486:      token, and abort these steps.</p></li>
                   6487: 
                   6488:      <li><p>Set <var title="">node</var> to the previous entry in the
                   6489:      <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
                   6490: 
                   6491:      <li><p>Return to step 2.</p></li>
                   6492: 
                   6493:     </ol></dd>
                   6494: 
1.755     mike     6495:   </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     6496: 
                   6497:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incdata" title="insertion
1.540     mike     6498:   mode: text">text</a>", tokens must be handled as follows:</p>
1.1       mike     6499: 
                   6500:   <dl class="switch"><dt>A character token</dt>
                   6501:    <dd>
                   6502: 
                   6503:     <p><a href="#insert-a-character" title="insert a character">Insert the token's
                   6504:     character</a> into the <a href="#current-node">current node</a>.</p>
                   6505: 
                   6506:    </dd>
                   6507: 
                   6508:    <dt>An end-of-file token</dt>
                   6509:    <dd>
                   6510: 
                   6511:     <!-- can't be the fragment case -->
                   6512:     <p><a href="#parse-error">Parse error</a>.</p>
                   6513: 
                   6514:     <p>If the <a href="#current-node">current node</a> is a <code><a href="semantics.html#script">script</a></code>
1.484     mike     6515:     element, mark the <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
                   6516:     started"</a>.</p>
1.1       mike     6517: 
                   6518:     <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6519:     elements</a>.</p>
                   6520: 
                   6521:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
                   6522:     insertion mode</a> and reprocess the current token.</p>
                   6523: 
                   6524:    </dd>
                   6525: 
1.878     mike     6526:    <dt id="scriptEndTag">An end tag whose tag name is "script"</dt>
1.1       mike     6527:    <dd>
                   6528: 
                   6529:     <p>Let <var title="">script</var> be the <a href="#current-node">current node</a>
                   6530:     (which will be a <code><a href="semantics.html#script">script</a></code> element).</p>
                   6531: 
                   6532:     <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6533:     elements</a>.</p>
                   6534: 
                   6535:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
                   6536:     insertion mode</a>.</p>
                   6537: 
                   6538:     <p>Let the <var title="">old insertion point</var> have the
                   6539:     same value as the current <a href="#insertion-point">insertion point</a>. Let
                   6540:     the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
                   6541:     input character</a>.</p>
                   6542: 
                   6543:     <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
                   6544:     one.</p>
                   6545: 
                   6546:     <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     6547:     which might cause <a href="embedded-content-0.html#dom-document-write" title="dom-document-write">new characters
1.1       mike     6548:     to be inserted into the tokenizer</a>, and might cause the
                   6549:     tokenizer to output more tokens, resulting in a <a href="#nestedParsing">reentrant invocation of the parser</a>.</p>
                   6550: 
                   6551:     <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
                   6552:     one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
                   6553:     then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
                   6554: 
                   6555:     <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
                   6556:     <a href="#insertion-point">insertion point</a> to its previous value. This value
                   6557:     might be the "undefined" value.)</p>
                   6558: 
                   6559:     <p id="scriptTagParserResumes">At this stage, if there is a
1.484     mike     6560:     <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking script</a>, then:</p>
1.1       mike     6561: 
                   6562:     <dl class="switch"><dt>If the <a href="#script-nesting-level">script nesting level</a> is not zero:</dt>
                   6563: 
                   6564:      <dd>
                   6565: 
                   6566:       <p>Set the <a href="#parser-pause-flag">parser pause flag</a> to true, and abort the
                   6567:       processing of any nested invocations of the tokenizer, yielding
                   6568:       control back to the caller. (Tokenization will resume when the
                   6569:       caller returns to the "outer" tree construction stage.)</p>
                   6570: 
                   6571:       <p class="note">The tree construction stage of this particular
                   6572:       parser is <a href="#nestedParsing">being called reentrantly</a>,
1.159     mike     6573:       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     6574: 
                   6575:      </dd>
                   6576: 
                   6577: 
                   6578:      <dt>Otherwise:</dt>
                   6579: 
                   6580:      <dd>
                   6581: 
1.854     mike     6582:       <p>Run these steps:</p>
1.1       mike     6583: 
1.484     mike     6584:       <ol><li><p>Let <var title="">the script</var> be the <a href="semantics.html#pending-parsing-blocking-script">pending
                   6585:        parsing-blocking script</a>. There is no longer a <a href="semantics.html#pending-parsing-blocking-script">pending
                   6586:        parsing-blocking script</a>.</p></li>
                   6587: 
                   6588:        <li><p>Block the <a href="#tokenization" title="tokenization">tokenizer</a>
                   6589:        for this instance of the <a href="#html-parser">HTML parser</a>, such that
1.794     mike     6590:        the <a href="webappapis.html#event-loop">event loop</a> will not run <a href="webappapis.html#concept-task" title="concept-task">tasks</a> that invoke the <a href="#tokenization" title="tokenization">tokenizer</a>.</p></li>
1.484     mike     6591: 
1.794     mike     6592:        <li><p><a href="webappapis.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     6593:        scripts</a> and <var title="">the script</var>'s
                   6594:        <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag is set.</p></li>
                   6595: 
                   6596:        <li><p>Unblock the <a href="#tokenization" title="tokenization">tokenizer</a>
                   6597:        for this instance of the <a href="#html-parser">HTML parser</a>, such that
1.794     mike     6598:        <a href="webappapis.html#concept-task" title="concept-task">tasks</a> that invoke the <a href="#tokenization" title="tokenization">tokenizer</a> can again be
1.484     mike     6599:        run.</p></li>
1.1       mike     6600: 
                   6601:        <li><p>Let the <a href="#insertion-point">insertion point</a> be just before the
                   6602:        <a href="#next-input-character">next input character</a>.</p></li>
                   6603: 
                   6604:        <li><p>Increment the parser's <a href="#script-nesting-level">script nesting level</a>
                   6605:        by one (it should be zero before this step, so this sets it to
                   6606:        one).</p></li>
                   6607: 
1.484     mike     6608:        <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a>
                   6609:        <var title="">the script</var>.</p></li>
1.1       mike     6610: 
                   6611:        <li><p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a>
                   6612:        by one. If the parser's <a href="#script-nesting-level">script nesting level</a> is
                   6613:        zero (which it always should be at this point), then set the
                   6614:        <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
                   6615: 
                   6616:        </li><li><p>Let the <a href="#insertion-point">insertion point</a> be undefined
                   6617:        again.</p></li>
                   6618: 
1.484     mike     6619:        <li><p>If there is once again a <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking
1.1       mike     6620:        script</a>, then repeat these steps from step 1.</p></li>
                   6621: 
                   6622:       </ol></dd>
                   6623: 
                   6624:     </dl></dd>
                   6625: 
                   6626:    <dt>Any other end tag</dt>
                   6627:    <dd>
                   6628: 
                   6629:     <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6630:     elements</a>.</p>
                   6631: 
                   6632:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
                   6633:     insertion mode</a>.</p>
                   6634: 
                   6635:    </dd>
                   6636: 
1.755     mike     6637:   </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     6638: 
                   6639:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion
                   6640:   mode: in table">in table</a>", tokens must be handled as follows:</p>
                   6641: 
                   6642:   <dl class="switch"><dt>A character token</dt>
                   6643:    <dd>
                   6644: 
                   6645:      <p>Let the <dfn id="pending-table-character-tokens"><var>pending table character tokens</var></dfn>
                   6646:      be an empty list of tokens.</p>
                   6647: 
                   6648:      <p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
                   6649:      <a href="#insertion-mode">insertion mode</a>.</p>
                   6650: 
                   6651:      <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
                   6652:      reprocess the token.</p>
                   6653: 
                   6654:    </dd>
                   6655: 
                   6656:    <dt>A comment token</dt>
                   6657:    <dd>
1.882     mike     6658:     <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1       mike     6659:     node</a> with the <code title="">data</code> attribute set to
                   6660:     the data given in the comment token.</p>
                   6661:    </dd>
                   6662: 
                   6663:    <dt>A DOCTYPE token</dt>
                   6664:    <dd>
                   6665:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6666:    </dd>
                   6667: 
                   6668:    <dt>A start tag whose tag name is "caption"</dt>
                   6669:    <dd>
                   6670: 
                   6671:     <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
                   6672:     below.)</p>
                   6673: 
                   6674:     <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
                   6675:     formatting elements</a>.</p>
                   6676: 
                   6677:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
                   6678:     switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incaption" title="insertion mode: in caption">in caption</a>".</p>
                   6679: 
                   6680:    </dd>
                   6681: 
                   6682:    <dt>A start tag whose tag name is "colgroup"</dt>
                   6683:    <dd>
                   6684: 
                   6685:     <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
                   6686:     below.)</p>
                   6687: 
                   6688:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
                   6689:     switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incolgroup" title="insertion mode: in column group">in column
                   6690:     group</a>".</p>
                   6691: 
                   6692:    </dd>
                   6693: 
                   6694:    <dt>A start tag whose tag name is "col"</dt>
                   6695:    <dd>
                   6696:     <p>Act as if a start tag token with the tag name "colgroup"
                   6697:     had been seen, then reprocess the current token.</p>
                   6698:    </dd>
                   6699: 
                   6700:    <dt>A start tag whose tag name is one of: "tbody", "tfoot", "thead"</dt>
                   6701:    <dd>
                   6702: 
                   6703:     <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
                   6704:     below.)</p>
                   6705: 
                   6706:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
                   6707:     switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   6708:     body</a>".</p>
                   6709: 
                   6710:    </dd>
                   6711: 
                   6712:    <dt>A start tag whose tag name is one of: "td", "th", "tr"</dt>
                   6713:    <dd>
                   6714:     <p>Act as if a start tag token with the tag name "tbody" had
                   6715:     been seen, then reprocess the current token.</p>
                   6716:    </dd>
                   6717: 
                   6718:    <dt>A start tag whose tag name is "table"</dt>
                   6719:    <dd>
                   6720: 
                   6721:     <p><a href="#parse-error">Parse error</a>. Act as if an end tag token with
                   6722:     the tag name "table" had been seen, then, if that token wasn't
                   6723:     ignored, reprocess the current token.</p>
                   6724: 
                   6725:     <p class="note">The fake end tag token here can only be
                   6726:     ignored in the <a href="#fragment-case">fragment case</a>.</p>
                   6727: 
                   6728:    </dd>
                   6729: 
                   6730:    <dt>An end tag whose tag name is "table"</dt>
                   6731:    <dd>
                   6732: 
                   6733:     <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
                   6734:     scope</a> with the same tag name as the token, this is a
                   6735:     <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   6736:     case</a>)</p>
                   6737: 
                   6738:     <p>Otherwise:</p>
                   6739: 
                   6740:     <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-table-element">table</a></code>
                   6741:     element has been popped from the stack.</p>
                   6742: 
                   6743:     <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
                   6744: 
                   6745:    </dd>
                   6746: 
                   6747:    <dt>An end tag whose tag name is one of: "body", "caption",
                   6748:    "col", "colgroup", "html", "tbody", "td", "tfoot", "th",
                   6749:    "thead", "tr"</dt>
                   6750:    <dd>
                   6751:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6752:    </dd>
                   6753: 
                   6754:    <dt>A start tag whose tag name is one of: "style", "script"</dt>
                   6755:    <dd>
                   6756: 
                   6757:     <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
                   6758:     mode</a>.</p>
                   6759: 
                   6760:    </dd>
                   6761: 
                   6762:    <dt>A start tag whose tag name is "input"</dt>
                   6763:    <dd>
                   6764: 
                   6765:     <p>If the token does not have an attribute with the name "type",
                   6766:     or if it does, but that attribute's value is not an <a href="infrastructure.html#ascii-case-insensitive">ASCII
                   6767:     case-insensitive</a> match for the string "<code title="">hidden</code>", then: act as described in the "anything
                   6768:     else" entry below.</p>
                   6769: 
                   6770:     <p>Otherwise:</p>
                   6771: 
                   6772:     <p><a href="#parse-error">Parse error</a>.</p>
                   6773: 
                   6774:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6775: 
                   6776:     <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
                   6777:     open elements</a>.</p>
                   6778: 
                   6779:    </dd>
                   6780: 
1.603     mike     6781:    <dt>A start tag whose tag name is "form"</dt>
                   6782:    <dd>
                   6783: 
                   6784:     <p><a href="#parse-error">Parse error</a>.</p>
                   6785: 
1.717     mike     6786:     <p>If the <a href="#form-element-pointer"><code title="form">form</code> element
                   6787:     pointer</a> is not null, ignore the token.</p>
                   6788: 
                   6789:     <p>Otherwise:</p>
                   6790: 
1.603     mike     6791:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   6792: 
1.637     mike     6793:     <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     6794:     open elements</a>.</p>
                   6795: 
                   6796:    </dd>
                   6797: 
1.721     mike     6798:    <!-- "form" end tag falls through to in-body, which does the right thing -->
1.717     mike     6799: 
1.1       mike     6800:    <dt>An end-of-file token</dt>
                   6801:    <dd>
                   6802: 
                   6803:     <p>If the <a href="#current-node">current node</a> is not the root
1.159     mike     6804:     <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     6805:     error</a>.</p>
                   6806: 
                   6807:     <p class="note">It can only be the <a href="#current-node">current node</a> in
                   6808:     the <a href="#fragment-case">fragment case</a>.</p>
                   6809: 
                   6810:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   6811: 
                   6812:    </dd>
                   6813: 
                   6814:    <dt>Anything else</dt>
                   6815:    <dd>
                   6816: 
                   6817:     <p><a href="#parse-error">Parse error</a>. Process the token <a href="#using-the-rules-for">using the
                   6818:     rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
                   6819:     body</a>" <a href="#insertion-mode">insertion mode</a>, except that if the
                   6820:     <a href="#current-node">current node</a> is a <code><a href="tabular-data.html#the-table-element">table</a></code>,
                   6821:     <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
                   6822:     <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then, whenever a node would be inserted
                   6823:     into the <a href="#current-node">current node</a>, it must instead be <a href="#foster-parent" title="foster parent">foster parented</a>.</p>
                   6824: 
                   6825:    </dd>
                   6826: 
                   6827:   </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-context">clear the stack
                   6828:   back to a table context</dfn>, it means that the UA must, while
                   6829:   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     6830:   element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1       mike     6831:   <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   6832: 
                   6833:   <p class="note">The <a href="#current-node">current node</a> being an
1.159     mike     6834:   <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     6835:   case</a>.</p>
                   6836: 
                   6837: 
                   6838: 
1.755     mike     6839:   <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     6840: 
                   6841:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intabletext" title="insertion
                   6842:   mode: in table text">in table text</a>", tokens must be handled
                   6843:   as follows:</p>
                   6844: 
                   6845:   <dl class="switch"><dt>A character token</dt>
                   6846:    <dd>
                   6847: 
                   6848:     <p>Append the character token to the <var><a href="#pending-table-character-tokens">pending table character
                   6849:     tokens</a></var> list.</p>
                   6850: 
                   6851:    </dd>
                   6852: 
                   6853: 
                   6854:    <dt>Anything else</dt>
                   6855:    <dd>
                   6856: 
                   6857:     <p>If any of the tokens in the <var><a href="#pending-table-character-tokens">pending table character
                   6858:     tokens</a></var> list are character tokens that are not one of U+0009
                   6859:     CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED
1.882     mike     6860:     (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE, then
1.1       mike     6861:     reprocess those character tokens using the rules given in the
                   6862:     "anything else" entry in the <a href="#parsing-main-intable" title="insertion mode: in
                   6863:     table">in table</a>" insertion mode.</p>
                   6864: 
                   6865:     <p>Otherwise, <a href="#insert-a-character" title="insert a character">insert the
                   6866:     characters</a> given by the <var><a href="#pending-table-character-tokens">pending table character
                   6867:     tokens</a></var> list into the <a href="#current-node">current node</a>.</p>
                   6868: 
                   6869:     <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
                   6870:     insertion mode</a> and reprocess the token.</p>
                   6871: 
                   6872:    </dd>
                   6873: 
1.755     mike     6874:   </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     6875: 
                   6876:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incaption" title="insertion
                   6877:   mode: in caption">in caption</a>", tokens must be handled as follows:</p>
                   6878: 
                   6879:   <dl class="switch"><dt>An end tag whose tag name is "caption"</dt>
                   6880:    <dd>
                   6881: 
                   6882:     <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
                   6883:     scope</a> with the same tag name as the token, this is a
                   6884:     <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   6885:     case</a>)</p>
                   6886: 
                   6887:     <p>Otherwise:</p>
                   6888: 
                   6889:     <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
                   6890: 
                   6891:     <p>Now, if the <a href="#current-node">current node</a> is not a
                   6892:     <code><a href="tabular-data.html#the-caption-element">caption</a></code> element, then this is a <a href="#parse-error">parse
                   6893:     error</a>.</p>
                   6894: 
                   6895:     <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-caption-element">caption</a></code>
                   6896:     element has been popped from the stack.</p>
                   6897: 
                   6898:     <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
                   6899:     the last marker</a>.</p>
                   6900: 
                   6901:     <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>
                   6902: 
                   6903:    </dd>
                   6904: 
                   6905:    <dt>A start tag whose tag name is one of: "caption", "col",
                   6906:    "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
                   6907:    <dt>An end tag whose tag name is "table"</dt>
                   6908:    <dd>
                   6909: 
                   6910:     <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
                   6911:     name "caption" had been seen, then, if that token wasn't
                   6912:     ignored, reprocess the current token.</p>
                   6913: 
                   6914:     <p class="note">The fake end tag token here can only be
                   6915:     ignored in the <a href="#fragment-case">fragment case</a>.</p>
                   6916: 
                   6917:    </dd>
                   6918: 
                   6919:    <dt>An end tag whose tag name is one of: "body", "col",
                   6920:    "colgroup", "html", "tbody", "td", "tfoot", "th", "thead",
                   6921:    "tr"</dt>
                   6922:    <dd>
                   6923:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6924:    </dd>
                   6925: 
                   6926:    <dt>Anything else</dt>
                   6927:    <dd>
                   6928:     <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
                   6929:     mode</a>.</p>
                   6930:    </dd>
                   6931: 
1.755     mike     6932:   </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     6933: 
                   6934:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incolgroup" title="insertion
                   6935:   mode: in column group">in column group</a>", tokens must be handled as follows:</p>
                   6936: 
                   6937:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   6938:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882     mike     6939:    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1       mike     6940:    <dd>
                   6941:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   6942:     the <a href="#current-node">current node</a>.</p>
                   6943:    </dd>
                   6944: 
                   6945:    <dt>A comment token</dt>
                   6946:    <dd>
1.882     mike     6947:     <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1       mike     6948:     node</a> with the <code title="">data</code> attribute set to
                   6949:     the data given in the comment token.</p>
                   6950:    </dd>
                   6951: 
                   6952:    <dt>A DOCTYPE token</dt>
                   6953:    <dd>
                   6954:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6955:    </dd>
                   6956: 
                   6957:    <dt>A start tag whose tag name is "html"</dt>
                   6958:    <dd>
                   6959:     <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
                   6960:     mode</a>.</p>
                   6961:    </dd>
                   6962: 
                   6963:    <dt>A start tag whose tag name is "col"</dt>
                   6964:    <dd>
                   6965: 
                   6966:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
                   6967:     pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   6968:     elements</a>.</p>
                   6969: 
                   6970:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   6971:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   6972: 
                   6973:    </dd>
                   6974: 
                   6975:    <dt>An end tag whose tag name is "colgroup"</dt>
                   6976:    <dd>
                   6977: 
                   6978:     <p>If the <a href="#current-node">current node</a> is the root
1.159     mike     6979:     <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     6980:     error</a>; ignore the token. (<a href="#fragment-case">fragment
                   6981:     case</a>)</p>
                   6982: 
                   6983:     <p>Otherwise, pop the <a href="#current-node">current node</a> (which will be
                   6984:     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
                   6985:     elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
                   6986:     "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
                   6987: 
                   6988:    </dd>
                   6989: 
                   6990:    <dt>An end tag whose tag name is "col"</dt>
                   6991:    <dd>
                   6992:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   6993:    </dd>
                   6994: 
                   6995:    <dt>An end-of-file token</dt>
                   6996:    <dd>
                   6997: 
1.159     mike     6998:     <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     6999:     element, then <a href="#stop-parsing">stop parsing</a>. (<a href="#fragment-case">fragment
                   7000:     case</a>)</p>
                   7001: 
                   7002:     <p>Otherwise, act as described in the "anything else" entry
                   7003:     below.</p>
                   7004: 
                   7005:    </dd>
                   7006: 
                   7007:    <dt>Anything else</dt>
                   7008:    <dd>
                   7009: 
                   7010:     <p>Act as if an end tag with the tag name "colgroup" had been
                   7011:     seen, and then, if that token wasn't ignored, reprocess the
                   7012:     current token.</p>
                   7013: 
                   7014:     <p class="note">The fake end tag token here can only be
                   7015:     ignored in the <a href="#fragment-case">fragment case</a>.</p>
                   7016: 
                   7017:    </dd>
                   7018: 
1.755     mike     7019:   </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     7020: 
                   7021:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion
                   7022:   mode: in table body">in table body</a>", tokens must be handled as follows:</p>
                   7023: 
                   7024:   <dl class="switch"><dt>A start tag whose tag name is "tr"</dt>
                   7025:    <dd>
                   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><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
                   7031:     the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion mode:
                   7032:     in row">in row</a>".</p>
                   7033: 
                   7034:    </dd>
                   7035: 
                   7036:    <dt>A start tag whose tag name is one of: "th", "td"</dt>
                   7037:    <dd>
                   7038:     <p><a href="#parse-error">Parse error</a>. Act as if a start tag with
                   7039:     the tag name "tr" had been seen, then reprocess the current
                   7040:     token.</p>
                   7041:    </dd>
                   7042: 
                   7043:    <dt>An end tag whose tag name is one of: "tbody", "tfoot",
                   7044:    "thead"</dt>
                   7045:    <dd>
                   7046: 
                   7047:     <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
                   7048:     scope</a> with the same tag name as the token, this is a
                   7049:     <a href="#parse-error">parse error</a>. Ignore the token.</p>
                   7050: 
                   7051:     <p>Otherwise:</p>
                   7052: 
                   7053:     <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
                   7054:     context</a>. (See below.)</p>
                   7055: 
                   7056:     <p>Pop the <a href="#current-node">current node</a> from the <a href="#stack-of-open-elements">stack of
                   7057:     open elements</a>. Switch the <a href="#insertion-mode">insertion mode</a>
                   7058:     to "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
                   7059: 
                   7060:    </dd>
                   7061: 
                   7062:    <dt>A start tag whose tag name is one of: "caption", "col",
                   7063:    "colgroup", "tbody", "tfoot", "thead"</dt>
                   7064:    <dt>An end tag whose tag name is "table"</dt>
                   7065:    <dd>
                   7066: 
                   7067:     <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
                   7068:     <code>tbody</code>, <code>thead</code>, or <code>tfoot</code>
                   7069:     element in table scope</a>, this is a <a href="#parse-error">parse
                   7070:     error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   7071:     case</a>)</p>
                   7072: 
                   7073:     <p>Otherwise:</p>
                   7074: 
                   7075:     <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
                   7076:     context</a>. (See below.)</p>
                   7077: 
                   7078:     <p>Act as if an end tag with the same tag name as the
                   7079:     <a href="#current-node">current node</a> ("tbody", "tfoot", or "thead") had
                   7080:     been seen, then reprocess the current token.</p>
                   7081: 
                   7082:    </dd>
                   7083: 
                   7084:    <dt>An end tag whose tag name is one of: "body", "caption",
                   7085:    "col", "colgroup", "html", "td", "th", "tr"</dt>
                   7086:    <dd>
                   7087:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7088:    </dd>
                   7089: 
                   7090:    <dt>Anything else</dt>
                   7091:    <dd>
                   7092:     <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
                   7093:     mode</a>.</p>
                   7094:    </dd>
                   7095: 
                   7096:   </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-body-context">clear the stack
                   7097:   back to a table body context</dfn>, it means that the UA must,
                   7098:   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     7099:   <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     7100:   element, pop elements from the <a href="#stack-of-open-elements">stack of open
                   7101:   elements</a>.</p>
                   7102: 
                   7103:   <p class="note">The <a href="#current-node">current node</a> being an
1.159     mike     7104:   <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     7105:   case</a>.</p>
                   7106: 
                   7107: 
1.755     mike     7108:   <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     7109: 
                   7110:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
                   7111:   mode: in row">in row</a>", tokens must be handled as follows:</p>
                   7112: 
                   7113:   <dl class="switch"><dt>A start tag whose tag name is one of: "th", "td"</dt>
                   7114:    <dd>
                   7115: 
                   7116:     <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
                   7117:     context</a>. (See below.)</p>
                   7118: 
                   7119:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
                   7120:     the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion mode:
                   7121:     in cell">in cell</a>".</p>
                   7122: 
                   7123:     <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
                   7124:     formatting elements</a>.</p>
                   7125: 
                   7126:    </dd>
                   7127: 
                   7128:    <dt>An end tag whose tag name is "tr"</dt>
                   7129:    <dd>
                   7130: 
                   7131:     <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
                   7132:     scope</a> with the same tag name as the token, this is a
                   7133:     <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   7134:     case</a>)</p>
                   7135: 
                   7136:     <p>Otherwise:</p>
                   7137: 
                   7138:     <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
                   7139:     context</a>. (See below.)</p>
                   7140: 
                   7141:     <p>Pop the <a href="#current-node">current node</a> (which will be a
                   7142:     <code><a href="tabular-data.html#the-tr-element">tr</a></code> element) from the <a href="#stack-of-open-elements">stack of open
                   7143:     elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
                   7144:     "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   7145:     body</a>".</p>
                   7146: 
                   7147:    </dd>
                   7148: 
                   7149:    <dt>A start tag whose tag name is one of: "caption", "col",
                   7150:    "colgroup", "tbody", "tfoot", "thead", "tr"</dt>
                   7151:    <dt>An end tag whose tag name is "table"</dt>
                   7152:    <dd>
                   7153: 
                   7154:     <p>Act as if an end tag with the tag name "tr" had been seen,
                   7155:     then, if that token wasn't ignored, reprocess the current
                   7156:     token.</p>
                   7157: 
                   7158:     <p class="note">The fake end tag token here can only be
                   7159:     ignored in the <a href="#fragment-case">fragment case</a>.</p>
                   7160: 
                   7161:    </dd>
                   7162: 
                   7163:    <dt>An end tag whose tag name is one of: "tbody", "tfoot",
                   7164:    "thead"</dt>
                   7165:    <dd>
                   7166: 
                   7167:     <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
                   7168:     scope</a> with the same tag name as the token, this is a
                   7169:     <a href="#parse-error">parse error</a>. Ignore the token.</p>
                   7170: 
                   7171:     <p>Otherwise, act as if an end tag with the tag name "tr" had
                   7172:     been seen, then reprocess the current token.</p>
                   7173: 
                   7174:    </dd>
                   7175: 
                   7176:    <dt>An end tag whose tag name is one of: "body", "caption",
                   7177:    "col", "colgroup", "html", "td", "th"</dt>
                   7178:    <dd>
                   7179:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7180:    </dd>
                   7181: 
                   7182:    <dt>Anything else</dt>
                   7183:    <dd>
                   7184:     <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
                   7185:     mode</a>.</p>
                   7186:    </dd>
                   7187: 
                   7188:   </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-row-context">clear the stack
                   7189:   back to a table row context</dfn>, it means that the UA must,
                   7190:   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     7191:   element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1       mike     7192:   <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   7193: 
                   7194:   <p class="note">The <a href="#current-node">current node</a> being an
1.159     mike     7195:   <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     7196:   case</a>.</p>
                   7197: 
                   7198: 
1.755     mike     7199:   <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     7200: 
                   7201:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intd" title="insertion
                   7202:   mode: in cell">in cell</a>", tokens must be handled as follows:</p>
                   7203: 
                   7204:   <dl class="switch"><dt>An end tag whose tag name is one of: "td", "th"</dt>
                   7205:    <dd>
                   7206: 
                   7207:     <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
                   7208:     scope</a> with the same tag name as that of the token, then
                   7209:     this is a <a href="#parse-error">parse error</a> and the token must be
                   7210:     ignored.</p>
                   7211: 
                   7212:     <p>Otherwise:</p>
                   7213: 
                   7214:     <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
                   7215: 
                   7216:     <p>Now, if the <a href="#current-node">current node</a> is not an element
                   7217:     with the same tag name as the token, then this is a
                   7218:     <a href="#parse-error">parse error</a>.</p>
                   7219: 
1.856     mike     7220:     <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a> stack
                   7221:     until an element with the same tag name as the token has been
                   7222:     popped from the stack.</p>
1.1       mike     7223: 
                   7224:     <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
                   7225:     the last marker</a>.</p>
                   7226: 
                   7227:     <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
                   7228:     <a href="#current-node">current node</a> will be a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element at
                   7229:     this point.)</p>
                   7230: 
                   7231:    </dd>
                   7232: 
                   7233:    <dt>A start tag whose tag name is one of: "caption", "col",
                   7234:    "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
                   7235:    <dd>
                   7236: 
                   7237:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does
                   7238:     <em>not</em> <a href="#has-an-element-in-table-scope" title="has an element in table scope">have
                   7239:     a <code>td</code> or <code>th</code> element in table
                   7240:     scope</a>, then this is a <a href="#parse-error">parse error</a>; ignore
                   7241:     the token. (<a href="#fragment-case">fragment case</a>)</p>
                   7242: 
                   7243:     <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
                   7244:     reprocess the current token.</p>
                   7245: 
                   7246:    </dd>
                   7247: 
                   7248:    <dt>An end tag whose tag name is one of: "body", "caption",
                   7249:    "col", "colgroup", "html"</dt>
                   7250:    <dd>
                   7251:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7252:    </dd>
                   7253: 
                   7254:    <dt>An end tag whose tag name is one of: "table", "tbody",
                   7255:    "tfoot", "thead", "tr"</dt>
                   7256:    <dd>
                   7257: 
                   7258:     <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
                   7259:     scope</a> with the same tag name as that of the token
                   7260:     (which can only happen for "tbody", "tfoot" and "thead", or,
                   7261:     in the <a href="#fragment-case">fragment case</a>), then this is a <a href="#parse-error">parse
                   7262:     error</a> and the token must be ignored.</p>
                   7263: 
                   7264:     <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
                   7265:     reprocess the current token.</p>
                   7266: 
                   7267:    </dd>
                   7268: 
                   7269:    <dt>Anything else</dt>
                   7270:    <dd>
                   7271:     <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
                   7272:     mode</a>.</p>
                   7273:    </dd>
                   7274: 
                   7275:   </dl><p>Where the steps above say to <dfn id="close-the-cell">close the cell</dfn>, they
                   7276:   mean to run the following algorithm:</p>
                   7277: 
                   7278:   <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>
                   7279:    element in table scope</a>, then act as if an end tag token
                   7280:    with the tag name "td" had been seen.</p></li>
                   7281: 
                   7282:    <li><p>Otherwise, the <a href="#stack-of-open-elements">stack of open elements</a> will
                   7283:    <a href="#has-an-element-in-table-scope" title="has an element in table scope">have a
                   7284:    <code>th</code> element in table scope</a>; act as if an end
                   7285:    tag token with the tag name "th" had been seen.</p></li>
                   7286: 
                   7287:   </ol><p class="note">The <a href="#stack-of-open-elements">stack of open elements</a> cannot
                   7288:   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
                   7289:   the same time, nor can it have neither when the <a href="#insertion-mode">insertion
                   7290:   mode</a> is "<a href="#parsing-main-intd" title="insertion mode: in cell">in
                   7291:   cell</a>".</p>
                   7292: 
                   7293: 
1.755     mike     7294:   <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     7295: 
                   7296:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselect" title="insertion
                   7297:   mode: in select">in select</a>", tokens must be handled as follows:</p>
                   7298: 
                   7299:   <dl class="switch"><dt>A character token</dt>
                   7300:    <dd>
                   7301:     <p><a href="#insert-a-character" title="insert a character">Insert the token's
                   7302:     character</a> into the <a href="#current-node">current node</a>.</p>
                   7303:    </dd>
                   7304: 
                   7305:    <dt>A comment token</dt>
                   7306:    <dd>
1.882     mike     7307:     <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1       mike     7308:     node</a> with the <code title="">data</code> attribute set to
                   7309:     the data given in the comment token.</p>
                   7310:    </dd>
                   7311: 
                   7312:    <dt>A DOCTYPE token</dt>
                   7313:    <dd>
                   7314:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7315:    </dd>
                   7316: 
                   7317:    <dt>A start tag whose tag name is "html"</dt>
                   7318:    <dd>
                   7319:     <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
                   7320:     mode</a>.</p>
                   7321:    </dd>
                   7322: 
                   7323:    <dt>A start tag whose tag name is "option"</dt>
                   7324:    <dd>
                   7325: 
                   7326:     <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
                   7327:     element, act as if an end tag with the tag name "option" had
                   7328:     been seen.</p>
                   7329: 
                   7330:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   7331: 
                   7332:    </dd>
                   7333: 
                   7334:    <dt>A start tag whose tag name is "optgroup"</dt>
                   7335:    <dd>
                   7336: 
                   7337:     <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
                   7338:     element, act as if an end tag with the tag name "option" had
                   7339:     been seen.</p>
                   7340: 
                   7341:     <p>If the <a href="#current-node">current node</a> is an
                   7342:     <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, act as if an end tag with the
                   7343:     tag name "optgroup" had been seen.</p>
                   7344: 
                   7345:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   7346: 
                   7347:    </dd>
                   7348: 
                   7349:    <dt>An end tag whose tag name is "optgroup"</dt>
                   7350:    <dd>
                   7351: 
                   7352:     <p>First, if the <a href="#current-node">current node</a> is an
                   7353:     <code><a href="forms.html#the-option-element">option</a></code> element, and the node immediately before
                   7354:     it in the <a href="#stack-of-open-elements">stack of open elements</a> is an
                   7355:     <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then act as if an end tag with
                   7356:     the tag name "option" had been seen.</p>
                   7357: 
                   7358:     <p>If the <a href="#current-node">current node</a> is an
                   7359:     <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then pop that node from the
                   7360:     <a href="#stack-of-open-elements">stack of open elements</a>. Otherwise, this is a
                   7361:     <a href="#parse-error">parse error</a>; ignore the token.</p>
                   7362: 
                   7363:    </dd>
                   7364: 
                   7365:    <dt>An end tag whose tag name is "option"</dt>
                   7366:    <dd>
                   7367: 
                   7368:     <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
                   7369:     element, then pop that node from the <a href="#stack-of-open-elements">stack of open
                   7370:     elements</a>. Otherwise, this is a <a href="#parse-error">parse
                   7371:     error</a>; ignore the token.</p>
                   7372: 
                   7373:    </dd>
                   7374: 
                   7375:    <dt>An end tag whose tag name is "select"</dt>
                   7376:    <dd>
                   7377: 
                   7378:     <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
                   7379:     scope</a> with the same tag name as the token, this is a
                   7380:     <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
                   7381:     case</a>)</p>
                   7382: 
                   7383:     <p>Otherwise:</p>
                   7384: 
                   7385:     <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
                   7386:     until a <code><a href="forms.html#the-select-element">select</a></code> element has been popped from the
                   7387:     stack.</p>
                   7388: 
                   7389:     <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
                   7390: 
                   7391:    </dd>
                   7392: 
                   7393:    <dt>A start tag whose tag name is "select"</dt>
                   7394:    <dd>
                   7395: 
                   7396:     <p><a href="#parse-error">Parse error</a>. Act as if the token had been
                   7397:     an end tag with the tag name "select" instead.</p>
                   7398: 
                   7399:    </dd>
                   7400: 
                   7401:    <dt>A start tag whose tag name is one of: "input", "keygen", "textarea"</dt>
                   7402:    <dd>
1.73      mike     7403: 
                   7404:     <p><a href="#parse-error">Parse error</a>.</p>
                   7405: 
1.124     mike     7406:     <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>
                   7407:     element in table scope</a>, ignore the token. (<a href="#fragment-case">fragment
                   7408:     case</a>)</p>
1.73      mike     7409: 
                   7410:     <p>Otherwise, act as if an end tag with the tag name "select" had
                   7411:     been seen, and reprocess the token.</p>
                   7412: 
1.1       mike     7413:    </dd>
                   7414: 
                   7415:    <dt>A start tag token whose tag name is "script"</dt>
                   7416:    <dd>
                   7417:     <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
                   7418:     mode</a>.</p>
                   7419:    </dd>
                   7420: 
                   7421:    <dt>An end-of-file token</dt>
                   7422:    <dd>
                   7423: 
                   7424:     <p>If the <a href="#current-node">current node</a> is not the root
1.159     mike     7425:     <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     7426:     error</a>.</p>
                   7427: 
                   7428:     <p class="note">It can only be the <a href="#current-node">current node</a> in
                   7429:     the <a href="#fragment-case">fragment case</a>.</p>
                   7430: 
                   7431:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7432: 
                   7433:    </dd>
                   7434: 
                   7435:    <dt>Anything else</dt>
                   7436:    <dd>
                   7437:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7438:    </dd>
                   7439: 
1.755     mike     7440:   </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     7441: 
                   7442:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselectintable" title="insertion
                   7443:   mode: in select in table">in select in table</a>", tokens must be handled as follows:</p>
                   7444: 
                   7445:   <dl class="switch"><dt>A start tag whose tag name is one of: "caption", "table",
                   7446:    "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
                   7447:    <dd>
                   7448:     <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
                   7449:     name "select" had been seen, and reprocess the token.</p>
                   7450:    </dd>
                   7451: 
                   7452:    <dt>An end tag whose tag name is one of: "caption", "table",
                   7453:    "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
                   7454:    <dd>
                   7455: 
                   7456:     <p><a href="#parse-error">Parse error</a>.</p>
                   7457: 
                   7458:     <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-table-scope">has an
                   7459:     element in table scope</a> with the same tag name as that
                   7460:     of the token, then act as if an end tag with the tag name
                   7461:     "select" had been seen, and reprocess the token. Otherwise,
                   7462:     ignore the token.</p>
                   7463: 
                   7464:    </dd>
                   7465: 
                   7466:    <dt>Anything else</dt>
                   7467:    <dd>
                   7468:     <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
                   7469:     mode</a>.</p>
                   7470:    </dd>
                   7471: 
1.755     mike     7472:   </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     7473: 
                   7474:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inforeign" title="insertion
                   7475:   mode: in foreign content">in foreign content</a>", tokens must be
                   7476:   handled as follows:</p>
                   7477: 
                   7478:   <dl class="switch"><dt>A character token</dt>
                   7479:    <dd>
                   7480: 
                   7481:     <p><a href="#insert-a-character" title="insert a character">Insert the token's
                   7482:     character</a> into the <a href="#current-node">current node</a>.</p>
                   7483: 
                   7484:     <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
1.882     mike     7485:     LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN
                   7486:     (CR), or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
1.1       mike     7487:     flag</a> to "not ok".</p>
                   7488: 
                   7489:    </dd>
                   7490: 
                   7491:    <dt>A comment token</dt>
                   7492:    <dd>
1.882     mike     7493:     <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1       mike     7494:     node</a> with the <code title="">data</code> attribute set to
                   7495:     the data given in the comment token.</p>
                   7496:    </dd>
                   7497: 
                   7498:    <dt>A DOCTYPE token</dt>
                   7499:    <dd>
                   7500:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7501:    </dd>
                   7502: 
1.878     mike     7503:    <dt id="scriptForeignEndTag">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     7504:    <dd>
                   7505: 
                   7506:     <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   7507:     elements</a>.</p>
                   7508: 
                   7509:     <p>Let the <var title="">old insertion point</var> have the
                   7510:     same value as the current <a href="#insertion-point">insertion point</a>. Let
                   7511:     the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
                   7512:     input character</a>.</p>
                   7513: 
                   7514:     <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
                   7515:     one. Set the <a href="#parser-pause-flag">parser pause flag</a> to true.</p>
                   7516: 
                   7517:     <p><a href="http://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing">Process
                   7518:     the <code title="">script</code> element</a> according to the SVG
1.187     mike     7519:     rules, if the user agent supports SVG. <a href="references.html#refsSVG">[SVG]</a></p>
1.1       mike     7520: 
1.159     mike     7521:     <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     7522:     tokenizer</a>, the parser will not be executed reentrantly,
                   7523:     since the <a href="#parser-pause-flag">parser pause flag</a> is true.</p>
                   7524: 
                   7525:     <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
                   7526:     one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
                   7527:     then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
                   7528: 
                   7529:     <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
                   7530:     <a href="#insertion-point">insertion point</a> to its previous value. This value
                   7531:     might be the "undefined" value.)</p>
                   7532: 
                   7533:    </dd>
                   7534: 
1.855     mike     7535:    <dt>An end tag, if the <a href="#current-node">current node</a> is not an element in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>.</dt>
                   7536: 
                   7537:    <dd>
                   7538: 
                   7539:     <p>Run these steps:</p>
                   7540: 
                   7541:     <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
                   7542:      node</a> (the bottommost node of the stack).</p></li>
                   7543: 
                   7544:      <li><p>If <var title="">node</var> is not an element with the
                   7545:      same tag name as the token, then this is a <a href="#parse-error">parse
                   7546:      error</a>.</p></li>
                   7547: 
                   7548:      <li><p><i>Loop</i>: If <var title="">node</var> has the same tag
                   7549:      name as the token, pop elements from the <a href="#stack-of-open-elements">stack of
                   7550:      open elements</a> until <var title="">node</var> has been
                   7551:      popped from the stack, and then abort these steps.</p></li>
                   7552: 
                   7553:      <li><p>Set <var title="">node</var> to the previous entry in the
                   7554:      <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
                   7555: 
                   7556:      <li>
                   7557: 
                   7558:       <p>If <var title="">node</var> is an element in the <a href="infrastructure.html#html-namespace-0">HTML
                   7559:       namespace</a>, process the token <a href="#using-the-rules-for">using the rules
                   7560:       for</a> the <a href="#secondary-insertion-mode">secondary insertion mode</a>. If, after
                   7561:       doing so, the <a href="#insertion-mode">insertion mode</a> is still "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
                   7562:       content</a>", but there is no element <a href="#has-an-element-in-scope" title="has an
                   7563:       element in scope">in scope</a> that has a namespace other
                   7564:       than the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, switch the <a href="#insertion-mode">insertion
                   7565:       mode</a> to the <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
                   7566: 
                   7567:      </li>
                   7568: 
                   7569:      <li><p>Return to the step labeled <i>loop</i>.</p></li>
                   7570: 
                   7571:     </ol></dd>
                   7572: 
1.724     mike     7573:    <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>
                   7574:    <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>
                   7575:    <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>
                   7576:    <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>
                   7577:    <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>
                   7578:    <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>
                   7579:    <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>
                   7580:    <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>
                   7581:    <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>
                   7582:    <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.855     mike     7583:    <dt>Any other end tag</dt>
1.1       mike     7584:    <dd>
                   7585: 
                   7586:     <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the
                   7587:     <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
                   7588: 
                   7589:     <p>If, after doing so, the <a href="#insertion-mode">insertion mode</a> is still
                   7590:     "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
1.336     mike     7591:     content</a>", but there is no element <a href="#has-an-element-in-scope" title="has an
                   7592:     element in scope">in scope</a> that has a namespace other than
1.724     mike     7593:     the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, switch the <a href="#insertion-mode">insertion
1.1       mike     7594:     mode</a> to the <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
                   7595: 
                   7596:    </dd>
                   7597: 
                   7598:    <dt>A start tag whose tag name is one of: <!--"a",--> "b", "big",
                   7599:    "blockquote", "body"<!--by inspection-->, "br", "center", "code",
1.422     mike     7600:    "dd", "div", "dl", "dt"<!-- so that dd and dt can be handled
                   7601:    uniformly throughout the parser -->, "em", "embed", "h1", "h2",
                   7602:    "h3", "h4"<!--for completeness-->, "h5", "h6"<!--for
1.1       mike     7603:    completeness-->, "head"<!--by inspection-->, "hr", "i", "img",
                   7604:    "li", "listing"<!-- so that pre and listing can be handled
                   7605:    uniformly throughout the parser -->, "menu", "meta", "nobr",
                   7606:    "ol"<!-- so that dl, ul, and ol can be handled uniformly throughout
                   7607:    the parser -->, "p", "pre", "ruby", "s", <!--"script",--> "small",
                   7608:    "span", "strong", "strike"<!-- so that s and strike can be handled
                   7609:    uniformly throughout the parser -->, <!--"style",--> "sub", "sup",
1.305     mike     7610:    "table"<!--by inspection-->, "tt", "u", "ul", "var"</dt> <!-- this
                   7611:    list was determined empirically by studying over 6,000,000,000
1.422     mike     7612:    pages that were specifically not XML pages -->
                   7613:    <dt>A start tag whose tag name is "font", if the token has any
                   7614:    attributes named "color", "face", or "size"</dt> <!-- the
                   7615:    attributes here are required so that SVG <font> will go through as
                   7616:    SVG but legacy <font>s won't -->
                   7617:    <dt>An end-of-file token</dt> <dd>
1.1       mike     7618: 
                   7619:     <p><a href="#parse-error">Parse error</a>.</p>
                   7620: 
                   7621:     <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a> until
1.857     mike     7622:     either a <code><a href="the-canvas-element.html#math">math</a></code> element or an <code><a href="the-canvas-element.html#svg">svg</a></code> element
                   7623:     has been popped from the stack, and reprocess the token.</p>
1.1       mike     7624: 
                   7625:    </dd>
                   7626: 
                   7627:    <dt>Any other start tag</dt>
                   7628:    <dd>
                   7629: 
                   7630:     <p>If the <a href="#current-node">current node</a> is an element in the
1.724     mike     7631:     <a href="infrastructure.html#mathml-namespace">MathML namespace</a>, <a href="#adjust-mathml-attributes">adjust MathML
1.1       mike     7632:     attributes</a> for the token. (This fixes the case of MathML
                   7633:     attributes that are not all lowercase.)</p>
                   7634: 
1.724     mike     7635:     <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     7636:     namespace</a>, and the token's tag name is one of the ones in
                   7637:     the first column of the following table, change the tag name to
                   7638:     the name given in the corresponding cell in the second
                   7639:     column. (This fixes the case of SVG elements that are not all
                   7640:     lowercase.)</p>
                   7641: 
                   7642:     <table><thead><tr><th> Tag name </th><th> Element name
                   7643:      </th></tr></thead><tbody><tr><td> <code title="">altglyph</code> </td><td> <code title="">altGlyph</code>
                   7644:       </td></tr><tr><td> <code title="">altglyphdef</code> </td><td> <code title="">altGlyphDef</code>
                   7645:       </td></tr><tr><td> <code title="">altglyphitem</code> </td><td> <code title="">altGlyphItem</code>
                   7646:       </td></tr><tr><td> <code title="">animatecolor</code> </td><td> <code title="">animateColor</code>
                   7647:       </td></tr><tr><td> <code title="">animatemotion</code> </td><td> <code title="">animateMotion</code>
                   7648:       </td></tr><tr><td> <code title="">animatetransform</code> </td><td> <code title="">animateTransform</code>
                   7649:       </td></tr><tr><td> <code title="">clippath</code> </td><td> <code title="">clipPath</code>
                   7650:       </td></tr><tr><td> <code title="">feblend</code> </td><td> <code title="">feBlend</code>
                   7651:       </td></tr><tr><td> <code title="">fecolormatrix</code> </td><td> <code title="">feColorMatrix</code>
                   7652:       </td></tr><tr><td> <code title="">fecomponenttransfer</code> </td><td> <code title="">feComponentTransfer</code>
                   7653:       </td></tr><tr><td> <code title="">fecomposite</code> </td><td> <code title="">feComposite</code>
                   7654:       </td></tr><tr><td> <code title="">feconvolvematrix</code> </td><td> <code title="">feConvolveMatrix</code>
                   7655:       </td></tr><tr><td> <code title="">fediffuselighting</code> </td><td> <code title="">feDiffuseLighting</code>
                   7656:       </td></tr><tr><td> <code title="">fedisplacementmap</code> </td><td> <code title="">feDisplacementMap</code>
                   7657:       </td></tr><tr><td> <code title="">fedistantlight</code> </td><td> <code title="">feDistantLight</code>
                   7658:       </td></tr><tr><td> <code title="">feflood</code> </td><td> <code title="">feFlood</code>
                   7659:       </td></tr><tr><td> <code title="">fefunca</code> </td><td> <code title="">feFuncA</code>
                   7660:       </td></tr><tr><td> <code title="">fefuncb</code> </td><td> <code title="">feFuncB</code>
                   7661:       </td></tr><tr><td> <code title="">fefuncg</code> </td><td> <code title="">feFuncG</code>
                   7662:       </td></tr><tr><td> <code title="">fefuncr</code> </td><td> <code title="">feFuncR</code>
                   7663:       </td></tr><tr><td> <code title="">fegaussianblur</code> </td><td> <code title="">feGaussianBlur</code>
                   7664:       </td></tr><tr><td> <code title="">feimage</code> </td><td> <code title="">feImage</code>
                   7665:       </td></tr><tr><td> <code title="">femerge</code> </td><td> <code title="">feMerge</code>
                   7666:       </td></tr><tr><td> <code title="">femergenode</code> </td><td> <code title="">feMergeNode</code>
                   7667:       </td></tr><tr><td> <code title="">femorphology</code> </td><td> <code title="">feMorphology</code>
                   7668:       </td></tr><tr><td> <code title="">feoffset</code> </td><td> <code title="">feOffset</code>
                   7669:       </td></tr><tr><td> <code title="">fepointlight</code> </td><td> <code title="">fePointLight</code>
                   7670:       </td></tr><tr><td> <code title="">fespecularlighting</code> </td><td> <code title="">feSpecularLighting</code>
                   7671:       </td></tr><tr><td> <code title="">fespotlight</code> </td><td> <code title="">feSpotLight</code>
                   7672:       </td></tr><tr><td> <code title="">fetile</code> </td><td> <code title="">feTile</code>
                   7673:       </td></tr><tr><td> <code title="">feturbulence</code> </td><td> <code title="">feTurbulence</code>
                   7674:       </td></tr><tr><td> <code title="">foreignobject</code> </td><td> <code title="">foreignObject</code>
                   7675:       </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
                   7676:       </td></tr><tr><td> <code title="">lineargradient</code> </td><td> <code title="">linearGradient</code>
                   7677:       </td></tr><tr><td> <code title="">radialgradient</code> </td><td> <code title="">radialGradient</code>
                   7678:       <!--<tr> <td> <code title="">solidcolor</code> <td> <code title="">solidColor</code> (SVG 1.2)-->
                   7679:       </td></tr><tr><td> <code title="">textpath</code> </td><td> <code title="">textPath</code>
1.724     mike     7680:     </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     7681:     namespace</a>, <a href="#adjust-svg-attributes">adjust SVG attributes</a> for the
                   7682:     token. (This fixes the case of SVG attributes that are not all
                   7683:     lowercase.)</p>
                   7684: 
                   7685:     <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
                   7686:     fixes the use of namespaced attributes, in particular XLink in
                   7687:     SVG.)</p>
                   7688: 
                   7689:     <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
                   7690:     same namespace as the <a href="#current-node">current node</a>.</p>
                   7691: 
                   7692:     <p>If the token has its <i>self-closing flag</i> set, pop the
                   7693:     <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
                   7694:     elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
                   7695:     flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
                   7696: 
                   7697:    </dd>
                   7698: 
1.755     mike     7699:   </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     7700: 
                   7701:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterbody" title="insertion
                   7702:   mode: after body">after body</a>", tokens must be handled as follows:</p>
                   7703: 
                   7704:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   7705:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882     mike     7706:    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1       mike     7707:    <dd>
                   7708:     <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
                   7709:     mode</a>.</p>
                   7710:    </dd>
                   7711: 
                   7712:    <dt>A comment token</dt>
                   7713:    <dd>
1.882     mike     7714:     <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the first element in
1.159     mike     7715:     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     7716:     element), with the <code title="">data</code> attribute set to
                   7717:     the data given in the comment token.</p>
                   7718:    </dd>
                   7719: 
                   7720:    <dt>A DOCTYPE token</dt>
                   7721:    <dd>
                   7722:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7723:    </dd>
                   7724: 
                   7725:    <dt>A start tag whose tag name is "html"</dt>
                   7726:    <dd>
                   7727:     <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
                   7728:     mode</a>.</p>
                   7729:    </dd>
                   7730: 
                   7731:    <dt>An end tag whose tag name is "html"</dt>
                   7732:    <dd>
                   7733: 
                   7734:     <p>If the parser was originally created as part of the <a href="#html-fragment-parsing-algorithm">HTML
                   7735:     fragment parsing algorithm</a>, this is a <a href="#parse-error">parse
                   7736:     error</a>; ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
                   7737: 
                   7738:     <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
                   7739:     body</a>".</p>
                   7740: 
                   7741:    </dd>
                   7742: 
                   7743:    <dt>An end-of-file token</dt>
                   7744:    <dd>
                   7745:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7746:    </dd>
                   7747: 
                   7748:    <dt>Anything else</dt>
                   7749:    <dd>
                   7750: 
                   7751:     <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion
                   7752:     mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in body">in
                   7753:     body</a>" and reprocess the token.</p>
                   7754: 
                   7755:    </dd>
                   7756: 
1.755     mike     7757:   </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     7758: 
                   7759:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inframeset" title="insertion
                   7760:   mode: in frameset">in frameset</a>", tokens must be handled as follows:</p>
                   7761: 
                   7762:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   7763:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882     mike     7764:    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1       mike     7765:    <dd>
                   7766:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   7767:     the <a href="#current-node">current node</a>.</p>
                   7768:    </dd>
                   7769: 
                   7770:    <dt>A comment token</dt>
                   7771:    <dd>
1.882     mike     7772:     <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1       mike     7773:     node</a> with the <code title="">data</code> attribute set to
                   7774:     the data given in the comment token.</p>
                   7775:    </dd>
                   7776: 
                   7777:    <dt>A DOCTYPE token</dt>
                   7778:    <dd>
                   7779:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7780:    </dd>
                   7781: 
                   7782:    <dt>A start tag whose tag name is "html"</dt>
                   7783:    <dd>
                   7784:     <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
                   7785:     mode</a>.</p>
                   7786:    </dd>
                   7787: 
                   7788:    <dt>A start tag whose tag name is "frameset"</dt>
                   7789:    <dd>
                   7790:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
                   7791:    </dd>
                   7792: 
                   7793:    <dt>An end tag whose tag name is "frameset"</dt>
                   7794:    <dd>
                   7795: 
                   7796:     <p>If the <a href="#current-node">current node</a> is the root
1.159     mike     7797:     <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     7798:     error</a>; ignore the token. (<a href="#fragment-case">fragment
                   7799:     case</a>)</p>
                   7800: 
                   7801:     <p>Otherwise, pop the <a href="#current-node">current node</a> from the
                   7802:     <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   7803: 
                   7804:     <p>If the parser was <em>not</em> originally created as part
                   7805:     of the <a href="#html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>
                   7806:     (<a href="#fragment-case">fragment case</a>), and the <a href="#current-node">current
1.5       mike     7807:     node</a> is no longer a <code><a href="obsolete.html#frameset">frameset</a></code> element, then
1.1       mike     7808:     switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-afterframeset" title="insertion mode: after frameset">after
                   7809:     frameset</a>".</p>
                   7810: 
                   7811:    </dd>
                   7812: 
                   7813:    <dt>A start tag whose tag name is "frame"</dt>
                   7814:    <dd>
                   7815: 
                   7816:     <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.
                   7817:     Immediately pop the <a href="#current-node">current node</a> off the
                   7818:     <a href="#stack-of-open-elements">stack of open elements</a>.</p>
                   7819: 
                   7820:     <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
                   7821:     token's <i>self-closing flag</i></a>, if it is set.</p>
                   7822: 
                   7823:    </dd>
                   7824: 
                   7825:    <dt>A start tag whose tag name is "noframes"</dt>
                   7826:    <dd>
                   7827:     <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
                   7828:     mode</a>.</p>
                   7829:    </dd>
                   7830: 
                   7831:    <dt>An end-of-file token</dt>
                   7832:    <dd>
                   7833: 
                   7834:     <p>If the <a href="#current-node">current node</a> is not the root
1.159     mike     7835:     <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     7836:     error</a>.</p>
                   7837: 
                   7838:     <p class="note">It can only be the <a href="#current-node">current node</a> in
                   7839:     the <a href="#fragment-case">fragment case</a>.</p>
                   7840: 
                   7841:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7842: 
                   7843:    </dd>
                   7844: 
                   7845:    <dt>Anything else</dt>
                   7846:    <dd>
                   7847:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7848:    </dd>
                   7849: 
1.755     mike     7850:   </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     7851: 
                   7852:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterframeset" title="insertion
                   7853:   mode: after frameset">after frameset</a>", tokens must be handled as follows:</p>
                   7854: 
                   7855:   <!-- due to rules in the "in frameset" mode, this can't be entered in the fragment case -->
                   7856:   <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
                   7857:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882     mike     7858:    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1       mike     7859:    <dd>
                   7860:     <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
                   7861:     the <a href="#current-node">current node</a>.</p>
                   7862:    </dd>
                   7863: 
                   7864:    <dt>A comment token</dt>
                   7865:    <dd>
1.882     mike     7866:     <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1       mike     7867:     node</a> with the <code title="">data</code> attribute set to
                   7868:     the data given in the comment token.</p>
                   7869:    </dd>
                   7870: 
                   7871:    <dt>A DOCTYPE token</dt>
                   7872:    <dd>
                   7873:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7874:    </dd>
                   7875: 
                   7876:    <dt>A start tag whose tag name is "html"</dt>
                   7877:    <dd>
                   7878:     <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
                   7879:     mode</a>.</p>
                   7880:    </dd>
                   7881: 
                   7882:    <dt>An end tag whose tag name is "html"</dt>
                   7883:    <dd>
                   7884:     <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
                   7885:     frameset</a>".</p>
                   7886:    </dd>
                   7887: 
                   7888:    <dt>A start tag whose tag name is "noframes"</dt>
                   7889:    <dd>
                   7890:     <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
                   7891:     mode</a>.</p>
                   7892:    </dd>
                   7893: 
                   7894:    <dt>An end-of-file token</dt>
                   7895:    <dd>
                   7896:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7897:    </dd>
                   7898: 
                   7899:    <dt>Anything else</dt>
                   7900:    <dd>
                   7901:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7902:    </dd>
                   7903: 
1.755     mike     7904:   </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     7905: 
                   7906:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-body-insertion-mode" title="insertion
                   7907:   mode: after after body">after after body</a>", tokens must be handled as follows:</p>
                   7908: 
                   7909:   <dl class="switch"><dt>A comment token</dt>
                   7910:    <dd>
1.882     mike     7911:     <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <code><a href="infrastructure.html#document">Document</a></code>
1.1       mike     7912:     object with the <code title="">data</code> attribute set to the
                   7913:     data given in the comment token.</p>
                   7914:    </dd>
                   7915: 
                   7916:    <dt>A DOCTYPE token</dt>
                   7917:    <dt>A character token that is one of U+0009 CHARACTER
                   7918:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882     mike     7919:    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1       mike     7920:    <dt>A start tag whose tag name is "html"</dt>
                   7921:    <dd>
                   7922:     <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
                   7923:     mode</a>.</p>
                   7924:    </dd>
                   7925: 
                   7926:    <dt>An end-of-file token</dt>
                   7927:    <dd>
                   7928:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7929:    </dd>
                   7930: 
                   7931:    <dt>Anything else</dt>
                   7932:    <dd>
                   7933:     <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion mode</a>
                   7934:     to "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" and
                   7935:     reprocess the token.</p>
                   7936:    </dd>
                   7937: 
1.755     mike     7938:   </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     7939: 
                   7940:   <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-frameset-insertion-mode" title="insertion
                   7941:   mode: after after frameset">after after frameset</a>", tokens must be handled as follows:</p>
                   7942: 
                   7943:   <dl class="switch"><dt>A comment token</dt>
                   7944:    <dd>
1.882     mike     7945:     <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <code><a href="infrastructure.html#document">Document</a></code>
1.1       mike     7946:     object with the <code title="">data</code> attribute set to the
                   7947:     data given in the comment token.</p>
                   7948:    </dd>
                   7949: 
                   7950:    <dt>A DOCTYPE token</dt>
                   7951:    <dt>A character token that is one of U+0009 CHARACTER
                   7952:    TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882     mike     7953:    U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1       mike     7954:    <dt>A start tag whose tag name is "html"</dt>
                   7955:    <dd>
                   7956:     <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
                   7957:     mode</a>.</p>
                   7958:    </dd>
                   7959: 
                   7960:    <dt>An end-of-file token</dt>
                   7961:    <dd>
                   7962:     <p><a href="#stop-parsing">Stop parsing</a>.</p>
                   7963:    </dd>
                   7964: 
                   7965:    <dt>A start tag whose tag name is "noframes"</dt>
                   7966:    <dd>
                   7967:     <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
                   7968:     mode</a>.</p>
                   7969:    </dd>
                   7970: 
                   7971:    <dt>Anything else</dt>
                   7972:    <dd>
                   7973:     <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
                   7974:    </dd>
                   7975: 
1.266     mike     7976:   </dl></div><div class="impl">
                   7977: 
1.755     mike     7978:   <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     7979: 
                   7980:   <p>Once the user agent <dfn id="stop-parsing" title="stop parsing">stops parsing</dfn>
1.484     mike     7981:   the document, the user agent must run the following steps:</p>
1.1       mike     7982: 
1.484     mike     7983:   <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
                   7984:    "interactive" <!-- this also synchronously fires an event --> and
                   7985:    the <a href="#insertion-point">insertion point</a> to undefined.</p></li>
                   7986: 
1.838     mike     7987:    <li><p>Pop <em>all</em> the nodes off the <a href="#stack-of-open-elements">stack of open
                   7988:    elements</a>.</p></li>
                   7989: 
1.484     mike     7990:    <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
                   7991:    document has finished parsing</a> is not empty, run these
                   7992:    substeps:</p>
                   7993: 
1.794     mike     7994:     <ol><li><p><a href="webappapis.html#spin-the-event-loop">Spin the event loop</a> until the first
1.484     mike     7995:      <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
                   7996:      execute when the document has finished parsing</a> has its
                   7997:      <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag set <em>and</em> there
                   7998:      is no <a href="semantics.html#a-style-sheet-blocking-scripts" title="a style sheet blocking scripts">style sheet
                   7999:      blocking scripts</a>.</p></li>
                   8000: 
                   8001:      <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a> the
                   8002:      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
                   8003:      execute when the document has finished parsing</a>.</p></li>
                   8004: 
                   8005:      <li><p>Remove the first <code><a href="semantics.html#script">script</a></code> element from the
                   8006:      <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
                   8007:      finished parsing</a> (i.e. shift out the first entry in the
                   8008:      list).</p></li>
                   8009:  
                   8010:      <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
                   8011:      document has finished parsing</a> is still not empty, repeat
                   8012:      these substeps again from substep 1.</p>
                   8013: 
                   8014:     </li></ol></li>
                   8015: 
1.794     mike     8016:    <li><p><a href="webappapis.html#queue-a-task">Queue a task</a> to <a href="webappapis.html#fire-a-simple-event">fire a simple
1.484     mike     8017:    event</a> named <code title="event-DOMContentLoaded">DOMContentLoaded</code> at the
1.810     mike     8018:    <code><a href="infrastructure.html#document">Document</a></code>.</p></li>
1.484     mike     8019: 
1.879     mike     8020:    <li><p><a href="webappapis.html#spin-the-event-loop">Spin the event loop</a> until the <a href="semantics.html#set-of-scripts-that-will-execute-as-soon-as-possible">set of
1.877     mike     8021:    scripts that will execute as soon as possible</a> is
                   8022:    empty.</p></li> <!-- this step is redundant with the next one,
                   8023:    really, since all those scripts also delay the load event. It's
                   8024:    here in case we add an event between this step and the next or if
                   8025:    we move the previous step (DOMContentLoaded) down again. -->
                   8026: 
1.794     mike     8027:    <li><p><a href="webappapis.html#spin-the-event-loop">Spin the event loop</a> until there is nothing that
1.484     mike     8028:    <dfn id="delay-the-load-event" title="delay the load event">delays the load event</dfn> in
1.810     mike     8029:    the <code><a href="infrastructure.html#document">Document</a></code>.</p></li>
1.484     mike     8030: 
1.794     mike     8031:    <li><p><a href="webappapis.html#queue-a-task">Queue a task</a> to set the <a href="dom.html#current-document-readiness">current document
1.484     mike     8032:    readiness</a> to "complete". <!-- this also fires an event
                   8033:    synchronously during the task --></p></li>
1.1       mike     8034: 
1.810     mike     8035:    <li><p>If the <code><a href="infrastructure.html#document">Document</a></code> is in a <a href="browsers.html#browsing-context">browsing
1.794     mike     8036:    context</a>, then <a href="webappapis.html#queue-a-task">queue a task</a> to <a href="webappapis.html#fire-a-simple-event">fire a
1.460     mike     8037:    simple event</a> named <code title="event-load">load</code> at
1.810     mike     8038:    the <code><a href="infrastructure.html#document">Document</a></code>'s <code><a href="browsers.html#window">Window</a></code> object, but with
1.882     mike     8039:    its <code title="dom-event-target"><a href="infrastructure.html#dom-event-target">target</a></code> set to the
1.810     mike     8040:    <code><a href="infrastructure.html#document">Document</a></code> object (and the <code title="dom-event-currentTarget">currentTarget</code> set to the
1.484     mike     8041:    <code><a href="browsers.html#window">Window</a></code> object).</p></li>
1.1       mike     8042: 
1.810     mike     8043:    <li><p>If the <code><a href="infrastructure.html#document">Document</a></code> is in a <a href="browsers.html#browsing-context">browsing
1.852     mike     8044:    context</a>, then <a href="webappapis.html#queue-a-task">queue a task</a> to fire a <code title="event-pageshow"><a href="history.html#event-pageshow">pageshow</a></code> event at the
                   8045:    <code><a href="browsers.html#window">Window</a></code> object of the <code><a href="infrastructure.html#document">Document</a></code>, but with
1.882     mike     8046:    its <code title="dom-event-target"><a href="infrastructure.html#dom-event-target">target</a></code> set to the
1.852     mike     8047:    <code><a href="infrastructure.html#document">Document</a></code> object (and the <code title="dom-event-currentTarget">currentTarget</code> set to the
                   8048:    <code><a href="browsers.html#window">Window</a></code> object), using the
                   8049:    <code><a href="history.html#pagetransitionevent">PageTransitionEvent</a></code> interface, with the <code title="dom-PageTransitionEvent-persisted"><a href="history.html#dom-pagetransitionevent-persisted">persisted</a></code>
                   8050:    attribute set to false. This event must not bubble, must not be
                   8051:    cancelable, and has no default action.</p></li>
1.569     mike     8052: 
1.810     mike     8053:    <li><p>If the <code><a href="infrastructure.html#document">Document</a></code> has a <a href="history.html#pending-state-object">pending state
1.794     mike     8054:    object</a>, then <a href="webappapis.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.810     mike     8055:    <code><a href="infrastructure.html#document">Document</a></code>'s <code><a href="browsers.html#window">Window</a></code> object using the
1.1       mike     8056:    <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
                   8057:    current value of the <a href="history.html#pending-state-object">pending state object</a>. This event
1.484     mike     8058:    must bubble but not be cancelable and has no default
                   8059:    action.</p></li>
1.1       mike     8060: 
1.810     mike     8061:    <li><p>If the <code><a href="infrastructure.html#document">Document</a></code> has any <a href="offline.html#pending-application-cache-download-process-tasks">pending
1.794     mike     8062:    application cache download process tasks</a>, then <a href="webappapis.html#queue-a-task" title="queue a task">queue</a> each such <a href="webappapis.html#concept-task" title="concept-task">task</a> in the order they were added to
1.725     mike     8063:    the list of <a href="offline.html#pending-application-cache-download-process-tasks">pending application cache download process
                   8064:    tasks</a>, and then empty the list of <a href="offline.html#pending-application-cache-download-process-tasks">pending application
1.794     mike     8065:    cache download process tasks</a>. The <a href="webappapis.html#task-source">task source</a>
                   8066:    for these <a href="webappapis.html#concept-task" title="concept-task">tasks</a> is the
                   8067:    <a href="webappapis.html#networking-task-source">networking task source</a>.</p></li>
1.725     mike     8068: 
1.810     mike     8069:    <li><p>The <code><a href="infrastructure.html#document">Document</a></code> is now <dfn id="completely-loaded">completely
1.725     mike     8070:    loaded</dfn>.</p></li>
                   8071: 
1.838     mike     8072:   </ol><p>When the user agent is to <dfn id="abort-an-html-parser">abort an HTML parser</dfn>, it
                   8073:   must run the following steps:</p>
                   8074: 
                   8075:   <ol><li><p>Throw away any pending content in the <a href="#the-input-stream">input
                   8076:    stream</a>, and discard any future content that would have been
                   8077:    added to it.</p></li>
                   8078: 
                   8079:    <li><p>Pop <em>all</em> the nodes off the <a href="#stack-of-open-elements">stack of open
                   8080:    elements</a>.</p></li>
                   8081: 
                   8082:    <!-- anything else? this is things that happen when you call
                   8083:    document.open() on a document that's still being parsed. Should the
                   8084:    pending scripts be blown away or anything? -->
                   8085: 
1.794     mike     8086:   </ol><p>Except where otherwise specified, the <a href="webappapis.html#task-source">task source</a>
                   8087:   for the <a href="webappapis.html#concept-task" title="concept-task">tasks</a> mentioned in this
                   8088:   section is the <a href="webappapis.html#dom-manipulation-task-source">DOM manipulation task source</a>.</p>
1.1       mike     8089: 
1.266     mike     8090:   </div><div class="impl">
1.1       mike     8091: 
1.755     mike     8092:   <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     8093: 
                   8094:   <p>When an application uses an <a href="#html-parser">HTML parser</a> in
                   8095:   conjunction with an XML pipeline, it is possible that the
                   8096:   constructed DOM is not compatible with the XML tool chain in certain
                   8097:   subtle ways. For example, an XML toolchain might not be able to
                   8098:   represent attributes with the name <code title="">xmlns</code>,
                   8099:   since they conflict with the Namespaces in XML syntax. There is also
                   8100:   some data that the <a href="#html-parser">HTML parser</a> generates that isn't
                   8101:   included in the DOM itself. This section specifies some rules for
                   8102:   handling these issues.</p>
                   8103: 
                   8104:   <p>If the XML API being used doesn't support DOCTYPEs, the tool may
                   8105:   drop DOCTYPEs altogether.</p>
                   8106: 
                   8107:   <p>If the XML API doesn't support attributes in no namespace that
                   8108:   are named "<code title="">xmlns</code>", attributes whose names
                   8109:   start with "<code title="">xmlns:</code>", or attributes in the
1.724     mike     8110:   <a href="infrastructure.html#xmlns-namespace">XMLNS namespace</a>, then the tool may drop such
1.1       mike     8111:   attributes.</p>
                   8112: 
                   8113:   <p>The tool may annotate the output with any namespace declarations
                   8114:   required for proper operation.</p>
                   8115: 
                   8116:   <p>If the XML API being used restricts the allowable characters in
                   8117:   the local names of elements and attributes, then the tool may map
                   8118:   all element and attribute local names that the API wouldn't support
                   8119:   to a set of names that <em>are</em> allowed, by replacing any
                   8120:   character that isn't supported with the uppercase letter U and the
                   8121:   six digits of the character's Unicode code point when expressed in
                   8122:   hexadecimal, using digits 0-9 and capital letters A-F as the
                   8123:   symbols, in increasing numeric order.</p>
                   8124: 
                   8125:   <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
                   8126:   parser</a>, though it is neither a legal HTML element name nor a
                   8127:   well-formed XML element name, would be converted into <code title="">fooU00003Cbar</code>, which <em>is</em> a well-formed XML
                   8128:   element name (though it's still not legal in HTML by any means).</p>
                   8129: 
                   8130:   <p class="example">As another example, consider the attribute
                   8131:   <code>xlink:href</code>. Used on a MathML element, it becomes, after
                   8132:   being <a href="#adjust-foreign-attributes" title="adjust foreign attributes">adjusted</a>, an
                   8133:   attribute with a prefix "<code title="">xlink</code>" and a local
                   8134:   name "<code title="">href</code>". However, used on an HTML element,
                   8135:   it becomes an attribute with no prefix and the local name "<code title="">xlink:href</code>", which is not a valid NCName, and thus
                   8136:   might not be accepted by an XML API. It could thus get converted,
                   8137:   becoming "<code title="">xlinkU00003Ahref</code>".</p>
                   8138: 
                   8139:   <p class="note">The resulting names from this conversion
                   8140:   conveniently can't clash with any attribute generated by the
                   8141:   <a href="#html-parser">HTML parser</a>, since those are all either lowercase or
                   8142:   those listed in the <a href="#adjust-foreign-attributes">adjust foreign attributes</a>
                   8143:   algorithm's table.</p>
                   8144: 
                   8145:   <p>If the XML API restricts comments from having two consecutive
                   8146:   U+002D HYPHEN-MINUS characters (--), the tool may insert a single
                   8147:   U+0020 SPACE character between any such offending characters.</p>
                   8148: 
                   8149:   <p>If the XML API restricts comments from ending in a
                   8150:   U+002D HYPHEN-MINUS character (-), the tool may insert a single
                   8151:   U+0020 SPACE character at the end of such comments.</p>
                   8152: 
                   8153:   <p>If the XML API restricts allowed characters in character data,
1.439     mike     8154:   attribute values, or comments, the tool may replace any U+000C FORM
                   8155:   FEED (FF) character with a U+0020 SPACE character, and any other
                   8156:   literal non-XML character with a U+FFFD REPLACEMENT CHARACTER.</p>
1.1       mike     8157: 
                   8158:   <p>If the tool has no way to convey out-of-band information, then
                   8159:   the tool may drop the following information:</p>
                   8160: 
1.880     mike     8161:   <ul><li>Whether the document is set to <i><a href="dom.html#no-quirks-mode">no-quirks mode</a></i>,
                   8162:    <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>
1.1       mike     8163: 
                   8164:    <li>The association between form controls and forms that aren't
                   8165:    their nearest <code><a href="forms.html#the-form-element">form</a></code> element ancestor (use of the
                   8166:    <a href="#form-element-pointer"><code>form</code> element pointer</a> in the parser)</li>
                   8167: 
                   8168:   </ul><p class="note">The mutations allowed by this section apply
                   8169:   <em>after</em> the <a href="#html-parser">HTML parser</a>'s rules have been
                   8170:   applied. For example, a <code title="">&lt;a::&gt;</code> start tag
                   8171:   will be closed by a <code title="">&lt;/a::&gt;</code> end tag, and
                   8172:   never by a <code title="">&lt;/aU00003AU00003A&gt;</code> end tag, even
                   8173:   if the user agent is using the rules above to then generate an
                   8174:   actual element in the DOM with the name <code title="">aU00003AU00003A</code> for that start tag.</p>
                   8175: 
1.266     mike     8176:   </div><div class="impl">
1.1       mike     8177: 
1.755     mike     8178:   <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     8179: 
                   8180:   <p><i>This section is non-normative.</i></p>
                   8181: 
                   8182:   <p>This section examines some erroneous markup and discusses how
                   8183:   the <a href="#html-parser">HTML parser</a> handles these cases.</p>
                   8184: 
                   8185: 
1.755     mike     8186:   <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     8187: 
                   8188:   <p><i>This section is non-normative.</i></p>
                   8189: 
                   8190:   <p>The most-often discussed example of erroneous markup is as
                   8191:   follows:</p>
                   8192: 
                   8193:   <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>
                   8194: 
                   8195:   <p>The parsing of this markup is straightforward up to the "3". At
                   8196:   this point, the DOM looks like this:</p>
                   8197: 
1.159     mike     8198:   <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
                   8199:   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     8200:   <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
                   8201:   formatting elements</a> just has two: <code><a href="text-level-semantics.html#the-b-element">b</a></code> and
                   8202:   <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>
                   8203: 
                   8204:   <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is
                   8205:   invoked. This is a simple case, in that the <var title="">formatting
                   8206:   element</var> is the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element, and there is no
                   8207:   <var title="">furthest block</var>. Thus, the <a href="#stack-of-open-elements">stack of open
1.159     mike     8208:   elements</a> ends up with just three elements: <code><a href="semantics.html#the-html-element-0">html</a></code>,
                   8209:   <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     8210:   active formatting elements</a> has just one: <code><a href="text-level-semantics.html#the-i-element">i</a></code>. The
                   8211:   DOM tree is unmodified at this point.</p>
                   8212: 
                   8213:   <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
                   8214:   the active formatting elements</a>, in this case just the
                   8215:   <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
                   8216:   for the "4" text node. After the end tag token for the "i" is also
                   8217:   received, and the "5" text node is inserted, the DOM looks as
                   8218:   follows:</p>
                   8219: 
1.755     mike     8220:   <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     8221: 
                   8222:   <p><i>This section is non-normative.</i></p>
                   8223: 
                   8224:   <p>A case similar to the previous one is the following:</p>
                   8225: 
                   8226:   <pre>&lt;b&gt;1&lt;p&gt;2&lt;/b&gt;3&lt;/p&gt;</pre>
                   8227: 
                   8228:   <p>Up to the "2" the parsing here is straightforward:</p>
                   8229: 
1.159     mike     8230:   <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     8231:   "b" is parsed.</p>
                   8232: 
                   8233:   <p>Before that token is seen, the <a href="#stack-of-open-elements">stack of open
1.159     mike     8234:   elements</a> has four elements on it: <code><a href="semantics.html#the-html-element-0">html</a></code>,
                   8235:   <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     8236:   <a href="#list-of-active-formatting-elements">list of active formatting elements</a> just has the one:
                   8237:   <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>
                   8238: 
                   8239:   <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is invoked, as
                   8240:   in the previous example. However, in this case, there <em>is</em> a
                   8241:   <var title="">furthest block</var>, namely the <code><a href="semantics.html#the-p-element">p</a></code> element. Thus,
                   8242:   this time the adoption agency algorithm isn't skipped over.</p>
                   8243: 
1.159     mike     8244:   <p>The <var title="">common ancestor</var> is the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1       mike     8245:   element. A conceptual "bookmark" marks the position of the
                   8246:   <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
                   8247:   elements</a>, but since that list has only one element in it,
                   8248:   it won't have much effect.</p>
                   8249: 
                   8250:   <p>As the algorithm progresses, <var title="">node</var> ends up set
                   8251:   to the formatting element (<code><a href="text-level-semantics.html#the-b-element">b</a></code>), and <var title="">last
                   8252:   node</var> ends up set to the <var title="">furthest block</var>
                   8253:   (<code><a href="semantics.html#the-p-element">p</a></code>).</p>
                   8254: 
                   8255:   <p>The <var title="">last node</var> gets appended (moved) to the
                   8256:   <var title="">common ancestor</var>, so that the DOM looks like:</p>
                   8257: 
1.159     mike     8258:   <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     8259:   <code><a href="semantics.html#the-p-element">p</a></code> element are moved to it:</p>
                   8260: 
1.159     mike     8261:   <ul class="domTree"><li class="t1"><code><a href="semantics.html#the-html-element-0">html</a></code><ul><li class="t1"><code><a href="semantics.html#the-head-element-0">head</a></code></li><li class="t1"><code><a href="semantics.html#the-body-element-0">body</a></code><ul><li class="t1"><code><a href="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     8262:   <code><a href="semantics.html#the-p-element">p</a></code> element, so that the DOM looks like:</p>
                   8263: 
1.159     mike     8264:   <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     8265:   active formatting elements</a> and the <a href="#stack-of-open-elements">stack of open
                   8266:   elements</a>, so that when the "3" is parsed, it is appended to
                   8267:   the <code><a href="semantics.html#the-p-element">p</a></code> element:</p>
                   8268: 
1.755     mike     8269:   <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     8270: 
                   8271:   <p><i>This section is non-normative.</i></p>
                   8272: 
                   8273:   <p>Error handling in tables is, for historical reasons, especially
                   8274:   strange. For example, consider the following markup:</p>
                   8275: 
                   8276:   <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>
                   8277: 
                   8278:   <p>The highlighted <code><a href="text-level-semantics.html#the-b-element">b</a></code> element start tag is not allowed
                   8279:   directly inside a table like that, and the parser handles this case
                   8280:   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
                   8281:   examining the DOM tree as it stands just after the
                   8282:   <code><a href="tabular-data.html#the-table-element">table</a></code> element's start tag has been seen:</p>
                   8283: 
1.159     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="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     8285:   tag has been seen:</p>
                   8286: 
1.159     mike     8287:   <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
                   8288:   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     8289:   <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
                   8290:   resulting DOM tree); the <a href="#list-of-active-formatting-elements">list of active formatting
                   8291:   elements</a> just has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it; and the
                   8292:   <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion mode: in
                   8293:   table">in table</a>".</p>
                   8294: 
                   8295:   <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
                   8296:   to be popped off the stack and a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> start tag to be
                   8297:   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
                   8298:   then handled in a rather straight-forward manner, taking the parser
                   8299:   through the "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
                   8300:   body</a>" and "<a href="#parsing-main-intr" title="insertion mode: in row">in
                   8301:   row</a>" insertion modes, after which the DOM looks as
                   8302:   follows:</p>
                   8303: 
1.159     mike     8304:   <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
                   8305:   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     8306:   <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
                   8307:   formatting elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in
                   8308:   it; and the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
                   8309:   mode: in row">in row</a>".</p>
                   8310: 
                   8311:   <p>The <code><a href="tabular-data.html#the-td-element">td</a></code> element start tag token, after putting a
                   8312:   <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
                   8313:   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
                   8314:   mode</a>).</p>
                   8315: 
1.159     mike     8316:   <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     8317:   no <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created to hold the resulting text
                   8318:   node:</p>
                   8319: 
1.159     mike     8320:   <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     8321:   handling them, the <a href="#stack-of-open-elements">stack of open elements</a> has on it the
1.159     mike     8322:   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     8323:   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
                   8324:   elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it (the
                   8325:   marker having been removed by the "td" end tag token); and the
                   8326:   <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion mode: in
                   8327:   table body">in table body</a>".</p>
                   8328: 
                   8329:   <p>Thus it is that the "bbb" character tokens are found. These
                   8330:   trigger the "<a href="#parsing-main-intabletext" title="insertion mode: in table text">in table
                   8331:   text</a>" insertion mode to be used (with the <a href="#original-insertion-mode">original
                   8332:   insertion mode</a> set to "<a href="#parsing-main-intbody" title="insertion mode: in table
                   8333:   body">in table body</a>"). The character tokens are collected,
                   8334:   and when the next token (the <code><a href="tabular-data.html#the-table-element">table</a></code> element end tag) is
                   8335:   seen, they are processed as a group. Since they are not all spaces,
                   8336:   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,
                   8337:   which defer to the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
                   8338:   body</a>" insertion mode but with <a href="#foster-parent" title="foster
                   8339:   parent">foster parenting</a>.</p>
                   8340: 
                   8341:   <p>When <a href="#reconstruct-the-active-formatting-elements" title="reconstruct the active formatting elements">the
                   8342:   active formatting elements are reconstructed</a>, a
                   8343:   <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created and <a href="#foster-parent" title="foster
                   8344:   parent">foster parented</a>, and then the "bbb" text node is
                   8345:   appended to it:</p>
                   8346: 
1.159     mike     8347:   <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
                   8348:   <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     8349:   <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
                   8350:   this doesn't match the resulting tree!); the <a href="#list-of-active-formatting-elements">list of active
                   8351:   formatting elements</a> has the new <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it;
                   8352:   and the <a href="#insertion-mode">insertion mode</a> is still "<a href="#parsing-main-intbody" title="insertion
                   8353:   mode: in table body">in table body</a>".</p>
                   8354: 
                   8355:   <p>Had the character tokens been only <a href="infrastructure.html#space-character" title="space
                   8356:   character">space characters</a> instead of "bbb", then those
                   8357:   <a href="infrastructure.html#space-character" title="space character">space characters</a> would just be
                   8358:   appended to the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element.</p>
                   8359: 
                   8360:   <p>Finally, the <code><a href="tabular-data.html#the-table-element">table</a></code> is closed by a "table" end
                   8361:   tag. This pops all the nodes from the <a href="#stack-of-open-elements">stack of open
                   8362:   elements</a> up to and including the <code><a href="tabular-data.html#the-table-element">table</a></code> element,
                   8363:   but it doesn't affect the <a href="#list-of-active-formatting-elements">list of active formatting
                   8364:   elements</a>, so the "ccc" character tokens after the table
                   8365:   result in yet another <code><a href="text-level-semantics.html#the-b-element">b</a></code> element being created, this
                   8366:   time after the table:</p>
                   8367: 
1.755     mike     8368:   <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     8369: 
                   8370:   <p><i>This section is non-normative.</i></p>
                   8371: 
                   8372:   <p>Consider the following markup, which for this example we will
                   8373:   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     8374:   content of an <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code> in another document with the
1.1       mike     8375:   <a href="infrastructure.html#url">URL</a> <code title="">http://example.com/outer</code>:</p>
                   8376: 
                   8377:   <pre>&lt;div id=a&gt;
                   8378:  &lt;script&gt;
                   8379:   var div = document.getElementById('a');
                   8380:   parent.document.body.appendChild(div);
                   8381:  &lt;/script&gt;
                   8382:  &lt;script&gt;
                   8383:   alert(document.URL);
                   8384:  &lt;/script&gt;
                   8385: &lt;/div&gt;
                   8386: &lt;script&gt;
                   8387:  alert(document.URL);
                   8388: &lt;/script&gt;</pre>
                   8389: 
                   8390:   <p>Up to the first "script" end tag, before the script is parsed,
                   8391:   the result is relatively straightforward:</p>
                   8392: 
1.306     mike     8393:   <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="">
                   8394:  </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     8395:   and its child <code><a href="semantics.html#script">script</a></code> element are gone:</p>
                   8396: 
1.810     mike     8397:   <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><a href="infrastructure.html#document">Document</a></code> of the
1.1       mike     8398:   aforementioned outer <a href="browsers.html#browsing-context">browsing context</a>. However, the
                   8399:   <a href="#stack-of-open-elements">stack of open elements</a> <em>still contains the
1.306     mike     8400:   <code><a href="semantics.html#the-div-element">div</a></code> element</em>.</p>
1.1       mike     8401: 
                   8402:   <p>Thus, when the second <code><a href="semantics.html#script">script</a></code> element is parsed, it
1.810     mike     8403:   is inserted <em>into the outer <code><a href="infrastructure.html#document">Document</a></code>
1.1       mike     8404:   object</em>.</p>
                   8405: 
1.794     mike     8406:   <p>This also means that the <a href="webappapis.html#script-s-global-object">script's global object</a> is
1.1       mike     8407:   the outer <a href="browsers.html#browsing-context">browsing context</a>'s <code><a href="browsers.html#window">Window</a></code>
                   8408:   object, <em>not</em> the <code><a href="browsers.html#window">Window</a></code> object inside the
1.159     mike     8409:   <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code>.</p>
1.1       mike     8410: 
                   8411:   <p class="note">This isn't a security problem since the script that
1.810     mike     8412:   moves the <code><a href="semantics.html#the-div-element">div</a></code> into the outer <code><a href="infrastructure.html#document">Document</a></code> can
                   8413:   only do so because the two <code><a href="infrastructure.html#document">Document</a></code> object have the
1.714     mike     8414:   same <a href="browsers.html#origin">origin</a>.</p>
1.1       mike     8415: 
                   8416:   <p>Thus, the first alert says "http://example.com/outer".</p>
                   8417: 
1.306     mike     8418:   <p>Once the <code><a href="semantics.html#the-div-element">div</a></code> element's end tag is parsed, the
                   8419:   <code><a href="semantics.html#the-div-element">div</a></code> element is popped off the stack, and so the next
1.810     mike     8420:   <code><a href="semantics.html#script">script</a></code> element is in the inner <code><a href="infrastructure.html#document">Document</a></code>:</p>
1.1       mike     8421: 
1.159     mike     8422:   <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     8423: 
                   8424: 
                   8425: 
                   8426: 
1.755     mike     8427:   <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     8428: 
                   8429:   <p>The following steps form the <dfn id="html-fragment-serialization-algorithm">HTML fragment serialization
                   8430:   algorithm</dfn>. The algorithm takes as input a DOM
1.810     mike     8431:   <code><a href="infrastructure.html#element">Element</a></code> or <code><a href="infrastructure.html#document">Document</a></code>, referred to as <var title="">the node</var>, and either returns a string or raises an
1.1       mike     8432:   exception.</p>
                   8433: 
                   8434:   <p class="note">This algorithm serializes the <em>children</em> of
                   8435:   the node being serialized, not the node itself.</p>
                   8436: 
                   8437:   <ol><li><p>Let <var title="">s</var> be a string, and initialize it to
                   8438:    the empty string.</p></li>
                   8439: 
                   8440:    <li>
                   8441: 
                   8442:     <p>For each child node of <var title="">the node</var>, in
                   8443:     <a href="infrastructure.html#tree-order">tree order</a>, run the following steps:
                   8444: 
                   8445:     </p><ol><li><p>Let <var title="">current node</var> be the child node
                   8446:      being processed.</p></li>
                   8447: 
                   8448:      <li>
                   8449: 
                   8450:       <p>Append the appropriate string from the following list to
                   8451:       <var title="">s</var>:</p>
                   8452: 
                   8453:       <dl class="switch"><dt>If <var title="">current node</var> is an <code title="">Element</code></dt>
                   8454: 
                   8455:        <dd>
                   8456: 
1.588     mike     8457:         <p>Append a U+003C LESS-THAN SIGN character character (&lt;),
                   8458:         followed by the element's tag name. (For nodes created by the
                   8459:         <a href="#html-parser">HTML parser</a> or <code title="">Document.createElement()</code>, the tag name will be
1.1       mike     8460:         lowercase.)</p>
                   8461: 
                   8462:         <p>For each attribute that the element has, append a U+0020
                   8463:         SPACE character, the attribute's name (which, for attributes
                   8464:         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     8465:         U+003D EQUALS SIGN character (=), a U+0022 QUOTATION MARK
                   8466:         character ("), the attribute's value, <a href="#escapingString" title="escaping a string">escaped as described below</a> in
                   8467:         <i>attribute mode</i>, and a second U+0022 QUOTATION MARK
                   8468:         character (").</p>
1.1       mike     8469: 
                   8470:         <p>While the exact order of attributes is UA-defined, and may
                   8471:         depend on factors such as the order that the attributes were
                   8472:         given in the original markup, the sort order must be stable,
                   8473:         such that consecutive invocations of this algorithm serialize an
                   8474:         element's attributes in the same order.</p>
                   8475: 
1.588     mike     8476:         <p>Append a U+003E GREATER-THAN SIGN character (&gt;).</p>
1.1       mike     8477: 
                   8478:         <p>If <var title="">current node</var> is an
1.5       mike     8479:         <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     8480:         <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     8481:         <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>,
                   8482:         <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     8483:         <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     8484:         <code><a href="obsolete.html#wbr">wbr</a></code> element, then continue on to the next child
1.589     mike     8485:         node at this point.</p> <!-- also, i guess: image and isindex,
                   8486:         but we don't list those because we don't consider those
                   8487:         "elements", more "macros", and thus we should never serialize
                   8488:         them -->
1.1       mike     8489: 
                   8490:         <p>If <var title="">current node</var> is a <code><a href="semantics.html#the-pre-element">pre</a></code>,
1.42      mike     8491:         <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     8492:         a U+000A LINE FEED (LF) character.</p>
                   8493: 
                   8494:         <p>Append the value of running the <a href="#html-fragment-serialization-algorithm">HTML fragment
                   8495:         serialization algorithm</a> on the <var title="">current
                   8496:         node</var> element (thus recursing into this algorithm for
1.588     mike     8497:         that element), followed by a U+003C LESS-THAN SIGN character
                   8498:         (&lt;), a U+002F SOLIDUS character (/), the element's tag name
                   8499:         again, and finally a U+003E GREATER-THAN SIGN character
                   8500:         (&gt;).</p>
1.1       mike     8501: 
                   8502:        </dd>
                   8503: 
                   8504: 
                   8505:        <dt>If <var title="">current node</var> is a <code title="">Text</code> or <code title="">CDATASection</code>
                   8506:        node</dt>
                   8507: 
                   8508:        <dd>
                   8509: 
1.19      mike     8510:         <p>If the parent of <var title="">current node</var> is a
1.42      mike     8511:         <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     8512:         <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     8513:         <code><a href="obsolete.html#noframes">noframes</a></code>, or <code><a href="obsolete.html#plaintext">plaintext</a></code> element, or
                   8514:         if the parent of <var title="">current node</var> is
1.794     mike     8515:         <code><a href="semantics.html#the-noscript-element">noscript</a></code> element and <a href="webappapis.html#concept-n-script" title="concept-n-script">scripting is enabled</a> for the
1.222     mike     8516:         node, then append the value of <var title="">current
                   8517:         node</var>'s <code title="">data</code> IDL attribute
                   8518:         literally.</p>
1.1       mike     8519: 
                   8520:         <p>Otherwise, append the value of <var title="">current
1.192     mike     8521:         node</var>'s <code title="">data</code> IDL attribute, <a href="#escapingString" title="escaping a string">escaped as described
1.1       mike     8522:         below</a>.</p>
                   8523: 
                   8524:        </dd>
                   8525: 
                   8526: 
                   8527:        <dt>If <var title="">current node</var> is a <code title="">Comment</code></dt>
                   8528: 
                   8529:        <dd>
                   8530: 
                   8531:         <p>Append the literal string <code>&lt;!--</code> (U+003C
                   8532:         LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS,
1.192     mike     8533:         U+002D HYPHEN-MINUS), followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1       mike     8534:         attribute, followed by the literal string <code>--&gt;</code>
                   8535:         (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN
                   8536:         SIGN).</p>
                   8537: 
                   8538:        </dd>
                   8539: 
                   8540: 
                   8541:        <dt>If <var title="">current node</var> is a <code title="">ProcessingInstruction</code></dt>
                   8542: 
                   8543:        <dd>
                   8544: 
                   8545:         <p>Append the literal string <code>&lt;?</code> (U+003C
                   8546:         LESS-THAN SIGN, U+003F QUESTION MARK), followed by the value
1.192     mike     8547:         of <var title="">current node</var>'s <code title="">target</code> IDL attribute, followed by a single
                   8548:         U+0020 SPACE character, followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1       mike     8549:         attribute, followed by a single U+003E GREATER-THAN SIGN
1.464     mike     8550:         character (&gt;).</p>
1.1       mike     8551: 
                   8552:        </dd>
                   8553: 
                   8554: 
                   8555:        <dt>If <var title="">current node</var> is a <code title="">DocumentType</code></dt>
                   8556: 
                   8557:        <dd>
                   8558: 
                   8559:         <p>Append the literal string <code>&lt;!DOCTYPE</code> (U+003C
                   8560:         LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+0044 LATIN CAPITAL
                   8561:         LETTER D, U+004F LATIN CAPITAL LETTER O, U+0043 LATIN CAPITAL
                   8562:         LETTER C, U+0054 LATIN CAPITAL LETTER T, U+0059 LATIN CAPITAL
                   8563:         LETTER Y, U+0050 LATIN CAPITAL LETTER P, U+0045 LATIN CAPITAL
                   8564:         LETTER E), followed by a space (U+0020 SPACE), followed by the
1.192     mike     8565:         value of <var title="">current node</var>'s <code title="">name</code> IDL attribute, followed by the literal
1.1       mike     8566:         string <code>&gt;</code> (U+003E GREATER-THAN SIGN).</p>
                   8567: 
                   8568:        </dd>
                   8569: 
                   8570: 
                   8571:       </dl><p>Other node types (e.g. <code title="">Attr</code>) cannot
                   8572:       occur as children of elements. If, despite this, they somehow do
                   8573:       occur, this algorithm must raise an
                   8574:       <code><a href="infrastructure.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception.</p>
                   8575: 
                   8576:      </li>
                   8577: 
                   8578:     </ol></li>
                   8579: 
                   8580:    <li><p>The result of the algorithm is the string <var title="">s</var>.</p></li>
                   8581: 
                   8582:   </ol><p><dfn id="escapingString">Escaping a string</dfn> (for the
                   8583:   purposes of the algorithm above) consists of replacing any
                   8584:   occurrences of the "<code title="">&amp;</code>" character by the
                   8585:   string "<code title="">&amp;amp;</code>", any occurrences of the
                   8586:   U+00A0 NO-BREAK SPACE character by the string "<code title="">&amp;nbsp;</code>", and, if the algorithm was invoked in
                   8587:   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
                   8588:   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>
                   8589: 
                   8590:   <p class="note">Entity reference nodes are <a href="infrastructure.html#entity-references">assumed to be expanded</a> by the user
                   8591:   agent, and are therefore not covered in the algorithm above.</p>
                   8592: 
                   8593:   <p class="note">It is possible that the output of this algorithm, if
                   8594:   parsed with an <a href="#html-parser">HTML parser</a>, will not return the
                   8595:   original tree structure. For instance, if a <code><a href="forms.html#the-textarea-element">textarea</a></code>
                   8596:   element to which a <code title="">Comment</code> node has been
                   8597:   appended is serialized and the output is then reparsed, the comment
                   8598:   will end up being displayed in the text field. Similarly, if, as a
                   8599:   result of DOM manipulation, an element contains a comment that
                   8600:   contains the literal string "<code title="">--&gt;</code>", then
                   8601:   when the result of serializing the element is parsed, the comment
                   8602:   will be truncated at that point and the rest of the comment will be
                   8603:   interpreted as markup. More examples would be making a
                   8604:   <code><a href="semantics.html#script">script</a></code> element contain a text node with the text string
                   8605:   "<code>&lt;/script&gt;</code>", or having a <code><a href="semantics.html#the-p-element">p</a></code> element that
                   8606:   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
                   8607:   <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> would imply the end
                   8608:   tag for the <code><a href="semantics.html#the-p-element">p</a></code>).</p>
                   8609: 
                   8610: 
1.755     mike     8611:   <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     8612: 
                   8613:   <p>The following steps form the <dfn id="html-fragment-parsing-algorithm">HTML fragment parsing
                   8614:   algorithm</dfn>. The algorithm optionally takes as input an
1.810     mike     8615:   <code><a href="infrastructure.html#element">Element</a></code> node, referred to as the <var title="">context</var> element, which gives the context for the
1.1       mike     8616:   parser, as well as <var title="">input</var>, a string to parse, and
                   8617:   returns a list of zero or more nodes.</p>
                   8618: 
                   8619:   <p class="note">Parts marked <dfn id="fragment-case">fragment case</dfn> in algorithms
                   8620:   in the parser section are parts that only occur if the parser was
                   8621:   created for the purposes of this algorithm (and with a <var title="">context</var> element). The algorithms have been annotated
                   8622:   with such markings for informational purposes only; such markings
                   8623:   have no normative weight. If it is possible for a condition
                   8624:   described as a <a href="#fragment-case">fragment case</a> to occur even when the
                   8625:   parser wasn't created for the purposes of handling this algorithm,
                   8626:   then that is an error in the specification.</p>
                   8627: 
                   8628:   <ol><li>
                   8629: 
1.810     mike     8630:     <p>Create a new <code><a href="infrastructure.html#document">Document</a></code> node, and mark it as being
1.1       mike     8631:     an <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
                   8632: 
                   8633:    </li>
                   8634: 
                   8635:    <li>
                   8636: 
                   8637:     <p>If there is a <var title="">context</var> element, and the
1.810     mike     8638:     <code><a href="infrastructure.html#document">Document</a></code> of the <var title="">context</var> element
                   8639:     is in <a href="dom.html#quirks-mode">quirks mode</a>, then let the <code><a href="infrastructure.html#document">Document</a></code>
                   8640:     be in <a href="dom.html#quirks-mode">quirks mode</a>. Otherwise, if there is a <var title="">context</var> element, and the <code><a href="infrastructure.html#document">Document</a></code> of
1.880     mike     8641:     the <var title="">context</var> element is in <a href="dom.html#limited-quirks-mode">limited-quirks
1.810     mike     8642:     mode</a>, then let the <code><a href="infrastructure.html#document">Document</a></code> be in
1.880     mike     8643:     <a href="dom.html#limited-quirks-mode">limited-quirks mode</a>. Otherwise, leave the
                   8644:     <code><a href="infrastructure.html#document">Document</a></code> in <a href="dom.html#no-quirks-mode">no-quirks mode</a>.</p>
1.1       mike     8645: 
                   8646:    </li>
                   8647: 
                   8648:    <li>
                   8649: 
                   8650:     <p>Create a new <a href="#html-parser">HTML parser</a>, and associate it with
1.810     mike     8651:     the just created <code><a href="infrastructure.html#document">Document</a></code> node.</p>
1.1       mike     8652: 
                   8653:    </li>
                   8654: 
                   8655:    <li>
                   8656: 
                   8657:     <p>If there is a <var title="">context</var> element, run these
                   8658:     substeps:</p>
                   8659: 
                   8660:     <ol><li>
                   8661: 
1.541     mike     8662:       <p>Set the state of the <a href="#html-parser">HTML parser</a>'s
                   8663:       <a href="#tokenization">tokenization</a> stage as follows:</p>
1.1       mike     8664: 
1.159     mike     8665:       <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     8666:        element</dt>
                   8667: 
1.541     mike     8668:        <dd>Switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1       mike     8669: 
                   8670: 
1.672     mike     8671:        <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>,
                   8672:        <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     8673:        <code><a href="obsolete.html#noframes">noframes</a></code> element</dt>
1.1       mike     8674: 
1.541     mike     8675:        <dd>Switch the tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1       mike     8676: 
                   8677: 
1.672     mike     8678:        <dt>If it is a <code><a href="semantics.html#script">script</a></code> element</dt>
                   8679: 
                   8680:        <dd>Switch the tokenizer to the <a href="#script-data-state">script data state</a>.</dd>
                   8681: 
                   8682: 
1.1       mike     8683:        <dt>If it is a <code><a href="semantics.html#the-noscript-element">noscript</a></code> element</dt>
                   8684: 
1.541     mike     8685:        <dd>If the <a href="#scripting-flag">scripting flag</a> is enabled, switch the
                   8686:        tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>.  Otherwise,
                   8687:        leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1       mike     8688: 
                   8689: 
1.42      mike     8690:        <dt>If it is a <code><a href="obsolete.html#plaintext">plaintext</a></code> element</dt>
1.1       mike     8691: 
1.541     mike     8692:        <dd>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT
                   8693:        state</a>.</dd>
1.1       mike     8694: 
                   8695: 
                   8696:        <dt>Otherwise</dt>
                   8697: 
1.541     mike     8698:        <dd>Leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1       mike     8699: 
1.672     mike     8700:       </dl><p class="note">For performance reasons, an implementation that
1.756     mike     8701:       does not report errors and that uses the actual state machine
                   8702:       described in this specification directly could use the PLAINTEXT
                   8703:       state instead of the RAWTEXT and script data states where those
                   8704:       are mentioned in the list above. Except for rules regarding
                   8705:       parse errors, they are equivalent, since there is no
                   8706:       <a href="#appropriate-end-tag-token">appropriate end tag token</a> in the fragment case, yet
                   8707:       they involve far fewer state transitions.</p>
1.672     mike     8708: 
                   8709:      </li>
1.1       mike     8710: 
                   8711:      <li>
                   8712: 
1.159     mike     8713:       <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     8714:       with no attributes.</p>
                   8715: 
                   8716:      </li>
                   8717: 
                   8718:      <li>
                   8719: 
                   8720:       <p>Append the element <var title="">root</var> to the
1.810     mike     8721:       <code><a href="infrastructure.html#document">Document</a></code> node created above.</p>
1.1       mike     8722: 
                   8723:      </li>
                   8724: 
                   8725:      <li>
                   8726: 
                   8727:       <p>Set up the parser's <a href="#stack-of-open-elements">stack of open elements</a> so that
                   8728:       it contains just the single element <var title="">root</var>.</p>
                   8729: 
                   8730:      </li>
                   8731: 
                   8732:      <li>
                   8733: 
                   8734:       <p><a href="#reset-the-insertion-mode-appropriately" title="reset the insertion mode appropriately">Reset the
                   8735:       parser's insertion mode appropriately</a>.</p>
                   8736: 
                   8737:       <p class="note">The parser will reference the <var title="">context</var> element as part of that algorithm.</p>
                   8738: 
                   8739:      </li>
                   8740: 
                   8741:      <li>
                   8742: 
                   8743:       <p>Set the parser's <a href="#form-element-pointer"><code>form</code> element pointer</a>
                   8744:       to the nearest node to the <var title="">context</var> element
                   8745:       that is a <code><a href="forms.html#the-form-element">form</a></code> element (going straight up the
                   8746:       ancestor chain, and including the element itself, if it is a
                   8747:       <code><a href="forms.html#the-form-element">form</a></code> element), or, if there is no such
                   8748:       <code><a href="forms.html#the-form-element">form</a></code> element, to null.</p>
                   8749: 
                   8750:      </li>
                   8751: 
                   8752:     </ol></li>
                   8753: 
                   8754:    <li>
                   8755: 
                   8756:     <p>Place into the <a href="#the-input-stream">input stream</a> for the <a href="#html-parser">HTML
                   8757:     parser</a> just created the <var title="">input</var>. The
                   8758:     encoding <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
                   8759:     <i>irrelevant</i>.</p>
                   8760: 
                   8761:    </li>
                   8762: 
                   8763:    <li>
                   8764: 
                   8765:     <p>Start the parser and let it run until it has consumed all the
                   8766:     characters just inserted into the input stream.</p>
                   8767: 
                   8768:    </li>
                   8769: 
                   8770:    <li>
                   8771: 
                   8772:     <p>If there is a <var title="">context</var> element, return the
                   8773:     child nodes of <var title="">root</var>, in <a href="infrastructure.html#tree-order">tree
                   8774:     order</a>.</p>
                   8775: 
1.810     mike     8776:     <p>Otherwise, return the children of the <code><a href="infrastructure.html#document">Document</a></code>
1.1       mike     8777:     object, in <a href="infrastructure.html#tree-order">tree order</a>.</p>
                   8778: 
                   8779:    </li>
                   8780: 
1.123     mike     8781:   </ol></div></body></html>

Webmaster