Annotation of html5/spec/syntax.html, revision 1.973
1.872 mike 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
1.894 mike 2: <!DOCTYPE html>
1.755 mike 3: <!-- when publishing, change bits marked ZZZ --><html lang="en-US-x-Hixie"><head><title>8 The HTML syntax — HTML 5</title><style type="text/css">
1.1 mike 4: pre { margin-left: 2em; white-space: pre-wrap; }
5: h2 { margin: 3em 0 1em 0; }
6: h3 { margin: 2.5em 0 1em 0; }
7: h4 { margin: 2.5em 0 0.75em 0; }
8: h5, h6 { margin: 2.5em 0 1em; }
9: h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
10: h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
11: p { margin: 1em 0; }
12: hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
13: dl, dd { margin-top: 0; margin-bottom: 0; }
14: dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
15: dt + dt { margin-top: 0; }
16: dd dt { margin-top: 0.25em; margin-bottom: 0; }
17: dd p { margin-top: 0; }
18: dd dl + p { margin-top: 1em; }
19: dd table + p { margin-top: 1em; }
20: p + * > li, dd li { margin: 1em 0; }
21: dt, dfn { font-weight: bold; font-style: normal; }
22: dt dfn { font-style: italic; }
23: pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
24: pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
25: pre em { font-weight: bolder; font-style: normal; }
26: @media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
27: var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
28: table { border-collapse: collapse; border-style: hidden hidden none hidden; }
29: table thead { border-bottom: solid; }
30: table tbody th:first-child { border-left: solid; }
1.475 mike 31: table tbody th { text-align: left; }
1.1 mike 32: table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
33: blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
34:
35: .bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
36: .matrix, .matrix td { border: none; text-align: right; }
37: .matrix { margin-left: 2em; }
38: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
39: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
40: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
41:
42: .toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
43: img.extra { float: right; }
44: pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; }
45: pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
46: pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
47: pre.css:first-line { color: #AAAA50; }
1.840 mike 48: dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
1.1 mike 49: hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
50: dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
51: dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
52: dl.domintro dd p { margin: 0.5em 0; }
53: dl.switch { padding-left: 2em; }
54: dl.switch > dt { text-indent: -1.5em; }
55: dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
56: dl.triple { padding: 0 0 0 1em; }
57: dl.triple dt, dl.triple dd { margin: 0; display: inline }
58: dl.triple dt:after { content: ':'; }
59: dl.triple dd:after { content: '\A'; white-space: pre; }
60: .diff-old { text-decoration: line-through; color: silver; background: transparent; }
61: .diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
62: a .diff-new { border-bottom: 1px blue solid; }
63:
64: h2 { page-break-before: always; }
65: h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
66: h1 + h2, hr + h2.no-toc { page-break-before: auto; }
67:
68: p > span:not([title=""]):not([class="XXX"]):not([class="impl"]), li > span:not([title=""]):not([class="XXX"]):not([class="impl"]) { border-bottom: solid #9999CC; }
69:
70: div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
71: div.head p { margin: 0; }
72: div.head h1 { margin: 0; }
73: div.head .logo { float: right; margin: 0 1em; }
74: div.head .logo img { border: none } /* remove border from top image */
75: div.head dl { margin: 1em 0; }
1.671 mike 76: div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }
1.1 mike 77:
78: body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
79: body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
80: body > .toc > li > * { margin-bottom: 0.5em; }
81: body > .toc > li > * > li > * { margin-bottom: 0.25em; }
82: .toc, .toc li { list-style: none; }
83:
84: .brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
85: .brief li { margin: 0; padding: 0; }
86: .brief li p { margin: 0; padding: 0; }
87:
88: .category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
89: .category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
90: .category-list li { display: inline; }
91: .category-list li:not(:last-child)::after { content: ', '; }
92: .category-list li > span, .category-list li > a { text-transform: lowercase; }
93: .category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
94:
95: .XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
96: .XXX > :first-child { margin-top: 0; }
97: p .XXX { line-height: 3em; }
1.159 mike 98: .annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
99: .annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
100: .annotation :link, .annotation :visited { color: inherit; }
101: .annotation :link:hover, .annotation :visited:hover { background: transparent; }
102: .annotation span { border: none ! important; }
1.1 mike 103: .note { color: green; background: transparent; font-family: sans-serif; }
104: .warning { color: red; background: transparent; }
105: .note, .warning { font-weight: bolder; font-style: italic; }
106: p.note, div.note { padding: 0.5em 2em; }
107: span.note { padding: 0 2em; }
108: .note p:first-child, .warning p:first-child { margin-top: 0; }
109: .note p:last-child, .warning p:last-child { margin-bottom: 0; }
110: .warning:before { font-style: normal; }
111: p.note:before { content: 'Note: '; }
112: p.warning:before { content: '\26A0 Warning! '; }
113:
114: .bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
115: .bookkeeping { font-size: 0.8em; margin: 2em 0; }
116: .bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
117:
118: h4 { position: relative; z-index: 3; }
119: h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
120: .element {
121: background: #EEEEFF;
122: color: black;
123: margin: 0 0 1em 0.15em;
124: padding: 0 1em 0.25em 0.75em;
125: border-left: solid #9999FF 0.25em;
126: position: relative;
127: z-index: 1;
128: }
129: .element:before {
130: position: absolute;
131: z-index: 2;
132: top: 0;
133: left: -1.15em;
134: height: 2em;
135: width: 0.9em;
136: background: #EEEEFF;
137: content: ' ';
138: border-style: none none solid solid;
139: border-color: #9999FF;
140: border-width: 0.25em;
141: }
142:
1.149 mike 143: .example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
144: td > .example:only-child { margin: 0 0 0 0.1em; }
1.1 mike 145:
146: ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
147: ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
148: ul.domTree li li { list-style: none; }
149: 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; }
150: 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; }
151: ul.domTree span { font-style: italic; font-family: serif; }
152: ul.domTree .t1 code { color: purple; font-weight: bold; }
153: ul.domTree .t2 { font-style: normal; font-family: monospace; }
154: ul.domTree .t2 .name { color: black; font-weight: bold; }
155: ul.domTree .t2 .value { color: blue; font-weight: normal; }
156: ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
157: ul.domTree .t7 code, .domTree .t8 code { color: green; }
158: ul.domTree .t10 code { color: teal; }
159:
1.736 mike 160: body.dfnEnabled dfn { cursor: pointer; }
161: .dfnPanel {
162: display: inline;
163: position: absolute;
164: z-index: 10;
165: height: auto;
166: width: auto;
167: padding: 0.5em 0.75em;
168: font: small sans-serif, Droid Sans Fallback;
169: background: #DDDDDD;
170: color: black;
171: border: outset 0.2em;
172: }
173: .dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
174: .dfnPanel :link, .dfnPanel :visited { color: black; }
175: .dfnPanel p { font-weight: bolder; }
176: .dfnPanel * + p { margin-top: 0.25em; }
177: .dfnPanel li { list-style-position: inside; }
178:
1.671 mike 179: #configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
180: #configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
181: #configUI p label { display: block; }
182: #configUI #updateUI, #configUI .loginUI { text-align: center; }
183: #configUI input[type=button] { display: block; margin: auto; }
1.267 mike 184: </style><style type="text/css">
185:
1.292 mike 186: .applies thead th > * { display: block; }
187: .applies thead code { display: block; }
188: .applies tbody th { whitespace: nowrap; }
189: .applies td { text-align: center; }
190: .applies .yes { background: yellow; }
191:
1.267 mike 192: .matrix, .matrix td { border: none; text-align: right; }
193: .matrix { margin-left: 2em; }
194:
195: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
196: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
197: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
198:
199: #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
200: #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
201: #table-example-1 caption { padding-bottom: 0.5em; }
202: #table-example-1 thead, #table-example-1 tbody { border: none; }
203: #table-example-1 th, #table-example-1 td { border: solid thin; }
204: #table-example-1 th { font-weight: normal; }
205: #table-example-1 td { border-style: none solid; vertical-align: top; }
206: #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
207: #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
208: #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
209: #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
210: #table-example-1 tbody td:first-child::after { content: leader(". "); }
211: #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
212: #table-example-1 tbody td:first-child + td { width: 10em; }
213: #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
214: #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
215:
216: .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
217: .apple-table-examples * { font-family: "Times", serif; }
218: .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
219: .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
220: .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
221: .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
222: .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
223: .apple-table-examples td { text-align: right; vertical-align: top; }
224: .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
225: .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
226: .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
227: .apple-table-examples sup { line-height: 0; }
228:
1.724 mike 229: .details-example img { vertical-align: top; }
230:
1.882 mike 231: #named-character-references-table {
232: font-size: 0.6em;
233: column-width: 28em;
234: column-gap: 1em;
235: -moz-column-width: 28em;
236: -moz-column-gap: 1em;
237: -webkit-column-width: 28em;
238: -webkit-column-gap: 1em;
239: }
240: #named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
241: #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; }
242:
1.872 mike 243: </style><style type="text/css">
1.881 mike 244: .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; }
245: </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 246: function getCookie(name) {
247: var params = location.search.substr(1).split("&");
248: for (var index = 0; index < params.length; index++) {
249: if (params[index] == name)
250: return "1";
251: var data = params[index].split("=");
252: if (data[0] == name)
253: return unescape(data[1]);
254: }
255: var cookies = document.cookie.split("; ");
256: for (var index = 0; index < cookies.length; index++) {
257: var data = cookies[index].split("=");
258: if (data[0] == name)
259: return unescape(data[1]);
260: }
261: return null;
262: }
263: function load(script) {
264: var e = document.createElement('script');
265: e.setAttribute('src', 'http://www.whatwg.org/specs/web-apps/current-work/' + script + '?' + encodeURIComponent(location) + '&' + encodeURIComponent(document.referrer));
266: document.body.appendChild(e);
267: }
268: function init() {
269: if (location.search == '?slow-browser')
270: return;
271: var configUI = document.createElement('div');
272: configUI.id = 'configUI';
273: document.body.appendChild(configUI);
274: // load('reviewer.js'); // would need cross-site XHR
275: if (document.getElementById('head'))
276: load('toc.js');
277: load('styler.js');
278: // load('updater.js'); // would need cross-site XHR
1.724 mike 279: load('dfn.js'); // doesn't support split-out specs, but, oh well.
1.671 mike 280: // load('status.js'); // would need cross-site XHR
281: if (getCookie('profile') == '1')
282: document.getElementsByTagName('h2')[0].textContent += '; load: ' + (new Date() - loadTimer) + 'ms';
283: fixBrokenLink();
284: }
1.905 mike 285: </script><link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel="stylesheet" type="text/css">
1.873 mike 286: <script src="link-fixup.js" type="text/javascript"></script>
1.755 mike 287: <link href="editing.html" title="7 User interaction" rel="prev">
1.2 mike 288: <link href="spec.html#contents" title="Table of contents" rel="index">
1.755 mike 289: <link href="named-character-references.html" title="8.5 Named character references" rel="next">
1.671 mike 290: </head><body onload="fixBrokenLink(); init()"><div class="head" id="head">
1.1 mike 291: <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 292: <h1>HTML5</h1>
1.973 ! mike 293: <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.4069.</p>
1.905 mike 294:
1.885 mike 295:
1.874 mike 296: </div><div>
1.755 mike 297: <a href="editing.html">← 7 User interaction</a> –
1.2 mike 298: <a href="spec.html#contents">Table of contents</a> –
1.755 mike 299: <a href="named-character-references.html">8.5 Named character references →</a>
1.874 mike 300: </div>
1.1 mike 301:
1.755 mike 302: <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 303: labeled with an <a href="infrastructure.html#html-mime-type">HTML MIME type</a>. Rules for XML resources
304: are discussed in the section below entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
1.895 mike 305: 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 306:
307: <p><i>This section only applies to documents, authoring tools, and
308: markup generators. In particular, it does not apply to conformance
309: checkers; conformance checkers must use the requirements given in
310: the next section ("parsing HTML documents").</i></p>
311:
1.123 mike 312: </div><p>Documents must consist of the following parts, in the given
313: order:</p><ol><li>Optionally, a single U+FEFF BYTE ORDER MARK (BOM) character.</li>
1.1 mike 314:
315: <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
316: <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
317:
318: <li>A <a href="#syntax-doctype" title="syntax-doctype">DOCTYPE</a>.
319:
320: </li><li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
321: <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
322:
1.159 mike 323: <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 324:
325: <li>Any number of <a href="#syntax-comments" title="syntax-comments">comments</a> and
326: <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
327:
328: </ol><p>The various types of content mentioned above are described in the
1.123 mike 329: 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 330: declarations</a> are to be serialized, as discussed in the
1.123 mike 331: section on that topic.</p><div class="note">
1.1 mike 332:
1.159 mike 333: <p>Space characters before the root <code><a href="semantics.html#the-html-element-0">html</a></code> element, and
334: space characters at the start of the <code><a href="semantics.html#the-html-element-0">html</a></code> element and
335: before the <code><a href="semantics.html#the-head-element-0">head</a></code> element, will be dropped when the
1.1 mike 336: document is parsed; space characters <em>after</em> the root
1.159 mike 337: <code><a href="semantics.html#the-html-element-0">html</a></code> element will be parsed as if they were at the end
338: of the <code><a href="semantics.html#the-body-element-0">body</a></code> element. Thus, space characters around the
1.1 mike 339: root element do not round-trip.</p>
340:
341: <p>It is suggested that newlines be inserted after the DOCTYPE,
342: after any comments that are before the root element, after the
1.159 mike 343: <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
344: that are inside the <code><a href="semantics.html#the-html-element-0">html</a></code> element but before the
345: <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1 mike 346:
1.123 mike 347: </div><p>Many strings in the HTML syntax (e.g. the names of elements and
1.1 mike 348: their attributes) are case-insensitive, but only for characters in
1.547 mike 349: the ranges U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL
350: LETTER Z) and U+0061 to U+007A (LATIN SMALL LETTER A to LATIN SMALL
1.1 mike 351: LETTER Z). For convenience, in this section this is just referred to
1.895 mike 352: 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
1.884 mike 353: useless but nonetheless --> required preamble.</p><p class="note">DOCTYPEs are required for legacy reasons. When
1.1 mike 354: omitted, browsers tend to use a different rendering mode that is
355: incompatible with some specifications. Including the DOCTYPE in a
356: document ensures that the browser makes a best-effort attempt at
1.123 mike 357: following the relevant specifications.</p><p>A DOCTYPE must consist of the following characters, in this
1.882 mike 358: 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=""><!DOCTYPE</code>".</li>
1.1 mike 359: <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
360: <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 361: <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 362: <li>Zero or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
1.588 mike 363: <li>A U+003E GREATER-THAN SIGN character (>).</li>
1.1 mike 364: </ol><p class="note">In other words, <code><!DOCTYPE HTML></code>,
1.861 mike 365: case-insensitively.</p><hr><p>For the purposes of HTML generators that cannot output HTML
1.1 mike 366: markup with the short DOCTYPE "<code title=""><!DOCTYPE
367: HTML></code>", a <dfn id="doctype-legacy-string">DOCTYPE legacy string</dfn> may be inserted
368: into the DOCTYPE (in the position defined above). This string must
1.123 mike 369: 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 370: <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 371: <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
1.1 mike 372: <li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>quote mark</i>).</li>
1.465 mike 373: <li>The literal string "<code><a href="infrastructure.html#about:legacy-compat">about:legacy-compat</a></code>".</li>
1.856 mike 374: <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 375: </ol><p class="note">In other words, <code><!DOCTYPE HTML SYSTEM
376: "about:legacy-compat"></code> or <code><!DOCTYPE HTML SYSTEM
377: 'about:legacy-compat'></code>, case-insensitively except for the bit
1.724 mike 378: 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 379: the document is generated from a system that cannot output the
1.861 mike 380: shorter string.</p><hr><!-- see the parser section before changing this bit --><p>To help authors transition from HTML4 and XHTML1, an
381: <dfn id="obsolete-permitted-doctype-string">obsolete permitted DOCTYPE string</dfn> can be inserted into
382: the DOCTYPE (in the position defined above). This string must
383: consist of:</p><ol class="brief"><li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
384: <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>
385: <li>One or more <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
386: <li>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>first quote mark</i>).</li>
387: <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>
388: <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>
389: <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>
390: <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>
391: <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>
392: <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>
393: </ol><table><caption>
394: Allowed values for public and system identifiers in an <a href="#obsolete-permitted-doctype-string">obsolete permitted DOCTYPE string</a>.
395: </caption>
396: <thead><tr><th> Public identifier
397: </th><th> System identifier
398: </th></tr></thead><tbody><tr><td> <code title="">-//W3C//DTD HTML 4.0//EN</code>
399: </td><td>
400: </td></tr><tr><td> <code title="">-//W3C//DTD HTML 4.0//EN</code>
401: </td><td> <code title="">http://www.w3.org/TR/REC-html40/strict.dtd</code>
402: </td></tr><tr><td> <code title="">-//W3C//DTD HTML 4.01//EN</code>
403: </td><td>
404: </td></tr><tr><td> <code title="">-//W3C//DTD HTML 4.01//EN</code>
405: </td><td> <code title="">http://www.w3.org/TR/html4/strict.dtd</code>
406: </td></tr><tr><td> <code title="">-//W3C//DTD XHTML 1.0 Strict//EN</code>
407: </td><td> <code title="">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</code>
408: </td></tr><tr><td> <code title="">-//W3C//DTD XHTML 1.1//EN</code>
409: </td><td> <code title="">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</code>
410: </td></tr></tbody></table><p>A <a href="#syntax-doctype" title="syntax-doctype">DOCTYPE</a> containing an
411: <a href="#obsolete-permitted-doctype-string">obsolete permitted DOCTYPE string</a> is an <dfn id="obsolete-permitted-doctype">obsolete
412: permitted DOCTYPE</dfn>. Authors should not use <a href="#obsolete-permitted-doctype" title="obsolete permitted DOCTYPE">obsolete permitted
1.895 mike 413: 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 414: <a href="#raw-text-elements">raw text elements</a>, <a href="#rcdata-elements">RCDATA elements</a>,
415: <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 416:
1.893 mike 417: <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="text-level-semantics.html#the-br-element">br</a></code>,
1.159 mike 418: <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>,
419: <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 420: <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.973 ! mike 421: <code><a href="text-level-semantics.html#the-param-element">param</a></code>, <code><a href="video.html#the-source-element">source</a></code>, <code><a href="video.html#the-track-element">track</a></code>,
! 422: <code><a href="text-level-semantics.html#the-wbr-element">wbr</a></code></dd>
1.1 mike 423:
1.373 mike 424: <dt><dfn id="raw-text-elements">Raw text elements</dfn></dt>
1.1 mike 425:
426: <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 427: noscript don't count as raw text for syntax purposes -->
1.1 mike 428:
1.373 mike 429: <dt><dfn id="rcdata-elements">RCDATA elements</dfn></dt>
1.1 mike 430:
1.159 mike 431: <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 432:
1.373 mike 433: <dt><dfn id="foreign-elements">Foreign elements</dfn></dt>
1.1 mike 434:
1.724 mike 435: <dd>Elements from the <a href="infrastructure.html#mathml-namespace">MathML namespace</a>
436: and the <a href="infrastructure.html#svg-namespace">SVG namespace</a>.</dd>
1.1 mike 437:
1.373 mike 438: <dt><dfn id="normal-elements">Normal elements</dfn></dt>
1.1 mike 439:
440: <dd>All other allowed <a href="infrastructure.html#html-elements">HTML elements</a> are normal
441: elements.</dd>
442:
443: </dl><p><dfn id="syntax-tags" title="syntax-tags">Tags</dfn> are used to delimit the start
1.373 mike 444: and end of elements in the markup. <a href="#raw-text-elements" title="raw text
445: elements">Raw text</a>, <a href="#rcdata-elements" title="RCDATA
446: elements">RCDATA</a>, and <a href="#normal-elements" title="normal
447: elements">normal</a> elements have a <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> to indicate where they
448: begin, and an <a href="#syntax-end-tag" title="syntax-end-tag">end tag</a> to
449: indicate where they end. The start and end tags of certain
450: <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 451: later. Those that cannot be omitted must not be omitted. <a href="#void-elements">Void
452: elements</a> only have a start tag; end tags must not be
1.373 mike 453: specified for <a href="#void-elements">void elements</a>. <a href="#foreign-elements">Foreign
454: elements</a> must either have a start tag and an end tag, or a
455: start tag that is marked as self-closing, in which case they must
456: not have an end tag.</p><p>The contents of the element must be placed between just after the
1.1 mike 457: start tag (which <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied,
458: in certain cases</a>) and just before the end tag (which again,
459: <a href="#syntax-tag-omission" title="syntax-tag-omission">might be implied in certain
460: cases</a>). The exact allowed contents of each individual element
461: depends on the content model of that element, as described earlier
462: in this specification. Elements must not contain content that their
463: content model disallows. In addition to the restrictions placed on
464: the contents by those content models, however, the five types of
1.123 mike 465: 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 466: no end tag, no content can be put between the start tag and the end
1.373 mike 467: 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
468: 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
469: must not contain an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.
1.1 mike 470: There are also <a href="#cdata-rcdata-restrictions">further
1.373 mike 471: restrictions</a> described below.</p><p><a href="#foreign-elements">Foreign elements</a> whose start tag is marked as
472: self-closing can't have any contents (since, again, as there's no
473: end tag, no content can be put between the start tag and the end
474: tag). <a href="#foreign-elements">Foreign elements</a> whose start tag is <em>not</em>
475: 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 476: contain the character U+003C LESS-THAN SIGN (<) or an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>.</p><div class="note">
1.374 mike 477:
478: <p>The HTML syntax does not support namespace
479: declarations, even in <a href="#foreign-elements">foreign elements</a>.</p>
480:
481: <p>For instance, consider the following HTML fragment:</p>
482:
483: <pre><p>
484: <svg>
485: <metadata>
486: <!-- this is invalid -->
487: <cdr:license xmlns:cdr="http://www.example.com/cdr/metadata" name="MIT"/>
488: </metadata>
489: </svg>
490: </p></pre>
491:
492: <p>The innermost element, <code title="">cdr:license</code>, is
493: actually in the SVG namespace, as the "<code title="">xmlns:cdr</code>" attribute has no effect (unlike in
494: XML). In fact, as the comment in the fragment above says, the
495: fragment is actually non-conforming. This is because the SVG
496: specification does not define any elements called "<code title="">cdr:license</code>" in the SVG namespace.</p>
497:
498: </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 499: contain the character U+003C LESS-THAN SIGN (<) or an <a href="#syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous ampersand</a>. Some
500: <a href="#normal-elements">normal elements</a> also have <a href="#element-restrictions">yet more restrictions</a> on what
1.1 mike 501: content they are allowed to hold, beyond the restrictions imposed by
502: the content model and those described in this paragraph. Those
1.123 mike 503: restrictions are described below.</p><p>Tags contain a <dfn id="syntax-tag-name" title="syntax-tag-name">tag name</dfn>,
1.1 mike 504: giving the element's name. HTML elements all have names that only
1.464 mike 505: use characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
506: NINE (9), U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER
507: Z, and U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER
508: Z. In the HTML syntax, tag names, even those for <a href="#foreign-elements">foreign
1.462 mike 509: elements</a>, may be written with any mix of lower- and uppercase
510: letters that, when converted to all-lowercase, matches the element's
1.895 mike 511: 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 512: following format:</p><ol><li>The first character of a start tag must be a U+003C LESS-THAN
1.588 mike 513: SIGN character (<).</li>
1.1 mike 514:
515: <li>The next few characters of a start tag must be the element's
516: <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
517:
518: <li>If there are to be any attributes in the next step, there must
519: first be one or more <a href="infrastructure.html#space-character" title="space character">space
520: characters</a>.</li>
521:
522: <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
523: below. Attributes may be separated from each other by one or more
524: <a href="infrastructure.html#space-character" title="space character">space characters</a>.</li>
525:
1.766 mike 526: <li>After the attributes, or after the <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a> if there are no attributes,
527: there may be one or more <a href="infrastructure.html#space-character" title="space character">space
528: characters</a>. (Some attributes are required to be followed by
529: a space. See the <a href="#syntax-attributes" title="syntax-attributes">attributes
530: section</a> below.)</li>
1.1 mike 531:
532: <li>Then, if the element is one of the <a href="#void-elements">void elements</a>,
1.373 mike 533: or if the element is a <a href="#foreign-elements" title="foreign elements">foreign
1.588 mike 534: element</a>, then there may be a single U+002F SOLIDUS character
535: (/). This character has no effect on <a href="#void-elements">void elements</a>,
536: but on <a href="#foreign-elements">foreign elements</a> it marks the start tag as
537: self-closing.</li>
1.1 mike 538:
539: <li>Finally, start tags must be closed by a U+003E GREATER-THAN
1.588 mike 540: SIGN character (>).</li>
1.1 mike 541:
1.895 mike 542: </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 543: following format:</p><ol><li>The first character of an end tag must be a U+003C LESS-THAN
1.588 mike 544: SIGN character (<).</li>
1.1 mike 545:
546: <li>The second character of an end tag must be a U+002F SOLIDUS
1.588 mike 547: character (/).</li>
1.1 mike 548:
549: <li>The next few characters of an end tag must be the element's
550: <a href="#syntax-tag-name" title="syntax-tag-name">tag name</a>.</li>
551:
552: <li>After the tag name, there may be one or more <a href="infrastructure.html#space-character" title="space
553: character">space characters</a>.</li>
554:
1.588 mike 555: <li>Finally, end tags must be closed by a U+003E GREATER-THAN SIGN
556: character (>).</li>
1.1 mike 557:
1.955 mike 558: </ol><h5 id="attributes-0"><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 559: 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 560: one or more characters other than the <a href="infrastructure.html#space-character" title="space
561: character">space characters</a>, U+0000 NULL, U+0022 QUOTATION
562: MARK ("), U+0027 APOSTROPHE ('), U+003E GREATER-THAN SIGN
563: (>), U+002F SOLIDUS (/), and U+003D EQUALS SIGN (=) characters,
564: the control characters, and any characters that are not defined by
1.462 mike 565: Unicode. In the HTML syntax, attribute names, even those for
566: <a href="#foreign-elements">foreign elements</a>, may be written with any mix of lower-
567: and uppercase letters that are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1.123 mike 568: 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 569: 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 570: 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 571:
572: <dd>
573:
574: <p>Just the <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute
1.837 mike 575: name</a>. The value is implicitly the empty string.</p>
1.1 mike 576:
577: <div class="example">
578:
579: <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
580: the empty attribute syntax:</p>
581:
582: <pre><input <em>disabled</em>></pre>
583:
584: </div>
585:
586: <p>If an attribute using the empty attribute syntax is to be
587: followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
588: character</a> separating the two.</p>
589:
590: </dd>
591:
1.2 mike 592: <dt id="unquoted">Unquoted attribute value syntax</dt>
1.1 mike 593:
594: <dd>
595:
596: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
597: followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
598: characters</a>, followed by a single U+003D EQUALS SIGN
599: character, followed by zero or more <a href="infrastructure.html#space-character" title="space
600: character">space characters</a>, followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
601: addition to the requirements given above for attribute values,
602: must not contain any literal <a href="infrastructure.html#space-character" title="space character">space
1.588 mike 603: characters</a>, any U+0022 QUOTATION MARK characters ("),
604: U+0027 APOSTROPHE characters ('), U+003D EQUALS SIGN
605: characters (=), U+003C LESS-THAN SIGN characters (<), U+003E
606: GREATER-THAN SIGN characters (>), or U+0060 GRAVE ACCENT
607: characters (`), and must not be the empty string.</p>
1.463 mike 608:
609: <!-- The ` character is in this list on a temporary basis, waiting
610: for IE to fix it's parsing bug whereby it treats ` as an
611: attribute value delimiter. Otherwise, escaping software that
612: tries to be clever and not use quotes when it doesn't need to
613: could be tricked by an attacker.
614:
615: Posit a site that allows the user to input text that is used
616: verbatim in two attributes, such that the user can set the
617: first attribute's value to:
618:
619: `
620:
621: ...and the second to:
622:
623: ` onload='...payload...' end=x
624:
625: ...with the assumption that the site is going to not quote
626: the first one, and quote the second one with double quotes:
627:
628: <body title=` class="` onload='...payload...' end=x">
629:
630: In IE, this is treated as:
631:
632: <body title=' class="'
633: onload='...payload...'
634: end='x"'>
635:
636: -->
637:
1.1 mike 638:
639: <div class="example">
640:
641: <p>In the following example, the <code title="attr-input-value"><a href="forms.html#attr-input-value">value</a></code> attribute is given
642: with the unquoted attribute value syntax:</p>
643:
644: <pre><input <em>value=yes</em>></pre>
645:
646: </div>
647:
648: <p>If an attribute using the unquoted attribute syntax is to be
1.101 mike 649: followed by another attribute or by the optional U+002F SOLIDUS
1.464 mike 650: 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 651: must be a <a href="infrastructure.html#space-character">space character</a> separating the two.</p>
652:
653: </dd>
654:
655: <dt>Single-quoted attribute value syntax</dt>
656:
657: <dd>
658:
659: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
660: followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
661: characters</a>, followed by a single U+003D EQUALS SIGN
662: character, followed by zero or more <a href="infrastructure.html#space-character" title="space
663: character">space characters</a>, followed by a single U+0027
1.588 mike 664: APOSTROPHE character ('), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1 mike 665: addition to the requirements given above for attribute values,
1.588 mike 666: must not contain any literal U+0027 APOSTROPHE characters ('), and
667: finally followed by a second single U+0027 APOSTROPHE character
668: (').</p>
1.1 mike 669:
670: <div class="example">
671:
672: <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
673: single-quoted attribute value syntax:</p>
674:
675: <pre><input <em>type='checkbox'</em>></pre>
676:
677: </div>
678:
679: <p>If an attribute using the single-quoted attribute syntax is to
680: be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
681: character</a> separating the two.</p>
682:
683: </dd>
684:
685: <dt>Double-quoted attribute value syntax</dt>
686:
687: <dd>
688:
689: <p>The <a href="#syntax-attribute-name" title="syntax-attribute-name">attribute name</a>,
690: followed by zero or more <a href="infrastructure.html#space-character" title="space character">space
691: characters</a>, followed by a single U+003D EQUALS SIGN
692: character, followed by zero or more <a href="infrastructure.html#space-character" title="space
693: character">space characters</a>, followed by a single U+0022
1.588 mike 694: QUOTATION MARK character ("), followed by the <a href="#syntax-attribute-value" title="syntax-attribute-value">attribute value</a>, which, in
1.1 mike 695: addition to the requirements given above for attribute values,
1.588 mike 696: must not contain any literal U+0022 QUOTATION MARK characters ("),
697: and finally followed by a second single U+0022 QUOTATION MARK
698: character (").</p>
1.1 mike 699:
700: <div class="example">
701:
702: <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
703: double-quoted attribute value syntax:</p>
704:
705: <pre><input <em>name="be evil"</em>></pre>
706:
707: </div>
708:
709: <p>If an attribute using the double-quoted attribute syntax is to
710: be followed by another attribute, then there must be a <a href="infrastructure.html#space-character">space
711: character</a> separating the two.</p>
712:
713: </dd>
714:
715: </dl><p>There must never be two or more attributes on the same start tag
716: whose names are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for
1.462 mike 717: each other.</p><hr><p>When a <a href="#foreign-elements" title="foreign elements">foreign element</a> has
718: one of the namespaced attributes given by the local name and
719: namespace of the first and second cells of a row from the following
720: table, it must be written using the name given by the third cell
721: from the same row.</p><table><thead><tr><th> Local name </th><th> Namespace </th><th> Attribute name
1.724 mike 722: </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>
723: </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>
724: </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>
725: </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>
726: </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>
727: </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>
728: </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>
729: </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>
730: </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>
731: </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>
732: </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>
733: </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 734: </td></tr></tbody></table><p>No other namespaced attribute can be expressed in <a href="#syntax">the
1.895 mike 735: 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 736: is not present; it is implied, but it is still there. An HTML
1.159 mike 737: document always has a root <code><a href="semantics.html#the-html-element-0">html</a></code> element, even if the
1.1 mike 738: string <code title=""><html></code> doesn't appear anywhere in
1.159 mike 739: 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
740: 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
741: 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 742: 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
743: element is empty, or if the first thing inside the
1.159 mike 744: <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
745: tag</a> may be omitted if the <code><a href="semantics.html#the-head-element-0">head</a></code> element is not
746: 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
747: 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 748: 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 749: 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 750: <code><a href="semantics.html#the-style-element">style</a></code> element. <!-- Note that even if the </head> end
1.872 mike 751: tag is present, the parser makes <style type="text/css"> and <script type="text/javascript"> elements
1.1 mike 752: between </head> and <body> end up in the <head> instead of implying
1.159 mike 753: 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
754: 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 755: 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 756: tag</a> may be omitted if the <code><a href="semantics.html#the-li-element">li</a></code> element is
757: immediately followed by another <code><a href="semantics.html#the-li-element">li</a></code> element or if there
1.422 mike 758: 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 759: tag</a> may be omitted if the <code><a href="semantics.html#the-dt-element">dt</a></code> element is
760: immediately followed by another <code><a href="semantics.html#the-dt-element">dt</a></code> element or a
1.123 mike 761: <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 762: tag</a> may be omitted if the <code><a href="semantics.html#the-dd-element">dd</a></code> element is
763: immediately followed by another <code><a href="semantics.html#the-dd-element">dd</a></code> element or a
764: <code><a href="semantics.html#the-dt-element">dt</a></code> element, or if there is no more content in the
1.123 mike 765: 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 766: tag</a> may be omitted if the <code><a href="semantics.html#the-p-element">p</a></code> element is
767: immediately followed by an <code><a href="semantics.html#the-address-element">address</a></code>,
768: <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 769: <!--v2DATAGRID <code>datagrid</code>,--> <code><a href="obsolete.html#dir">dir</a></code>,
1.306 mike 770: <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 771: <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>,
772: <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>,
773: <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>,
774: <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>,
775: <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 776: <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>,
777: element, or if there is no more content in the parent element and
1.123 mike 778: 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 779: tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rt-element">rt</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><!-- </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 782: tag</a> may be omitted if the <code><a href="text-level-semantics.html#the-rp-element">rp</a></code> element is
783: 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 784: 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 785: <select>; commented out text below can handle the non-<select> case
1.123 mike 786: 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 787: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element <!--has an ancestor
788: <code>select</code> element and--> is immediately followed by
789: another <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or if <!--all of the elements
790: that are ancestors of the <code>optgroup</code> element, up to and
791: including the first ancestor element that is not an
792: <code>optgroup</code> element, have no more content--> there is no
1.123 mike 793: more content in the parent element.</p><!-- so e.g. the max number of </optgroup>s are omitted here:
1.1 mike 794: <select><optgroup></select>
795: <p id=x><optgroup></optgroup>x</p>
796: <p id=x><optgroup><optgroup></optgroup></optgroup>x</p>
797: <p><optgroup id=x><optgroup></optgroup>x</p>
798: <p><optgroup><optgroup id=x>x</p>
1.123 mike 799: --><!-- </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 800: tag</a> may be omitted if the <code><a href="forms.html#the-option-element">option</a></code> element is
801: immediately followed by another <code><a href="forms.html#the-option-element">option</a></code> element, or if
802: it is immediately followed by an <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, or
1.123 mike 803: 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 804: first thing inside the <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is a
805: <code><a href="tabular-data.html#the-col-element">col</a></code> element, and if the element is not immediately
806: 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 807: 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 808: <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element is not immediately followed by a
1.123 mike 809: <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 810: tag</a> may be omitted if the <code><a href="tabular-data.html#the-thead-element">thead</a></code> element is
811: 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 812: 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 813: first thing inside the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is a
814: <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, and if the element is not immediately
815: 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
816: <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element whose <a href="#syntax-end-tag" title="syntax-end-tag">end
817: tag</a> has been omitted. (It can't be omitted if the element is
1.123 mike 818: 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 819: tag</a> may be omitted if the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element is
820: 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 821: 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 822: tag</a> may be omitted if the <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code> element is
823: immediately followed by a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element, or if there is
1.123 mike 824: 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 825: tag</a> may be omitted if the <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
826: immediately followed by another <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, or if there
1.123 mike 827: 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 828: tag</a> may be omitted if the <code><a href="tabular-data.html#the-td-element">td</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><!-- </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 831: tag</a> may be omitted if the <code><a href="tabular-data.html#the-th-element">th</a></code> element is
832: 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 833: 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.895 mike 834: 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 835: 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 836: elements, even though these elements are technically allowed inside
837: <code><a href="tabular-data.html#the-table-element">table</a></code> elements according to the content models
838: described in this specification. (If a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element is
839: 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 840: 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
841: placed immediately after the <a href="#syntax-start-tag" title="syntax-start-tag">start
1.1 mike 842: 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>
843: elements. This does not affect the processing of the element. The
1.304 mike 844: otherwise optional <a href="#syntax-newlines" title="syntax-newlines">newline</a>
1.381 mike 845: <em>must</em> be included if the element's contents themselves start
846: with a <a href="#syntax-newlines" title="syntax-newlines">newline</a> (because
847: otherwise the leading newline in the contents would be treated like
848: the optional newline, and ignored).</p><div class="example">
1.1 mike 849: <p>The following two <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are equivalent:</p>
850: <pre><pre>Hello</pre></pre>
851: <pre><pre><br>Hello</pre></pre>
1.895 mike 852: </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 853: <a href="#rcdata-elements">RCDATA elements</a> must not contain any occurrences of the
854: string "<code title=""></</code>" (U+003C LESS-THAN SIGN, U+002F
855: SOLIDUS) followed by characters that case-insensitively match the
856: tag name of the element followed by one of U+0009 CHARACTER
857: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D
858: CARRIAGE RETURN (CR), U+0020 SPACE, U+003E GREATER-THAN SIGN (>), or
1.895 mike 859: 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 860: attributes, and comments. Text must consist of Unicode characters.
861: Text must not contain U+0000 characters. Text must not contain
1.316 mike 862: permanently undefined Unicode characters (noncharacters). Text must
863: not contain control characters other than <a href="infrastructure.html#space-character" title="space
864: character">space characters</a>. Extra constraints are placed on
865: what is and what is not allowed in text based on where the text is
1.895 mike 866: 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 867: represented either as U+000D CARRIAGE RETURN (CR) characters, U+000A
868: LINE FEED (LF) characters, or pairs of U+000D CARRIAGE RETURN (CR),
1.882 mike 869: U+000A LINE FEED (LF) characters in that order.</p><p>Where <a href="#syntax-charref" title="syntax-charref">character references</a>
870: are allowed, a character reference of a U+000A LINE FEED (LF)
871: character (but not a U+000D CARRIAGE RETURN (CR) character) also
1.895 mike 872: 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 873: to escape characters that couldn't otherwise legally be included in
1.588 mike 874: <a href="#syntax-text" title="syntax-text">text</a>.</p><p>Character references must start with a U+0026 AMPERSAND character
875: (&). Following this, there are three possible kinds of character
876: references:</p><dl><dt>Named character references</dt>
1.1 mike 877:
878: <dd>The ampersand must be followed by one of the names given in the
879: <a href="named-character-references.html#named-character-references">named character references</a> section, using the same
1.677 mike 880: case. <span class="impl">The name must be one that is terminated by
881: a U+003B SEMICOLON character (;).</span></dd>
1.1 mike 882:
883:
884: <dt>Decimal numeric character reference</dt>
885:
886: <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588 mike 887: character (#), followed by one or more digits in the range U+0030
888: DIGIT ZERO (0) to U+0039 DIGIT NINE (9), representing a base-ten
889: integer that corresponds to a Unicode code point that is allowed
890: according to the definition below. The digits must then be followed
891: by a U+003B SEMICOLON character (;).</dd>
1.1 mike 892:
893:
894: <dt>Hexadecimal numeric character reference</dt>
895:
896: <dd>The ampersand must be followed by a U+0023 NUMBER SIGN
1.588 mike 897: character (#), which must be followed by either a U+0078 LATIN
898: SMALL LETTER X character (x) or a U+0058 LATIN CAPITAL LETTER X
899: character (X), which must then be followed by one or more digits in
900: the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061
901: LATIN SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041
902: LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F,
1.464 mike 903: representing a base-sixteen integer that corresponds to a Unicode
904: code point that is allowed according to the definition below. The
905: digits must then be followed by a U+003B SEMICOLON character
906: (;).</dd>
1.378 mike 907:
908: </dl><p>The numeric character reference forms described above are allowed
1.882 mike 909: to reference any Unicode code point other than U+0000, U+000D,
910: permanently undefined Unicode characters (noncharacters), and
911: control characters other than <a href="infrastructure.html#space-character" title="space character">space
1.378 mike 912: characters</a>.</p><p>An <dfn id="syntax-ambiguous-ampersand" title="syntax-ambiguous-ampersand">ambiguous
1.464 mike 913: ampersand</dfn> is a U+0026 AMPERSAND character (&) that is
1.897 mike 914: followed by one or more characters in the range U+0030 DIGIT ZERO
915: (0) to U+0039 DIGIT NINE (9), U+0061 LATIN SMALL LETTER A to U+007A
916: LATIN SMALL LETTER Z, and U+0041 LATIN CAPITAL LETTER A to U+005A
917: LATIN CAPITAL LETTER Z, followed by a U+003B SEMICOLON character
918: (;), where these characters do not match any of the names given in
919: the <a href="named-character-references.html#named-character-references">named character references</a> section.</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 920: the character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
921: MARK, U+005B LEFT SQUARE BRACKET, U+0043 LATIN CAPITAL LETTER C,
922: U+0044 LATIN CAPITAL LETTER D, U+0041 LATIN CAPITAL LETTER A, U+0054
923: LATIN CAPITAL LETTER T, U+0041 LATIN CAPITAL LETTER A, U+005B LEFT
924: SQUARE BRACKET (<code title=""><![CDATA[</code>). Following this
925: sequence, the CDATA section may have <a href="#syntax-text" title="syntax-text">text</a>, with the additional restriction
926: that the text must not contain the three character sequence U+005D
927: RIGHT SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E
928: GREATER-THAN SIGN (<code title="">]]></code>). Finally, the CDATA
929: section must be ended by the three character sequence U+005D RIGHT
930: SQUARE BRACKET, U+005D RIGHT SQUARE BRACKET, U+003E GREATER-THAN
1.724 mike 931: SIGN (<code title="">]]></code>).</p><div class="example">
932:
933: <p>CDATA sections can only be used in foreign content (MathML or
934: SVG). In this example, a CDATA section is used to escape the
935: contents of an <code>ms</code> element:</p>
936:
937: <pre><p>You can add a string to a number, but this stringifies the number:</p>
938: <math>
939: <ms><![CDATA[x<y]]></ms>
940: <mo>+</mo>
941: <mn>3</mn>
942: <mo>=</mo>
943: <ms><![CDATA[x<y3]]></ms>
944: </math></pre>
945:
1.895 mike 946: </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 947: four character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
948: MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS (<code title=""><!--</code>). Following this sequence, the comment may
949: have <a href="#syntax-text" title="syntax-text">text</a>, with the additional
950: restriction that the text must not start with a single U+003E
1.588 mike 951: GREATER-THAN SIGN character (>), nor start with a U+002D
952: HYPHEN-MINUS character (-) followed by a U+003E GREATER-THAN SIGN
953: (>) character, nor contain two consecutive U+002D HYPHEN-MINUS
954: characters (<code title="">--</code>), nor end with a U+002D
955: HYPHEN-MINUS character (-). Finally, the comment must be ended by
1.1 mike 956: the three character sequence U+002D HYPHEN-MINUS, U+002D
1.123 mike 957: HYPHEN-MINUS, U+003E GREATER-THAN SIGN (<code title="">--></code>).</p><div class="impl">
1.1 mike 958:
1.895 mike 959: <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 960:
961: <p><i>This section only applies to user agents, data mining tools,
962: and conformance checkers.</i></p>
963:
964: <p class="note">The rules for parsing XML documents into DOM trees
965: are covered by the next section, entitled "<a href="the-xhtml-syntax.html#the-xhtml-syntax">The XHTML
966: syntax</a>".</p>
967:
968: <p>For <a href="dom.html#html-documents">HTML documents</a>, user agents must use the parsing
969: rules described in this section to generate the DOM trees. Together,
970: these rules define what is referred to as the <dfn id="html-parser">HTML
971: parser</dfn>.</p>
972:
973: <div class="note">
974:
975: <p>While the HTML syntax described in this specification bears a
976: close resemblance to SGML and XML, it is a separate language with
977: its own parsing rules.</p>
978:
1.183 mike 979: <p>Some earlier versions of HTML (in particular from HTML2 to
980: HTML4) were based on SGML and used SGML parsing rules. However, few
1.1 mike 981: (if any) web browsers ever implemented true SGML parsing for HTML
982: documents; the only user agents to strictly handle HTML as an SGML
983: application have historically been validators. The resulting
984: confusion — with validators claiming documents to have one
985: representation while widely deployed Web browsers interoperably
986: implemented a different representation — has wasted decades
987: of productivity. This version of HTML thus returns to a non-SGML
988: basis.</p>
989:
990: <p>Authors interested in using SGML tools in their authoring
991: pipeline are encouraged to use XML tools and the XML serialization
992: of HTML.</p>
993:
994: </div>
995:
996: <p>This specification defines the parsing rules for HTML documents,
997: whether they are syntactically correct or not. Certain points in the
998: parsing algorithm are said to be <dfn id="parse-error" title="parse error">parse
999: errors</dfn>. The error handling for parse errors is well-defined:
1000: user agents must either act as described below when encountering
1001: such problems, or must abort processing at the first error that they
1002: encounter for which they do not wish to apply the rules described
1003: below.</p>
1004:
1005: <p>Conformance checkers must report at least one parse error
1006: condition to the user if one or more parse error conditions exist in
1007: the document and must not report parse error conditions if none
1008: exist in the document. Conformance checkers may report more than one
1.174 mike 1009: parse error condition if more than one parse error condition exists
1.1 mike 1010: in the document. Conformance checkers are not required to recover
1011: from parse errors.</p>
1012:
1013: <p class="note">Parse errors are only errors with the
1014: <em>syntax</em> of HTML. In addition to checking for parse errors,
1015: conformance checkers will also verify that the document obeys all
1016: the other conformance requirements described in this
1017: specification.</p>
1018:
1019: <p>For the purposes of conformance checkers, if a resource is
1020: determined to be in <a href="#syntax">the HTML syntax</a>, then it is an
1021: <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
1022:
1.266 mike 1023: </div><div class="impl">
1.1 mike 1024:
1.895 mike 1025: <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 1026:
1027: <p>The input to the HTML parsing process consists of a stream of
1028: Unicode characters, which is passed through a
1029: <a href="#tokenization">tokenization</a> stage followed by a <a href="#tree-construction">tree
1.810 mike 1030: construction</a> stage. The output is a <code><a href="infrastructure.html#document">Document</a></code>
1.1 mike 1031: object.</p>
1032:
1033: <p class="note">Implementations that <a href="infrastructure.html#non-scripted">do not
1034: support scripting</a> do not have to actually create a DOM
1.810 mike 1035: <code><a href="infrastructure.html#document">Document</a></code> object, but the DOM tree in such cases is
1.1 mike 1036: still used as the model for the rest of the specification.</p>
1037:
1038: <p>In the common case, the data handled by the tokenization stage
1.159 mike 1039: comes from the network, but <a href="embedded-content-0.html#dynamic-markup-insertion" title="dynamic markup
1040: 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 1041:
1.724 mike 1042: <p><img alt="" src="http://dev.w3.org/html5/spec/images/parsing-model-overview.png"></p>
1.1 mike 1043:
1044: <p id="nestedParsing">There is only one set of states for the
1045: tokenizer stage and the tree construction stage, but the tree
1046: construction stage is reentrant, meaning that while the tree
1047: construction stage is handling one token, the tokenizer might be
1048: resumed, causing further tokens to be emitted and processed before
1049: the first token's processing is complete.</p>
1050:
1051: <div class="example">
1052:
1053: <p>In the following example, the tree construction stage will be
1054: called upon to handle a "p" start tag token while handling the
1055: "script" start tag token:</p>
1056:
1057: <pre>...
1058: <script>
1059: document.write('<p>');
1060: </script>
1061: ...</pre>
1062:
1063: </div>
1064:
1065: <p>To handle these cases, parsers have a <dfn id="script-nesting-level">script nesting
1066: level</dfn>, which must be initially set to zero, and a <dfn id="parser-pause-flag">parser
1067: pause flag</dfn>, which must be initially set to false.</p>
1068:
1.266 mike 1069: </div><div class="impl">
1.1 mike 1070:
1.895 mike 1071: <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 1072:
1073: <p>The stream of Unicode characters that comprises the input to the
1074: tokenization stage will be initially seen by the user agent as a
1075: stream of bytes (typically coming over the network or from the local
1076: file system). The bytes encode the actual characters according to a
1077: particular <em>character encoding</em>, which the user agent must
1078: use to decode the bytes into characters.</p>
1079:
1080: <p class="note">For XML documents, the algorithm user agents must
1081: use to determine the character encoding is given by the XML
1.104 mike 1082: specification. This section does not apply to XML documents. <a href="references.html#refsXML">[XML]</a></p>
1.1 mike 1083:
1084:
1.895 mike 1085: <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 1086:
1087: <p>In some cases, it might be impractical to unambiguously determine
1088: the encoding before parsing the document. Because of this, this
1089: specification provides for a two-pass mechanism with an optional
1090: pre-scan. Implementations are allowed, as described below, to apply
1091: a simplified parsing algorithm to whatever bytes they have available
1092: before beginning to parse the document. Then, the real parser is
1093: started, using a tentative encoding derived from this pre-parse and
1094: other out-of-band metadata. If, while the document is being loaded,
1095: the user agent discovers an encoding declaration that conflicts with
1096: this information, then the parser can get reinvoked to perform a
1097: parse of the document with the real encoding.</p>
1098:
1099: <p id="documentEncoding">User agents must use the following
1100: algorithm (the <dfn id="encoding-sniffing-algorithm">encoding sniffing algorithm</dfn>) to determine
1101: the character encoding to use when decoding a document in the first
1102: pass. This algorithm takes as input any out-of-band metadata
1103: available to the user agent (e.g. the <a href="infrastructure.html#content-type" title="Content-Type">Content-Type metadata</a> of the document)
1104: and all the bytes available so far, and returns an encoding and a
1105: <dfn id="concept-encoding-confidence" title="concept-encoding-confidence">confidence</dfn>. The
1106: confidence is either <i>tentative</i>, <i>certain</i>, or
1107: <i>irrelevant</i>. The encoding used, and whether the confidence in
1108: that encoding is <i>tentative</i> or <i>certain</i>, is <a href="#meta-charset-during-parse">used during the parsing</a> to
1109: determine whether to <a href="#change-the-encoding">change the encoding</a>. If no
1110: encoding is necessary, e.g. because the parser is operating on a
1111: stream of Unicode characters and doesn't have to use an encoding at
1112: all, then the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
1113: <i>irrelevant</i>.</p>
1114:
1115: <ol><li><p>If the transport layer specifies an encoding, and it is
1116: supported, return that encoding with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1117: <i>certain</i>, and abort these steps.</p></li>
1118:
1119: <li><p>The user agent may wait for more bytes of the resource to be
1120: available, either in this step or at any later step in this
1121: algorithm. For instance, a user agent might wait 500ms or 512
1122: bytes, whichever came first. In general preparsing the source to
1123: find the encoding improves performance, as it reduces the need to
1124: throw away the data structures used when parsing upon finding the
1125: encoding information. However, if the user agent delays too long to
1126: obtain data to determine the encoding, then the cost of the delay
1127: could outweigh any performance improvements from the
1128: preparse.</p></li>
1129:
1130: <li><p>For each of the rows in the following table, starting with
1131: the first one and going down, if there are as many or more bytes
1132: available than the number of bytes in the first column, and the
1133: first bytes of the file match the bytes given in the first column,
1134: then return the encoding given in the cell in the second column of
1135: that row, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1136: <i>certain</i>, and abort these steps:</p>
1137:
1138: <!-- this table is present in several forms in this file; keep them in sync -->
1139: <table><thead><tr><th>Bytes in Hexadecimal
1140: </th><th>Encoding
1141: </th></tr></thead><tbody><!-- nobody uses this
1142: <tr>
1143: <td>00 00 FE FF
1144: <td>UTF-32BE
1145: <tr>
1146: <td>FF FE 00 00
1147: <td>UTF-32LE
1148: --><tr><td>FE FF
1149: </td><td>UTF-16BE
1150: </td></tr><tr><td>FF FE
1151: </td><td>UTF-16LE
1152: </td></tr><tr><td>EF BB BF
1153: </td><td>UTF-8
1154: <!-- nobody uses this
1155: <tr>
1156: <td>DD 73 66 73
1157: <td>UTF-EBCDIC
1158: -->
1159: </td></tr></tbody></table><p class="note">This step looks for Unicode Byte Order Marks
1160: (BOMs).</p></li>
1161:
1162: <li><p>Otherwise, the user agent will have to search for explicit
1163: character encoding information in the file itself. This should
1164: proceed as follows:
1165:
1166: </p><p>Let <var title="">position</var> be a pointer to a byte in the
1167: input stream, initially pointing at the first byte. If at any
1168: point during these substeps the user agent either runs out of
1169: bytes or decides that scanning further bytes would not be
1170: efficient, then skip to the next step of the overall character
1171: encoding detection algorithm. User agents may decide that scanning
1172: <em>any</em> bytes is not efficient, in which case these substeps
1173: are entirely skipped.</p>
1174:
1175: <p>Now, repeat the following "two" steps until the algorithm
1176: aborts (either because user agent aborts, as described above, or
1177: because a character encoding is found):</p>
1178:
1179: <ol><li><p>If <var title="">position</var> points to:</p>
1180:
1181: <dl class="switch"><dt>A sequence of bytes starting with: 0x3C 0x21 0x2D 0x2D (ASCII '<!--')</dt>
1182: <dd>
1183:
1184: <p>Advance the <var title="">position</var> pointer so that it
1185: points at the first 0x3E byte which is preceded by two 0x2D
1186: bytes (i.e. at the end of an ASCII '-->' sequence) and comes
1187: after the 0x3C byte that was found. (The two 0x2D bytes can be
1188: the same as the those in the '<!--' sequence.)</p>
1189:
1190: </dd>
1191:
1192: <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 '<meta' followed by a space or slash)</dt>
1193: <dd>
1194:
1195: <ol><li><p>Advance the <var title="">position</var> pointer so
1196: that it points at the next 0x09, 0x0A, 0x0C, 0x0D, 0x20, or
1197: 0x2F byte (the one in sequence of characters matched
1198: above).</p></li>
1199:
1.923 mike 1200: <li><p>Let <var title="">attribute list</var> be an empty
1201: list of strings.</p></li> <!-- so long as we only care about
1202: http-equiv, content, and charset, this can be a 3-bit
1203: bitfield -->
1204:
1205: <li><p>Let <var title="">got pragma</var> be false.</p></li>
1206:
1207: <li><p>Let <var title="">mode</var> be null.</p></li>
1208:
1209: <li><p>Let <var title="">charset</var> be the null value
1210: (which, for the purposes of this algorithm, is distinct from
1211: an unrecognised encoding or the empty string).</p></li>
1212:
1213: <li><p><i>Attributes</i>: <a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">Get an
1214: attribute</a> and its value. If no attribute was sniffed,
1215: then jump to the <i>processing</i> step below.</p></li>
1216:
1217: <li><p>If the attribute's name is already in <var title="">attribute list</var>, then return to the step
1218: labeled <i>attributes</i>.</p>
1219:
1220: </li><li>
1221:
1222: <p>Run the appropriate step from the following list, if one
1223: applies:</p>
1224:
1225: <dl class="switch"><dt>If the attribute's name is "<code title="">http-equiv</code>"</dt>
1226:
1227: <dd><p>If the attribute's value is "<code title="">content-type</code>", then set <var title="">got
1228: pragma</var> to true.</p></dd>
1229:
1230: <dt>If the attribute's name is "<code title="">charset</code>"</dt>
1231:
1232: <dd><p>If <var title="">charset</var> is still set to null,
1233: let <var title="">charset</var> be the encoding
1234: corresponding to the attribute's value, and set <var title="">mode</var> to "charset".</p></dd>
1235:
1236: <dt>If the attribute's name is "<code title="">content</code>"</dt>
1237:
1238: <dd><p>Apply the <a href="infrastructure.html#algorithm-for-extracting-an-encoding-from-a-content-type">algorithm for extracting an encoding
1239: from a Content-Type</a>, giving the attribute's value as
1240: the string to parse. If an encoding is returned, and if
1241: <var title="">charset</var> is still set to null, let <var title="">charset</var> be the encoding returned, and set
1242: <var title="">mode</var> to "pragma".</p></dd>
1243:
1244: </dl></li>
1245:
1246: <li><p>Return to the step labeled <i>attributes</i>.</p></li>
1247:
1248: <li><p><i>Processing</i>: If <var title="">mode</var> is
1249: null, then jump to the second step of the overall "two step"
1250: algorithm.</p></li>
1251:
1252: <li><p>If <var title="">mode</var> is "pragma" but <var title="">got pragma</var> is false, then jump to the second
1253: step of the overall "two step" algorithm.</p></li>
1.1 mike 1254:
1255: <li><p>If <var title="">charset</var> is a UTF-16 encoding,
1256: change the value of <var title="">charset</var> to
1257: UTF-8.</p></li>
1258:
1.923 mike 1259: <li><p>If <var title="">charset</var> is not a supported
1260: character encoding, then jump to the second step of the
1261: overall "two step" algorithm.</p></li>
1262:
1263: <li><p>Return the encoding given by <var title="">charset</var>, with <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1.1 mike 1264: <i>tentative</i>, and abort all these steps.</p></li>
1265:
1266: </ol></dd>
1267:
1.464 mike 1268: <dt>A sequence of bytes starting with a 0x3C byte (ASCII <), optionally a 0x2F byte (ASCII /), and finally a byte in the range 0x41-0x5A or 0x61-0x7A (an ASCII letter)</dt>
1.1 mike 1269: <dd>
1270:
1271: <ol><li><p>Advance the <var title="">position</var> pointer so
1272: that it points at the next 0x09 (ASCII TAB), 0x0A (ASCII LF),
1273: 0x0C (ASCII FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E
1.464 mike 1274: (ASCII >) byte.</p></li>
1.1 mike 1275:
1276: <li><p>Repeatedly <a href="#concept-get-attributes-when-sniffing" title="concept-get-attributes-when-sniffing">get an
1277: attribute</a> until no further attributes can be found,
1278: then jump to the second step in the overall "two step"
1279: algorithm.</p></li>
1280:
1281: </ol></dd>
1282:
1283: <dt>A sequence of bytes starting with: 0x3C 0x21 (ASCII '<!')</dt>
1284: <dt>A sequence of bytes starting with: 0x3C 0x2F (ASCII '</')</dt>
1285: <dt>A sequence of bytes starting with: 0x3C 0x3F (ASCII '<?')</dt>
1286: <dd>
1287:
1288: <p>Advance the <var title="">position</var> pointer so that it
1.464 mike 1289: points at the first 0x3E byte (ASCII >) that comes after the
1.1 mike 1290: 0x3C byte that was found.</p>
1291:
1292: </dd>
1293:
1294: <dt>Any other byte</dt>
1295: <dd>
1296:
1297: <p>Do nothing with that byte.</p>
1298:
1299: </dd>
1300:
1301: </dl></li>
1302:
1303: <li>Move <var title="">position</var> so it points at the next
1304: byte in the input stream, and return to the first step of this
1305: "two step" algorithm.</li>
1306:
1307: </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
1308: attribute</dfn>, it means doing this:</p>
1309:
1310: <ol><li><p>If the byte at <var title="">position</var> is one of 0x09
1311: (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR),
1.464 mike 1312: 0x20 (ASCII space), or 0x2F (ASCII /) then advance <var title="">position</var> to the next byte and redo this
1.1 mike 1313: substep.</p></li>
1314:
1315: <li><p>If the byte at <var title="">position</var> is 0x3E (ASCII
1.464 mike 1316: >), then abort the "get an attribute" algorithm. There isn't
1.1 mike 1317: one.</p></li>
1318:
1319: <li><p>Otherwise, the byte at <var title="">position</var> is the
1320: start of the attribute name. Let <var title="">attribute
1321: name</var> and <var title="">attribute value</var> be the empty
1322: string.</p></li>
1323:
1324: <li><p><i>Attribute name</i>: Process the byte at <var title="">position</var> as follows:</p>
1325:
1.464 mike 1326: <dl class="switch"><dt>If it is 0x3D (ASCII =), and the <var title="">attribute
1.1 mike 1327: name</var> is longer than the empty string</dt>
1328:
1329: <dd>Advance <var title="">position</var> to the next byte and
1330: jump to the step below labeled <i>value</i>.</dd>
1331:
1332: <dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
1333: FF), 0x0D (ASCII CR), or 0x20 (ASCII space)</dt>
1334:
1335: <dd>Jump to the step below labeled <i>spaces</i>.</dd>
1336:
1.464 mike 1337: <dt>If it is 0x2F (ASCII /) or 0x3E (ASCII >)</dt>
1.1 mike 1338:
1339: <dd>Abort the "get an attribute" algorithm. The attribute's
1340: name is the value of <var title="">attribute name</var>, its
1341: value is the empty string.</dd>
1342:
1.464 mike 1343: <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
1344: Z)</dt>
1.1 mike 1345:
1346: <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
1347: name</var> (where <var title="">b</var> is the value of the
1348: byte at <var title="">position</var>).</dd>
1349:
1350: <dt>Anything else</dt>
1351:
1352: <dd>Append the Unicode character with the same code point as the
1353: value of the byte at <var title="">position</var>) to <var title="">attribute name</var>. (It doesn't actually matter how
1354: bytes outside the ASCII range are handled here, since only
1355: ASCII characters can contribute to the detection of a character
1356: encoding.)</dd>
1357:
1358: </dl></li>
1359:
1360: <li><p>Advance <var title="">position</var> to the next byte and
1361: return to the previous step.</p></li>
1362:
1363: <li><p><i>Spaces</i>: If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
1364: LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
1365: advance <var title="">position</var> to the next byte, then,
1366: repeat this step.</p></li>
1367:
1368: <li><p>If the byte at <var title="">position</var> is
1.464 mike 1369: <em>not</em> 0x3D (ASCII =), abort the "get an attribute"
1.1 mike 1370: algorithm. The attribute's name is the value of <var title="">attribute name</var>, its value is the empty
1371: string.</p></li>
1372:
1373: <li><p>Advance <var title="">position</var> past the 0x3D (ASCII
1.464 mike 1374: =) byte.</p></li>
1.1 mike 1375:
1.916 mike 1376: <li><p><i>Value</i>: If the byte at <var title="">position</var> is one of 0x09 (ASCII TAB), 0x0A (ASCII
1.1 mike 1377: LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then
1378: advance <var title="">position</var> to the next byte, then,
1379: repeat this step.</p></li>
1380:
1381: <li><p>Process the byte at <var title="">position</var> as
1382: follows:</p>
1383:
1.464 mike 1384: <dl class="switch"><dt>If it is 0x22 (ASCII ") or 0x27 (ASCII ')</dt>
1.1 mike 1385:
1386: <dd>
1387:
1388: <ol><li>Let <var title="">b</var> be the value of the byte at
1389: <var title="">position</var>.</li>
1390:
1391: <li>Advance <var title="">position</var> to the next
1392: byte.</li>
1393:
1394: <li>If the value of the byte at <var title="">position</var>
1395: is the value of <var title="">b</var>, then advance <var title="">position</var> to the next byte and abort the "get
1396: an attribute" algorithm. The attribute's name is the value of
1397: <var title="">attribute name</var>, and its value is the
1398: value of <var title="">attribute value</var>.</li>
1399:
1.464 mike 1400: <li>Otherwise, if the value of the byte at <var title="">position</var> is in the range 0x41 (ASCII A) to
1401: 0x5A (ASCII Z), then append a Unicode character to <var title="">attribute value</var> whose code point is 0x20 more
1.1 mike 1402: than the value of the byte at <var title="">position</var>.</li>
1403:
1404: <li>Otherwise, append a Unicode character to <var title="">attribute value</var> whose code point is the same as
1405: the value of the byte at <var title="">position</var>.</li>
1406:
1407: <li>Return to the second step in these substeps.</li>
1408:
1409: </ol></dd>
1410:
1.464 mike 1411: <dt>If it is 0x3E (ASCII >)</dt>
1.1 mike 1412:
1413: <dd>Abort the "get an attribute" algorithm. The attribute's
1414: name is the value of <var title="">attribute name</var>, its
1415: value is the empty string.</dd>
1416:
1417:
1.464 mike 1418: <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
1419: Z)</dt>
1.1 mike 1420:
1421: <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
1422: value</var> (where <var title="">b</var> is the value of the
1423: byte at <var title="">position</var>). Advance <var title="">position</var> to the next byte.</dd>
1424:
1425: <dt>Anything else</dt>
1426:
1427: <dd>Append the Unicode character with the same code point as the
1428: 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>
1429:
1430: </dl></li>
1431:
1432: <li><p>Process the byte at <var title="">position</var> as
1433: follows:</p>
1434:
1435: <dl class="switch"><dt>If it is 0x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII
1436: FF), 0x0D (ASCII CR), 0x20 (ASCII space), or 0x3E (ASCII
1.464 mike 1437: >)</dt>
1.1 mike 1438:
1439: <dd>Abort the "get an attribute" algorithm. The attribute's
1440: name is the value of <var title="">attribute name</var> and its
1441: value is the value of <var title="">attribute value</var>.</dd>
1442:
1.464 mike 1443: <dt>If it is in the range 0x41 (ASCII A) to 0x5A (ASCII
1444: Z)</dt>
1.1 mike 1445:
1446: <dd>Append the Unicode character with code point <span title=""><var title="">b</var>+0x20</span> to <var title="">attribute
1447: value</var> (where <var title="">b</var> is the value of the
1448: byte at <var title="">position</var>).</dd>
1449:
1450: <dt>Anything else</dt>
1451:
1452: <dd>Append the Unicode character with the same code point as the
1453: value of the byte at <var title="">position</var>) to <var title="">attribute value</var>.</dd>
1454:
1455: </dl></li>
1456:
1457: <li><p>Advance <var title="">position</var> to the next byte and
1458: return to the previous step.</p></li>
1459:
1460: </ol><p>For the sake of interoperability, user agents should not use a
1461: pre-scan algorithm that returns different results than the one
1462: described above. (But, if you do, please at least let us know, so
1463: that we can improve this algorithm and benefit everyone...)</p>
1464:
1465: </li>
1466:
1467: <li><p>If the user agent has information on the likely encoding for
1468: this page, e.g. based on the encoding of the page when it was last
1469: visited, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1470: <i>tentative</i>, and abort these steps.</p></li>
1471:
1.322 mike 1472: <li>
1473:
1474: <p>The user agent may attempt to autodetect the character encoding
1475: from applying frequency analysis or other algorithms to the data
1.568 mike 1476: stream. Such algorithms may use information about the resource
1477: other than the resource's contents, including the address of the
1478: resource. If autodetection succeeds in determining a character
1.322 mike 1479: encoding, then return that encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1480: <i>tentative</i>, and abort these steps. <a href="references.html#refsUNIVCHARDET">[UNIVCHARDET]</a></p>
1481:
1482: <p class="note">The UTF-8 encoding has a highly detectable bit
1483: pattern. Documents that contain bytes with values greater than
1484: 0x7F which match the UTF-8 pattern are very likely to be UTF-8,
1485: while documents with byte sequences that do not match it are very
1486: likely not. User-agents are therefore encouraged to search for
1.485 mike 1487: this common encoding. <a href="references.html#refsPPUTF8">[PPUTF8]</a> <a href="references.html#refsUTF8DET">[UTF8DET]</a></p>
1.322 mike 1488:
1489: </li>
1.1 mike 1490:
1.501 mike 1491: <li>
1492:
1493: <p>Otherwise, return an implementation-defined or user-specified
1494: default character encoding, with the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a>
1495: <i>tentative</i>.</p>
1496:
1497: <p>In controlled environments or in environments where the
1498: encoding of documents can be prescribed (for example, for user
1499: agents intended for dedicated use in new networks), the
1500: comprehensive <code title="">UTF-8</code> encoding is
1501: suggested.</p>
1502:
1503: <p>In other environments, the default encoding is typically
1504: dependent on the user's locale (an approximation of the languages,
1.760 mike 1505: and thus often encodings, of the pages that the user is likely to
1506: frequent). The following table gives suggested defaults based on
1507: the user's locale, for compatibility with legacy content. Locales
1.934 mike 1508: are identified by BCP 47 language tags. <a href="references.html#refsBCP47">[BCP47]</a></p>
1.501 mike 1509:
1.920 mike 1510: <!-- based on mozilla 1.9.1 localizations:
1.501 mike 1511: http://mxr.mozilla.org/l10n-mozilla1.9.1/find?string=global%2Fintl.properties&tree=l10n-mozilla1.9.1&hint= -->
1512:
1.504 mike 1513: <table><thead><tr><th>Locale language
1.501 mike 1514: </th><th>Suggested default encoding
1515: </th></tr></thead><tbody><tr><td>ar
1516: </td><td>UTF-8
1517:
1518: </td></tr><tr><td>be
1519: </td><td>ISO-8859-5
1520:
1521: </td></tr><tr><td>bg
1522: </td><td>windows-1251
1523:
1524: </td></tr><tr><td>cs<!-- -CZ -->
1525: </td><td>ISO-8859-2
1526:
1527: </td></tr><tr><td>cy
1528: </td><td>UTF-8
1529:
1530: </td></tr><tr><td>fa<!-- -IR -->
1531: </td><td>UTF-8
1532:
1533: </td></tr><tr><td>he<!-- -IL -->
1534: </td><td>windows-1255
1535:
1536: </td></tr><tr><td>hr
1537: </td><td>UTF-8
1538:
1539: </td></tr><tr><td>hu<!-- -HU -->
1540: </td><td>ISO-8859-2
1541:
1542: </td></tr><tr><td>ja <!-- and ja-JP-mac -->
1.863 mike 1543: </td><td>Windows-31J <!-- Shift_JIS -->
1.501 mike 1544:
1545: </td></tr><tr><td>kk
1546: </td><td>UTF-8
1547:
1548: </td></tr><tr><td>ko<!-- -KR -->
1549: </td><td>windows-949 <!-- EUC-KR -->
1550:
1551: </td></tr><tr><td>ku
1552: </td><td>windows-1254 <!-- ISO-8859-9 -->
1553:
1554: </td></tr><tr><td>lt
1555: </td><td>windows-1257
1556:
1557: </td></tr><tr><td>lv<!-- -LV -->
1558: </td><td>ISO-8859-13
1559:
1560: </td></tr><tr><td>mk<!-- -MK -->
1561: </td><td>UTF-8
1562:
1563: </td></tr><tr><td>or
1564: </td><td>UTF-8
1565:
1566: </td></tr><tr><td>pl<!-- -PL -->
1567: </td><td>ISO-8859-2
1568:
1569: </td></tr><tr><td>ro
1570: </td><td>UTF-8
1571:
1572: </td></tr><tr><td>ru
1573: </td><td>windows-1251
1574:
1575: </td></tr><tr><td>sk
1576: </td><td>windows-1250
1577:
1578: </td></tr><tr><td>sl
1579: </td><td>ISO-8859-2
1580:
1581: </td></tr><tr><td>sr
1582: </td><td>UTF-8
1583:
1584: </td></tr><tr><td>th
1585: </td><td>windows-874 <!-- TIS-620 -->
1586:
1587: </td></tr><tr><td>tr<!-- -TR -->
1588: </td><td>windows-1254 <!-- ISO-8859-9 -->
1589:
1.503 mike 1590: </td></tr><tr><td>uk
1.501 mike 1591: </td><td>windows-1251
1592:
1593: </td></tr><tr><td>vi
1594: </td><td>UTF-8
1595:
1596: </td></tr><tr><td>zh-CN
1597: </td><td>GB18030
1598:
1599: </td></tr><tr><td>zh-TW
1600: </td><td>Big5
1601:
1602: </td></tr><tr><td>All other locales
1603: </td><td>windows-1252
1604:
1605: </td></tr></tbody></table></li>
1.1 mike 1606:
1607: </ol><p>The <a href="dom.html#document-s-character-encoding">document's character encoding</a> must immediately
1608: be set to the value returned from this algorithm, at the same time
1609: as the user agent uses the returned value to select the decoder to
1610: use for the input stream.</p>
1611:
1.582 mike 1612: <p class="note">This algorithm is a <a href="introduction.html#willful-violation">willful violation</a>
1613: of the HTTP specification, which requires that the encoding be
1614: assumed to be ISO-8859-1 in the absence of a <a href="semantics.html#character-encoding-declaration">character
1.647 mike 1615: encoding declaration</a> to the contrary, and of RFC 2046,
1.582 mike 1616: which requires that the encoding be assumed to be US-ASCII in the
1617: absence of a <a href="semantics.html#character-encoding-declaration">character encoding declaration</a> to the
1618: contrary. This specification's third approach is motivated by a
1619: desire to be maximally compatible with legacy content. <a href="references.html#refsHTTP">[HTTP]</a> <a href="references.html#refsRFC2046">[RFC2046]</a></p>
1620:
1.1 mike 1621:
1.895 mike 1622: <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 1623:
1.237 mike 1624: <p>User agents must at a minimum support the UTF-8 and Windows-1252
1625: encodings, but may support more.</p>
1626:
1627: <p class="note">It is not unusual for Web browsers to support dozens
1628: if not upwards of a hundred distinct character encodings.</p>
1629:
1.365 mike 1630: <p>User agents must support the <a href="infrastructure.html#preferred-mime-name">preferred MIME name</a> of
1631: every character encoding they support, and should support all the
1632: IANA-registered names and aliases of every character encoding they
1633: support. <a href="references.html#refsIANACHARSET">[IANACHARSET]</a></p>
1.237 mike 1634:
1635: <p>When comparing a string specifying a character encoding with the
1636: name or alias of a character encoding to determine if they are
1637: 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
1638: then perform the comparison in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
1639: case-insensitive</a> manner.</p>
1640:
1.539 mike 1641: <hr><p>When a user agent would otherwise use an encoding given in the
1.237 mike 1642: first column of the following table to either convert content to
1643: Unicode characters or convert Unicode characters to bytes, it must
1644: instead use the encoding given in the cell in the second column of
1645: the same row. When a byte or sequence of bytes is treated
1646: differently due to this encoding aliasing, it is said to have been
1647: <dfn id="misinterpreted-for-compatibility">misinterpreted for compatibility</dfn>.</p>
1648:
1649: <table><caption>Character encoding overrides</caption>
1650: <thead><tr><th> Input encoding </th><th> Replacement encoding </th><th> References
1651: </th></tr></thead><tbody><!-- how about EUC-JP? --><tr><td> EUC-KR </td><td> windows-949 </td><td>
1652: <a href="references.html#refsEUCKR">[EUCKR]</a>
1653: <a href="references.html#refsWIN949">[WIN949]</a>
1654: </td></tr><tr><td> GB2312 </td><td> GBK </td><td>
1655: <a href="references.html#refsRFC1345">[RFC1345]</a>
1656: <a href="references.html#refsGBK">[GBK]</a>
1657: </td></tr><tr><td> GB_2312-80 </td><td> GBK </td><td>
1658: <a href="references.html#refsRFC1345">[RFC1345]</a>
1659: <a href="references.html#refsGBK">[GBK]</a>
1660: </td></tr><tr><td> ISO-8859-1 </td><td> windows-1252 </td><td>
1661: <a href="references.html#refsRFC1345">[RFC1345]</a>
1662: <a href="references.html#refsWIN1252">[WIN1252]</a>
1663: </td></tr><tr><td> ISO-8859-9 </td><td> windows-1254 </td><td>
1664: <a href="references.html#refsRFC1345">[RFC1345]</a>
1665: <a href="references.html#refsWIN1254">[WIN1254]</a>
1666: </td></tr><tr><td> ISO-8859-11 </td><td> windows-874 </td><td>
1667: <a href="references.html#refsISO885911">[ISO885911]</a>
1668: <a href="references.html#refsWIN874">[WIN874]</a>
1669: </td></tr><tr><td> KS_C_5601-1987 </td><td> windows-949 </td><td>
1670: <a href="references.html#refsRFC1345">[RFC1345]</a>
1671: <a href="references.html#refsWIN949">[WIN949]</a>
1.863 mike 1672: </td></tr><tr><td> Shift_JIS </td><td> Windows-31J </td><td>
1.237 mike 1673: <a href="references.html#refsSHIFTJIS">[SHIFTJIS]</a>
1674: <a href="references.html#refsWIN31J">[WIN31J]</a>
1675: </td></tr><tr><td> TIS-620 </td><td> windows-874 </td><td>
1676: <a href="references.html#refsTIS620">[TIS620]</a>
1677: <a href="references.html#refsWIN874">[WIN874]</a>
1678: </td></tr><tr><td> US-ASCII </td><td> windows-1252 </td><td>
1679: <a href="references.html#refsRFC1345">[RFC1345]</a>
1680: <a href="references.html#refsWIN1252">[WIN1252]</a>
1681: </td></tr></tbody></table><p class="note">The requirement to treat certain encodings as other
1682: encodings according to the table above is a <a href="introduction.html#willful-violation">willful
1683: violation</a> of the W3C Character Model specification, motivated
1684: by a desire for compatibility with legacy content. <a href="references.html#refsCHARMOD">[CHARMOD]</a></p>
1685:
1686: <p>When a user agent is to use the UTF-16 encoding but no BOM has
1687: been found, user agents must default to UTF-16LE.</p>
1688:
1689: <p class="note">The requirement to default UTF-16 to LE rather than
1690: BE is a <a href="introduction.html#willful-violation">willful violation</a> of RFC 2781, motivated by a
1.581 mike 1691: desire for compatibility with legacy content. <a href="references.html#refsRFC2781">[RFC2781]</a></p>
1.237 mike 1692:
1693: <hr><p>User agents must not support the CESU-8, UTF-7, BOCU-1 and SCSU
1694: 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>
1695:
1696: <p>Support for encodings based on EBCDIC is not recommended. This
1697: encoding is rarely used for publicly-facing Web content.</p>
1698:
1699: <p>Support for UTF-32 is not recommended. This encoding is rarely
1700: used, and frequently implemented incorrectly.</p>
1701:
1702: <p class="note">This specification does not make any attempt to
1703: support EBCDIC-based encodings and UTF-32 in its algorithms; support
1704: and use of these encodings can thus lead to unexpected behavior in
1705: implementations of this specification.</p>
1706:
1707:
1708:
1.895 mike 1709: <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 1710:
1711: <p>Given an encoding, the bytes in the input stream must be
1712: converted to Unicode characters for the tokenizer, as described by
1713: the rules for that encoding, except that the leading U+FEFF BYTE
1714: ORDER MARK character, if any, must not be stripped by the encoding
1715: layer (it is stripped by the rule below).</p> <!-- this is to
1716: prevent two leading BOMs from being both stripped, once by the
1717: decoder, and once by the parser -->
1718:
1719: <p>Bytes or sequences of bytes in the original byte stream that
1.393 mike 1720: could not be converted to Unicode code points must be converted to
1721: U+FFFD REPLACEMENT CHARACTERs.</p>
1.1 mike 1722:
1723: <p class="note">Bytes or sequences of bytes in the original byte
1724: stream that did not conform to the encoding specification
1725: (e.g. invalid UTF-8 byte sequences in a UTF-8 input stream) are
1726: errors that conformance checkers are expected to report.</p>
1727:
1.438 mike 1728: <p>Any byte or sequence of bytes in the original byte stream that is
1729: <a href="#misinterpreted-for-compatibility">misinterpreted for compatibility</a> is a <a href="#parse-error">parse
1.1 mike 1730: error</a>.</p>
1731:
1732: <p>One leading U+FEFF BYTE ORDER MARK character must be ignored if
1733: any are present.</p>
1734:
1.300 mike 1735: <p class="note">The requirement to strip a U+FEFF BYTE ORDER MARK
1736: character regardless of whether that character was used to determine
1737: the byte order is a <a href="introduction.html#willful-violation">willful violation</a> of Unicode,
1738: motivated by a desire to increase the resilience of user agents in
1739: the face of naïve transcoders.</p>
1740:
1.316 mike 1741: <p>All U+0000 NULL characters and code points in the range U+D800 to
1.315 mike 1742: U+DFFF<!-- surrogates not allowed e.g. in UTF-8, and we don't want
1743: them to suddenly turn into codepoints when they go through a UTF-16
1744: pipe --> in the input must be replaced by U+FFFD REPLACEMENT
1.316 mike 1745: CHARACTERs. Any occurrences of such characters and code points are
1746: <a href="#parse-error" title="parse error">parse errors</a>.</p>
1.1 mike 1747:
1748: <p>Any occurrences of any characters in the ranges U+0001 to U+0008,
1749: <!-- HT, LF allowed --> <!-- U+000B is in the next list --> <!-- FF,
1750: CR allowed --> U+000E to U+001F, <!-- ASCII allowed --> U+007F
1.315 mike 1751: <!--to U+0084, (U+0085 NEL not allowed), U+0086--> to U+009F, U+FDD0
1752: to U+FDEF, and characters U+000B, U+FFFE, U+FFFF, U+1FFFE, U+1FFFF,
1753: U+2FFFE, U+2FFFF, U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE,
1754: U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF,
1755: U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE,
1756: U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF,
1757: U+10FFFE, and U+10FFFF are <a href="#parse-error" title="parse error">parse
1.316 mike 1758: errors</a>. These are all control characters or permanently
1759: undefined Unicode characters (noncharacters).</p>
1.1 mike 1760:
1761: <p>U+000D CARRIAGE RETURN (CR) characters and U+000A LINE FEED (LF)
1762: characters are treated specially. Any CR characters that are
1763: followed by LF characters must be removed, and any CR characters not
1764: followed by LF characters must be converted to LF characters. Thus,
1765: newlines in HTML DOMs are represented by LF characters, and there
1766: are never any CR characters in the input to the
1767: <a href="#tokenization">tokenization</a> stage.</p>
1768:
1769: <p>The <dfn id="next-input-character">next input character</dfn> is the first character in the
1770: input stream that has not yet been <dfn id="consumed">consumed</dfn>. Initially,
1771: the <i><a href="#next-input-character">next input character</a></i> is the first character in the
1772: input. The <dfn id="current-input-character">current input character</dfn> is the last character
1773: to have been <i><a href="#consumed">consumed</a></i>.</p>
1774:
1775: <p>The <dfn id="insertion-point">insertion point</dfn> is the position (just before a
1776: character or just before the end of the input stream) where content
1.159 mike 1777: 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 1778: inserted. The insertion point is relative to the position of the
1779: character immediately after it, it is not an absolute offset into
1780: the input stream. Initially, the insertion point is
1.10 mike 1781: undefined.</p>
1.1 mike 1782:
1783: <p>The "EOF" character in the tables below is a conceptual character
1784: representing the end of the <a href="#the-input-stream">input stream</a>. If the parser
1.159 mike 1785: is a <a href="embedded-content-0.html#script-created-parser">script-created parser</a>, then the end of the
1.1 mike 1786: <a href="#the-input-stream">input stream</a> is reached when an <dfn id="explicit-eof-character">explicit "EOF"
1.159 mike 1787: 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 1788: consumed. Otherwise, the "EOF" character is not a real character in
1789: the stream, but rather the lack of any further characters.</p>
1790:
1791:
1.895 mike 1792: <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 1793:
1794: <p>When the parser requires the user agent to <dfn id="change-the-encoding">change the
1795: encoding</dfn>, it must run the following steps. This might happen
1796: if the <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> described above
1797: failed to find an encoding, or if it found an encoding that was not
1798: the actual encoding of the file.</p>
1799:
1800: <ol><li>If the new encoding is identical or equivalent to the encoding
1801: that is already being used to interpret the input stream, then set
1802: the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1803: <i>certain</i> and abort these steps. This happens when the
1804: encoding information found in the file matches what the
1805: <a href="#encoding-sniffing-algorithm">encoding sniffing algorithm</a> determined to be the
1806: encoding, and in the second pass through the parser if the first
1807: pass found that the encoding sniffing algorithm described in the
1808: earlier section failed to find the right encoding.</li>
1809:
1810: <li>If the encoding that is already being used to interpret the
1811: input stream is a UTF-16 encoding, then set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1812: <i>certain</i> and abort these steps. The new encoding is ignored;
1813: if it was anything but the same encoding, then it would be clearly
1814: incorrect.</li>
1815:
1816: <li>If the new encoding is a UTF-16 encoding, change it to
1817: UTF-8.</li>
1818:
1819: <li>If all the bytes up to the last byte converted by the current
1820: decoder have the same Unicode interpretations in both the current
1821: encoding and the new encoding, and if the user agent supports
1822: changing the converter on the fly, then the user agent may change
1823: to the new converter for the encoding on the fly. Set the
1824: <a href="dom.html#document-s-character-encoding">document's character encoding</a> and the encoding used to
1825: convert the input stream to the new encoding, set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1826: <i>certain</i>, and abort these steps.</li>
1827:
1828: <li>Otherwise, <a href="history.html#navigate">navigate</a> to the document again, with
1829: <a href="history.html#replacement-enabled">replacement enabled</a>, and using the same <a href="history.html#source-browsing-context">source
1830: browsing context</a>, but this time skip the <a href="#encoding-sniffing-algorithm">encoding
1831: sniffing algorithm</a> and instead just set the encoding to the
1832: new encoding and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1833: <i>certain</i>. Whenever possible, this should be done without
1834: actually contacting the network layer (the bytes should be
1835: re-parsed from memory), even if, e.g., the document is marked as
1836: not being cacheable. If this is not possible and contacting the
1837: network layer would involve repeating a request that uses a method
1838: other than HTTP GET (<a href="infrastructure.html#concept-http-equivalent-get" title="concept-http-equivalent-get">or
1839: equivalent</a> for non-HTTP URLs), then instead set the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> to
1840: <i>certain</i> and ignore the new encoding. The resource will be
1841: misinterpreted. User agents may notify the user of the situation,
1842: to aid in application development.</li>
1843:
1.266 mike 1844: </ol></div><div class="impl">
1845:
1.895 mike 1846: <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 1847:
1.895 mike 1848: <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 1849:
1850: <p>The <dfn id="insertion-mode">insertion mode</dfn> is a state variable that controls
1851: the primary operation of the tree construction stage.</p>
1852:
1853: <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
1854: "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before html</a>",
1855: "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before head</a>",
1856: "<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 1857: "<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 1858: "<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>",
1859: "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table body</a>",
1860: "<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
1861: table</a>", "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in
1862: foreign content</a>", "<a href="#parsing-main-afterbody" title="insertion mode: after
1863: body">after body</a>", "<a href="#parsing-main-inframeset" title="insertion mode: in
1864: frameset">in frameset</a>", "<a href="#parsing-main-afterframeset" title="insertion mode: after
1865: frameset">after frameset</a>", "<a href="#the-after-after-body-insertion-mode" title="insertion mode:
1866: after after body">after after body</a>", and "<a href="#the-after-after-frameset-insertion-mode" title="insertion mode: after after frameset">after after
1867: frameset</a>" during the course of the parsing, as described in
1868: the <a href="#tree-construction">tree construction</a> stage. The insertion mode affects
1869: how tokens are processed and whether CDATA sections are
1870: supported.</p>
1871:
1872: <p>Seven of these modes, namely "<a href="#parsing-main-inhead" title="insertion mode: in
1873: head">in head</a>", "<a href="#parsing-main-inbody" title="insertion mode: in body">in
1874: body</a>", "<a href="#parsing-main-intable" title="insertion mode: in table">in
1875: table</a>", "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
1876: body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in row</a>",
1877: "<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
1878: that the other modes defer to them at various times. When the
1879: algorithm below says that the user agent is to do something
1880: "<dfn id="using-the-rules-for">using the rules for</dfn> the <var title="">m</var> insertion
1881: mode", where <var title="">m</var> is one of these modes, the user
1882: agent must use the rules described under the <var title="">m</var>
1883: <a href="#insertion-mode">insertion mode</a>'s section, but must leave the
1884: <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>
1885: to a new value.</p>
1886:
1887: <p>When the insertion mode is switched to "<a href="#parsing-main-incdata" title="insertion
1.540 mike 1888: mode: text">text</a>" or "<a href="#parsing-main-intabletext" title="insertion mode: in table
1889: text">in table text</a>", the <dfn id="original-insertion-mode">original insertion mode</dfn>
1890: is also set. This is the insertion mode to which the tree
1891: construction stage will return.</p>
1.1 mike 1892:
1893: <p>When the insertion mode is switched to "<a href="#parsing-main-inforeign" title="insertion
1894: mode: in foreign content">in foreign content</a>", the
1895: <dfn id="secondary-insertion-mode">secondary insertion mode</dfn> is also set. This secondary mode
1896: is used within the rules for the "<a href="#parsing-main-inforeign" title="insertion mode: in
1897: foreign content">in foreign content</a>" mode to handle HTML
1898: (i.e. not foreign) content.</p>
1899:
1900: <hr><p>When the steps below require the UA to <dfn id="reset-the-insertion-mode-appropriately">reset the insertion
1901: mode appropriately</dfn>, it means the UA must follow these
1902: steps:</p>
1903:
1904: <ol><li>Let <var title="">last</var> be false.</li>
1905:
1.604 mike 1906: <li>Let <var title="">foreign</var> be false.</li>
1907:
1.1 mike 1908: <li>Let <var title="">node</var> be the last node in the
1909: <a href="#stack-of-open-elements">stack of open elements</a>.</li>
1910:
1.604 mike 1911: <li><i>Loop</i>: If <var title="">node</var> is the first node in
1912: the stack of open elements, then set <var title="">last</var> to
1913: 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 1914:
1915: <li>If <var title="">node</var> is a <code><a href="forms.html#the-select-element">select</a></code> element,
1.604 mike 1916: 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 1917: step labeled <i title="">end</i>. (<a href="#fragment-case">fragment case</a>)</li>
1.1 mike 1918:
1919: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-td-element">td</a></code> or
1920: <code><a href="tabular-data.html#the-th-element">th</a></code> element and <var title="">last</var> is false, then
1921: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion
1.856 mike 1922: mode: in cell">in cell</a>" and jump to the step labeled <i title="">end</i>.</li>
1.1 mike 1923:
1924: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then
1925: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion
1.856 mike 1926: mode: in row">in row</a>" and jump to the step labeled <i title="">end</i>.</li>
1.1 mike 1927:
1928: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>,
1929: <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
1930: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in
1.856 mike 1931: table body">in table body</a>" and jump to the step labeled <i title="">end</i>.</li>
1.1 mike 1932:
1933: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-caption-element">caption</a></code> element,
1.604 mike 1934: 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 1935: the step labeled <i title="">end</i>.</li>
1.1 mike 1936:
1937: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code> element,
1938: 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 1939: jump to the step labeled <i title="">end</i>. (<a href="#fragment-case">fragment
1.604 mike 1940: case</a>)</li>
1.1 mike 1941:
1942: <li>If <var title="">node</var> is a <code><a href="tabular-data.html#the-table-element">table</a></code> element,
1.604 mike 1943: 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 1944: step labeled <i title="">end</i>.</li>
1.1 mike 1945:
1.159 mike 1946: <li>If <var title="">node</var> is a <code><a href="semantics.html#the-head-element-0">head</a></code> element,
1.604 mike 1947: 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 1948: the step labeled <i title="">end</i>. (<a href="#fragment-case">fragment
1.604 mike 1949: case</a>)</li> <!-- This is only here for now in case people
1950: think that the spec accidentally omitted it and try to "fix"
1951: it. Note that noscript-in-head is also handled this way. This is
1952: all intentional. The only thing it doesn't handle is the
1953: scripting-disabled fragment parsing case for a <head> element
1954: containing a <noscript> which itself contains something other than
1.872 mike 1955: a <link> or a <style type="text/css"> element; you'd expect that to break out of
1.604 mike 1956: the <noscript> but it doesn't. This is an edge case that doesn't
1957: affect the spec, since the algorithm for fragment parsing is only
1958: used for innerHTML/outerHTML/insertAdjacentHTML(), where we know
1959: scripting is enabled. -->
1.1 mike 1960:
1.159 mike 1961: <li>If <var title="">node</var> is a <code><a href="semantics.html#the-body-element-0">body</a></code> element,
1.604 mike 1962: 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 1963: step labeled <i title="">end</i>.</li>
1.1 mike 1964:
1.5 mike 1965: <li>If <var title="">node</var> is a <code><a href="obsolete.html#frameset">frameset</a></code> element,
1.604 mike 1966: 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 1967: the step labeled <i title="">end</i>. (<a href="#fragment-case">fragment
1.604 mike 1968: case</a>)</li>
1.1 mike 1969:
1.159 mike 1970: <li>If <var title="">node</var> is an <code><a href="semantics.html#the-html-element-0">html</a></code> element,
1.333 mike 1971: then <!--: if the <span><code title="">head</code> element
1972: pointer</span> is null,--> switch the <a href="#insertion-mode">insertion mode</a>
1973: to "<a href="#the-before-head-insertion-mode" title="insertion mode: before head">before
1974: head</a>"<!--, otherwise, switch the <span>insertion mode</span>
1975: to "<span title="insertion mode: after head">after head</span>".-->
1.856 mike 1976: 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 1977: head element pointer can ever be non-null when we're going through
1978: these steps, we'll need to uncomment out the commented-out bits -->
1979:
1.724 mike 1980: <li>If <var title="">node</var> is an element from the <a href="infrastructure.html#mathml-namespace">MathML
1981: namespace</a> or the <a href="infrastructure.html#svg-namespace">SVG namespace</a>, then set the
1.604 mike 1982: <var title="">foreign</var> flag to true.</li>
1.1 mike 1983:
1984: <li>If <var title="">last</var> is true, then switch the
1985: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in
1.856 mike 1986: 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 1987:
1988: <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
1989: elements</a>.</li>
1990:
1.856 mike 1991: <li>Return to the step labeled <i>loop</i>.</li>
1.604 mike 1992:
1993: <li><i>End</i>: If <var title="">foreign</var> is true, switch the
1994: <a href="#secondary-insertion-mode">secondary insertion mode</a> to whatever the
1995: <a href="#insertion-mode">insertion mode</a> is set to, and switch the
1996: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
1997: foreign content">in foreign content</a>".</li>
1.1 mike 1998:
1.895 mike 1999: </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 2000:
2001: <p>Initially, the <dfn id="stack-of-open-elements">stack of open elements</dfn> is empty. The
2002: stack grows downwards; the topmost node on the stack is the first
2003: one added to the stack, and the bottommost node of the stack is the
2004: most recently added node in the stack (notwithstanding when the
2005: stack is manipulated in a random access fashion as part of <a href="#adoptionAgency">the handling for misnested tags</a>).</p>
2006:
2007: <p>The "<a href="#the-before-html-insertion-mode" title="insertion mode: before html">before
2008: html</a>" <a href="#insertion-mode">insertion mode</a> creates the
1.159 mike 2009: <code><a href="semantics.html#the-html-element-0">html</a></code> root element node, which is then added to the
1.1 mike 2010: stack.</p>
2011:
2012: <p>In the <a href="#fragment-case">fragment case</a>, the <a href="#stack-of-open-elements">stack of open
1.159 mike 2013: elements</a> is initialized to contain an <code><a href="semantics.html#the-html-element-0">html</a></code>
1.1 mike 2014: element that is created as part of <a href="#html-fragment-parsing-algorithm" title="html fragment
2015: parsing algorithm">that algorithm</a>. (The <a href="#fragment-case">fragment
2016: case</a> skips the "<a href="#the-before-html-insertion-mode" title="insertion mode: before
2017: html">before html</a>" <a href="#insertion-mode">insertion mode</a>.)</p>
2018:
1.159 mike 2019: <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 2020: node of the stack. It only gets popped off the stack when the parser
2021: <a href="#stop-parsing" title="stop parsing">finishes</a>.</p>
1.1 mike 2022:
2023: <p>The <dfn id="current-node">current node</dfn> is the bottommost node in this
2024: stack.</p>
2025:
2026: <p>The <dfn id="current-table">current table</dfn> is the last <code><a href="tabular-data.html#the-table-element">table</a></code>
2027: element in the <a href="#stack-of-open-elements">stack of open elements</a>, if there is
2028: 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
2029: open elements</a> (<a href="#fragment-case">fragment case</a>), then the
2030: <a href="#current-table">current table</a> is the first element in the <a href="#stack-of-open-elements">stack
1.159 mike 2031: of open elements</a> (the <code><a href="semantics.html#the-html-element-0">html</a></code> element).</p>
1.1 mike 2032:
2033: <p>Elements in the stack fall into the following categories:</p>
2034:
2035: <dl><dt><dfn id="special">Special</dfn></dt>
2036: <dd><p>The following HTML elements have varying levels of special
2037: 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>,
2038: <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 2039: <code><a href="obsolete.html#basefont">basefont</a></code>, <code><a href="obsolete.html#bgsound">bgsound</a></code>,
1.893 mike 2040: <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="text-level-semantics.html#the-br-element">br</a></code>,
1.953 mike 2041: <code><a href="forms.html#the-button-element">button</a></code>, <code><a href="obsolete.html#center">center</a></code>, <code><a href="tabular-data.html#the-col-element">col</a></code>,
2042: <code><a href="tabular-data.html#the-colgroup-element">colgroup</a></code>, <code><a href="interactive-elements.html#the-command">command</a></code>, <!--v2DDATAGRID
2043: <code>datagrid</code>-->, <code><a href="semantics.html#the-dd-element">dd</a></code>, <code><a href="interactive-elements.html#the-details-element">details</a></code>,
2044: <code><a href="obsolete.html#dir">dir</a></code>, <code><a href="semantics.html#the-div-element">div</a></code>, <code><a href="semantics.html#the-dl-element">dl</a></code>,
2045: <code><a href="semantics.html#the-dt-element">dt</a></code>, <code><a href="text-level-semantics.html#the-embed-element">embed</a></code>, <code><a href="forms.html#the-fieldset-element">fieldset</a></code>,
2046: <code><a href="semantics.html#the-figure-element">figure</a></code>, <code><a href="semantics.html#the-footer-element">footer</a></code>, <code><a href="forms.html#the-form-element">form</a></code>,
2047: <code><a href="obsolete.html#frame">frame</a></code>, <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>,
2048: <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>,
2049: <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h6</a></code>, <code><a href="semantics.html#the-head-element-0">head</a></code>, <code><a href="semantics.html#the-header-element">header</a></code>,
2050: <code><a href="semantics.html#the-hgroup-element">hgroup</a></code>, <code><a href="semantics.html#the-hr-element">hr</a></code>, <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code>, <!--
2051: <code>image</code>, (commented out because this isn't an element
2052: that can end up on the stack, so it doesn't matter) -->
2053: <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="obsolete.html#isindex-0">isindex</a></code>,
2054: <code><a href="semantics.html#the-li-element">li</a></code>, <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="obsolete.html#listing">listing</a></code>,
2055: <code><a href="interactive-elements.html#menus">menu</a></code>, <code><a href="semantics.html#meta">meta</a></code>, <code><a href="semantics.html#the-nav-element">nav</a></code>,
2056: <code><a href="obsolete.html#noembed">noembed</a></code>, <code><a href="obsolete.html#noframes">noframes</a></code>, <code><a href="semantics.html#the-noscript-element">noscript</a></code>,
2057: <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="text-level-semantics.html#the-param-element">param</a></code>,
2058: <code><a href="obsolete.html#plaintext">plaintext</a></code>, <code><a href="semantics.html#the-pre-element">pre</a></code>, <code><a href="semantics.html#script">script</a></code>,
2059: <code><a href="semantics.html#the-section-element">section</a></code>, <code><a href="forms.html#the-select-element">select</a></code>, <code><a href="semantics.html#the-style-element">style</a></code>,
2060: <code><a href="tabular-data.html#the-tbody-element">tbody</a></code>, <code><a href="forms.html#the-textarea-element">textarea</a></code>, <code><a href="tabular-data.html#the-tfoot-element">tfoot</a></code>,
2061: <code><a href="tabular-data.html#the-thead-element">thead</a></code>, <code><a href="semantics.html#the-title-element-0">title</a></code>, <code><a href="tabular-data.html#the-tr-element">tr</a></code>,
2062: <code><a href="semantics.html#the-ul-element">ul</a></code>, <code><a href="text-level-semantics.html#the-wbr-element">wbr</a></code>, and <code><a href="obsolete.html#xmp">xmp</a></code>.</p></dd>
1.1 mike 2063:
2064: <dt><dfn id="scoping">Scoping</dfn></dt>
2065: <dd><p>The following HTML elements introduce new <a href="#has-an-element-in-scope" title="has
2066: an element in scope">scopes</a> for various parts of the
1.953 mike 2067: parsing: <code><a href="obsolete.html#the-applet-element">applet</a></code>, <code><a href="tabular-data.html#the-caption-element">caption</a></code>,
2068: <code><a href="semantics.html#the-html-element-0">html</a></code>, <code><a href="obsolete.html#the-marquee-element">marquee</a></code>, <code><a href="text-level-semantics.html#the-object-element">object</a></code>,
2069: <code><a href="tabular-data.html#the-table-element">table</a></code>, <code><a href="tabular-data.html#the-td-element">td</a></code>, <code><a href="tabular-data.html#the-th-element">th</a></code>, and SVG's
2070: <code>foreignObject</code>.</p></dd>
1.1 mike 2071:
2072: <dt><dfn id="formatting">Formatting</dfn></dt>
2073: <dd><p>The following HTML elements are those that end up in the
2074: <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 2075: <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>,
2076: <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 2077: <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 2078: <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
2079: <code><a href="obsolete.html#u">u</a></code>.</p></dd>
1.1 mike 2080:
2081: <dt><dfn id="phrasing">Phrasing</dfn></dt>
2082: <dd><p>All other elements found while parsing an HTML
2083: document.</p></dd>
2084:
1.234 mike 2085: </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
2086: specific scope</dfn> consisting of a list of element types <var title="">list</var> when the following algorithm terminates in a
2087: match state:</p>
1.1 mike 2088:
2089: <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
2090: node</a> (the bottommost node of the stack).</p></li>
2091:
2092: <li><p>If <var title="">node</var> is the target node, terminate in
2093: a match state.</p></li>
2094:
1.234 mike 2095: <li><p>Otherwise, if <var title="">node</var> is one of the element
2096: types in <var title="">list</var>, terminate in a failure
2097: state.</p></li>
1.1 mike 2098:
2099: <li><p>Otherwise, set <var title="">node</var> to the previous
2100: entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to step
2101: 2. (This will never fail, since the loop will always terminate in
2102: the previous step if the top of the stack — an
1.159 mike 2103: <code><a href="semantics.html#the-html-element-0">html</a></code> element — is reached.)</p></li>
1.1 mike 2104:
1.234 mike 2105: </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
2106: it <a href="#has-an-element-in-the-specific-scope">has an element in the specific scope</a> consisting
2107: of the following element types:</p>
2108:
2109: <ul class="brief"><li><code><a href="obsolete.html#the-applet-element">applet</a></code> in the HTML namespace</li>
2110: <li><code><a href="tabular-data.html#the-caption-element">caption</a></code> in the HTML namespace</li>
2111: <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.) -->
2112: <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
2113: <li><code><a href="tabular-data.html#the-td-element">td</a></code> in the HTML namespace</li>
2114: <li><code><a href="tabular-data.html#the-th-element">th</a></code> in the HTML namespace</li>
2115: <li><code><a href="forms.html#the-button-element">button</a></code> in the HTML namespace</li>
2116: <li><code><a href="obsolete.html#the-marquee-element">marquee</a></code> in the HTML namespace</li>
2117: <li><code><a href="text-level-semantics.html#the-object-element">object</a></code> in the HTML namespace</li>
2118: <li><code title="">foreignObject</code> in the SVG namespace</li>
2119: </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
2120: item scope</dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
2121: scope</a> consisting of the following element types:</p>
2122:
2123: <ul class="brief"><li>All the element types listed above for the <i><a href="#has-an-element-in-scope">has an element
2124: in scope</a></i> algorithm.</li>
2125: <li><code><a href="semantics.html#the-ol-element">ol</a></code> in the HTML namespace</li>
2126: <li><code><a href="semantics.html#the-ul-element">ul</a></code> in the HTML namespace</li>
2127: </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
2128: scope</em></dfn> when it <a href="#has-an-element-in-the-specific-scope">has an element in the specific
2129: scope</a> consisting of the following element types:</p>
2130:
2131: <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.) -->
2132: <li><code><a href="tabular-data.html#the-table-element">table</a></code> in the HTML namespace</li>
2133: </ul><p>Nothing happens if at any time any of the elements in the
1.1 mike 2134: <a href="#stack-of-open-elements">stack of open elements</a> are moved to a new location in,
1.810 mike 2135: or removed from, the <code><a href="infrastructure.html#document">Document</a></code> tree. In particular, the
1.1 mike 2136: stack is not changed in this situation. This can cause, amongst
2137: other strange effects, content to be appended to nodes that are no
2138: longer in the DOM.</p>
2139:
2140: <p class="note">In some cases (namely, when <a href="#adoptionAgency">closing misnested formatting elements</a>),
2141: the stack is manipulated in a random-access fashion.</p>
2142:
2143:
1.895 mike 2144: <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 2145:
2146: <p>Initially, the <dfn id="list-of-active-formatting-elements">list of active formatting elements</dfn> is
2147: empty. It is used to handle mis-nested <a href="#formatting" title="formatting">formatting element tags</a>.</p>
2148:
2149: <p>The list contains elements in the <a href="#formatting">formatting</a>
2150: category, and scope markers. The scope markers are inserted when
1.159 mike 2151: 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 2152: elements, marquees, table cells, and table captions, and are used to
1.5 mike 2153: prevent formatting from "leaking" <em>into</em> <code><a href="obsolete.html#the-applet-element">applet</a></code>
1.159 mike 2154: elements, buttons, <code><a href="text-level-semantics.html#the-object-element">object</a></code> elements, marquees, and
1.1 mike 2155: tables.</p>
2156:
2157: <p class="note">The scope markers are unrelated to the concept of an
2158: element being <a href="#has-an-element-in-scope" title="has an element in scope">in
2159: scope</a>.</p>
2160:
2161: <p>In addition, each element in the <a href="#list-of-active-formatting-elements">list of active formatting
2162: elements</a> is associated with the token for which it was
2163: created, so that further elements can be created for that token if
2164: necessary.</p>
2165:
2166: <p>When the steps below require the UA to <dfn id="reconstruct-the-active-formatting-elements">reconstruct the
2167: active formatting elements</dfn>, the UA must perform the following
2168: steps:</p>
2169:
2170: <ol><li>If there are no entries in the <a href="#list-of-active-formatting-elements">list of active formatting
2171: elements</a>, then there is nothing to reconstruct; stop this
2172: algorithm.</li>
2173:
2174: <li>If the last (most recently added) entry in the <a href="#list-of-active-formatting-elements">list of
2175: active formatting elements</a> is a marker, or if it is an
2176: element that is in the <a href="#stack-of-open-elements">stack of open elements</a>, then
2177: there is nothing to reconstruct; stop this algorithm.</li>
2178:
2179: <li>Let <var title="">entry</var> be the last (most recently added)
2180: element in the <a href="#list-of-active-formatting-elements">list of active formatting
2181: elements</a>.</li>
2182:
2183: <li>If there are no entries before <var title="">entry</var> in the
2184: <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, then jump to step
2185: 8.</li>
2186:
2187: <li>Let <var title="">entry</var> be the entry one earlier than
2188: <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
2189: elements</a>.</li>
2190:
2191: <li>If <var title="">entry</var> is neither a marker nor an element
2192: that is also in the <a href="#stack-of-open-elements">stack of open elements</a>, go to step
2193: 4.</li>
2194:
2195: <li>Let <var title="">entry</var> be the element one later than
2196: <var title="">entry</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
2197: elements</a>.</li>
2198:
2199: <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
2200: element <var title="">entry</var> was created, to obtain <var title="">new element</var>.</li>
2201:
2202: <li>Append <var title="">new element</var> to the <a href="#current-node">current
2203: node</a> and push it onto the <a href="#stack-of-open-elements">stack of open
2204: elements</a> so that it is the new <a href="#current-node">current
2205: node</a>.</li>
2206:
2207: <li>Replace the entry for <var title="">entry</var> in the list
2208: with an entry for <var title="">new element</var>.</li>
2209:
2210: <li>If the entry for <var title="">new element</var> in the
2211: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> is not the last
2212: entry in the list, return to step 7.</li>
2213:
2214: </ol><p>This has the effect of reopening all the formatting elements that
2215: were opened in the current body, cell, or caption (whichever is
2216: youngest) that haven't been explicitly closed.</p>
2217:
2218: <p class="note">The way this specification is written, the
2219: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> always consists of
2220: elements in chronological order with the least recently added
2221: element first and the most recently added element last (except for
2222: while steps 8 to 11 of the above algorithm are being executed, of
2223: course).</p>
2224:
2225: <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
2226: active formatting elements up to the last marker</dfn>, the UA must
2227: perform the following steps:</p>
2228:
2229: <ol><li>Let <var title="">entry</var> be the last (most recently added)
2230: entry in the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</li>
2231:
2232: <li>Remove <var title="">entry</var> from the <a href="#list-of-active-formatting-elements">list of active
2233: formatting elements</a>.</li>
2234:
2235: <li>If <var title="">entry</var> was a marker, then stop the
2236: algorithm at this point. The list has been cleared up to the last
2237: marker.</li>
2238:
2239: <li>Go to step 1.</li>
2240:
1.895 mike 2241: </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 2242:
2243: <p>Initially, the <dfn id="head-element-pointer"><code title="">head</code> element
2244: pointer</dfn> and the <dfn id="form-element-pointer"><code title="">form</code> element
2245: pointer</dfn> are both null.</p>
2246:
1.159 mike 2247: <p>Once a <code><a href="semantics.html#the-head-element-0">head</a></code> element has been parsed (whether
1.1 mike 2248: implicitly or explicitly) the <a href="#head-element-pointer"><code title="">head</code>
2249: element pointer</a> gets set to point to this node.</p>
2250:
2251: <p>The <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
2252: points to the last <code><a href="forms.html#the-form-element">form</a></code> element that was opened and
2253: whose end tag has not yet been seen. It is used to make form
2254: controls associate with forms in the face of dramatically bad
2255: markup, for historical reasons.</p>
2256:
2257:
1.895 mike 2258: <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 2259:
1.794 mike 2260: <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 2261: <code><a href="infrastructure.html#document">Document</a></code> with which the parser is associated when the
1.1 mike 2262: parser was created, and "disabled" otherwise.</p>
2263:
2264: <p class="note">The <a href="#scripting-flag">scripting flag</a> can be enabled even
2265: when the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML fragment
2266: parsing algorithm</a>, even though <code><a href="semantics.html#script">script</a></code> elements
2267: don't execute in that case.</p>
2268:
2269: <p>The <dfn id="frameset-ok-flag">frameset-ok flag</dfn> is set to "ok" when the parser is
2270: created. It is set to "not ok" after certain tokens are seen.</p>
2271:
1.266 mike 2272: </div><div class="impl">
1.1 mike 2273:
1.895 mike 2274: <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 2275:
2276: <p>Implementations must act as if they used the following state
2277: machine to tokenize HTML. The state machine must start in the
2278: <a href="#data-state">data state</a>. Most states consume a single character,
2279: which may have various side-effects, and either switches the state
2280: machine to a new state to <em>reconsume</em> the same character, or
2281: switches it to a new state (to consume the next character), or
2282: repeats the same state (to consume the next character). Some states
2283: have more complicated behavior and can consume several characters
1.541 mike 2284: before switching to another state. In some cases, the tokenizer
2285: state is also changed by the tree construction stage.</p>
1.1 mike 2286:
1.541 mike 2287: <p>The exact behavior of certain states depends on the
2288: <a href="#insertion-mode">insertion mode</a> and the <a href="#stack-of-open-elements">stack of open
2289: elements</a>. Certain states also use a <dfn id="temporary-buffer"><var>temporary
2290: buffer</var></dfn> to track progress.</p>
1.1 mike 2291:
2292: <p>The output of the tokenization step is a series of zero or more
2293: of the following tokens: DOCTYPE, start tag, end tag, comment,
2294: character, end-of-file. DOCTYPE tokens have a name, a public
2295: identifier, a system identifier, and a <i>force-quirks
2296: flag</i>. When a DOCTYPE token is created, its name, public
2297: identifier, and system identifier must be marked as missing (which
2298: is a distinct state from the empty string), and the <i>force-quirks
2299: flag</i> must be set to <i>off</i> (its other state is
2300: <i>on</i>). Start and end tag tokens have a tag name, a
2301: <i>self-closing flag</i>, and a list of attributes, each of which
2302: has a name and a value. When a start or end tag token is created,
2303: its <i>self-closing flag</i> must be unset (its other state is that
2304: it be set), and its attributes list must be empty. Comment and
2305: character tokens have data.</p>
2306:
2307: <p>When a token is emitted, it must immediately be handled by the
2308: <a href="#tree-construction">tree construction</a> stage. The tree construction stage
1.541 mike 2309: can affect the state of the tokenization stage, and can insert
2310: additional characters into the stream. (For example, the
1.1 mike 2311: <code><a href="semantics.html#script">script</a></code> element can result in scripts executing and
1.159 mike 2312: using the <a href="embedded-content-0.html#dynamic-markup-insertion">dynamic markup insertion</a> APIs to insert
1.1 mike 2313: characters into the stream being tokenized.)</p>
2314:
2315: <p>When a start tag token is emitted with its <i>self-closing
2316: flag</i> set, if the flag is not <dfn id="acknowledge-self-closing-flag" title="acknowledge
2317: self-closing flag">acknowledged</dfn> when it is processed by the
2318: tree construction stage, that is a <a href="#parse-error">parse error</a>.</p>
2319:
2320: <p>When an end tag token is emitted with attributes, that is a
2321: <a href="#parse-error">parse error</a>.</p>
2322:
2323: <p>When an end tag token is emitted with its <i>self-closing
2324: flag</i> set, that is a <a href="#parse-error">parse error</a>.</p>
2325:
1.541 mike 2326: <p>An <dfn id="appropriate-end-tag-token">appropriate end tag token</dfn> is an end tag token whose
2327: tag name matches the tag name of the last start tag to have been
2328: emitted from this tokenizer, if any. If no start tag has been
2329: emitted from this tokenizer, then no end tag token is
2330: appropriate.</p>
2331:
1.1 mike 2332: <p>Before each step of the tokenizer, the user agent must first
2333: check the <a href="#parser-pause-flag">parser pause flag</a>. If it is true, then the
2334: tokenizer must abort the processing of any nested invocations of the
1.479 mike 2335: tokenizer, yielding control back to the caller.</p>
1.1 mike 2336:
2337: <p>The tokenizer state machine consists of the states defined in the
2338: following subsections.</p>
2339:
1.541 mike 2340:
1.333 mike 2341: <!-- Order of the lists below is supposed to be non-error then
2342: error, by unicode, then EOF, ending with "anything else" -->
1.1 mike 2343:
1.541 mike 2344:
1.895 mike 2345: <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 2346:
2347: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2348:
2349: <dl class="switch"><dt>U+0026 AMPERSAND (&)</dt>
1.541 mike 2350: <dd>Switch to the <a href="#character-reference-in-data-state">character reference in data
1.56 mike 2351: state</a>.</dd>
1.1 mike 2352:
1.541 mike 2353: <dt>U+003C LESS-THAN SIGN (<)</dt>
2354: <dd>Switch to the <a href="#tag-open-state">tag open state</a>.</dd>
2355:
2356: <dt>EOF</dt>
2357: <dd>Emit an end-of-file token.</dd>
2358:
2359: <dt>Anything else</dt>
2360: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2361: token. Stay in the <a href="#data-state">data state</a>.</dd>
1.1 mike 2362:
1.895 mike 2363: </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 2364:
2365: <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>, with no
2366: <a href="#additional-allowed-character">additional allowed character</a>.</p>
2367:
2368: <p>If nothing is returned, emit a U+0026 AMPERSAND character
2369: token.</p>
2370:
2371: <p>Otherwise, emit the character token that was returned.</p>
2372:
2373: <p>Finally, switch to the <a href="#data-state">data state</a>.</p>
2374:
2375:
1.895 mike 2376: <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 2377:
1.541 mike 2378: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2379:
1.541 mike 2380: <dl class="switch"><dt>U+0026 AMPERSAND (&)</dt>
1.618 mike 2381: <dd>Switch to the <a href="#character-reference-in-rcdata-state">character reference in RCDATA
1.541 mike 2382: state</a>.</dd>
1.1 mike 2383:
2384: <dt>U+003C LESS-THAN SIGN (<)</dt>
1.541 mike 2385: <dd>Switch to the <a href="#rcdata-less-than-sign-state">RCDATA less-than sign state</a>.</dd>
2386:
2387: <dt>EOF</dt>
2388: <dd>Emit an end-of-file token.</dd>
1.1 mike 2389:
1.541 mike 2390: <dt>Anything else</dt>
2391: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2392: token. Stay in the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1 mike 2393:
1.755 mike 2394: </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 2395:
2396: <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>, with no
2397: <a href="#additional-allowed-character">additional allowed character</a>.</p>
2398:
2399: <p>If nothing is returned, emit a U+0026 AMPERSAND character
2400: token.</p>
2401:
2402: <p>Otherwise, emit the character token that was returned.</p>
2403:
2404: <p>Finally, switch to the <a href="#rcdata-state">RCDATA state</a>.</p>
2405:
2406:
1.895 mike 2407: <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 2408:
1.541 mike 2409: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2410:
1.541 mike 2411: <dl class="switch"><dt>U+003C LESS-THAN SIGN (<)</dt>
2412: <dd>Switch to the <a href="#rawtext-less-than-sign-state">RAWTEXT less-than sign state</a>.</dd>
1.1 mike 2413:
2414: <dt>EOF</dt>
2415: <dd>Emit an end-of-file token.</dd>
2416:
2417: <dt>Anything else</dt>
1.541 mike 2418: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2419: token. Stay in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1 mike 2420:
1.895 mike 2421: </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 2422:
1.541 mike 2423: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2424:
1.541 mike 2425: <dl class="switch"><dt>U+003C LESS-THAN SIGN (<)</dt>
2426: <dd>Switch to the <a href="#script-data-less-than-sign-state">script data less-than sign state</a>.</dd>
1.1 mike 2427:
1.541 mike 2428: <dt>EOF</dt>
2429: <dd>Emit an end-of-file token.</dd>
1.1 mike 2430:
1.541 mike 2431: <dt>Anything else</dt>
2432: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2433: token. Stay in the <a href="#script-data-state">script data state</a>.</dd>
1.1 mike 2434:
1.895 mike 2435: </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 2436:
1.541 mike 2437: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2438:
1.541 mike 2439: <dl class="switch"><dt>EOF</dt>
2440: <dd>Emit an end-of-file token.</dd>
1.1 mike 2441:
1.541 mike 2442: <dt>Anything else</dt>
2443: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2444: token. Stay in the <a href="#plaintext-state">PLAINTEXT state</a>.</dd>
1.1 mike 2445:
1.895 mike 2446: </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 2447:
1.541 mike 2448: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2449:
1.541 mike 2450: <dl class="switch"><dt>U+0021 EXCLAMATION MARK (!)</dt>
2451: <dd>Switch to the <a href="#markup-declaration-open-state">markup declaration open state</a>.</dd>
1.1 mike 2452:
1.541 mike 2453: <dt>U+002F SOLIDUS (/)</dt>
1.755 mike 2454: <dd>Switch to the <a href="#end-tag-open-state">end tag open state</a>.</dd>
1.1 mike 2455:
1.541 mike 2456: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2457: <dd>Create a new start tag token, set its tag name to the
2458: lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
2459: character's code point), then switch to the <a href="#tag-name-state">tag name
2460: state</a>. (Don't emit the token yet; further details will
2461: be filled in before it is emitted.)</dd>
1.1 mike 2462:
1.541 mike 2463: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2464: <dd>Create a new start tag token, set its tag name to the
2465: <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
2466: name state</a>. (Don't emit the token yet; further details will
2467: be filled in before it is emitted.)</dd>
1.1 mike 2468:
1.541 mike 2469: <dt>U+003F QUESTION MARK (?)</dt>
2470: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
2471: comment state</a>.</dd>
1.1 mike 2472:
1.541 mike 2473: <dt>Anything else</dt>
2474: <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
2475: character token and reconsume the <a href="#current-input-character">current input
2476: character</a> in the <a href="#data-state">data state</a>.</dd>
1.1 mike 2477:
1.755 mike 2478: </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 2479:
1.541 mike 2480: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
1.1 mike 2481:
2482: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2483: <dd>Create a new end tag token, set its tag name to the lowercase
1.541 mike 2484: version of the <a href="#current-input-character">current input character</a> (add 0x0020 to
2485: the character's code point), then switch to the <a href="#tag-name-state">tag name
1.1 mike 2486: state</a>. (Don't emit the token yet; further details will be
2487: filled in before it is emitted.)</dd>
2488:
2489: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
1.541 mike 2490: <dd>Create a new end tag token, set its tag name to the
2491: <a href="#current-input-character">current input character</a>, then switch to the <a href="#tag-name-state">tag
2492: name state</a>. (Don't emit the token yet; further details will
2493: be filled in before it is emitted.)</dd>
1.1 mike 2494:
2495: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2496: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#data-state">data
2497: state</a>.</dd>
2498:
2499: <dt>EOF</dt>
2500: <dd><a href="#parse-error">Parse error</a>. Emit a U+003C LESS-THAN SIGN
2501: character token and a U+002F SOLIDUS character token. Reconsume
2502: the EOF character in the <a href="#data-state">data state</a>.</dd>
2503:
2504: <dt>Anything else</dt>
2505: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-comment-state">bogus
2506: comment state</a>.</dd>
2507:
1.895 mike 2508: </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 2509:
2510: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2511:
2512: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2513: <dt>U+000A LINE FEED (LF)</dt>
2514: <dt>U+000C FORM FEED (FF)</dt>
2515: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2516: <dt>U+0020 SPACE</dt>
2517: <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
2518:
2519: <dt>U+002F SOLIDUS (/)</dt>
2520: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
2521:
2522: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2523: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
2524: state</a>.</dd>
2525:
2526: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541 mike 2527: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2528: character</a> (add 0x0020 to the character's code point) to the
2529: current tag token's tag name. Stay in the <a href="#tag-name-state">tag name
2530: state</a>.</dd>
2531:
2532: <dt>EOF</dt>
2533: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2534: <a href="#data-state">data state</a>.</dd>
2535:
2536: <dt>Anything else</dt>
2537: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2538: tag token's tag name. Stay in the <a href="#tag-name-state">tag name state</a>.</dd>
2539:
1.895 mike 2540: </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 2541: <!-- identical to the RAWTEXT less-than sign state, except s/RAWTEXT/RCDATA/g -->
2542:
2543: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2544:
2545: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2546: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2547: to the <a href="#rcdata-end-tag-open-state">RCDATA end tag open state</a>.</dd>
2548:
2549: <dt>Anything else</dt>
2550: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2551: <a href="#current-input-character">current input character</a> in the <a href="#rcdata-state">RCDATA
2552: state</a>.</dd>
2553:
1.895 mike 2554: </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 2555: <!-- identical to the RAWTEXT (and Script data) end tag open state, except s/RAWTEXT/RCDATA/g -->
2556:
2557: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2558:
2559: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2560: <dd>Create a new end tag token, and set its tag name to the
2561: lowercase version of the <a href="#current-input-character">current input character</a> (add
2562: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2563: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2564: switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
2565: the token yet; further details will be filled in before it is
2566: emitted.)</dd>
2567:
2568: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2569: <dd>Create a new end tag token, and set its tag name to the
2570: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2571: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2572: switch to the <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>. (Don't emit
2573: the token yet; further details will be filled in before it is
2574: emitted.)</dd>
2575:
2576: <dt>Anything else</dt>
2577: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2578: character token, and reconsume the <a href="#current-input-character">current input
2579: character</a> in the <a href="#rcdata-state">RCDATA state</a>.</dd>
2580:
1.895 mike 2581: </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 2582: <!-- identical to the RAWTEXT (and Script data) end tag name state, except s/RAWTEXT/RCDATA/g -->
2583:
2584: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2585:
2586: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2587: <dt>U+000A LINE FEED (LF)</dt>
2588: <dt>U+000C FORM FEED (FF)</dt>
2589: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2590: <dt>U+0020 SPACE</dt>
2591: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2592: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2593: state</a>. Otherwise, treat it as per the "anything else" entry
2594: below.</dd>
2595:
2596: <dt>U+002F SOLIDUS (/)</dt>
2597: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2598: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2599: state</a>. Otherwise, treat it as per the "anything else" entry
2600: below.</dd>
2601:
2602: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2603: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2604: token</a>, then emit the current tag token and switch to the
2605: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2606: else" entry below.</dd>
2607:
2608: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2609: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2610: character</a> (add 0x0020 to the character's code point) to the
2611: current tag token's tag name. Append the <a href="#current-input-character">current input
2612: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2613: <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
2614:
2615: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2616: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2617: tag token's tag name. Append the <a href="#current-input-character">current input
2618: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2619: <a href="#rcdata-end-tag-name-state">RCDATA end tag name state</a>.</dd>
2620:
2621: <dt>Anything else</dt>
2622: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2623: character token, a character token for each of the characters in
2624: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2625: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2626: in the <a href="#rcdata-state">RCDATA state</a>.</dd>
2627:
1.895 mike 2628: </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 2629: <!-- identical to the RCDATA less-than sign state, except s/RCDATA/RAWTEXT/g -->
2630:
2631: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2632:
2633: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2634: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2635: to the <a href="#rawtext-end-tag-open-state">RAWTEXT end tag open state</a>.</dd>
2636:
2637: <dt>Anything else</dt>
2638: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2639: <a href="#current-input-character">current input character</a> in the <a href="#rawtext-state">RAWTEXT
2640: state</a>.</dd>
2641:
1.895 mike 2642: </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 2643: <!-- identical to the RCDATA (and Script data) end tag open state, except s/RCDATA/RAWTEXT/g -->
2644:
2645: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2646:
2647: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2648: <dd>Create a new end tag token, and set its tag name to the
2649: lowercase version of the <a href="#current-input-character">current input character</a> (add
2650: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2651: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2652: switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
2653: the token yet; further details will be filled in before it is
2654: emitted.)</dd>
2655:
2656: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2657: <dd>Create a new end tag token, and set its tag name to the
2658: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2659: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2660: switch to the <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>. (Don't emit
2661: the token yet; further details will be filled in before it is
2662: emitted.)</dd>
2663:
2664: <dt>Anything else</dt>
2665: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2666: character token, and reconsume the <a href="#current-input-character">current input
2667: character</a> in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
2668:
1.895 mike 2669: </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 2670: <!-- identical to the RCDATA (and Script data) end tag name state, except s/RCDATA/RAWTEXT/g -->
2671:
2672: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2673:
2674: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2675: <dt>U+000A LINE FEED (LF)</dt>
2676: <dt>U+000C FORM FEED (FF)</dt>
2677: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2678: <dt>U+0020 SPACE</dt>
2679: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2680: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2681: state</a>. Otherwise, treat it as per the "anything else" entry
2682: below.</dd>
2683:
2684: <dt>U+002F SOLIDUS (/)</dt>
2685: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2686: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2687: state</a>. Otherwise, treat it as per the "anything else" entry
2688: below.</dd>
2689:
2690: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2691: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2692: token</a>, then emit the current tag token and switch to the
2693: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2694: else" entry below.</dd>
2695:
2696: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2697: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2698: character</a> (add 0x0020 to the character's code point) to the
2699: current tag token's tag name. Append the <a href="#current-input-character">current input
2700: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2701: <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
2702:
2703: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2704: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2705: tag token's tag name. Append the <a href="#current-input-character">current input
2706: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2707: <a href="#rawtext-end-tag-name-state">RAWTEXT end tag name state</a>.</dd>
2708:
2709: <dt>Anything else</dt>
2710: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2711: character token, a character token for each of the characters in
2712: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2713: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2714: in the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
2715:
1.895 mike 2716: </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 2717:
2718: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2719:
2720: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2721: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2722: to the <a href="#script-data-end-tag-open-state">script data end tag open state</a>.</dd>
2723:
2724: <dt>U+0021 EXCLAMATION MARK (!)</dt>
2725: <dd>Emit a U+003C LESS-THAN SIGN character token and a U+0021
2726: EXCLAMATION MARK character token. Switch to the <a href="#script-data-escape-start-state">script data
2727: escape start state</a>.</dd>
2728:
2729: <dt>Anything else</dt>
2730: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2731: <a href="#current-input-character">current input character</a> in the <a href="#script-data-state">script data
2732: state</a>.</dd>
2733:
1.895 mike 2734: </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 2735: <!-- identical to the RCDATA (and RAWTEXT) end tag open state, except s/RCDATA/Script data/g -->
2736:
2737: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2738:
2739: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2740: <dd>Create a new end tag token, and set its tag name to the
2741: lowercase version of the <a href="#current-input-character">current input character</a> (add
2742: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2743: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2744: switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
2745: the token yet; further details will be filled in before it is
2746: emitted.)</dd>
2747:
2748: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2749: <dd>Create a new end tag token, and set its tag name to the
2750: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2751: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2752: switch to the <a href="#script-data-end-tag-name-state">script data end tag name state</a>. (Don't emit
2753: the token yet; further details will be filled in before it is
2754: emitted.)</dd>
2755:
2756: <dt>Anything else</dt>
2757: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2758: character token, and reconsume the <a href="#current-input-character">current input
2759: character</a> in the <a href="#script-data-state">script data state</a>.</dd>
2760:
1.895 mike 2761: </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 2762: <!-- identical to the RCDATA (and RAWTEXT) end tag name state, except s/RCDATA/Script data/g -->
2763:
2764: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2765:
2766: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2767: <dt>U+000A LINE FEED (LF)</dt>
2768: <dt>U+000C FORM FEED (FF)</dt>
2769: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2770: <dt>U+0020 SPACE</dt>
2771: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2772: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2773: state</a>. Otherwise, treat it as per the "anything else" entry
2774: below.</dd>
2775:
2776: <dt>U+002F SOLIDUS (/)</dt>
2777: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2778: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2779: state</a>. Otherwise, treat it as per the "anything else" entry
2780: below.</dd>
2781:
2782: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2783: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2784: token</a>, then emit the current tag token and switch to the
2785: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2786: else" entry below.</dd>
2787:
2788: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2789: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2790: character</a> (add 0x0020 to the character's code point) to the
2791: current tag token's tag name. Append the <a href="#current-input-character">current input
2792: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542 mike 2793: <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541 mike 2794:
2795: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2796: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2797: tag token's tag name. Append the <a href="#current-input-character">current input
2798: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
1.542 mike 2799: <a href="#script-data-end-tag-name-state">script data end tag name state</a>.</dd>
1.541 mike 2800:
2801: <dt>Anything else</dt>
2802: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2803: character token, a character token for each of the characters in
2804: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2805: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2806: in the <a href="#script-data-state">script data state</a>.</dd>
2807:
1.895 mike 2808: </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 2809:
2810: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2811:
2812: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2813: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2814: <a href="#script-data-escape-start-dash-state">script data escape start dash state</a>.</dd>
2815:
2816: <dt>Anything else</dt>
2817: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
2818: <a href="#script-data-state">script data state</a>.</dd>
2819:
1.895 mike 2820: </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 2821:
2822: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2823:
2824: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2825: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2826: <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
2827:
2828: <dt>Anything else</dt>
2829: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
2830: <a href="#script-data-state">script data state</a>.</dd>
2831:
1.895 mike 2832: </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 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. Switch to the
2838: <a href="#script-data-escaped-dash-state">script data escaped dash state</a>.</dd>
2839:
1.542 mike 2840: <dt>U+003C LESS-THAN SIGN (<)</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>EOF</dt>
2845: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2846: <a href="#data-state">data state</a>.</dd>
2847:
2848: <dt>Anything else</dt>
1.542 mike 2849: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2850: token. Stay in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541 mike 2851:
1.895 mike 2852: </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 2853:
2854: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2855:
2856: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2857: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
2858: <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
2859:
1.542 mike 2860: <dt>U+003C LESS-THAN SIGN (<)</dt>
2861: <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
2862: state</a>.</p></dd>
2863:
1.541 mike 2864: <dt>EOF</dt>
2865: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2866: <a href="#data-state">data state</a>.</dd>
2867:
2868: <dt>Anything else</dt>
1.542 mike 2869: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2870: token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
1.541 mike 2871:
1.895 mike 2872: </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 2873:
2874: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2875:
2876: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
2877: <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
2878: <a href="#script-data-escaped-dash-dash-state">script data escaped dash dash state</a>.</dd>
2879:
1.542 mike 2880: <dt>U+003C LESS-THAN SIGN (<)</dt>
2881: <dd><p>Switch to the <a href="#script-data-escaped-less-than-sign-state">script data escaped less-than sign
2882: state</a>.</p></dd>
2883:
1.541 mike 2884: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2885: <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
2886: <a href="#script-data-state">script data state</a>.</dd>
1.1 mike 2887:
2888: <dt>EOF</dt>
2889: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
2890: <a href="#data-state">data state</a>.</dd>
2891:
2892: <dt>Anything else</dt>
1.542 mike 2893: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
2894: token. Switch to the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2895:
1.895 mike 2896: </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 2897:
2898: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2899:
2900: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
2901: <dd>Set the <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Switch
2902: to the <a href="#script-data-escaped-end-tag-open-state">script data escaped end tag open state</a>.</dd>
2903:
2904: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2905: <dd>Emit a U+003C LESS-THAN SIGN character token and the
2906: <a href="#current-input-character">current input character</a> as a character token. Set the
2907: <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
2908: lowercase version of the <a href="#current-input-character">current input character</a> (add
2909: 0x0020 to the character's code point) to the <var><a href="#temporary-buffer">temporary
2910: buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
2911: state</a>.</dd>
2912:
2913: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2914: <dd>Emit a U+003C LESS-THAN SIGN character token and the
2915: <a href="#current-input-character">current input character</a> as a character token. Set the
2916: <var><a href="#temporary-buffer">temporary buffer</a></var> to the empty string. Append the
2917: <a href="#current-input-character">current input character</a> to the <var><a href="#temporary-buffer">temporary
2918: buffer</a></var>. Switch to the <a href="#script-data-double-escape-start-state">script data double escape start
2919: state</a>.</dd>
2920:
2921: <dt>Anything else</dt>
2922: <dd>Emit a U+003C LESS-THAN SIGN character token and reconsume the
2923: <a href="#current-input-character">current input character</a> in the <a href="#script-data-escaped-state">script data
2924: escaped state</a>.</dd>
2925:
1.895 mike 2926: </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 2927:
2928: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2929:
2930: <dl class="switch"><dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2931: <dd>Create a new end tag token, and set its tag name to the
2932: lowercase version of the <a href="#current-input-character">current input character</a> (add
2933: 0x0020 to the character's code point). Append the <a href="#current-input-character">current
2934: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2935: switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
2936: state</a>. (Don't emit the token yet; further details will be
2937: filled in before it is emitted.)</dd>
2938:
2939: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2940: <dd>Create a new end tag token, and set its tag name to the
2941: <a href="#current-input-character">current input character</a>. Append the <a href="#current-input-character">current
2942: input character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Finally,
2943: switch to the <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name
2944: state</a>. (Don't emit the token yet; further details will be
2945: filled in before it is emitted.)</dd>
2946:
2947: <dt>Anything else</dt>
2948: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2949: character token, and reconsume the <a href="#current-input-character">current input
2950: character</a> in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2951:
1.895 mike 2952: </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 2953:
2954: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
2955:
2956: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
2957: <dt>U+000A LINE FEED (LF)</dt>
2958: <dt>U+000C FORM FEED (FF)</dt>
2959: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
2960: <dt>U+0020 SPACE</dt>
2961: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2962: token</a>, then switch to the <a href="#before-attribute-name-state">before attribute name
2963: state</a>. Otherwise, treat it as per the "anything else" entry
2964: below.</dd>
2965:
2966: <dt>U+002F SOLIDUS (/)</dt>
2967: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2968: token</a>, then switch to the <a href="#self-closing-start-tag-state">self-closing start tag
2969: state</a>. Otherwise, treat it as per the "anything else" entry
2970: below.</dd>
2971:
2972: <dt>U+003E GREATER-THAN SIGN (>)</dt>
2973: <dd>If the current end tag token is an <a href="#appropriate-end-tag-token">appropriate end tag
2974: token</a>, then emit the current tag token and switch to the
2975: <a href="#data-state">data state</a>. Otherwise, treat it as per the "anything
2976: else" entry below.</dd>
2977:
2978: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
2979: <dd>Append the lowercase version of the <a href="#current-input-character">current input
2980: character</a> (add 0x0020 to the character's code point) to the
2981: current tag token's tag name. Append the <a href="#current-input-character">current input
2982: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2983: <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
2984:
2985: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
2986: <dd>Append the <a href="#current-input-character">current input character</a> to the current
2987: tag token's tag name. Append the <a href="#current-input-character">current input
2988: character</a> to the <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the
2989: <a href="#script-data-escaped-end-tag-name-state">script data escaped end tag name state</a>.</dd>
2990:
2991: <dt>Anything else</dt>
2992: <dd>Emit a U+003C LESS-THAN SIGN character token, a U+002F SOLIDUS
2993: character token, a character token for each of the characters in
2994: the <var><a href="#temporary-buffer">temporary buffer</a></var> (in the order they were added to
2995: the buffer), and reconsume the <a href="#current-input-character">current input character</a>
2996: in the <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
2997:
1.895 mike 2998: </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 2999:
3000: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3001:
3002: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3003: <dt>U+000A LINE FEED (LF)</dt>
3004: <dt>U+000C FORM FEED (FF)</dt>
3005: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3006: <dt>U+0020 SPACE</dt>
3007: <dt>U+002F SOLIDUS (/)</dt>
3008: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3009: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3010: 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
3011: double escaped state</a>. Otherwise, switch to the <a href="#script-data-escaped-state">script
3012: data escaped state</a>.</dd>
3013:
3014: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3015: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3016: token. Append the lowercase version of the <a href="#current-input-character">current input
3017: character</a> (add 0x0020 to the character's code point) to the
3018: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
3019: escape start state</a>.</dd>
3020:
3021: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
3022: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3023: token. Append the <a href="#current-input-character">current input character</a> to the
3024: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-start-state">script data double
3025: escape start state</a>.</dd>
3026:
3027: <dt>Anything else</dt>
3028: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
3029: <a href="#script-data-escaped-state">script data escaped state</a>.</dd>
3030:
1.895 mike 3031: </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 3032:
3033: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3034:
3035: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3036: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
3037: <a href="#script-data-double-escaped-dash-state">script data double escaped dash state</a>.</dd>
3038:
3039: <dt>U+003C LESS-THAN SIGN (<)</dt>
3040: <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
3041: <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
3042: state</a>.</p></dd>
3043:
3044: <dt>EOF</dt>
3045: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3046: <a href="#data-state">data state</a>.</dd>
3047:
3048: <dt>Anything else</dt>
3049: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3050: token. Stay in the <a href="#script-data-double-escaped-state">script data double escaped
3051: state</a>.</dd>
3052:
1.895 mike 3053: </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 3054:
3055: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3056:
3057: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3058: <dd>Emit a U+002D HYPHEN-MINUS character token. Switch to the
3059: <a href="#script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>.</dd>
3060:
3061: <dt>U+003C LESS-THAN SIGN (<)</dt>
3062: <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
3063: <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
3064: state</a>.</p></dd>
3065:
3066: <dt>EOF</dt>
3067: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3068: <a href="#data-state">data state</a>.</dd>
3069:
3070: <dt>Anything else</dt>
3071: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3072: token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
3073: state</a>.</dd>
3074:
1.895 mike 3075: </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 3076:
3077: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3078:
3079: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3080: <dd>Emit a U+002D HYPHEN-MINUS character token. Stay in the
3081: <a href="#script-data-double-escaped-dash-dash-state">script data double escaped dash dash state</a>.</dd>
3082:
3083: <dt>U+003C LESS-THAN SIGN (<)</dt>
3084: <dd><p>Emit a U+003C LESS-THAN SIGN character token. Switch to the
3085: <a href="#script-data-double-escaped-less-than-sign-state">script data double escaped less-than sign
3086: state</a>.</p></dd>
3087:
3088: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3089: <dd>Emit a U+003E GREATER-THAN SIGN character token. Switch to the
3090: <a href="#script-data-state">script data state</a>.</dd>
3091:
3092: <dt>EOF</dt>
3093: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3094: <a href="#data-state">data state</a>.</dd>
3095:
3096: <dt>Anything else</dt>
3097: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3098: token. Switch to the <a href="#script-data-double-escaped-state">script data double escaped
3099: state</a>.</dd>
3100:
1.895 mike 3101: </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 3102:
3103: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3104:
3105: <dl class="switch"><dt>U+002F SOLIDUS (/)</dt>
3106: <dd>Emit a U+002F SOLIDUS character token. Set the <var><a href="#temporary-buffer">temporary
3107: buffer</a></var> to the empty string. Switch to the <a href="#script-data-double-escape-end-state">script data
3108: double escape end state</a>.</dd>
3109:
3110: <dt>Anything else</dt>
3111: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
3112: <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
3113:
1.895 mike 3114: </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 3115:
3116: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3117:
3118: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3119: <dt>U+000A LINE FEED (LF)</dt>
3120: <dt>U+000C FORM FEED (FF)</dt>
3121: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3122: <dt>U+0020 SPACE</dt>
3123: <dt>U+002F SOLIDUS (/)</dt>
3124: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3125: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3126: 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
3127: escaped state</a>. Otherwise, switch to the <a href="#script-data-double-escaped-state">script data
3128: double escaped state</a>.</dd>
3129:
3130: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3131: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3132: token. Append the lowercase version of the <a href="#current-input-character">current input
3133: character</a> (add 0x0020 to the character's code point) to the
3134: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
3135: escape end state</a>.</dd>
3136:
3137: <dt>U+0061 LATIN SMALL LETTER A through to U+007A LATIN SMALL LETTER Z</dt>
3138: <dd>Emit the <a href="#current-input-character">current input character</a> as a character
3139: token. Append the <a href="#current-input-character">current input character</a> to the
3140: <var><a href="#temporary-buffer">temporary buffer</a></var>. Stay in the <a href="#script-data-double-escape-end-state">script data double
3141: escape end state</a>.</dd>
3142:
3143: <dt>Anything else</dt>
3144: <dd>Reconsume the <a href="#current-input-character">current input character</a> in the
3145: <a href="#script-data-double-escaped-state">script data double escaped state</a>.</dd>
1.1 mike 3146:
1.895 mike 3147: </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 3148:
3149: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3150:
3151: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3152: <dt>U+000A LINE FEED (LF)</dt>
3153: <dt>U+000C FORM FEED (FF)</dt>
3154: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3155: <dt>U+0020 SPACE</dt>
3156: <dd>Stay in the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3157:
3158: <dt>U+002F SOLIDUS (/)</dt>
3159: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3160:
3161: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3162: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3163: state</a>.</dd>
3164:
3165: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3166: <dd>Start a new attribute in the current tag token. Set that
3167: attribute's name to the lowercase version of the <a href="#current-input-character">current input
3168: character</a> (add 0x0020 to the character's code point), and its
3169: value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
3170: state</a>.</dd>
3171:
3172: <dt>U+0022 QUOTATION MARK (")</dt>
3173: <dt>U+0027 APOSTROPHE (')</dt>
3174: <dt>U+003C LESS-THAN SIGN (<)</dt>
3175: <dt>U+003D EQUALS SIGN (=)</dt>
3176: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3177: entry below.</dd>
3178:
3179: <dt>EOF</dt>
3180: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3181: <a href="#data-state">data state</a>.</dd>
3182:
3183: <dt>Anything else</dt>
3184: <dd>Start a new attribute in the current tag token. Set that
3185: attribute's name to the <a href="#current-input-character">current input character</a>, and its value to
3186: the empty string. Switch to the <a href="#attribute-name-state">attribute name
3187: state</a>.</dd>
3188:
1.895 mike 3189: </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 3190:
3191: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3192:
3193: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3194: <dt>U+000A LINE FEED (LF)</dt>
3195: <dt>U+000C FORM FEED (FF)</dt>
3196: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3197: <dt>U+0020 SPACE</dt>
3198: <dd>Switch to the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
3199:
3200: <dt>U+002F SOLIDUS (/)</dt>
3201: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3202:
3203: <dt>U+003D EQUALS SIGN (=)</dt>
3204: <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
3205:
3206: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3207: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3208: state</a>.</dd>
3209:
3210: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541 mike 3211: <dd>Append the lowercase version of the <a href="#current-input-character">current input
3212: character</a> (add 0x0020 to the character's code point) to the
3213: current attribute's name. Stay in the <a href="#attribute-name-state">attribute name
1.1 mike 3214: state</a>.</dd>
3215:
3216: <dt>U+0022 QUOTATION MARK (")</dt>
3217: <dt>U+0027 APOSTROPHE (')</dt>
3218: <dt>U+003C LESS-THAN SIGN (<)</dt>
3219: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3220: entry below.</dd>
3221:
3222: <dt>EOF</dt>
3223: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3224: <a href="#data-state">data state</a>.</dd>
3225:
3226: <dt>Anything else</dt>
1.541 mike 3227: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3228: attribute's name. Stay in the <a href="#attribute-name-state">attribute name
3229: state</a>.</dd>
1.1 mike 3230:
3231: </dl><p>When the user agent leaves the attribute name state (and before
3232: emitting the tag token, if appropriate), the complete attribute's
3233: name must be compared to the other attributes on the same token;
3234: if there is already an attribute on the token with the exact same
3235: name, then this is a <a href="#parse-error">parse error</a> and the new
3236: attribute must be dropped, along with the value that gets
3237: associated with it (if any).</p>
3238:
3239:
1.895 mike 3240: <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 3241:
3242: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3243:
3244: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3245: <dt>U+000A LINE FEED (LF)</dt>
3246: <dt>U+000C FORM FEED (FF)</dt>
3247: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3248: <dt>U+0020 SPACE</dt>
3249: <dd>Stay in the <a href="#after-attribute-name-state">after attribute name state</a>.</dd>
3250:
3251: <dt>U+002F SOLIDUS (/)</dt>
3252: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3253:
3254: <dt>U+003D EQUALS SIGN (=)</dt>
3255: <dd>Switch to the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
3256:
3257: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3258: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3259: state</a>.</dd>
3260:
3261: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3262: <dd>Start a new attribute in the current tag token. Set that
1.541 mike 3263: attribute's name to the lowercase version of the <a href="#current-input-character">current
3264: input character</a> (add 0x0020 to the character's code point),
3265: and its value to the empty string. Switch to the <a href="#attribute-name-state">attribute
3266: name state</a>.</dd>
1.1 mike 3267:
3268: <dt>U+0022 QUOTATION MARK (")</dt>
3269: <dt>U+0027 APOSTROPHE (')</dt>
3270: <dt>U+003C LESS-THAN SIGN (<)</dt>
3271: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3272: entry below.</dd>
3273:
3274: <dt>EOF</dt>
3275: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3276: <a href="#data-state">data state</a>.</dd>
3277:
3278: <dt>Anything else</dt>
3279: <dd>Start a new attribute in the current tag token. Set that
1.541 mike 3280: attribute's name to the <a href="#current-input-character">current input character</a>, and
3281: its value to the empty string. Switch to the <a href="#attribute-name-state">attribute name
1.1 mike 3282: state</a>.</dd>
3283:
1.895 mike 3284: </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 3285:
3286: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3287:
3288: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3289: <dt>U+000A LINE FEED (LF)</dt>
3290: <dt>U+000C FORM FEED (FF)</dt>
3291: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3292: <dt>U+0020 SPACE</dt>
3293: <dd>Stay in the <a href="#before-attribute-value-state">before attribute value state</a>.</dd>
3294:
3295: <dt>U+0022 QUOTATION MARK (")</dt>
3296: <dd>Switch to the <a href="#attribute-value-double-quoted-state">attribute value (double-quoted) state</a>.</dd>
3297:
3298: <dt>U+0026 AMPERSAND (&)</dt>
3299: <dd>Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted) state</a>
1.541 mike 3300: and reconsume this <a href="#current-input-character">current input character</a>.</dd>
1.1 mike 3301:
3302: <dt>U+0027 APOSTROPHE (')</dt>
3303: <dd>Switch to the <a href="#attribute-value-single-quoted-state">attribute value (single-quoted) state</a>.</dd>
3304:
3305: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3306: <dd><a href="#parse-error">Parse error</a>. Emit the current tag token. Switch to
3307: the <a href="#data-state">data state</a>.</dd>
3308:
3309: <dt>U+003C LESS-THAN SIGN (<)</dt>
3310: <dt>U+003D EQUALS SIGN (=)</dt>
1.463 mike 3311: <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1 mike 3312: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3313: entry below.</dd>
3314:
3315: <dt>EOF</dt>
3316: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3317: <a href="#data-state">data state</a>.</dd>
3318:
3319: <dt>Anything else</dt>
3320: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3321: attribute's value. Switch to the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
3322: state</a>.</dd>
3323:
1.755 mike 3324: </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 3325:
3326: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3327:
3328: <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
3329: <dd>Switch to the <a href="#after-attribute-value-quoted-state">after attribute value (quoted)
3330: state</a>.</dd>
3331:
3332: <dt>U+0026 AMPERSAND (&)</dt>
3333: <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
3334: state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
3335: being U+0022 QUOTATION MARK (").</dd>
3336:
3337: <dt>EOF</dt>
3338: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3339: <a href="#data-state">data state</a>.</dd>
3340:
3341: <dt>Anything else</dt>
1.541 mike 3342: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3343: attribute's value. Stay in the <a href="#attribute-value-double-quoted-state">attribute value
3344: (double-quoted) state</a>.</dd>
1.1 mike 3345:
1.755 mike 3346: </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 3347:
3348: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3349:
3350: <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
3351: <dd>Switch to the <a href="#after-attribute-value-quoted-state">after attribute value (quoted)
3352: state</a>.</dd>
3353:
3354: <dt>U+0026 AMPERSAND (&)</dt>
3355: <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
3356: state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
3357: being U+0027 APOSTROPHE (').</dd>
3358:
3359: <dt>EOF</dt>
3360: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3361: <a href="#data-state">data state</a>.</dd>
3362:
3363: <dt>Anything else</dt>
1.541 mike 3364: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3365: attribute's value. Stay in the <a href="#attribute-value-single-quoted-state">attribute value
3366: (single-quoted) state</a>.</dd>
1.1 mike 3367:
1.755 mike 3368: </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 3369:
3370: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3371:
3372: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3373: <dt>U+000A LINE FEED (LF)</dt>
3374: <dt>U+000C FORM FEED (FF)</dt>
3375: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3376: <dt>U+0020 SPACE</dt>
3377: <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3378:
3379: <dt>U+0026 AMPERSAND (&)</dt>
3380: <dd>Switch to the <a href="#character-reference-in-attribute-value-state">character reference in attribute value
1.299 mike 3381: state</a>, with the <a href="#additional-allowed-character">additional allowed character</a>
3382: being U+003E GREATER-THAN SIGN (>).</dd>
1.1 mike 3383:
3384: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3385: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3386: state</a>.</dd>
3387:
3388: <dt>U+0022 QUOTATION MARK (")</dt>
3389: <dt>U+0027 APOSTROPHE (')</dt>
3390: <dt>U+003C LESS-THAN SIGN (<)</dt>
3391: <dt>U+003D EQUALS SIGN (=)</dt>
1.463 mike 3392: <dt>U+0060 GRAVE ACCENT (`)</dt>
1.1 mike 3393: <dd><a href="#parse-error">Parse error</a>. Treat it as per the "anything else"
3394: entry below.</dd>
3395:
3396: <dt>EOF</dt>
3397: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3398: <a href="#data-state">data state</a>.</dd>
3399:
3400: <dt>Anything else</dt>
1.541 mike 3401: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3402: attribute's value. Stay in the <a href="#attribute-value-unquoted-state">attribute value (unquoted)
1.1 mike 3403: state</a>.</dd>
3404:
1.895 mike 3405: </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 3406:
3407: <p>Attempt to <a href="#consume-a-character-reference">consume a character reference</a>.</p>
3408:
3409: <p>If nothing is returned, append a U+0026 AMPERSAND character to
3410: the current attribute's value.</p>
3411:
3412: <p>Otherwise, append the returned character token to the current
3413: attribute's value.</p>
3414:
3415: <p>Finally, switch back to the attribute value state that you were
3416: in when were switched into this state.</p>
3417:
3418:
1.755 mike 3419: <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 3420:
3421: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3422:
3423: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3424: <dt>U+000A LINE FEED (LF)</dt>
3425: <dt>U+000C FORM FEED (FF)</dt>
3426: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3427: <dt>U+0020 SPACE</dt>
3428: <dd>Switch to the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3429:
3430: <dt>U+002F SOLIDUS (/)</dt>
3431: <dd>Switch to the <a href="#self-closing-start-tag-state">self-closing start tag state</a>.</dd>
3432:
3433: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3434: <dd>Emit the current tag token. Switch to the <a href="#data-state">data
3435: state</a>.</dd>
3436:
3437: <dt>EOF</dt>
3438: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3439: <a href="#data-state">data state</a>.</dd>
3440:
3441: <dt>Anything else</dt>
3442: <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
3443: the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3444:
1.895 mike 3445: </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 3446:
3447: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3448:
3449: <dl class="switch"><dt>U+003E GREATER-THAN SIGN (>)</dt>
3450: <dd>Set the <i>self-closing flag</i> of the current tag
3451: token. Emit the current tag token. Switch to the <a href="#data-state">data
3452: state</a>.</dd>
3453:
3454: <dt>EOF</dt>
3455: <dd><a href="#parse-error">Parse error</a>. Reconsume the EOF character in the
3456: <a href="#data-state">data state</a>.</dd>
3457:
3458: <dt>Anything else</dt>
3459: <dd><a href="#parse-error">Parse error</a>. Reconsume the character in
3460: the <a href="#before-attribute-name-state">before attribute name state</a>.</dd>
3461:
1.895 mike 3462: </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 3463:
3464: <p>Consume every character up to and including the first U+003E
3465: GREATER-THAN SIGN character (>) or the end of the file (EOF),
3466: whichever comes first. Emit a comment token whose data is the
3467: concatenation of all the characters starting from and including
3468: the character that caused the state machine to switch into the
3469: bogus comment state, up to and including the character immediately
3470: before the last consumed character (i.e. up to the character just
3471: before the U+003E or EOF character). (If the comment was started
3472: by the end of the file (EOF), the token is empty.)</p>
3473:
3474: <p>Switch to the <a href="#data-state">data state</a>.</p>
3475:
3476: <p>If the end of the file was reached, reconsume the EOF
3477: character.</p>
3478:
3479:
1.895 mike 3480: <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 3481:
1.588 mike 3482: <p>If the next two characters are both U+002D HYPHEN-MINUS
3483: characters (-), consume those two characters, create a comment token
1.1 mike 3484: whose data is the empty string, and switch to the <a href="#comment-start-state">comment
3485: start state</a>.</p>
3486:
3487: <p>Otherwise, if the next seven characters are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
3488: case-insensitive</a> match for the word "DOCTYPE", then consume
3489: those characters and switch to the <a href="#doctype-state">DOCTYPE state</a>.</p>
3490:
3491: <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
3492: content</a>" and the <a href="#current-node">current node</a> is not an element
1.724 mike 3493: in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a> and the next seven characters are
1.585 mike 3494: an <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string "[CDATA[" (the
3495: five uppercase letters "CDATA" with a U+005B LEFT SQUARE BRACKET
3496: character before and after), then consume those characters and
3497: switch to the <a href="#cdata-section-state">CDATA section state</a>.</p>
1.1 mike 3498:
3499: <p>Otherwise, this is a <a href="#parse-error">parse error</a>. Switch to the
3500: <a href="#bogus-comment-state">bogus comment state</a>. The next character that is
3501: consumed, if any, is the first character that will be in the
3502: comment.</p>
3503:
3504:
1.895 mike 3505: <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 3506:
3507: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3508:
3509: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3510: <dd>Switch to the <a href="#comment-start-dash-state">comment start dash state</a>.</dd>
3511:
3512: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3513: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to the
3514: <a href="#data-state">data state</a>.</dd> <!-- see comment in comment end state
3515: -->
3516:
3517: <dt>EOF</dt>
3518: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3519: the EOF character in the <a href="#data-state">data state</a>.</dd>
3520:
3521: <dt>Anything else</dt>
1.541 mike 3522: <dd>Append the <a href="#current-input-character">current input character</a> to the comment
3523: token's data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3524:
1.895 mike 3525: </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 3526:
3527: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3528:
3529: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3530: <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
3531:
3532: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3533: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Switch to
3534: the <a href="#data-state">data state</a>.</dd>
3535:
3536: <dt>EOF</dt>
3537: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
3538: EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
3539: in comment end state -->
3540:
3541: <dt>Anything else</dt>
1.541 mike 3542: <dd>Append a U+002D HYPHEN-MINUS character (-) and the
3543: <a href="#current-input-character">current input character</a> to the comment token's
3544: data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3545:
1.895 mike 3546: </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 3547:
3548: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3549:
3550: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3551: <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a></dd>
3552:
3553: <dt>EOF</dt>
3554: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
3555: EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
3556: in comment end state -->
3557:
3558: <dt>Anything else</dt>
1.541 mike 3559: <dd>Append the <a href="#current-input-character">current input character</a> to the comment
3560: token's data. Stay in the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3561:
1.895 mike 3562: </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 3563:
3564: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3565:
3566: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
3567: <dd>Switch to the <a href="#comment-end-state">comment end state</a></dd>
3568:
3569: <dt>EOF</dt>
3570: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume the
3571: EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see comment
3572: in comment end state -->
3573:
3574: <dt>Anything else</dt>
1.541 mike 3575: <dd>Append a U+002D HYPHEN-MINUS character (-) and the
3576: <a href="#current-input-character">current input character</a> to the comment token's
3577: data. Switch to the <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3578:
1.895 mike 3579: </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 3580:
3581: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3582:
3583: <dl class="switch"><dt>U+003E GREATER-THAN SIGN (>)</dt>
3584: <dd>Emit the comment token. Switch to the <a href="#data-state">data
3585: state</a>.</dd>
3586:
3587: <dt>U+0009 CHARACTER TABULATION</dt>
3588: <dt>U+000A LINE FEED (LF)</dt>
3589: <dt>U+000C FORM FEED (FF)</dt>
3590: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3591: <dt>U+0020 SPACE</dt>
1.588 mike 3592: <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS
3593: characters (-) and the <a href="#current-input-character">current input character</a> to the
1.541 mike 3594: comment token's data. Switch to the <a href="#comment-end-space-state">comment end space
3595: state</a>.</dd>
1.1 mike 3596:
3597: <dt>U+0021 EXCLAMATION MARK (!)</dt>
3598: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#comment-end-bang-state">comment end bang
3599: state</a>.</dd>
3600:
1.333 mike 3601: <dt>U+002D HYPHEN-MINUS (-)</dt>
3602: <dd><a href="#parse-error">Parse error</a>. Append a U+002D HYPHEN-MINUS
1.464 mike 3603: character (-) to the comment token's data. Stay in the
1.333 mike 3604: <a href="#comment-end-state">comment end state</a>.</dd>
3605:
1.1 mike 3606: <dt>EOF</dt>
3607: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3608: the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- For
1.724 mike 3609: security reasons: otherwise, hostile user could put a <script type="text/javascript"> in
1.1 mike 3610: a comment e.g. in a blog comment and then DOS the server so that
1.724 mike 3611: the end tag isn't read, and then the commented <script type="text/javascript"> tag would
1.1 mike 3612: be treated as live code -->
3613:
3614: <dt>Anything else</dt>
1.588 mike 3615: <dd><a href="#parse-error">Parse error</a>. Append two U+002D HYPHEN-MINUS
3616: characters (-) and the <a href="#current-input-character">current input character</a> to the
1.541 mike 3617: comment token's data. Switch to the <a href="#comment-state">comment
3618: state</a>.</dd>
1.1 mike 3619:
1.895 mike 3620: </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 3621:
3622: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3623:
1.333 mike 3624: <dl class="switch"><dt>U+002D HYPHEN-MINUS (-)</dt>
1.588 mike 3625: <dd>Append two U+002D HYPHEN-MINUS characters (-) and a U+0021
1.464 mike 3626: EXCLAMATION MARK character (!) to the comment token's data. Switch
1.1 mike 3627: to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
3628:
1.333 mike 3629: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3630: <dd>Emit the comment token. Switch to the <a href="#data-state">data
3631: state</a>.</dd>
3632:
1.1 mike 3633: <dt>EOF</dt>
3634: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3635: the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
3636: comment in comment end state -->
3637:
3638: <dt>Anything else</dt>
1.588 mike 3639: <dd>Append two U+002D HYPHEN-MINUS characters (-), a U+0021
1.541 mike 3640: EXCLAMATION MARK character (!), and the <a href="#current-input-character">current input
3641: character</a> to the comment token's data. Switch to the
3642: <a href="#comment-state">comment state</a>.</dd>
1.1 mike 3643:
1.895 mike 3644: </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 3645:
3646: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3647:
1.333 mike 3648: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
1.1 mike 3649: <dt>U+000A LINE FEED (LF)</dt>
3650: <dt>U+000C FORM FEED (FF)</dt>
3651: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3652: <dt>U+0020 SPACE</dt>
1.541 mike 3653: <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Stay in
1.1 mike 3654: the <a href="#comment-end-space-state">comment end space state</a>.</dd>
3655:
1.333 mike 3656: <dt>U+002D HYPHEN-MINUS (-)</dt>
3657: <dd>Switch to the <a href="#comment-end-dash-state">comment end dash state</a>.</dd>
3658:
3659: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3660: <dd>Emit the comment token. Switch to the <a href="#data-state">data
3661: state</a>.</dd>
3662:
1.1 mike 3663: <dt>EOF</dt>
3664: <dd><a href="#parse-error">Parse error</a>. Emit the comment token. Reconsume
3665: the EOF character in the <a href="#data-state">data state</a>.</dd> <!-- see
3666: comment in comment end state -->
3667:
3668: <dt>Anything else</dt>
1.541 mike 3669: <dd>Append the <a href="#current-input-character">current input character</a> to the comment token's data. Switch
1.1 mike 3670: to the <a href="#comment-state">comment state</a>.</dd>
3671:
1.895 mike 3672: </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 3673:
3674: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3675:
3676: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3677: <dt>U+000A LINE FEED (LF)</dt>
3678: <dt>U+000C FORM FEED (FF)</dt>
3679: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3680: <dt>U+0020 SPACE</dt>
3681: <dd>Switch to the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
3682:
3683: <dt>EOF</dt>
3684: <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
3685: <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
3686: the EOF character in the <a href="#data-state">data state</a>.</dd>
3687:
3688: <dt>Anything else</dt>
1.608 mike 3689: <dd><a href="#parse-error">Parse error</a>. Reconsume the character in the
3690: <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
1.1 mike 3691:
1.895 mike 3692: </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 3693:
3694: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3695:
3696: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3697: <dt>U+000A LINE FEED (LF)</dt>
3698: <dt>U+000C FORM FEED (FF)</dt>
3699: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3700: <dt>U+0020 SPACE</dt>
3701: <dd>Stay in the <a href="#before-doctype-name-state">before DOCTYPE name state</a>.</dd>
3702:
3703: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
3704: <dd>Create a new DOCTYPE token. Set the token's name to the
1.541 mike 3705: lowercase version of the <a href="#current-input-character">current input character</a> (add 0x0020 to the
1.1 mike 3706: character's code point). Switch to the <a href="#doctype-name-state">DOCTYPE name
3707: state</a>.</dd>
3708:
1.333 mike 3709: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3710: <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
3711: <i>force-quirks flag</i> to <i>on</i>. Emit the token. Switch to
3712: the <a href="#data-state">data state</a>.</dd>
3713:
1.1 mike 3714: <dt>EOF</dt>
3715: <dd><a href="#parse-error">Parse error</a>. Create a new DOCTYPE token. Set its
3716: <i>force-quirks flag</i> to <i>on</i>. Emit the token. Reconsume
3717: the EOF character in the <a href="#data-state">data state</a>.</dd>
3718:
3719: <dt>Anything else</dt>
3720: <dd>Create a new DOCTYPE token. Set the token's name to the
3721: <a href="#current-input-character">current input character</a>. Switch to the <a href="#doctype-name-state">DOCTYPE name
3722: state</a>.</dd>
3723:
1.895 mike 3724: </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 3725:
3726: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3727:
3728: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3729: <dt>U+000A LINE FEED (LF)</dt>
3730: <dt>U+000C FORM FEED (FF)</dt>
3731: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3732: <dt>U+0020 SPACE</dt>
3733: <dd>Switch to the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
3734:
3735: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3736: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3737: state</a>.</dd>
3738:
3739: <dt>U+0041 LATIN CAPITAL LETTER A through to U+005A LATIN CAPITAL LETTER Z</dt>
1.541 mike 3740: <dd>Append the lowercase version of the <a href="#current-input-character">current input
3741: character</a> (add 0x0020 to the character's code point) to the
3742: current DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
3743: state</a>.</dd>
1.1 mike 3744:
3745: <dt>EOF</dt>
3746: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3747: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3748: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3749:
3750: <dt>Anything else</dt>
1.541 mike 3751: <dd>Append the <a href="#current-input-character">current input character</a> to the current
3752: DOCTYPE token's name. Stay in the <a href="#doctype-name-state">DOCTYPE name
3753: state</a>.</dd>
1.1 mike 3754:
1.895 mike 3755: </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 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>Stay in the <a href="#after-doctype-name-state">after DOCTYPE name state</a>.</dd>
3765:
3766: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3767: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3768: state</a>.</dd>
3769:
3770: <dt>EOF</dt>
3771: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3772: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3773: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3774:
3775: <dt>Anything else</dt>
3776: <dd>
3777:
3778: <p>If the six characters starting from the <a href="#current-input-character">current input
3779: character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match
3780: for the word "PUBLIC", then consume those characters and switch to
1.444 mike 3781: the <a href="#after-doctype-public-keyword-state">after DOCTYPE public keyword state</a>.</p>
1.1 mike 3782:
3783: <p>Otherwise, if the six characters starting from the
3784: <a href="#current-input-character">current input character</a> are an <a href="infrastructure.html#ascii-case-insensitive">ASCII
3785: case-insensitive</a> match for the word "SYSTEM", then consume
1.444 mike 3786: those characters and switch to the <a href="#after-doctype-system-keyword-state">after DOCTYPE system
3787: keyword state</a>.</p>
1.1 mike 3788:
3789: <p>Otherwise, this is the <a href="#parse-error">parse error</a>. Set the
3790: DOCTYPE token's <i>force-quirks flag</i> to <i>on</i>. Switch to
3791: the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</p>
3792:
3793: </dd>
3794:
1.895 mike 3795: </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 3796:
3797: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3798:
3799: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3800: <dt>U+000A LINE FEED (LF)</dt>
3801: <dt>U+000C FORM FEED (FF)</dt>
3802: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3803: <dt>U+0020 SPACE</dt>
3804: <dd>Switch to the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier
3805: state</a>.</dd>
3806:
1.620 mike 3807: <dt>U+0022 QUOTATION MARK (")</dt>
3808: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's public
3809: identifier to the empty string (not missing), then switch to the
3810: <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public identifier (double-quoted) state</a>.</dd>
3811:
3812: <dt>U+0027 APOSTROPHE (')</dt>
3813: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's public
3814: identifier to the empty string (not missing), then switch to the
3815: <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public identifier (single-quoted) state</a>.</dd>
3816:
3817: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3818: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3819: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3820: token. Switch to the <a href="#data-state">data state</a>.</dd>
3821:
1.444 mike 3822: <dt>EOF</dt>
3823: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3824: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3825: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3826:
3827: <dt>Anything else</dt>
1.620 mike 3828: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3829: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3830: DOCTYPE state</a>.</dd>
1.444 mike 3831:
1.895 mike 3832: </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 3833:
3834: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3835:
3836: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3837: <dt>U+000A LINE FEED (LF)</dt>
3838: <dt>U+000C FORM FEED (FF)</dt>
3839: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3840: <dt>U+0020 SPACE</dt>
3841: <dd>Stay in the <a href="#before-doctype-public-identifier-state">before DOCTYPE public identifier state</a>.</dd>
3842:
3843: <dt>U+0022 QUOTATION MARK (")</dt>
3844: <dd>Set the DOCTYPE token's public identifier to the empty string
3845: (not missing), then switch to the <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public identifier
3846: (double-quoted) state</a>.</dd>
3847:
3848: <dt>U+0027 APOSTROPHE (')</dt>
3849: <dd>Set the DOCTYPE token's public identifier to the empty string
3850: (not missing), then switch to the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public identifier
3851: (single-quoted) state</a>.</dd>
3852:
3853: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3854: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3855: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3856: token. Switch to the <a href="#data-state">data state</a>.</dd>
3857:
3858: <dt>EOF</dt>
3859: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3860: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3861: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3862:
3863: <dt>Anything else</dt>
3864: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3865: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3866: DOCTYPE state</a>.</dd>
3867:
1.755 mike 3868: </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 3869:
3870: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3871:
3872: <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
3873: <dd>Switch to the <a href="#after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd>
3874:
3875: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3876: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3877: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3878: token. Switch to the <a href="#data-state">data state</a>.</dd>
3879:
3880: <dt>EOF</dt>
3881: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3882: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3883: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3884:
3885: <dt>Anything else</dt>
3886: <dd>Append the <a href="#current-input-character">current input character</a> to the current DOCTYPE
3887: token's public identifier. Stay in the <a href="#doctype-public-identifier-double-quoted-state">DOCTYPE public
3888: identifier (double-quoted) state</a>.</dd>
3889:
1.755 mike 3890: </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 3891:
3892: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3893:
3894: <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
3895: <dd>Switch to the <a href="#after-doctype-public-identifier-state">after DOCTYPE public identifier state</a>.</dd>
3896:
3897: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3898: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3899: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
3900: token. Switch to the <a href="#data-state">data state</a>.</dd>
3901:
3902: <dt>EOF</dt>
3903: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3904: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3905: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3906:
3907: <dt>Anything else</dt>
3908: <dd>Append the <a href="#current-input-character">current input character</a> to the current DOCTYPE
3909: token's public identifier. Stay in the <a href="#doctype-public-identifier-single-quoted-state">DOCTYPE public
3910: identifier (single-quoted) state</a>.</dd>
3911:
1.895 mike 3912: </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 3913:
3914: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3915:
3916: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3917: <dt>U+000A LINE FEED (LF)</dt>
3918: <dt>U+000C FORM FEED (FF)</dt>
3919: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3920: <dt>U+0020 SPACE</dt>
1.541 mike 3921: <dd>Switch to the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system
3922: identifiers state</a>.</dd>
1.444 mike 3923:
3924: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3925: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3926: state</a>.</dd>
3927:
3928: <dt>U+0022 QUOTATION MARK (")</dt>
3929: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3930: identifier to the empty string (not missing), then switch to the
3931: <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier (double-quoted) state</a>.</dd>
3932:
3933: <dt>U+0027 APOSTROPHE (')</dt>
3934: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3935: identifier to the empty string (not missing), then switch to the
3936: <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier (single-quoted) state</a>.</dd>
3937:
3938: <dt>EOF</dt>
3939: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3940: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3941: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3942:
3943: <dt>Anything else</dt>
3944: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3945: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3946: DOCTYPE state</a>.</dd>
3947:
1.895 mike 3948: </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 3949:
3950: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3951:
3952: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3953: <dt>U+000A LINE FEED (LF)</dt>
3954: <dt>U+000C FORM FEED (FF)</dt>
3955: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3956: <dt>U+0020 SPACE</dt>
1.541 mike 3957: <dd>Stay in the <a href="#between-doctype-public-and-system-identifiers-state">between DOCTYPE public and system identifiers
3958: state</a>.</dd>
1.444 mike 3959:
3960: <dt>U+003E GREATER-THAN SIGN (>)</dt>
3961: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
3962: state</a>.</dd>
1.1 mike 3963:
3964: <dt>U+0022 QUOTATION MARK (")</dt>
3965: <dd>Set the DOCTYPE token's system identifier to the empty string
3966: (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
3967: (double-quoted) state</a>.</dd>
3968:
3969: <dt>U+0027 APOSTROPHE (')</dt>
3970: <dd>Set the DOCTYPE token's system identifier to the empty string
3971: (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
3972: (single-quoted) state</a>.</dd>
3973:
3974: <dt>EOF</dt>
3975: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3976: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
3977: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
3978:
3979: <dt>Anything else</dt>
3980: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
3981: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
3982: DOCTYPE state</a>.</dd>
3983:
1.895 mike 3984: </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 3985:
3986: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
3987:
3988: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
3989: <dt>U+000A LINE FEED (LF)</dt>
3990: <dt>U+000C FORM FEED (FF)</dt>
3991: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
3992: <dt>U+0020 SPACE</dt>
3993: <dd>Switch to the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier
3994: state</a>.</dd>
3995:
1.620 mike 3996: <dt>U+0022 QUOTATION MARK (")</dt>
3997: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
3998: identifier to the empty string (not missing), then switch to the
3999: <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier (double-quoted) state</a>.</dd>
4000:
4001: <dt>U+0027 APOSTROPHE (')</dt>
4002: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's system
4003: identifier to the empty string (not missing), then switch to the
4004: <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier (single-quoted) state</a>.</dd>
4005:
4006: <dt>U+003E GREATER-THAN SIGN (>)</dt>
4007: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4008: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
4009: token. Switch to the <a href="#data-state">data state</a>.</dd>
4010:
1.444 mike 4011: <dt>EOF</dt>
4012: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4013: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
4014: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
4015:
4016: <dt>Anything else</dt>
1.620 mike 4017: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4018: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
4019: DOCTYPE state</a>.</dd>
1.444 mike 4020:
1.895 mike 4021: </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 4022:
4023: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
4024:
4025: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
4026: <dt>U+000A LINE FEED (LF)</dt>
4027: <dt>U+000C FORM FEED (FF)</dt>
4028: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
4029: <dt>U+0020 SPACE</dt>
4030: <dd>Stay in the <a href="#before-doctype-system-identifier-state">before DOCTYPE system identifier state</a>.</dd>
4031:
4032: <dt>U+0022 QUOTATION MARK (")</dt>
4033: <dd>Set the DOCTYPE token's system identifier to the empty string
4034: (not missing), then switch to the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system identifier
4035: (double-quoted) state</a>.</dd>
4036:
4037: <dt>U+0027 APOSTROPHE (')</dt>
4038: <dd>Set the DOCTYPE token's system identifier to the empty string
4039: (not missing), then switch to the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system identifier
4040: (single-quoted) state</a>.</dd>
4041:
4042: <dt>U+003E GREATER-THAN SIGN (>)</dt>
4043: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4044: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
4045: token. Switch to the <a href="#data-state">data state</a>.</dd>
4046:
4047: <dt>EOF</dt>
4048: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4049: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
4050: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
4051:
4052: <dt>Anything else</dt>
4053: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4054: <i>force-quirks flag</i> to <i>on</i>. Switch to the <a href="#bogus-doctype-state">bogus
4055: DOCTYPE state</a>.</dd>
4056:
1.755 mike 4057: </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 4058:
4059: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
4060:
4061: <dl class="switch"><dt>U+0022 QUOTATION MARK (")</dt>
1.541 mike 4062: <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
4063: state</a>.</dd>
1.1 mike 4064:
4065: <dt>U+003E GREATER-THAN SIGN (>)</dt>
4066: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4067: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
4068: token. Switch to the <a href="#data-state">data state</a>.</dd>
4069:
4070: <dt>EOF</dt>
4071: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4072: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
4073: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
4074:
4075: <dt>Anything else</dt>
1.541 mike 4076: <dd>Append the <a href="#current-input-character">current input character</a> to the current
4077: DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-double-quoted-state">DOCTYPE system
1.1 mike 4078: identifier (double-quoted) state</a>.</dd>
4079:
1.755 mike 4080: </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 4081:
4082: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
4083:
4084: <dl class="switch"><dt>U+0027 APOSTROPHE (')</dt>
1.541 mike 4085: <dd>Switch to the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
4086: state</a>.</dd>
1.1 mike 4087:
4088: <dt>U+003E GREATER-THAN SIGN (>)</dt>
4089: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4090: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE
4091: token. Switch to the <a href="#data-state">data state</a>.</dd>
4092:
4093: <dt>EOF</dt>
4094: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4095: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
4096: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
4097:
4098: <dt>Anything else</dt>
1.541 mike 4099: <dd>Append the <a href="#current-input-character">current input character</a> to the current
4100: DOCTYPE token's system identifier. Stay in the <a href="#doctype-system-identifier-single-quoted-state">DOCTYPE system
1.1 mike 4101: identifier (single-quoted) state</a>.</dd>
4102:
1.895 mike 4103: </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 4104:
4105: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
4106:
4107: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
4108: <dt>U+000A LINE FEED (LF)</dt>
4109: <dt>U+000C FORM FEED (FF)</dt>
4110: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
4111: <dt>U+0020 SPACE</dt>
1.541 mike 4112: <dd>Stay in the <a href="#after-doctype-system-identifier-state">after DOCTYPE system identifier
4113: state</a>.</dd>
1.1 mike 4114:
4115: <dt>U+003E GREATER-THAN SIGN (>)</dt>
4116: <dd>Emit the current DOCTYPE token. Switch to the <a href="#data-state">data
4117: state</a>.</dd>
4118:
4119: <dt>EOF</dt>
4120: <dd><a href="#parse-error">Parse error</a>. Set the DOCTYPE token's
4121: <i>force-quirks flag</i> to <i>on</i>. Emit that DOCTYPE token.
4122: Reconsume the EOF character in the <a href="#data-state">data state</a>.</dd>
4123:
4124: <dt>Anything else</dt>
4125: <dd><a href="#parse-error">Parse error</a>. Switch to the <a href="#bogus-doctype-state">bogus DOCTYPE
4126: state</a>. (This does <em>not</em> set the DOCTYPE token's
4127: <i>force-quirks flag</i> to <i>on</i>.)</dd>
4128:
1.895 mike 4129: </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 4130:
4131: <p>Consume the <a href="#next-input-character">next input character</a>:</p>
4132:
4133: <dl class="switch"><dt>U+003E GREATER-THAN SIGN (>)</dt>
4134: <dd>Emit the DOCTYPE token. Switch to the <a href="#data-state">data
4135: state</a>.</dd>
4136:
4137: <dt>EOF</dt>
4138: <dd>Emit the DOCTYPE token. Reconsume the EOF character in the
4139: <a href="#data-state">data state</a>.</dd>
4140:
4141: <dt>Anything else</dt>
4142: <dd>Stay in the <a href="#bogus-doctype-state">bogus DOCTYPE state</a>.</dd>
4143:
1.895 mike 4144: </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 4145:
4146: <p>Consume every character up to the next occurrence of the three
4147: character sequence U+005D RIGHT SQUARE BRACKET U+005D RIGHT SQUARE
4148: BRACKET U+003E GREATER-THAN SIGN (<code title="">]]></code>), or the
4149: end of the file (EOF), whichever comes first. Emit a series of
4150: character tokens consisting of all the characters consumed except
4151: the matching three character sequence at the end (if one was found
4152: before the end of the file).</p>
4153:
4154: <p>Switch to the <a href="#data-state">data state</a>.</p>
4155:
4156: <p>If the end of the file was reached, reconsume the EOF
4157: character.</p>
4158:
4159:
4160:
1.895 mike 4161: <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 4162:
4163: <p>This section defines how to <dfn id="consume-a-character-reference">consume a character
4164: reference</dfn>. This definition is used when parsing character
1.299 mike 4165: references <a href="#character-reference-in-data-state" title="character reference in data state">in
1.1 mike 4166: text</a> and <a href="#character-reference-in-attribute-value-state" title="character reference in attribute value
4167: state">in attributes</a>.</p>
4168:
4169: <p>The behavior depends on the identity of the next character (the
4170: one immediately after the U+0026 AMPERSAND character):</p>
4171:
4172: <dl class="switch"><dt>U+0009 CHARACTER TABULATION</dt>
4173: <dt>U+000A LINE FEED (LF)</dt>
4174: <dt>U+000C FORM FEED (FF)</dt>
4175: <!--<dt>U+000D CARRIAGE RETURN (CR)</dt>-->
4176: <dt>U+0020 SPACE</dt>
4177: <dt>U+003C LESS-THAN SIGN</dt>
4178: <dt>U+0026 AMPERSAND</dt>
4179: <dt>EOF</dt>
4180: <dt>The <dfn id="additional-allowed-character">additional allowed character</dfn>, if there is one</dt>
4181:
4182: <dd>Not a character reference. No characters are consumed, and
4183: nothing is returned. (This is not an error, either.)</dd>
4184:
4185:
4186: <dt>U+0023 NUMBER SIGN (#)</dt>
4187:
4188: <dd>
4189:
4190: <p>Consume the U+0023 NUMBER SIGN.</p>
4191:
4192: <p>The behavior further depends on the character after the U+0023
4193: NUMBER SIGN:</p>
4194:
4195: <dl class="switch"><dt>U+0078 LATIN SMALL LETTER X</dt>
4196: <dt>U+0058 LATIN CAPITAL LETTER X</dt>
4197:
4198: <dd>
4199:
4200: <p>Consume the X.</p>
4201:
4202: <p>Follow the steps below, but using the range of characters
1.464 mike 4203: U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), U+0061 LATIN
4204: SMALL LETTER A to U+0066 LATIN SMALL LETTER F, and U+0041 LATIN
4205: CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F (in other
4206: words, 0-9, A-F, a-f).</p>
1.1 mike 4207:
4208: <p>When it comes to interpreting the number, interpret it as a
4209: hexadecimal number.</p>
4210:
4211: </dd>
4212:
4213:
4214: <dt>Anything else</dt>
4215:
4216: <dd>
4217:
4218: <p>Follow the steps below, but using the range of characters
1.464 mike 4219: U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</p>
1.1 mike 4220:
4221: <p>When it comes to interpreting the number, interpret it as a
4222: decimal number.</p>
4223:
4224: </dd>
4225:
4226: </dl><p>Consume as many characters as match the range of characters
4227: given above.</p>
4228:
4229: <p>If no characters match the range, then don't consume any
4230: characters (and unconsume the U+0023 NUMBER SIGN character and, if
4231: appropriate, the X character). This is a <a href="#parse-error">parse
4232: error</a>; nothing is returned.</p>
4233:
4234: <p>Otherwise, if the next character is a U+003B SEMICOLON, consume
4235: that too. If it isn't, there is a <a href="#parse-error">parse
4236: error</a>.</p>
4237:
4238: <p>If one or more characters match the range, then take them all
4239: and interpret the string of characters as a number (either
4240: hexadecimal or decimal as appropriate).</p>
4241:
4242: <p>If that number is one of the numbers in the first column of the
4243: following table, then this is a <a href="#parse-error">parse error</a>. Find the
4244: row with that number in the first column, and return a character
4245: token for the Unicode character given in the second column of that
4246: row.</p>
4247:
4248: <table><thead><tr><th>Number </th><th colspan="2">Unicode character
4249: </th></tr></thead><tbody><tr><td>0x00 </td><td>U+FFFD </td><td>REPLACEMENT CHARACTER
1.882 mike 4250: </td></tr><tr><td>0x0D </td><td>U+000D </td><td>CARRIAGE RETURN (CR)
1.464 mike 4251: </td></tr><tr><td>0x80 </td><td>U+20AC </td><td>EURO SIGN (€)
1.1 mike 4252: </td></tr><tr><td>0x81 </td><td>U+0081 </td><td><control>
1.464 mike 4253: </td></tr><tr><td>0x82 </td><td>U+201A </td><td>SINGLE LOW-9 QUOTATION MARK (‚)
4254: </td></tr><tr><td>0x83 </td><td>U+0192 </td><td>LATIN SMALL LETTER F WITH HOOK (ƒ)
4255: </td></tr><tr><td>0x84 </td><td>U+201E </td><td>DOUBLE LOW-9 QUOTATION MARK („)
4256: </td></tr><tr><td>0x85 </td><td>U+2026 </td><td>HORIZONTAL ELLIPSIS (…)
4257: </td></tr><tr><td>0x86 </td><td>U+2020 </td><td>DAGGER (†)
4258: </td></tr><tr><td>0x87 </td><td>U+2021 </td><td>DOUBLE DAGGER (‡)
4259: </td></tr><tr><td>0x88 </td><td>U+02C6 </td><td>MODIFIER LETTER CIRCUMFLEX ACCENT (ˆ)
4260: </td></tr><tr><td>0x89 </td><td>U+2030 </td><td>PER MILLE SIGN (‰)
4261: </td></tr><tr><td>0x8A </td><td>U+0160 </td><td>LATIN CAPITAL LETTER S WITH CARON (Š)
4262: </td></tr><tr><td>0x8B </td><td>U+2039 </td><td>SINGLE LEFT-POINTING ANGLE QUOTATION MARK (‹)
4263: </td></tr><tr><td>0x8C </td><td>U+0152 </td><td>LATIN CAPITAL LIGATURE OE (Œ)
1.1 mike 4264: </td></tr><tr><td>0x8D </td><td>U+008D </td><td><control>
1.464 mike 4265: </td></tr><tr><td>0x8E </td><td>U+017D </td><td>LATIN CAPITAL LETTER Z WITH CARON (Ž)
1.1 mike 4266: </td></tr><tr><td>0x8F </td><td>U+008F </td><td><control>
4267: </td></tr><tr><td>0x90 </td><td>U+0090 </td><td><control>
1.464 mike 4268: </td></tr><tr><td>0x91 </td><td>U+2018 </td><td>LEFT SINGLE QUOTATION MARK (‘)
4269: </td></tr><tr><td>0x92 </td><td>U+2019 </td><td>RIGHT SINGLE QUOTATION MARK (’)
4270: </td></tr><tr><td>0x93 </td><td>U+201C </td><td>LEFT DOUBLE QUOTATION MARK (“)
4271: </td></tr><tr><td>0x94 </td><td>U+201D </td><td>RIGHT DOUBLE QUOTATION MARK (”)
4272: </td></tr><tr><td>0x95 </td><td>U+2022 </td><td>BULLET (•)
4273: </td></tr><tr><td>0x96 </td><td>U+2013 </td><td>EN DASH (–)
4274: </td></tr><tr><td>0x97 </td><td>U+2014 </td><td>EM DASH (—)
4275: </td></tr><tr><td>0x98 </td><td>U+02DC </td><td>SMALL TILDE (˜)
4276: </td></tr><tr><td>0x99 </td><td>U+2122 </td><td>TRADE MARK SIGN (™)
4277: </td></tr><tr><td>0x9A </td><td>U+0161 </td><td>LATIN SMALL LETTER S WITH CARON (š)
4278: </td></tr><tr><td>0x9B </td><td>U+203A </td><td>SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (›)
4279: </td></tr><tr><td>0x9C </td><td>U+0153 </td><td>LATIN SMALL LIGATURE OE (œ)
1.1 mike 4280: </td></tr><tr><td>0x9D </td><td>U+009D </td><td><control>
1.464 mike 4281: </td></tr><tr><td>0x9E </td><td>U+017E </td><td>LATIN SMALL LETTER Z WITH CARON (ž)
4282: </td></tr><tr><td>0x9F </td><td>U+0178 </td><td>LATIN CAPITAL LETTER Y WITH DIAERESIS (Ÿ)
1.315 mike 4283: </td></tr></tbody></table><p>Otherwise, if the number is in the range 0xD800 to 0xDFFF<!--
4284: surrogates not allowed; see the comment in the "preprocessing the
4285: input stream" section for details --> or is greater than 0x10FFFF,
4286: then this is a <a href="#parse-error">parse error</a>. Return a U+FFFD
4287: REPLACEMENT CHARACTER.</p>
1.18 mike 4288:
4289: <p>Otherwise, return a character token for the Unicode character
1.1 mike 4290: whose code point is that number.
4291:
4292: <!-- this is the same as the equivalent list in the input stream
4293: section -->
4294: If the number is in the range 0x0001 to 0x0008, <!-- HT, LF
4295: allowed --> <!-- U+000B is in the next list --> <!-- FF, CR
4296: allowed --> 0x000E to 0x001F, <!-- ASCII allowed --> 0x007F <!--to
1.315 mike 4297: 0x0084, (0x0085 NEL not allowed), 0x0086--> to 0x009F, 0xFDD0 to
4298: 0xFDEF, or is one of 0x000B, 0xFFFE, 0xFFFF, 0x1FFFE, 0x1FFFF,
4299: 0x2FFFE, 0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE,
4300: 0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE, 0x8FFFF,
4301: 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE, 0xBFFFF, 0xCFFFE,
4302: 0xCFFFF, 0xDFFFE, 0xDFFFF, 0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF,
4303: 0x10FFFE, or 0x10FFFF, then this is a <a href="#parse-error">parse
4304: error</a>.</p>
1.1 mike 4305:
4306: </dd>
4307:
4308:
4309: <dt>Anything else</dt>
4310:
4311: <dd>
4312:
4313: <p>Consume the maximum number of characters possible, with the
4314: consumed characters matching one of the identifiers in the first
4315: column of the <a href="named-character-references.html#named-character-references">named character references</a> table (in a
4316: <a href="infrastructure.html#case-sensitive">case-sensitive</a> manner).</p>
4317:
1.897 mike 4318: <p>If no match can be made, then no characters are consumed, and
4319: nothing is returned. In this case, if the characters after the
4320: U+0026 AMPERSAND character (&) consist of a sequence of one or
4321: more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
4322: NINE (9), U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER
4323: Z, and U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL
4324: LETTER Z, followed by a U+003B SEMICOLON character (;), then this
4325: is a <a href="#parse-error">parse error</a>.</p>
1.1 mike 4326:
4327: <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
4328: attribute</a>, and the last character matched is not a U+003B
1.896 mike 4329: SEMICOLON character (;), and the next character is either a U+003D
4330: EQUALS SIGN character (=) or in the range U+0030 DIGIT ZERO (0) to
4331: U+0039 DIGIT NINE (9), U+0041 LATIN CAPITAL LETTER A to U+005A
4332: LATIN CAPITAL LETTER Z, or U+0061 LATIN SMALL LETTER A to U+007A
4333: LATIN SMALL LETTER Z, then, for historical reasons, all the
4334: characters that were matched after the U+0026 AMPERSAND character
4335: (&) must be unconsumed, and nothing is returned.</p>
4336: <!-- "=" added because of http://www.w3.org/Bugs/Public/show_bug.cgi?id=9207#c5 -->
1.1 mike 4337:
1.897 mike 4338: <p>Otherwise, a character reference is parsed. If the last
4339: character matched is not a U+003B SEMICOLON character (;), there
4340: is a <a href="#parse-error">parse error</a>.</p>
4341:
4342: <p>Return a character token for the character corresponding to the
4343: character reference name (as given by the second column of the
4344: <a href="named-character-references.html#named-character-references">named character references</a> table).</p>
1.1 mike 4345:
4346: <div class="example">
4347:
1.897 mike 4348: <p>If the markup contains (not in an attribute) the string <code title="">I'm &notit; I tell you</code>, the character
4349: reference is parsed as "not", as in, <code title="">I'm ¬it;
4350: I tell you</code> (and this is a parse error). But if the markup
1.1 mike 4351: was <code title="">I'm &notin; I tell you</code>, the
4352: character reference would be parsed as "notin;", resulting in
1.897 mike 4353: <code title="">I'm ∉ I tell you</code> (and no parse
4354: error).</p>
1.1 mike 4355:
4356: </div>
4357:
4358: </dd>
4359:
1.266 mike 4360: </dl></div><div class="impl">
4361:
1.363 mike 4362: <!-- v2: One thing that this doesn't define is handling deeply
4363: nested documents. There are compatibility requirements around that:
4364: you can't throw away the elements altogether, consider Tux made only
4365: with opening <font> elements, one per character. Seems that the best
4366: thing to do is to close some formatting elements from the middle of
4367: the stack when you hit a limit, or something. -->
4368:
1.895 mike 4369: <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 4370:
4371: <p>The input to the tree construction stage is a sequence of tokens
4372: from the <a href="#tokenization">tokenization</a> stage. The tree construction
1.810 mike 4373: stage is associated with a DOM <code><a href="infrastructure.html#document">Document</a></code> object when a
1.1 mike 4374: parser is created. The "output" of this stage consists of
4375: dynamically modifying or extending that document's DOM tree.</p>
4376:
4377: <p>This specification does not define when an interactive user agent
1.810 mike 4378: has to render the <code><a href="infrastructure.html#document">Document</a></code> so that it is available to
1.1 mike 4379: the user, or when it has to begin accepting user input.</p>
4380:
4381: <p>As each token is emitted from the tokenizer, the user agent must
4382: process the token according to the rules given in the section
4383: corresponding to the current <a href="#insertion-mode">insertion mode</a>.</p>
4384:
4385: <p>When the steps below require the UA to <dfn id="insert-a-character">insert a
4386: character</dfn> into a node, if that node has a child immediately
4387: before where the character is to be inserted, and that child is a
1.882 mike 4388: <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 4389: node that the parser inserted into the document, then the character
1.882 mike 4390: must be appended to that <code><a href="infrastructure.html#text">Text</a></code> node; otherwise, a new
4391: <code><a href="infrastructure.html#text">Text</a></code> node whose data is just that character must be
1.1 mike 4392: inserted in the appropriate place.</p>
4393:
4394: <div class="example">
4395:
4396: <p>Here are some sample inputs to the parser and the corresponding
4397: number of text nodes that they result in, assuming a user agent
4398: that executes scripts.</p>
4399:
4400: <table><thead><tr><th>Input </th><th>Number of text nodes
4401: </th></tr></thead><tbody><tr><td><pre>A<script>
4402: var script = document.getElementsByTagName('script')[0];
4403: document.body.removeChild(script);
4404: </script>B</pre>
4405: </td><td>Two adjacent text nodes in the document, containing "A" and "B".
4406: </td></tr><tr><td><pre>A<script>
4407: var text = document.createTextNode('B');
4408: document.body.appendChild(text);
4409: </script>C</pre>
4410: </td><td>Four text nodes; "A" before the script, the script's contents, "B" after the script, and then, immediately after that, "C".
4411: </td></tr><tr><td><pre>A<script>
4412: var text = document.getElementsByTagName('script')[0].firstChild;
4413: text.data = 'B';
4414: document.body.appendChild(text);
4415: </script>B</pre>
4416: </td><td>Two adjacent text nodes in the document, containing "A" and "BB".
4417: </td></tr><tr><td><pre>A<table>B<tr>C</tr>C</table></pre>
4418: </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>.)
4419: </td></tr><tr><td><pre>A<table><tr> B</tr> B</table></pre>
4420: </td><td>Two adjacent text nodes before the table, containing "A" and " B B" (space-B-space-B) respectively. (This is caused by <a href="#foster-parent" title="foster parent">foster parenting</a>.)
4421: </td></tr><tr><td><pre>A<table><tr> B</tr> </em>C</table></pre>
4422: </td><td>Three adjacent text nodes before the table, containing "A", " 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.)
4423: </td></tr></tbody></table></div>
4424:
4425: <p id="mutation-during-parsing">DOM mutation events must not fire
4426: for changes caused by the UA parsing the document. (Conceptually,
4427: the parser is not mutating the DOM, it is constructing it.) This
1.159 mike 4428: 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 4429:
4430: <p class="note">Not all of the tag names mentioned below are
4431: conformant tag names in this specification; many are included to
4432: handle legacy content. They still form part of the algorithm that
4433: implementations are required to implement to claim conformance.</p>
4434:
4435: <p class="note">The algorithm described below places no limit on the
4436: depth of the DOM tree generated, or on the length of tag names,
4437: attribute names, attribute values, text nodes, etc. While
4438: implementors are encouraged to avoid arbitrary limits, it is
4439: recognized that <a href="infrastructure.html#hardwareLimitations">practical
1.445 mike 4440: concerns</a> will likely force user agents to impose nesting depth
4441: constraints.</p>
1.1 mike 4442:
4443:
1.895 mike 4444: <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 4445:
4446: <p>When the steps below require the UA to <dfn id="create-an-element-for-the-token" title="create an
4447: element for the token">create an element for a token</dfn> in a
4448: particular namespace, the UA must create a node implementing the
4449: interface appropriate for the element type corresponding to the tag
4450: name of the token in the given namespace (as given in the
4451: 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 4452: element in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, this specification
1.1 mike 4453: defines it to be the <code><a href="text-level-semantics.html#htmlanchorelement">HTMLAnchorElement</a></code> interface), with
4454: the tag name being the name of that element, with the node being in
4455: the given namespace, and with the attributes on the node being those
4456: given in the given token.</p>
4457:
1.724 mike 4458: <p>The interface appropriate for an element in the <a href="infrastructure.html#html-namespace-0">HTML
1.426 mike 4459: namespace</a> that is not defined in this specification (or
4460: <a href="infrastructure.html#other-applicable-specifications">other applicable specifications</a>) is
1.44 mike 4461: <code><a href="dom.html#htmlunknownelement">HTMLUnknownElement</a></code>. Element in other namespaces whose
1.1 mike 4462: interface is not defined by that namespace's specification must use
1.810 mike 4463: the interface <code><a href="infrastructure.html#element">Element</a></code>.</p>
1.1 mike 4464:
1.882 mike 4465: <p>When a <a href="forms.html#category-reset" title="category-reset">resettable element</a> is
1.1 mike 4466: created in this manner, its <a href="forms.html#concept-form-reset-control" title="concept-form-reset-control">reset algorithm</a> must be
4467: invoked once the attributes are set. (This initializes the element's
4468: <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
4469: attributes.)</p>
4470:
4471: <hr><p>When the steps below require the UA to <dfn id="insert-an-html-element">insert an HTML
4472: element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
1.724 mike 4473: for the token</a> in the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, and then
1.1 mike 4474: append this node to the <a href="#current-node">current node</a>, and push it onto
4475: the <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
4476: <a href="#current-node">current node</a>.</p>
4477:
4478: <p>The steps below may also require that the UA insert an HTML
4479: element in a particular place, in which case the UA must follow the
4480: same steps except that it must insert or append the new node in the
4481: location specified instead of appending it to the <a href="#current-node">current
4482: node</a>. (This happens in particular during the parsing of
4483: tables with invalid content.)</p>
4484:
4485: <p>If an element created by the <a href="#insert-an-html-element">insert an HTML element</a>
4486: algorithm is a <a href="forms.html#form-associated-element">form-associated element</a>, and the
4487: <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is not null,
4488: 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
4489: <a href="forms.html#concept-form-association" title="concept-form-association">associate</a> the newly
4490: created element with the <code><a href="forms.html#the-form-element">form</a></code> element pointed to by the
4491: <a href="#form-element-pointer"><code title="">form</code> element pointer</a> before
4492: inserting it wherever it is to be inserted.</p>
4493:
4494: <hr><p>When the steps below require the UA to <dfn id="insert-a-foreign-element">insert a foreign
4495: element</dfn> for a token, the UA must first <a href="#create-an-element-for-the-token">create an element
4496: for the token</a> in the given namespace, and then append this
4497: node to the <a href="#current-node">current node</a>, and push it onto the
4498: <a href="#stack-of-open-elements">stack of open elements</a> so that it is the new
1.724 mike 4499: <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 4500: whose value is not exactly the same as the element's namespace, that
4501: is a <a href="#parse-error">parse error</a>. Similarly, if the newly created
4502: element has an <code title="">xmlns:xlink</code> attribute in the
1.724 mike 4503: <a href="infrastructure.html#xmlns-namespace">XMLNS namespace</a> whose value is not the <a href="infrastructure.html#xlink-namespace">XLink
1.1 mike 4504: Namespace</a>, that is a <a href="#parse-error">parse error</a>.</p>
4505:
4506: <p>When the steps below require the user agent to <dfn id="adjust-mathml-attributes">adjust MathML
4507: attributes</dfn> for a token, then, if the token has an attribute
4508: named <code title="">definitionurl</code>, change its name to <code title="">definitionURL</code> (note the case difference).</p>
4509:
4510: <p>When the steps below require the user agent to <dfn id="adjust-svg-attributes">adjust SVG
4511: attributes</dfn> for a token, then, for each attribute on the token
4512: whose attribute name is one of the ones in the first column of the
4513: following table, change the attribute's name to the name given in
4514: the corresponding cell in the second column. (This fixes the case of
4515: SVG attributes that are not all lowercase.)</p>
4516:
4517: <table><thead><tr><th> Attribute name on token </th><th> Attribute name on element
4518: </th></tr></thead><tbody><tr><td> <code title="">attributename</code> </td><td> <code title="">attributeName</code>
4519: </td></tr><tr><td> <code title="">attributetype</code> </td><td> <code title="">attributeType</code>
4520: </td></tr><tr><td> <code title="">basefrequency</code> </td><td> <code title="">baseFrequency</code>
4521: </td></tr><tr><td> <code title="">baseprofile</code> </td><td> <code title="">baseProfile</code>
4522: </td></tr><tr><td> <code title="">calcmode</code> </td><td> <code title="">calcMode</code>
4523: </td></tr><tr><td> <code title="">clippathunits</code> </td><td> <code title="">clipPathUnits</code>
4524: </td></tr><tr><td> <code title="">contentscripttype</code> </td><td> <code title="">contentScriptType</code>
4525: </td></tr><tr><td> <code title="">contentstyletype</code> </td><td> <code title="">contentStyleType</code>
4526: </td></tr><tr><td> <code title="">diffuseconstant</code> </td><td> <code title="">diffuseConstant</code>
4527: </td></tr><tr><td> <code title="">edgemode</code> </td><td> <code title="">edgeMode</code>
4528: </td></tr><tr><td> <code title="">externalresourcesrequired</code> </td><td> <code title="">externalResourcesRequired</code>
4529: </td></tr><tr><td> <code title="">filterres</code> </td><td> <code title="">filterRes</code>
4530: </td></tr><tr><td> <code title="">filterunits</code> </td><td> <code title="">filterUnits</code>
4531: </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
4532: </td></tr><tr><td> <code title="">gradienttransform</code> </td><td> <code title="">gradientTransform</code>
4533: </td></tr><tr><td> <code title="">gradientunits</code> </td><td> <code title="">gradientUnits</code>
4534: </td></tr><tr><td> <code title="">kernelmatrix</code> </td><td> <code title="">kernelMatrix</code>
4535: </td></tr><tr><td> <code title="">kernelunitlength</code> </td><td> <code title="">kernelUnitLength</code>
4536: </td></tr><tr><td> <code title="">keypoints</code> </td><td> <code title="">keyPoints</code>
4537: </td></tr><tr><td> <code title="">keysplines</code> </td><td> <code title="">keySplines</code>
4538: </td></tr><tr><td> <code title="">keytimes</code> </td><td> <code title="">keyTimes</code>
4539: </td></tr><tr><td> <code title="">lengthadjust</code> </td><td> <code title="">lengthAdjust</code>
4540: </td></tr><tr><td> <code title="">limitingconeangle</code> </td><td> <code title="">limitingConeAngle</code>
4541: </td></tr><tr><td> <code title="">markerheight</code> </td><td> <code title="">markerHeight</code>
4542: </td></tr><tr><td> <code title="">markerunits</code> </td><td> <code title="">markerUnits</code>
4543: </td></tr><tr><td> <code title="">markerwidth</code> </td><td> <code title="">markerWidth</code>
4544: </td></tr><tr><td> <code title="">maskcontentunits</code> </td><td> <code title="">maskContentUnits</code>
4545: </td></tr><tr><td> <code title="">maskunits</code> </td><td> <code title="">maskUnits</code>
4546: </td></tr><tr><td> <code title="">numoctaves</code> </td><td> <code title="">numOctaves</code>
4547: </td></tr><tr><td> <code title="">pathlength</code> </td><td> <code title="">pathLength</code>
4548: </td></tr><tr><td> <code title="">patterncontentunits</code> </td><td> <code title="">patternContentUnits</code>
4549: </td></tr><tr><td> <code title="">patterntransform</code> </td><td> <code title="">patternTransform</code>
4550: </td></tr><tr><td> <code title="">patternunits</code> </td><td> <code title="">patternUnits</code>
4551: </td></tr><tr><td> <code title="">pointsatx</code> </td><td> <code title="">pointsAtX</code>
4552: </td></tr><tr><td> <code title="">pointsaty</code> </td><td> <code title="">pointsAtY</code>
4553: </td></tr><tr><td> <code title="">pointsatz</code> </td><td> <code title="">pointsAtZ</code>
4554: </td></tr><tr><td> <code title="">preservealpha</code> </td><td> <code title="">preserveAlpha</code>
4555: </td></tr><tr><td> <code title="">preserveaspectratio</code> </td><td> <code title="">preserveAspectRatio</code>
4556: </td></tr><tr><td> <code title="">primitiveunits</code> </td><td> <code title="">primitiveUnits</code>
4557: </td></tr><tr><td> <code title="">refx</code> </td><td> <code title="">refX</code>
4558: </td></tr><tr><td> <code title="">refy</code> </td><td> <code title="">refY</code>
4559: </td></tr><tr><td> <code title="">repeatcount</code> </td><td> <code title="">repeatCount</code>
4560: </td></tr><tr><td> <code title="">repeatdur</code> </td><td> <code title="">repeatDur</code>
4561: </td></tr><tr><td> <code title="">requiredextensions</code> </td><td> <code title="">requiredExtensions</code>
4562: </td></tr><tr><td> <code title="">requiredfeatures</code> </td><td> <code title="">requiredFeatures</code>
4563: </td></tr><tr><td> <code title="">specularconstant</code> </td><td> <code title="">specularConstant</code>
4564: </td></tr><tr><td> <code title="">specularexponent</code> </td><td> <code title="">specularExponent</code>
4565: </td></tr><tr><td> <code title="">spreadmethod</code> </td><td> <code title="">spreadMethod</code>
4566: </td></tr><tr><td> <code title="">startoffset</code> </td><td> <code title="">startOffset</code>
4567: </td></tr><tr><td> <code title="">stddeviation</code> </td><td> <code title="">stdDeviation</code>
4568: </td></tr><tr><td> <code title="">stitchtiles</code> </td><td> <code title="">stitchTiles</code>
4569: </td></tr><tr><td> <code title="">surfacescale</code> </td><td> <code title="">surfaceScale</code>
4570: </td></tr><tr><td> <code title="">systemlanguage</code> </td><td> <code title="">systemLanguage</code>
4571: </td></tr><tr><td> <code title="">tablevalues</code> </td><td> <code title="">tableValues</code>
4572: </td></tr><tr><td> <code title="">targetx</code> </td><td> <code title="">targetX</code>
4573: </td></tr><tr><td> <code title="">targety</code> </td><td> <code title="">targetY</code>
4574: </td></tr><tr><td> <code title="">textlength</code> </td><td> <code title="">textLength</code>
4575: </td></tr><tr><td> <code title="">viewbox</code> </td><td> <code title="">viewBox</code>
4576: </td></tr><tr><td> <code title="">viewtarget</code> </td><td> <code title="">viewTarget</code>
4577: </td></tr><tr><td> <code title="">xchannelselector</code> </td><td> <code title="">xChannelSelector</code>
4578: </td></tr><tr><td> <code title="">ychannelselector</code> </td><td> <code title="">yChannelSelector</code>
4579: </td></tr><tr><td> <code title="">zoomandpan</code> </td><td> <code title="">zoomAndPan</code>
4580: </td></tr></tbody></table><p>When the steps below require the user agent to <dfn id="adjust-foreign-attributes">adjust
4581: foreign attributes</dfn> for a token, then, if any of the attributes
4582: on the token match the strings given in the first column of the
4583: following table, let the attribute be a namespaced attribute, with
4584: the prefix being the string given in the corresponding cell in the
4585: second column, the local name being the string given in the
4586: corresponding cell in the third column, and the namespace being the
4587: namespace given in the corresponding cell in the fourth
4588: column. (This fixes the use of namespaced attributes, in particular
4589: <a href="dom.html#attr-xml-lang" title="attr-xml-lang"><code title="">lang</code> attributes in
4590: the <span>XML namespace</span></a>.)</p>
4591:
4592: <table><thead><tr><th> Attribute name </th><th> Prefix </th><th> Local name </th><th> Namespace
1.724 mike 4593: </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>
4594: </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>
4595: </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>
4596: </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>
4597: </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>
4598: </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>
4599: </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>
4600: </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 -->
4601: </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>
4602: </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>
4603: </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>
4604: </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 4605: </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 4606: <dfn id="generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</dfn> consist of the
4607: following steps. These algorithms are always invoked in response to
4608: a start tag token.</p>
4609:
4610: <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p></li>
4611:
1.91 mike 4612: <li><p>If the algorithm that was invoked is the <a href="#generic-raw-text-element-parsing-algorithm">generic raw
1.541 mike 4613: text element parsing algorithm</a>, switch the tokenizer to the
4614: <a href="#rawtext-state">RAWTEXT state</a>; otherwise the algorithm invoked
4615: was the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>,
4616: switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</p></li>
1.1 mike 4617:
4618: <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
4619: <a href="#insertion-mode">insertion mode</a>.</p>
4620:
1.540 mike 4621: </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 4622:
1.895 mike 4623: </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 4624:
4625: <p>When the steps below require the UA to <dfn id="generate-implied-end-tags">generate implied end
4626: tags</dfn>, then, while the <a href="#current-node">current node</a> is a
1.422 mike 4627: <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 4628: <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
4629: <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
4630: <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
4631: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
4632: elements</a>.</p>
4633:
4634: <p>If a step requires the UA to generate implied end tags but lists
4635: an element to exclude from the process, then the UA must perform the
4636: above steps as if that element was not in the above list.</p>
4637:
4638:
1.895 mike 4639: <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 4640:
4641: <p>Foster parenting happens when content is misnested in tables.</p>
4642:
4643: <p>When a node <var title="">node</var> is to be <dfn id="foster-parent" title="foster
4644: parent">foster parented</dfn>, the node <var title="">node</var>
4645: must be inserted into the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
4646:
4647: <p>The <dfn id="foster-parent-element">foster parent element</dfn> is the parent element of the
4648: 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
4649: elements</a>, if there is a <code><a href="tabular-data.html#the-table-element">table</a></code> element and it has
4650: such a parent element. If there is no <code><a href="tabular-data.html#the-table-element">table</a></code> element in
4651: the <a href="#stack-of-open-elements">stack of open elements</a> (<a href="#fragment-case">fragment
4652: case</a>), then the <i><a href="#foster-parent-element">foster parent element</a></i> is the first
4653: element in the <a href="#stack-of-open-elements">stack of open elements</a> (the
1.159 mike 4654: <code><a href="semantics.html#the-html-element-0">html</a></code> element). Otherwise, if there is a
1.1 mike 4655: <code><a href="tabular-data.html#the-table-element">table</a></code> element in the <a href="#stack-of-open-elements">stack of open
4656: elements</a>, but the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
4657: <a href="#stack-of-open-elements">stack of open elements</a> has no parent, or its parent
4658: node is not an element, then the <i><a href="#foster-parent-element">foster parent element</a></i> is
4659: the element before the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in the
4660: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
4661:
4662: <p>If the <i><a href="#foster-parent-element">foster parent element</a></i> is the parent element of the
4663: 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
4664: elements</a>, then <var title="">node</var> must be inserted
4665: immediately <em>before</em> the last <code><a href="tabular-data.html#the-table-element">table</a></code> element in
4666: the <a href="#stack-of-open-elements">stack of open elements</a> in the <i><a href="#foster-parent-element">foster parent
4667: element</a></i>; otherwise, <var title="">node</var> must be
4668: <em>appended</em> to the <i><a href="#foster-parent-element">foster parent element</a></i>.</p>
4669:
4670:
4671:
1.895 mike 4672: <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 4673:
4674: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-initial-insertion-mode" title="insertion
4675: mode: initial">initial</a>", tokens must be handled as follows:</p>
4676:
4677: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
4678: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 4679: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 4680: <dd>
4681: <p>Ignore the token.</p>
4682: </dd>
4683:
4684: <dt>A comment token</dt>
4685: <dd>
1.882 mike 4686: <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 4687: object with the <code title="">data</code> attribute set to the
4688: data given in the comment token.</p>
4689: </dd>
4690:
4691: <dt>A DOCTYPE token</dt>
4692: <dd>
4693:
4694: <p>If the DOCTYPE token's name is not a
4695: <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
4696: missing, or the token's system identifier is neither missing nor a
4697: <a href="infrastructure.html#case-sensitive">case-sensitive</a> match for the string
1.465 mike 4698: "<code><a href="infrastructure.html#about:legacy-compat">about:legacy-compat</a></code>", and none of the sets of
1.1 mike 4699: conditions in the following list are matched, then there is a
1.861 mike 4700: <a href="#parse-error">parse error</a>.</p>
1.1 mike 4701:
4702: <ul><!-- only things that trigger no-quirks mode and were valid in
1.688 mike 4703: 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>
4704: match for the string "<code title="">html</code>", the token's
4705: public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
4706: "<code title="">-//W3C//DTD HTML 4.0//EN</code>", and
4707: the token's system identifier is either missing or the
1.1 mike 4708: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/REC-html40/strict.dtd</code>".</li>
4709:
1.688 mike 4710: <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
4711: match for the string "<code title="">html</code>", the token's
4712: public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
4713: "<code title="">-//W3C//DTD HTML 4.01//EN</code>", and
4714: the token's system identifier is either missing or the
1.1 mike 4715: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/html4/strict.dtd</code>".</li>
4716:
1.688 mike 4717: <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
4718: match for the string "<code title="">html</code>", the token's
4719: public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
4720: "<code title="">-//W3C//DTD XHTML 1.0 Strict//EN</code>",
1.1 mike 4721: and the token's system identifier is the
4722: <a href="infrastructure.html#case-sensitive">case-sensitive</a> string "<code title="">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</code>".</li>
4723:
1.688 mike 4724: <li>The DOCTYPE token's name is a <a href="infrastructure.html#case-sensitive">case-sensitive</a>
4725: match for the string "<code title="">html</code>", the token's
4726: public identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a> string
4727: "<code title="">-//W3C//DTD XHTML 1.1//EN</code>", and
4728: the token's system identifier is the <a href="infrastructure.html#case-sensitive">case-sensitive</a>
1.1 mike 4729: string "<code title="">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</code>".</li>
4730:
4731: </ul><p>Conformance checkers may, based on the values (including
4732: presence or lack thereof) of the DOCTYPE token's name, public
4733: identifier, or system identifier, switch to a conformance checking
4734: mode for another language (e.g. based on the DOCTYPE token a
4735: conformance checker could recognize that the document is an
1.183 mike 4736: HTML4-era document, and defer to an HTML4 conformance
1.1 mike 4737: checker.)</p>
4738:
1.882 mike 4739: <p>Append a <code><a href="infrastructure.html#documenttype">DocumentType</a></code> node to the
1.810 mike 4740: <code><a href="infrastructure.html#document">Document</a></code> node, with the <code title="">name</code>
1.1 mike 4741: attribute set to the name given in the DOCTYPE token, or the empty
4742: string if the name was missing; the <code title="">publicId</code>
4743: attribute set to the public identifier given in the DOCTYPE token,
4744: or the empty string if the public identifier was missing; the
4745: <code title="">systemId</code> attribute set to the system
4746: identifier given in the DOCTYPE token, or the empty string if the
4747: system identifier was missing; and the other attributes specific
1.882 mike 4748: to <code><a href="infrastructure.html#documenttype">DocumentType</a></code> objects set to null and empty lists
4749: as appropriate. Associate the <code><a href="infrastructure.html#documenttype">DocumentType</a></code> node with
1.810 mike 4750: the <code><a href="infrastructure.html#document">Document</a></code> object so that it is returned as the
1.1 mike 4751: value of the <code title="">doctype</code> attribute of the
1.810 mike 4752: <code><a href="infrastructure.html#document">Document</a></code> object.</p>
1.1 mike 4753:
4754: <p id="quirks-mode-doctypes">Then, if the DOCTYPE token matches
4755: one of the conditions in the following list, then set the
1.810 mike 4756: <code><a href="infrastructure.html#document">Document</a></code> to <a href="dom.html#quirks-mode">quirks mode</a>:</p>
1.1 mike 4757:
4758: <ul class="brief"><li> The <i>force-quirks flag</i> is set to <i>on</i>. </li>
1.688 mike 4759: <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 4760: <li> The public identifier starts with: "<code title="">+//Silmaril//dtd html Pro v0r11 19970101//<!--EN--></code>" </li>
4761: <li> The public identifier starts with: "<code title="">-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
4762: <li> The public identifier starts with: "<code title="">-//AS//DTD HTML 3.0 asWedit + extensions//<!--EN--></code>" </li>
4763: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 1//<!--EN--></code>" </li>
4764: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Level 2//<!--EN--></code>" </li>
4765: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 1//<!--EN--></code>" </li>
4766: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict Level 2//<!--EN--></code>" </li>
4767: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0 Strict//<!--EN--></code>" </li>
4768: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.0//<!--EN--></code>" </li>
4769: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 2.1E//<!--EN--></code>" </li>
4770: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.0//<!--EN--></code>" </li>
4771: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML 3.0//EN//</code>" </li>-->
4772: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2 Final//<!--EN--></code>" </li>
4773: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3.2//<!--EN--></code>" </li>
4774: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML 3//<!--EN--></code>" </li>
4775: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 0//<!--EN--></code>" </li>
4776: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 0//EN//2.0</code>" </li>-->
4777: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 1//<!--EN--></code>" </li>
4778: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 1//EN//2.0</code>" </li>-->
4779: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 2//<!--EN--></code>" </li>
4780: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 2//EN//2.0</code>" </li>-->
4781: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Level 3//<!--EN--></code>" </li>
4782: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Level 3//EN//3.0</code>" </li>-->
4783: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 0//<!--EN--></code>" </li>
4784: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 0//EN//2.0</code>" </li>-->
4785: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 1//<!--EN--></code>" </li>
4786: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 1//EN//2.0</code>" </li>-->
4787: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 2//<!--EN--></code>" </li>
4788: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 2//EN//2.0</code>" </li>-->
4789: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict Level 3//<!--EN--></code>" </li>
4790: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict Level 3//EN//3.0</code>" </li>-->
4791: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML Strict//<!--EN--></code>" </li>
4792: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//2.0</code>" </li>-->
4793: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML Strict//EN//3.0</code>" </li>-->
4794: <li> The public identifier starts with: "<code title="">-//IETF//DTD HTML//<!--EN--></code>" </li>
4795: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//2.0</code>" </li>-->
4796: <!--<li> The public identifier is set to: "<code title="">-//IETF//DTD HTML//EN//3.0</code>" </li>-->
4797: <li> The public identifier starts with: "<code title="">-//Metrius//DTD Metrius Presentational//<!--EN--></code>" </li>
4798: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//<!--EN--></code>" </li>
4799: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 HTML//<!--EN--></code>" </li>
4800: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 2.0 Tables//<!--EN--></code>" </li>
4801: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//<!--EN--></code>" </li>
4802: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 HTML//<!--EN--></code>" </li>
4803: <li> The public identifier starts with: "<code title="">-//Microsoft//DTD Internet Explorer 3.0 Tables//<!--EN--></code>" </li>
4804: <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD HTML//<!--EN--></code>" </li>
4805: <li> The public identifier starts with: "<code title="">-//Netscape Comm. Corp.//DTD Strict HTML//<!--EN--></code>" </li>
4806: <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML 2.0//<!--EN--></code>" </li>
4807: <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended 1.0//<!--EN--></code>" </li>
4808: <li> The public identifier starts with: "<code title="">-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//<!--EN--></code>" </li>
4809: <li> The public identifier starts with: "<code title="">-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//<!--EN--></code>" </li>
4810: <li> The public identifier starts with: "<code title="">-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//<!--EN--></code>" </li>
4811: <li> The public identifier starts with: "<code title="">-//Spyglass//DTD HTML 2.0 Extended//<!--EN--></code>" </li>
4812: <li> The public identifier starts with: "<code title="">-//SQ//DTD HTML 2.0 HoTMetaL + extensions//<!--EN--></code>" </li>
4813: <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava HTML//<!--EN--></code>" </li>
4814: <li> The public identifier starts with: "<code title="">-//Sun Microsystems Corp.//DTD HotJava Strict HTML//<!--EN--></code>" </li>
4815: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3 1995-03-24//<!--EN--></code>" </li>
4816: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Draft//<!--EN--></code>" </li>
4817: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2 Final//<!--EN--></code>" </li>
4818: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2//<!--EN--></code>" </li>
4819: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 3.2S Draft//<!--EN--></code>" </li>
4820: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Frameset//<!--EN--></code>" </li>
4821: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML 4.0 Transitional//<!--EN--></code>" </li>
4822: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 19960712//<!--EN--></code>" </li>
4823: <li> The public identifier starts with: "<code title="">-//W3C//DTD HTML Experimental 970421//<!--EN--></code>" </li>
4824: <li> The public identifier starts with: "<code title="">-//W3C//DTD W3 HTML//<!--EN--></code>" </li>
4825: <li> The public identifier starts with: "<code title="">-//W3O//DTD W3 HTML 3.0//<!--EN--></code>" </li>
4826: <!--<li> The public identifier is set to: "<code title="">-//W3O//DTD W3 HTML 3.0//EN//</code>" </li>-->
4827: <li> The public identifier is set to: "<code title="">-//W3O//DTD W3 HTML Strict 3.0//EN//</code>" </li>
4828: <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML 2.0//<!--EN--></code>" </li>
4829: <li> The public identifier starts with: "<code title="">-//WebTechs//DTD Mozilla HTML//<!--EN--></code>" </li>
4830: <li> The public identifier is set to: "<code title="">-/W3C/DTD HTML 4.0 Transitional/EN</code>" </li>
4831: <li> The public identifier is set to: "<code title="">HTML</code>" </li>
4832: <li> The system identifier is set to: "<code title="">http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd</code>" </li>
4833: <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
4834: <li> The system identifier is missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Transitional//<!--EN--></code>" </li>
4835: </ul><p>Otherwise, if the DOCTYPE token matches one of the conditions
1.810 mike 4836: in the following list, then set the <code><a href="infrastructure.html#document">Document</a></code> to
1.880 mike 4837: <a href="dom.html#limited-quirks-mode">limited-quirks mode</a>:</p>
1.1 mike 4838:
4839: <ul class="brief"><li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Frameset//<!--EN--></code>" </li>
4840: <li> The public identifier starts with: "<code title="">-//W3C//DTD XHTML 1.0 Transitional//<!--EN--></code>" </li>
4841: <li> The system identifier is not missing and the public identifier starts with: "<code title="">-//W3C//DTD HTML 4.01 Frameset//<!--EN--></code>" </li>
4842: <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 4843: </ul><p>The system identifier and public identifier strings must be
4844: compared to the values given in the lists above in an <a href="infrastructure.html#ascii-case-insensitive">ASCII
4845: case-insensitive</a> manner. A system identifier whose value is
4846: the empty string is not considered missing for the purposes of the
4847: conditions above.</p>
1.1 mike 4848:
4849: <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>
4850:
4851: </dd>
4852:
4853: <dt>Anything else</dt>
4854: <dd>
4855:
1.727 mike 4856: <p>If the document is <em>not</em> <a href="text-level-semantics.html#an-iframe-srcdoc-document">an <code>iframe</code>
4857: <code title="attr-iframe-srcdoc">srcdoc</code> document</a>,
4858: then this is a <a href="#parse-error">parse error</a>; set the
1.810 mike 4859: <code><a href="infrastructure.html#document">Document</a></code> to <a href="dom.html#quirks-mode">quirks mode</a>.</p>
1.1 mike 4860:
1.727 mike 4861: <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 4862: reprocess the current token.</p>
4863:
4864: </dd>
4865:
1.895 mike 4866: </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 4867:
4868: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-html-insertion-mode" title="insertion
4869: mode: before html">before html</a>", tokens must be handled as follows:</p>
4870:
4871: <dl class="switch"><dt>A DOCTYPE token</dt>
4872: <dd>
4873: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4874: </dd>
4875:
4876: <dt>A comment token</dt>
4877: <dd>
1.882 mike 4878: <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 4879: object with the <code title="">data</code> attribute set to the
4880: data given in the comment token.</p>
4881: </dd>
4882:
4883: <dt>A character token that is one of U+0009 CHARACTER
4884: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 4885: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 4886: <dd>
4887: <p>Ignore the token.</p>
4888: </dd>
4889:
4890: <dt>A start tag whose tag name is "html"</dt>
4891: <dd>
4892:
1.724 mike 4893: <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 4894: namespace</a>. Append it to the <code><a href="infrastructure.html#document">Document</a></code>
1.1 mike 4895: object. Put this element in the <a href="#stack-of-open-elements">stack of open
4896: elements</a>.</p>
4897:
1.810 mike 4898: <p id="parser-appcache">If the <code><a href="infrastructure.html#document">Document</a></code> is being
1.1 mike 4899: loaded as part of <a href="history.html#navigate" title="navigate">navigation</a> of a
4900: <a href="browsers.html#browsing-context">browsing context</a>, then: if the newly created element
1.875 mike 4901: has a <code title="attr-html-manifest"><a href="semantics.html#attr-html-manifest">manifest</a></code> attribute
4902: whose value is not the empty string, then <a href="infrastructure.html#resolve-a-url" title="resolve a
4903: url">resolve</a> the value of that attribute to an
4904: <a href="infrastructure.html#absolute-url">absolute URL</a>, relative to the newly created element,
4905: and if that is successful, run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application cache selection
1.29 mike 4906: algorithm</a> with the resulting <a href="infrastructure.html#absolute-url">absolute URL</a> with
4907: any <a href="infrastructure.html#url-fragment" title="url-fragment"><fragment></a> component
1.875 mike 4908: removed; otherwise, if there is no such attribute, or its value is
4909: the empty string, or resolving its value fails, run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application cache selection
4910: algorithm</a> with no manifest. The algorithm must be passed
4911: the <code><a href="infrastructure.html#document">Document</a></code> object.</p>
1.1 mike 4912:
4913: <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>
4914:
4915: </dd>
4916:
1.334 mike 4917: <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
4918: <dd>
4919: <p>Act as described in the "anything else" entry below.</p>
4920: </dd>
4921:
4922: <dt>Any other end tag</dt>
4923: <dd>
4924: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4925: </dd>
4926:
1.1 mike 4927: <dt>Anything else</dt>
4928: <dd>
4929:
1.159 mike 4930: <p>Create an <code><a href="semantics.html#the-html-element-0">html</a></code> element. Append it to the
1.810 mike 4931: <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 4932: of open elements</a>.</p>
4933:
1.810 mike 4934: <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 4935: context</a>, then: run the <a href="offline.html#concept-appcache-init" title="concept-appcache-init">application cache selection
4936: algorithm</a> with no manifest, passing it the
1.810 mike 4937: <code><a href="infrastructure.html#document">Document</a></code> object.</p>
1.1 mike 4938:
4939: <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
4940: reprocess the current token.</p>
4941:
4942: </dd>
4943:
4944: </dl><p>The root element can end up being removed from the
1.810 mike 4945: <code><a href="infrastructure.html#document">Document</a></code> object, e.g. by scripts; nothing in particular
1.1 mike 4946: happens in such cases, content continues being appended to the nodes
4947: as described in the next section.</p>
4948:
4949:
1.895 mike 4950: <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 4951:
4952: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-before-head-insertion-mode" title="insertion
4953: mode: before head">before head</a>", tokens must be handled as follows:</p>
4954:
4955: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
4956: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 4957: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 4958: <dd>
4959: <p>Ignore the token.</p> <!-- :-( -->
4960: </dd>
4961:
4962: <dt>A comment token</dt>
4963: <dd>
1.882 mike 4964: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 4965: node</a> with the <code title="">data</code> attribute set to
4966: the data given in the comment token.</p>
4967: </dd>
4968:
4969: <dt>A DOCTYPE token</dt>
4970: <dd>
4971: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
4972: </dd>
4973:
4974: <dt>A start tag whose tag name is "html"</dt>
4975: <dd>
4976: <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
4977: mode</a>.</p>
4978: </dd>
4979:
4980: <dt>A start tag whose tag name is "head"</dt>
4981: <dd>
4982:
4983: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
4984:
4985: <p>Set the <a href="#head-element-pointer"><code title="">head</code> element pointer</a>
1.159 mike 4986: to the newly created <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1 mike 4987:
4988: <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>
4989:
4990: </dd>
4991:
4992: <dt>An end tag whose tag name is one of: "head", "body", "html", "br"</dt>
4993: <dd>
4994:
4995: <p>Act as if a start tag token with the tag name "head" and no
4996: attributes had been seen, then reprocess the current token.</p>
4997:
4998: </dd>
4999:
5000: <dt>Any other end tag</dt>
5001: <dd>
5002:
5003: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5004:
5005: </dd>
5006:
5007: <dt>Anything else</dt>
5008: <dd>
5009:
5010: <p>Act as if a start tag token with the tag name "head" and no
5011: attributes had been seen, then reprocess the current
5012: token.</p>
5013:
5014: </dd>
5015:
1.895 mike 5016: </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 5017:
5018: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inhead" title="insertion
5019: mode: in head">in head</a>", tokens must be handled as follows:</p>
5020:
5021: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
5022: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 5023: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 5024: <dd>
5025: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
5026: the <a href="#current-node">current node</a>.</p>
5027: </dd>
5028:
5029: <dt>A comment token</dt>
5030: <dd>
1.882 mike 5031: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 5032: node</a> with the <code title="">data</code> attribute set to
5033: the data given in the comment token.</p>
5034: </dd>
5035:
5036: <dt>A DOCTYPE token</dt>
5037: <dd>
5038: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5039: </dd>
5040:
5041: <dt>A start tag whose tag name is "html"</dt>
5042: <dd>
5043: <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
5044: mode</a>.</p>
5045: </dd>
5046:
5047: <dt>A start tag whose tag name is one of: "base", "command",
5048: "link"</dt>
5049: <dd>
5050:
5051: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
5052: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
5053: elements</a>.</p>
5054:
5055: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
5056: token's <i>self-closing flag</i></a>, if it is set.</p>
5057:
5058: </dd>
5059:
5060: <dt>A start tag whose tag name is "meta"</dt>
5061: <dd>
5062:
5063: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
5064: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
5065: elements</a>.</p>
5066:
5067: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
5068: token's <i>self-closing flag</i></a>, if it is set.</p>
5069:
5070: <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
5071: value is a supported encoding, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
5072: currently <i>tentative</i>, then <a href="#change-the-encoding">change the
5073: encoding</a> to the encoding given by the value of the
5074: <code title="attr-meta-charset"><a href="semantics.html#attr-meta-charset">charset</a></code> attribute.</p>
5075:
1.924 mike 5076: <p>Otherwise, if the element has an <code title="attr-meta-http-equiv"><a href="semantics.html#attr-meta-http-equiv">http-equiv</a></code> attribute whose
5077: value is an <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a> match for the
5078: string "<code title="">Content-Type</code>", and the element has a
5079: <code title="attr-meta-content"><a href="semantics.html#attr-meta-content">content</a></code> attribute, and
1.1 mike 5080: applying the <a href="infrastructure.html#algorithm-for-extracting-an-encoding-from-a-content-type">algorithm for extracting an encoding from a
1.924 mike 5081: Content-Type</a> to that attribute's value returns a supported
5082: encoding <var title="">encoding</var>, and the <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is currently
5083: <i>tentative</i>, then <a href="#change-the-encoding">change the encoding</a> to the
5084: encoding <var title="">encoding</var>.</p>
1.1 mike 5085:
5086: </dd>
5087:
5088: <dt>A start tag whose tag name is "title"</dt>
5089: <dd>
5090: <p>Follow the <a href="#generic-rcdata-element-parsing-algorithm">generic RCDATA element parsing algorithm</a>.</p>
5091: </dd>
5092:
5093: <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
5094: <dt>A start tag whose tag name is one of: "noframes", "style"</dt>
5095: <dd>
1.91 mike 5096: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 5097: </dd>
5098:
5099: <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is disabled</dt>
5100: <dd>
5101:
5102: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5103:
5104: <p>Switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inheadnoscript" title="insertion mode: in head noscript">in head
5105: noscript</a>".</p>
5106:
5107: </dd>
5108:
5109: <dt id="scriptTag">A start tag whose tag name is "script"</dt>
5110: <dd>
5111:
1.854 mike 5112: <p>Run these steps:</p>
5113:
1.1 mike 5114: <ol><li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> in the
1.724 mike 5115: <a href="infrastructure.html#html-namespace-0">HTML namespace</a>.</p></li>
1.1 mike 5116:
5117: <li>
5118:
5119: <p>Mark the element as being <a href="semantics.html#parser-inserted">"parser-inserted"</a>.</p>
5120:
5121: <p class="note">This ensures that, if the script is external,
1.159 mike 5122: any <code title="dom-document-write"><a href="embedded-content-0.html#dom-document-write">document.write()</a></code>
1.1 mike 5123: calls in the script will execute in-line, instead of blowing the
5124: document away, as would happen in most other cases. It also
5125: prevents the script from executing until the end tag is
5126: seen.</p>
5127:
5128: </li>
5129:
5130: <li><p>If the parser was originally created for the <a href="#html-fragment-parsing-algorithm">HTML
5131: fragment parsing algorithm</a>, then mark the
1.484 mike 5132: <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
5133: started"</a>. (<a href="#fragment-case">fragment case</a>)</p></li>
1.1 mike 5134:
5135: <li><p>Append the new element to the <a href="#current-node">current node</a>
5136: and push it onto the <a href="#stack-of-open-elements">stack of open
5137: elements</a>.</p></li>
5138:
1.541 mike 5139: <li><p>Switch the tokenizer to the <a href="#script-data-state">script data
5140: state</a>.</p></li>
1.1 mike 5141:
5142: <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
5143: <a href="#insertion-mode">insertion mode</a>.</p>
5144:
1.540 mike 5145: </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 5146:
5147: </ol></dd>
5148:
5149: <dt>An end tag whose tag name is "head"</dt>
5150: <dd>
5151:
5152: <p>Pop the <a href="#current-node">current node</a> (which will be the
1.159 mike 5153: <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 5154: elements</a>.</p>
5155:
5156: <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>
5157:
5158: </dd>
5159:
5160: <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
5161: <dd>
5162: <p>Act as described in the "anything else" entry below.</p>
5163: </dd>
5164:
5165: <dt>A start tag whose tag name is "head"</dt>
5166: <dt>Any other end tag</dt>
5167: <dd>
5168: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5169: </dd>
5170:
5171: <dt>Anything else</dt>
5172: <dd>
5173:
5174: <!-- can't get here with an EOF and a fragment case -->
5175:
5176: <p>Act as if an end tag token with the tag name "head" had
5177: been seen, and reprocess the current token.</p>
5178:
5179: </dd>
5180:
1.895 mike 5181: </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 5182:
5183: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inheadnoscript" title="insertion
5184: mode: in head noscript">in head noscript</a>", tokens must be handled as follows:</p>
5185:
5186: <dl class="switch"><dt>A DOCTYPE token</dt>
5187: <dd>
5188: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5189: </dd>
5190:
5191: <dt>A start tag whose tag name is "html"</dt>
5192: <dd>
5193: <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
5194: mode</a>.</p>
5195: </dd>
5196:
5197: <dt>An end tag whose tag name is "noscript"</dt>
5198: <dd>
5199:
5200: <p>Pop the <a href="#current-node">current node</a> (which will be a
5201: <code><a href="semantics.html#the-noscript-element">noscript</a></code> element) from the <a href="#stack-of-open-elements">stack of open
5202: elements</a>; the new <a href="#current-node">current node</a> will be a
1.159 mike 5203: <code><a href="semantics.html#the-head-element-0">head</a></code> element.</p>
1.1 mike 5204:
5205: <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>
5206:
5207: </dd>
5208:
5209: <dt>A character token that is one of U+0009 CHARACTER
5210: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 5211: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 5212: <dt>A comment token</dt>
5213: <dt>A start tag whose tag name is one of: "link", "meta", "noframes", "style"</dt>
5214: <dd>
5215: <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
5216: mode</a>.</p>
5217: </dd>
5218:
5219: <dt>An end tag whose tag name is "br"</dt>
5220: <dd>
5221: <p>Act as described in the "anything else" entry below.</p>
5222: </dd>
5223:
5224: <dt>A start tag whose tag name is one of: "head", "noscript"</dt>
5225: <dt>Any other end tag</dt>
5226: <dd>
5227: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5228: </dd>
5229:
5230: <dt>Anything else</dt>
5231: <dd>
5232:
5233: <!-- can't get here with an EOF and a fragment case -->
5234:
5235: <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
5236: name "noscript" had been seen and reprocess the current
5237: token.</p>
5238:
5239: </dd>
5240:
1.895 mike 5241: </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 5242:
5243: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-head-insertion-mode" title="insertion
5244: mode: after head">after head</a>", tokens must be handled as follows:</p>
5245:
5246: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
5247: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 5248: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 5249: <dd>
5250: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
5251: the <a href="#current-node">current node</a>.</p>
5252: </dd>
5253:
5254: <dt>A comment token</dt>
5255: <dd>
1.882 mike 5256: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 5257: node</a> with the <code title="">data</code> attribute set to
5258: the data given in the comment token.</p>
5259: </dd>
5260:
5261: <dt>A DOCTYPE token</dt>
5262: <dd>
5263: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5264: </dd>
5265:
5266: <dt>A start tag whose tag name is "html"</dt>
5267: <dd>
5268: <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
5269: mode</a>.</p>
5270: </dd>
5271:
5272: <dt>A start tag whose tag name is "body"</dt>
5273: <dd>
5274:
5275: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5276:
5277: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5278:
5279: <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>
5280:
5281: </dd>
5282:
5283: <dt>A start tag whose tag name is "frameset"</dt>
5284: <dd>
5285:
5286: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5287:
5288: <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>
5289:
5290: </dd>
5291:
5292: <dt>A start tag token whose tag name is one of: "base", "link",
5293: "meta", "noframes", "script", "style", "title"</dt>
5294: <dd>
5295:
5296: <p><a href="#parse-error">Parse error</a>.</p>
5297:
5298: <p>Push the node pointed to by the <a href="#head-element-pointer"><code title="">head</code> element pointer</a> onto the
5299: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
5300:
5301: <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
5302: mode</a>.</p>
5303:
5304: <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
5305: of open elements</a>.</p>
5306:
5307: <p class="note">The <a href="#head-element-pointer"><code title="">head</code> element
5308: pointer</a> cannot be null at this point.</p>
5309:
5310: </dd>
5311:
5312: <dt>An end tag whose tag name is one of: "body", "html", "br"</dt>
5313: <dd>
5314: <p>Act as described in the "anything else" entry below.</p>
5315: </dd>
5316:
5317: <dt>A start tag whose tag name is "head"</dt>
5318: <dt>Any other end tag</dt>
5319: <dd>
5320: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5321: </dd>
5322:
5323: <dt>Anything else</dt>
5324: <dd>
5325: <p>Act as if a start tag token with the tag name "body" and no
5326: attributes had been seen, then set the <a href="#frameset-ok-flag">frameset-ok
5327: flag</a> back to "ok", and then reprocess the current
5328: token.</p>
5329: </dd>
5330:
1.895 mike 5331: </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 5332:
5333: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inbody" title="insertion
5334: mode: in body">in body</a>", tokens must be handled as follows:</p>
5335:
5336: <dl class="switch"><dt>A character token</dt>
5337: <dd>
5338:
5339: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5340: any.</p>
5341:
5342: <p><a href="#insert-a-character" title="insert a character">Insert the token's
5343: character</a> into the <a href="#current-node">current node</a>.</p>
5344:
5345: <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
1.882 mike 5346: LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN
5347: (CR), or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
1.1 mike 5348: flag</a> to "not ok".</p>
5349:
5350: </dd>
5351:
5352: <dt>A comment token</dt>
5353: <dd>
1.882 mike 5354: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 5355: node</a> with the <code title="">data</code> attribute set to
5356: the data given in the comment token.</p>
5357: </dd>
5358:
5359: <dt>A DOCTYPE token</dt>
5360: <dd>
5361: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
5362: </dd>
5363:
5364: <dt>A start tag whose tag name is "html"</dt>
5365: <dd>
5366: <p><a href="#parse-error">Parse error</a>. For each attribute on the token,
5367: check to see if the attribute is already present on the top
5368: element of the <a href="#stack-of-open-elements">stack of open elements</a>. If it is not,
5369: add the attribute and its corresponding value to that element.</p>
5370: </dd>
5371:
5372: <dt>A start tag token whose tag name is one of: "base", "command",
5373: "link", "meta", "noframes", "script", "style", "title"</dt>
5374: <dd>
5375: <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
5376: mode</a>.</p>
5377: </dd>
5378:
5379: <dt>A start tag whose tag name is "body"</dt>
5380: <dd>
5381:
5382: <p><a href="#parse-error">Parse error</a>.</p>
5383:
5384: <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159 mike 5385: elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1 mike 5386: <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
5387: then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
5388:
5389: <p>Otherwise, for each attribute on the token, check to see if
1.159 mike 5390: the attribute is already present on the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1 mike 5391: element (the second element) on the <a href="#stack-of-open-elements">stack of open
5392: elements</a>. If it is not, add the attribute and its
5393: corresponding value to that element.</p>
5394:
5395: </dd>
5396:
5397: <dt>A start tag whose tag name is "frameset"</dt>
5398: <dd>
5399:
5400: <p><a href="#parse-error">Parse error</a>.</p>
5401:
5402: <p>If the second element on the <a href="#stack-of-open-elements">stack of open
1.159 mike 5403: elements</a> is not a <code><a href="semantics.html#the-body-element-0">body</a></code> element, or, if the
1.1 mike 5404: <a href="#stack-of-open-elements">stack of open elements</a> has only one node on it,
5405: then ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
5406:
5407: <p>If the <a href="#frameset-ok-flag">frameset-ok flag</a> is set to "not ok", ignore
5408: the token.</p>
5409:
5410: <p>Otherwise, run the following steps:</p>
5411:
5412: <ol><li><p>Remove the second element on the <a href="#stack-of-open-elements">stack of open
5413: elements</a> from its parent node, if it has one.</p></li>
5414:
5415: <li><p>Pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of
5416: open elements</a>, from the <a href="#current-node">current node</a> up to,
1.159 mike 5417: but not including, the root <code><a href="semantics.html#the-html-element-0">html</a></code> element.</p>
1.1 mike 5418:
5419: </li><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
5420: token.</p></li>
5421:
5422: <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>
5423:
5424: </li></ol></dd>
5425:
5426: <dt>An end-of-file token</dt>
5427: <dd>
5428:
5429: <p>If there is a node in the <a href="#stack-of-open-elements">stack of open elements</a>
1.422 mike 5430: 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>
5431: 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 5432: <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
5433: <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
5434: <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 5435: <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 5436: this is a <a href="#parse-error">parse error</a>.</p> <!-- (some of those are
1.422 mike 5437: fragment cases) -->
1.1 mike 5438:
5439: <p><a href="#stop-parsing">Stop parsing</a>.</p>
5440:
5441: </dd>
5442:
5443: <dt>An end tag whose tag name is "body"</dt>
5444: <dd>
5445:
5446: <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
5447: in scope</a>, this is a <a href="#parse-error">parse error</a>; ignore the
5448: token.</p>
5449:
5450: <!-- if we get here, the insertion mode here is forcibly "in
5451: body". -->
5452:
5453: <p>Otherwise, if there is a node in the <a href="#stack-of-open-elements">stack of open
1.422 mike 5454: elements</a> that is not either a <code><a href="semantics.html#the-dd-element">dd</a></code> element, a
1.1 mike 5455: <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
5456: <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
5457: <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
5458: <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
5459: <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
5460: <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 5461: <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
5462: <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 5463: error</a>.</p> <!-- (some of those are fragment cases, e.g. for
5464: <tbody> you'd have hit the first paragraph since the <body>
1.422 mike 5465: wouldn't be in scope, unless it was a fragment case) -->
1.1 mike 5466:
5467: <!-- If we ever change the frameset-ok flag to an insertion mode,
5468: then we'd have to somehow keep track of its state when we switch
5469: to after-body. -->
5470:
5471: <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>
5472:
5473: </dd>
5474:
5475: <dt>An end tag whose tag name is "html"</dt>
5476: <dd>
5477:
5478: <p>Act as if an end tag with tag name "body" had been seen,
5479: then, if that token wasn't ignored, reprocess the current
5480: token.</p>
5481:
5482: </dd>
5483:
5484: <!-- start tags for non-phrasing flow content elements -->
5485:
5486: <!-- the normal ones -->
5487: <dt>A start tag whose tag name is one of: "address", "article",
1.683 mike 5488: "aside", "blockquote", "center", <!--v2DATAGRID"datagrid",-->
1.305 mike 5489: "details", "dir", "div", "dl", "fieldset", "figure", "footer",
5490: "header", "hgroup", "menu", "nav", "ol", "p", "section", "ul"</dt>
1.1 mike 5491: <dd>
5492:
5493: <!-- As of May 2008 this doesn't match any browser exactly, but is
5494: as close to what IE does as I can get without doing the non-tree
5495: DOM nonsense, and thus should actually afford better compatibility
5496: when implemented by the other browsers. -->
5497:
5498: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5499: an element in scope">has a <code>p</code> element in
5500: scope</a>, then act as if an end tag with the tag name
5501: "p" had been seen.</p>
5502:
5503: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5504:
5505: </dd>
5506:
5507: <!-- as normal, but close h1-h6 if it's the current node -->
5508: <dt>A start tag whose tag name is one of: "h1", "h2", "h3", "h4",
5509: "h5", "h6"</dt>
5510: <dd>
5511:
5512: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5513: an element in scope">has a <code>p</code> element in
5514: scope</a>, then act as if an end tag with the tag name
5515: "p" had been seen.</p>
5516:
5517: <p>If the <a href="#current-node">current node</a> is an element whose tag name
5518: is one of "h1", "h2", "h3", "h4", "h5", or "h6", then this is a
5519: <a href="#parse-error">parse error</a>; pop the <a href="#current-node">current node</a> off
5520: the <a href="#stack-of-open-elements">stack of open elements</a>.</p>
5521: <!-- See https://bugs.webkit.org/show_bug.cgi?id=12646 -->
5522:
5523: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5524:
5525: </dd>
5526:
5527: <!-- as normal, but drops leading newline -->
5528: <dt>A start tag whose tag name is one of: "pre", "listing"</dt>
5529: <dd>
5530:
5531: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5532: an element in scope">has a <code>p</code> element in
5533: scope</a>, then act as if an end tag with the tag name
5534: "p" had been seen.</p>
5535:
5536: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5537:
5538: <p>If the next token is a U+000A LINE FEED (LF) character
5539: token, then ignore that token and move on to the next
5540: one. (Newlines at the start of <code><a href="semantics.html#the-pre-element">pre</a></code> blocks are
5541: ignored as an authoring convenience.)</p>
5542:
1.882 mike 5543: <!-- <pre>[CR]X will eat the [CR], <pre>X will eat the
5544: , but <pre>X will not eat the . -->
5545:
1.1 mike 5546: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5547:
5548: </dd>
5549:
5550: <!-- as normal, but interacts with the form element pointer -->
5551: <dt>A start tag whose tag name is "form"</dt>
5552: <dd>
5553:
5554: <p>If the <a href="#form-element-pointer"><code title="form">form</code> element
5555: pointer</a> is not null, then this is a <a href="#parse-error">parse
5556: error</a>; ignore the token.</p>
5557:
5558: <p>Otherwise:</p>
5559:
5560: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5561: an element in scope">has a <code>p</code> element in
5562: scope</a>, then act as if an end tag with the tag name
5563: "p" had been seen.</p>
5564:
5565: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, and set the
5566: <a href="#form-element-pointer"><code title="form">form</code> element pointer</a> to
5567: point to the element created.</p>
5568:
5569: </dd>
5570:
5571: <!-- as normal, but imply </li> when there's another <li> open in weird cases -->
5572: <dt>A start tag whose tag name is "li"</dt>
5573: <dd>
5574:
1.864 mike 5575: <p>Run these steps:</p>
1.1 mike 5576:
5577: <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
5578:
5579: <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
5580: node</a> (the bottommost node of the stack).</p></li>
5581:
1.578 mike 5582: <li><p><i>Loop</i>: If <var title="">node</var> is an
5583: <code><a href="semantics.html#the-li-element">li</a></code> element, then act as if an end tag with the tag
5584: name "li" had been seen, then jump to the last step.</p></li>
1.1 mike 5585:
1.578 mike 5586: <li><p>If <var title="">node</var> is not in the
1.1 mike 5587: <a href="#formatting">formatting</a> category, and is not in the
5588: <a href="#phrasing">phrasing</a> category, and is not an
1.306 mike 5589: <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 5590: element, then jump to the last step.</p></li> <!-- an element
5591: <foo> is in this list if the following markup:
5592:
5593: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><ol><li><foo><li>
5594:
5595: ...results in the second <li> not being (in any way) a descendant
5596: of the first <li>, or if <foo> is a formatting element that gets
5597: reopened later. -->
5598:
5599: <li><p>Otherwise, set <var title="">node</var> to the previous
5600: entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
5601: the step labeled <i>loop</i>.</p></li>
5602:
5603: <li>
5604:
5605: <p>This is the last step.</p>
5606:
5607: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5608: an element in scope">has a <code>p</code> element in
5609: scope</a>, then act as if an end tag with the tag name
5610: "p" had been seen.</p>
5611:
5612: <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
5613: token.</p>
5614:
5615: </li>
5616:
5617: </ol></dd>
5618:
5619: <!-- as normal, but imply </dt> or </dd> when there's another <dt> or <dd> open in weird cases -->
1.422 mike 5620: <dt>A start tag whose tag name is one of: "dd", "dt"</dt>
1.1 mike 5621: <dd>
5622:
1.854 mike 5623: <p>Run these steps:</p>
1.1 mike 5624:
5625: <ol><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p></li>
5626:
5627: <li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
5628: node</a> (the bottommost node of the stack).</p></li>
5629:
5630: <li><p><i>Loop</i>: If <var title="">node</var> is a
1.422 mike 5631: <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
5632: tag with the same tag name as <var title="">node</var> had been
5633: seen, then jump to the last step.</p></li>
1.1 mike 5634:
5635: <li><p>If <var title="">node</var> is not in the
5636: <a href="#formatting">formatting</a> category, and is not in the
5637: <a href="#phrasing">phrasing</a> category, and is not an
1.306 mike 5638: <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 5639: element, then jump to the last step.</p></li> <!-- an element
5640: <foo> is in this list if the following markup:
5641:
5642: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><body><dl><dt><foo><dt>
5643:
5644: ...results in the second <dt> not being (in any way) a descendant
5645: of the first <dt>, or if <foo> is a formatting element that gets
5646: reopened later. -->
5647:
5648: <li><p>Otherwise, set <var title="">node</var> to the previous
5649: entry in the <a href="#stack-of-open-elements">stack of open elements</a> and return to
5650: the step labeled <i>loop</i>.</p></li>
5651:
5652: <li>
5653:
5654: <p>This is the last step.</p>
5655:
5656: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5657: an element in scope">has a <code>p</code> element in
5658: scope</a>, then act as if an end tag with the tag name
5659: "p" had been seen.</p>
5660:
5661: <p>Finally, <a href="#insert-an-html-element">insert an HTML element</a> for the
5662: token.</p>
5663:
5664: </li>
5665:
5666: </ol></dd>
5667:
5668: <!-- same as normal, but effectively ends parsing -->
5669: <dt>A start tag whose tag name is "plaintext"</dt>
5670: <dd>
5671:
5672: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5673: an element in scope">has a <code>p</code> element in
5674: scope</a>, then act as if an end tag with the tag name
5675: "p" had been seen.</p>
5676:
5677: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5678:
1.541 mike 5679: <p>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1 mike 5680:
1.541 mike 5681: <p class="note">Once a start tag with the tag name "plaintext" has
5682: been seen, that will be the last token ever seen other than
5683: character tokens (and the end-of-file token), because there is no
5684: way to switch out of the <a href="#plaintext-state">PLAINTEXT state</a>.</p>
1.1 mike 5685:
5686: </dd>
5687:
1.953 mike 5688: <!-- button is a hybrid -->
5689: <dt>A start tag whose tag name is "button"</dt>
5690: <dd>
5691:
5692: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
5693: an element in scope">has a <code>button</code> element in
5694: scope</a>, then this is a <a href="#parse-error">parse error</a>;
5695: act as if an end tag with the tag name "button" had been seen,
5696: then reprocess the token.</p>
5697:
5698: <p>Otherwise:</p>
5699:
5700: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5701: any.</p>
5702:
5703: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
5704:
5705: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
5706:
5707: </dd>
5708:
5709: <!-- end tags for non-phrasing flow content elements (and button) -->
1.1 mike 5710:
5711: <!-- the normal ones -->
5712: <dt>An end tag whose tag name is one of: "address", "article",
1.953 mike 5713: "aside", "blockquote", "button", "center",
5714: <!--v2DATAGRID"datagrid",--> "details", "dir", "div", "dl",
5715: "fieldset", "figure", "footer", "header", "hgroup", "listing",
5716: "menu", "nav", "ol", "pre", "section", "ul"</dt>
1.1 mike 5717: <dd>
5718:
5719: <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>
5720: with the same tag name as that of the token, then this is a
5721: <a href="#parse-error">parse error</a>; ignore the token.</p>
5722:
5723: <p>Otherwise, run these steps:</p>
5724:
5725: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
5726:
5727: <li><p>If the <a href="#current-node">current node</a> is not an element with
5728: the same tag name as that of the token, then this is a
5729: <a href="#parse-error">parse error</a>.</p></li>
5730:
5731: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5732: until an element with the same tag name as the token has been
5733: popped from the stack.</p></li>
5734:
5735: </ol></dd>
5736:
5737: <!-- removes the form element pointer instead of the matching node -->
5738: <dt>An end tag whose tag name is "form"</dt>
5739: <dd>
5740:
5741: <p>Let <var title="">node</var> be the element that the
5742: <a href="#form-element-pointer"><code title="">form</code> element pointer</a> is set
5743: to.</p>
5744:
5745: <p>Set the <a href="#form-element-pointer"><code title="">form</code> element pointer</a>
5746: to null.</p>
5747:
5748: <p>If <var title="">node</var> is null or the <a href="#stack-of-open-elements">stack of open
5749: elements</a> does not <a href="#has-an-element-in-scope" title="has an element in
5750: scope">have <var title="">node</var> in scope</a>, then this is
5751: a <a href="#parse-error">parse error</a>; ignore the token.</p>
5752:
5753: <p>Otherwise, run these steps:</p>
5754:
5755: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
5756:
5757: <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
5758: error</a>.</p></li>
5759:
5760: <li><p>Remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of
5761: open elements</a>.</p></li>
5762:
5763: </ol></dd>
5764:
5765: <!-- as normal, except </p> implies <p> if there's no <p> in scope, and needs care as the elements have optional tags -->
5766: <dt>An end tag whose tag name is "p"</dt>
5767: <dd>
5768:
5769: <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>
5770: with the same tag name as that of the token, then this is a
5771: <a href="#parse-error">parse error</a>; act as if a start tag with the tag name
5772: "p" had been seen, then reprocess the current token.</p>
5773:
5774: <p>Otherwise, run these steps:</p>
5775:
5776: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
5777: for elements with the same tag name as the token.</p></li>
5778:
5779: <li><p>If the <a href="#current-node">current node</a> is not an element with
5780: the same tag name as that of the token, then this is a
5781: <a href="#parse-error">parse error</a>.</p></li>
5782:
5783: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5784: until an element with the same tag name as the token has been
5785: popped from the stack.</p></li>
5786:
5787: </ol></dd>
5788:
1.234 mike 5789: <!-- as normal, but needs care as the elements have optional tags, and are further scoped by <ol>/<ul> -->
5790: <dt>An end tag whose tag name is "li"</dt>
5791: <dd>
5792:
5793: <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
5794: item scope</a> with the same tag name as that of the token,
5795: then this is a <a href="#parse-error">parse error</a>; ignore the token.</p>
5796:
5797: <p>Otherwise, run these steps:</p>
5798:
5799: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
5800: for elements with the same tag name as the token.</p></li>
5801:
5802: <li><p>If the <a href="#current-node">current node</a> is not an element with
5803: the same tag name as that of the token, then this is a
5804: <a href="#parse-error">parse error</a>.</p></li>
5805:
5806: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5807: until an element with the same tag name as the token has been
5808: popped from the stack.</p></li>
5809:
5810: </ol></dd>
5811:
1.1 mike 5812: <!-- as normal, but needs care as the elements have optional tags -->
1.422 mike 5813: <dt>An end tag whose tag name is one of: "dd", "dt"</dt>
1.1 mike 5814: <dd>
5815:
5816: <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>
5817: with the same tag name as that of the token, then this is a
5818: <a href="#parse-error">parse error</a>; ignore the token.</p>
5819:
5820: <p>Otherwise, run these steps:</p>
5821:
5822: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>, except
5823: for elements with the same tag name as the token.</p></li>
5824:
5825: <li><p>If the <a href="#current-node">current node</a> is not an element with
5826: the same tag name as that of the token, then this is a
5827: <a href="#parse-error">parse error</a>.</p></li>
5828:
5829: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5830: until an element with the same tag name as the token has been
5831: popped from the stack.</p></li>
5832:
5833: </ol></dd>
5834:
5835: <!-- as normal, except acts as a closer for any of the h1-h6 elements -->
5836: <dt>An end tag whose tag name is one of: "h1", "h2", "h3", "h4", "h5", "h6"</dt>
5837: <dd>
5838:
5839: <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>
5840: whose tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6",
5841: then this is a <a href="#parse-error">parse error</a>; ignore the token.</p>
5842:
5843: <p>Otherwise, run these steps:</p>
5844:
5845: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
5846:
5847: <li><p>If the <a href="#current-node">current node</a> is not an element with
5848: the same tag name as that of the token, then this is a
5849: <a href="#parse-error">parse error</a>.</p></li>
5850:
5851: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
5852: until an element whose tag name is one of "h1", "h2", "h3", "h4",
5853: "h5", or "h6" has been popped from the stack.</p></li>
5854:
5855: </ol></dd>
5856:
1.953 mike 5857: <!-- see also applet/marquee/object lower down -->
5858:
1.1 mike 5859: <dt>An end tag whose tag name is "sarcasm"</dt>
5860: <dd>
5861: <p>Take a deep breath, then act as described in the "any other end
5862: tag" entry below.</p>
5863: </dd>
5864:
5865: <!-- ADOPTION AGENCY ELEMENTS
5866: Mozilla-only: bdo blink del ins sub sup q
5867: Safari-only: code dfn kbd nobr samp var wbr
5868: Both: a b big em font i s small strike strong tt u -->
5869:
5870: <dt>A start tag whose tag name is "a"</dt>
5871: <dd>
5872:
5873: <p>If the <a href="#list-of-active-formatting-elements">list of active formatting elements</a>
5874: contains an element whose tag name is "a" between the end of
5875: the list and the last marker on the list (or the start of the
5876: list if there is no marker on the list), then this is a
5877: <a href="#parse-error">parse error</a>; act as if an end tag with the tag
5878: name "a" had been seen, then remove that element from the
5879: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> and the
5880: <a href="#stack-of-open-elements">stack of open elements</a> if the end tag didn't
5881: already remove it (it might not have if the element is not
5882: <a href="#has-an-element-in-table-scope" title="has an element in table scope">in table
5883: scope</a>).</p>
5884:
5885: <p class="example">In the non-conforming stream
5886: <code><a href="a">a<table><a href="b">b</table>x</code>,
1.876 mike 5887: the first <code><a href="text-level-semantics.html#the-a-element">a</a></code> element would be closed upon seeing the
5888: second one, and the "x" character would be inside a link to "b",
5889: not to "a". This is despite the fact that the outer <code><a href="text-level-semantics.html#the-a-element">a</a></code>
5890: element is not in table scope (meaning that a regular
5891: <code></a></code> end tag at the start of the table wouldn't
5892: close the outer <code><a href="text-level-semantics.html#the-a-element">a</a></code> element). The result is that the
5893: two <code><a href="text-level-semantics.html#the-a-element">a</a></code> elements are indirectly nested inside each
5894: other — non-conforming markup will often result in
5895: non-conforming DOMs when parsed.</p>
1.1 mike 5896:
5897: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5898: any.</p>
5899:
5900: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
5901: element to the <a href="#list-of-active-formatting-elements">list of active formatting
5902: elements</a>.</p>
5903:
5904: </dd>
5905:
5906: <dt>A start tag whose tag name is one of: "b", "big", "code", "em",
5907: "font", "i", "s", "small", "strike", "strong", "tt", "u"</dt>
5908: <dd>
5909:
5910: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5911: any.</p>
5912:
5913: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
5914: element to the <a href="#list-of-active-formatting-elements">list of active formatting
5915: elements</a>.</p>
5916:
5917: </dd>
5918:
5919: <dt>A start tag whose tag name is "nobr"</dt>
5920: <dd>
5921:
5922: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
5923: any.</p>
5924:
5925: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
5926: element in scope">has a <code>nobr</code> element in scope</a>,
5927: then this is a <a href="#parse-error">parse error</a>; act as if an end tag with
5928: the tag name "nobr" had been seen, then once again
5929: <a href="#reconstruct-the-active-formatting-elements">reconstruct the active formatting elements</a>, if
5930: any.</p>
5931:
5932: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Add that
5933: element to the <a href="#list-of-active-formatting-elements">list of active formatting
5934: elements</a>.</p>
5935:
5936: </dd>
5937:
5938: <dt id="adoptionAgency">An end tag whose tag name is one of: "a",
5939: "b", "big", "code", "em", "font", "i", "nobr", "s", "small",
5940: "strike", "strong", "tt", "u"</dt>
5941: <dd>
5942:
1.854 mike 5943: <p>Run these steps:</p>
1.1 mike 5944:
5945: <ol><li>
5946:
5947: <p>Let the <var title="">formatting element</var> be the
5948: last element in the <a href="#list-of-active-formatting-elements">list of active formatting
5949: elements</a> that:</p>
5950:
5951: <ul><li>is between the end of the list and the last scope
5952: marker in the list, if any, or the start of the list
5953: otherwise, and</li>
5954:
5955: <li>has the same tag name as the token.</li>
5956:
5957: </ul><p>If there is no such node, or, if that node is also in the
5958: <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
5959: <a href="#parse-error">parse error</a>; ignore the token, and abort these
5960: steps.</p>
5961:
5962: <p>Otherwise, if there is such a node, but that node is not
5963: in the <a href="#stack-of-open-elements">stack of open elements</a>, then this is a
5964: <a href="#parse-error">parse error</a>; remove the element from the list,
5965: and abort these steps.</p>
5966:
5967: <p>Otherwise, there is a <var title="">formatting
5968: element</var> and that element is in <a href="#stack-of-open-elements" title="stack of
5969: open elements">the stack</a> and is <a href="#has-an-element-in-scope" title="has an
5970: element in scope">in scope</a>. If the element is not the
5971: <a href="#current-node">current node</a>, this is a <a href="#parse-error">parse
5972: error</a>. In any case, proceed with the algorithm as
5973: written in the following steps.</p>
5974:
5975: </li>
5976:
5977: <li><p>Let the <var title="">furthest block</var> be the
5978: topmost node in the <a href="#stack-of-open-elements">stack of open elements</a> that
5979: is lower in the stack than the <var title="">formatting
5980: element</var>, and is not an element in the
5981: <a href="#phrasing">phrasing</a> or <a href="#formatting">formatting</a>
5982: categories. There might not be one.</p></li>
5983:
5984: <li><p>If there is no <var title="">furthest block</var>,
5985: then the UA must skip the subsequent steps and instead just
5986: pop all the nodes from the bottom of the <a href="#stack-of-open-elements">stack of open
5987: elements</a>, from the <a href="#current-node">current node</a> up to and
5988: including the <var title="">formatting element</var>, and
5989: remove the <var title="">formatting element</var> from the
5990: <a href="#list-of-active-formatting-elements">list of active formatting elements</a>.</p></li>
5991:
5992: <li><p>Let the <var title="">common ancestor</var> be the element
5993: immediately above the <var title="">formatting element</var> in the
5994: <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
5995:
5996: <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
5997: formatting elements</a> relative to the elements on either
5998: side of it in the list.</p></li>
5999:
6000: <li>
6001:
6002: <p>Let <var title="">node</var> and <var title="">last node</var> be the
6003: <var title="">furthest block</var>. Follow these steps:</p>
6004:
6005: <ol><li>Let <var title="">node</var> be the element immediately
6006: above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
1.436 mike 6007: elements</a>, or if <var title="">node</var> is no longer in
6008: the <a href="#stack-of-open-elements">stack of open elements</a> (e.g. because it got
6009: removed by the next step), the element that was immediately
6010: above <var title="">node</var> in the <a href="#stack-of-open-elements">stack of open
6011: elements</a> before <var title="">node</var> was
6012: removed.</li>
1.1 mike 6013:
6014: <li>If <var title="">node</var> is not in the <a href="#list-of-active-formatting-elements">list of
6015: active formatting elements</a>, then remove <var title="">node</var> from the <a href="#stack-of-open-elements">stack of open
6016: elements</a> and then go back to step 1.</li>
6017:
6018: <li>Otherwise, if <var title="">node</var> is the <var title="">formatting element</var>, then go to the next step
6019: in the overall algorithm.</li>
6020:
6021: <li>Otherwise, if <var title="">last node</var> is the <var title="">furthest block</var>, then move the aforementioned
6022: bookmark to be immediately after the <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active formatting
6023: elements</a>.</li>
6024:
6025: <li><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
6026: element <var title="">node</var> was created, replace the entry
6027: for <var title="">node</var> in the <a href="#list-of-active-formatting-elements">list of active
6028: formatting elements</a> with an entry for the new element,
6029: replace the entry for <var title="">node</var> in the
6030: <a href="#stack-of-open-elements">stack of open elements</a> with an entry for the new
6031: element, and let <var title="">node</var> be the new
6032: element.</li>
6033:
6034: <li>Insert <var title="">last node</var> into <var title="">node</var>, first removing it from its previous
6035: parent node if any.</li>
6036:
6037: <li>Let <var title="">last node</var> be <var title="">node</var>.</li>
6038:
6039: <li>Return to step 1 of this inner set of steps.</li>
6040:
6041: </ol></li>
6042:
6043: <li>
6044:
6045: <p>If the <var title="">common ancestor</var> node is a
6046: <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>,
6047: <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,
6048: <a href="#foster-parent">foster parent</a> whatever <var title="">last
6049: node</var> ended up being in the previous step, first removing
6050: it from its previous parent node if any.</p>
6051:
6052: <p>Otherwise, append whatever <var title="">last node</var>
6053: ended up being in the previous step to the <var title="">common
6054: ancestor</var> node, first removing it from its previous parent
6055: node if any.</p>
6056:
6057: </li>
6058:
6059: <li><p><a href="#create-an-element-for-the-token">Create an element for the token</a> for which the
6060: <var title="">formatting element</var> was created.</p></li>
6061:
6062: <li><p>Take all of the child nodes of the <var title="">furthest
6063: block</var> and append them to the element created in the last
6064: step.</p></li>
6065:
6066: <li><p>Append that new element to the <var title="">furthest
6067: block</var>.</p></li>
6068:
6069: <li><p>Remove the <var title="">formatting element</var> from the
6070: <a href="#list-of-active-formatting-elements">list of active formatting elements</a>, and insert the
6071: new element into the <a href="#list-of-active-formatting-elements">list of active formatting
6072: elements</a> at the position of the aforementioned
6073: bookmark.</p></li>
6074:
6075: <li><p>Remove the <var title="">formatting element</var> from the
6076: <a href="#stack-of-open-elements">stack of open elements</a>, and insert the new element
6077: into the <a href="#stack-of-open-elements">stack of open elements</a> immediately below
6078: the position of the <var title="">furthest block</var> in that
6079: stack.</p></li>
6080:
6081: <li><p>Jump back to step 1 in this series of steps.</p></li>
6082:
1.334 mike 6083: </ol><p class="note">Because of the way this algorithm causes elements
1.304 mike 6084: to change parents, it has been dubbed the "adoption agency
6085: algorithm" (in contrast with other possible algorithms for dealing
6086: with misnested content, which included the "incest algorithm", the
1.1 mike 6087: "secret affair algorithm", and the "Heisenberg algorithm").</p>
6088:
6089: </dd>
6090:
6091: <dt>A start tag token whose tag name is one of: "applet",
6092: "marquee", "object"</dt>
6093: <dd>
6094:
6095: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6096: any.</p>
6097:
6098: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6099:
6100: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
6101: formatting elements</a>.</p>
6102:
6103: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6104:
6105: </dd>
6106:
1.953 mike 6107: <dt>An end tag token whose tag name is one of: "applet",
1.1 mike 6108: "marquee", "object"</dt>
6109: <dd>
6110:
6111: <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>
6112: with the same tag name as that of the token, then this is a
6113: <a href="#parse-error">parse error</a>; ignore the token.</p>
6114:
6115: <p>Otherwise, run these steps:</p>
6116:
6117: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
6118:
6119: <li><p>If the <a href="#current-node">current node</a> is not an element with
6120: the same tag name as that of the token, then this is a
6121: <a href="#parse-error">parse error</a>.</p></li>
6122:
6123: <li><p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
6124: until an element with the same tag name as the token has been
6125: popped from the stack.</p></li>
6126:
6127: <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
6128: last marker</a>.</li>
6129:
6130: </ol></dd>
6131:
6132: <dt>A start tag whose tag name is "table"</dt>
6133: <dd>
6134:
1.810 mike 6135: <p>If the <code><a href="infrastructure.html#document">Document</a></code> is <em>not</em> set to
1.1 mike 6136: <a href="dom.html#quirks-mode">quirks mode</a>, and the <a href="#stack-of-open-elements">stack of open
6137: elements</a> <a href="#has-an-element-in-scope" title="has an element in scope">has a
6138: <code>p</code> element in scope</a>, then act as if an end tag
6139: with the tag name "p" had been seen.</p> <!-- i hate myself (this
6140: quirk was basically caused by acid2; if i'd realised we could
6141: change the specs when i wrote acid2, we could have avoided having
6142: any parsing-mode quirks) -Hixie -->
6143:
6144: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6145:
6146: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6147:
6148: <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>
6149:
6150: </dd>
6151:
6152: <dt>A start tag whose tag name is one of: "area", "basefont",
1.589 mike 6153: "bgsound", "br", "embed", "img", "input", "keygen", "wbr"</dt>
1.1 mike 6154: <dd>
6155:
6156: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6157: any.</p>
6158:
6159: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
6160: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6161: elements</a>.</p>
6162:
6163: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6164: token's <i>self-closing flag</i></a>, if it is set.</p>
6165:
6166: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p> <!--
1.589 mike 6167: shouldn't really do it for <area>, <basefont>, and <bgsound> -->
1.1 mike 6168:
6169: </dd>
6170:
1.973 ! mike 6171: <dt>A start tag whose tag name is one of: "param", "source", "track"</dt>
1.1 mike 6172: <dd>
6173:
6174: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
6175: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6176: elements</a>.</p>
6177:
6178: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6179: token's <i>self-closing flag</i></a>, if it is set.</p>
6180:
6181: </dd>
6182:
6183: <dt>A start tag whose tag name is "hr"</dt>
6184: <dd>
6185:
6186: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
6187: an element in scope">has a <code>p</code> element in
6188: scope</a>, then act as if an end tag with the tag name
6189: "p" had been seen.</p>
6190:
6191: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
6192: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6193: elements</a>.</p>
6194:
6195: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6196: token's <i>self-closing flag</i></a>, if it is set.</p>
6197:
6198: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6199:
6200: </dd>
6201:
6202: <dt>A start tag whose tag name is "image"</dt>
6203: <dd>
6204: <p><a href="#parse-error">Parse error</a>. Change the token's tag name
6205: to "img" and reprocess it. (Don't ask.)</p> <!-- As of
6206: 2005-12, studies showed that around 0.2% of pages used the
6207: <image> element. -->
6208: </dd>
6209:
6210: <dt id="isindex">A start tag whose tag name is "isindex"</dt>
6211: <dd>
6212:
6213: <p><a href="#parse-error">Parse error</a>.</p>
6214:
6215: <p>If the <a href="#form-element-pointer"><code title="">form</code> element
6216: pointer</a> is not null, then ignore the token.</p>
6217:
6218: <p>Otherwise:</p>
6219:
6220: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
6221: token's <i>self-closing flag</i></a>, if it is set.</p> <!--
6222: purely to reduce the number of errors (we don't care if they
6223: included the /, they're not supposed to be including the tag at
6224: all! -->
6225:
6226: <p>Act as if a start tag token with the tag name "form" had been seen.</p>
6227:
6228: <p>If the token has an attribute called "action", set the
6229: <code title="attr-form-action">action</code> attribute on the
6230: resulting <code><a href="forms.html#the-form-element">form</a></code> element to the value of the
6231: "action" attribute of the token.</p>
6232:
6233: <p>Act as if a start tag token with the tag name "hr" had been
6234: seen.</p>
6235:
6236: <p>Act as if a start tag token with the tag name "label" had been
6237: seen.</p>
6238:
6239: <p>Act as if a stream of character tokens had been seen (see below
6240: for what they should say).</p>
6241:
6242: <p>Act as if a start tag token with the tag name "input" had been
6243: seen, with all the attributes from the "isindex" token except
6244: "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
6245: <code><a href="forms.html#the-input-element">input</a></code> element to the value "<code title="">isindex</code>".</p>
6246:
6247: <p>Act as if a stream of character tokens had been seen (see
6248: below for what they should say).</p>
6249:
6250: <p>Act as if an end tag token with the tag name "label" had been
6251: seen.</p>
6252:
6253: <p>Act as if a start tag token with the tag name "hr" had been
6254: seen.</p>
6255:
6256: <p>Act as if an end tag token with the tag name "form" had been
6257: seen.</p>
6258:
6259: <p>If the token has an attribute with the name "prompt", then the
6260: first stream of characters must be the same string as given in
6261: that attribute, and the second stream of characters must be
6262: empty. Otherwise, the two streams of character tokens together
6263: should, together with the <code><a href="forms.html#the-input-element">input</a></code> element, express the
1.883 mike 6264: equivalent of "This is a searchable index. Enter search keywords:
6265: (input field)" in the user's preferred language.</p>
1.1 mike 6266:
6267: </dd>
6268:
6269: <dt>A start tag whose tag name is "textarea"</dt>
6270: <dd>
6271:
1.854 mike 6272: <p>Run these steps:</p>
6273:
1.1 mike 6274: <ol><li><p><a href="#insert-an-html-element">Insert an HTML element</a> for the
6275: token.</p></li>
6276:
6277: <li><p>If the next token is a U+000A LINE FEED (LF) character
6278: token, then ignore that token and move on to the next
6279: one. (Newlines at the start of <code><a href="forms.html#the-textarea-element">textarea</a></code> elements are
6280: ignored as an authoring convenience.)</p></li>
1.920 mike 6281:
1.882 mike 6282: <!-- see comment in <pre> start tag bit -->
1.1 mike 6283:
1.671 mike 6284: <li><p>Switch the tokenizer to the <a href="#rcdata-state">RCDATA
1.541 mike 6285: state</a>.</p></li>
1.1 mike 6286:
6287: <li><p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the
6288: current <a href="#insertion-mode">insertion mode</a>.</p>
6289:
6290: </li><li><p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not
6291: ok".</p></li>
6292:
1.540 mike 6293: <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 6294:
6295: </ol></dd>
6296:
6297: <dt>A start tag whose tag name is "xmp"</dt>
6298: <dd>
6299:
1.233 mike 6300: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has
6301: an element in scope">has a <code>p</code> element in
6302: scope</a>, then act as if an end tag with the tag name
6303: "p" had been seen.</p>
6304:
1.1 mike 6305: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6306: any.</p>
6307:
6308: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6309:
1.91 mike 6310: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 6311:
6312: </dd>
6313:
6314: <dt>A start tag whose tag name is "iframe"</dt>
6315: <dd>
6316:
6317: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6318:
1.91 mike 6319: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 6320:
6321: </dd>
6322:
6323: <dt>A start tag whose tag name is "noembed"</dt>
6324: <dt>A start tag whose tag name is "noscript", if the <a href="#scripting-flag">scripting flag</a> is enabled</dt>
6325: <dd>
6326:
1.91 mike 6327: <p>Follow the <a href="#generic-raw-text-element-parsing-algorithm">generic raw text element parsing algorithm</a>.</p>
1.1 mike 6328:
6329: </dd>
6330:
6331: <dt>A start tag whose tag name is "select"</dt>
6332: <dd>
6333:
6334: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6335: any.</p>
6336:
6337: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6338:
6339: <p>Set the <a href="#frameset-ok-flag">frameset-ok flag</a> to "not ok".</p>
6340:
6341: <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>",
6342: "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
6343: body</a>", "<a href="#parsing-main-intr" title="insertion mode: in row">in
6344: row</a>", or "<a href="#parsing-main-intd" title="insertion mode: in cell">in
6345: cell</a>", then switch the <a href="#insertion-mode">insertion mode</a> to
6346: "<a href="#parsing-main-inselectintable" title="insertion mode: in select in table">in select in
6347: table</a>". Otherwise, switch the <a href="#insertion-mode">insertion mode</a>
6348: to "<a href="#parsing-main-inselect" title="insertion mode: in select">in select</a>".</p>
6349:
6350: </dd>
6351:
6352: <dt>A start tag whose tag name is one of: "optgroup", "option"</dt>
6353: <dd>
6354:
6355: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
6356: element in scope">has an <code>option</code> element in
6357: scope</a>, then act as if an end tag with the tag name "option"
6358: had been seen.</p>
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="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6364:
6365: </dd>
6366:
6367: <dt>A start tag whose tag name is one of: "rp", "rt"</dt>
6368: <dd>
6369:
6370: <!-- the parsing rules for ruby really don't match IE much at all,
6371: but in practice the markup used is very simple and so strict
6372: compatibility with IE isn't required. For example, as defined
6373: here we get very, very different behaviour than IE for
6374: pathological cases like:
6375:
6376: <ruby><ol><li><p>a<rt>b
6377: <ruby>a<rt>b<p>c
6378:
6379: But in practice most ruby markup falls into these cases:
6380:
6381: <ruby>a<rt>b</ruby>
6382: <ruby>a<rp>b<rt>c<rp>d</ruby>
6383: <ruby>a<rt>b</rt></ruby>
6384: <ruby>a<rp>b</rp><rt>c</rt><rp>d</rp></ruby>
6385:
6386: -->
6387:
6388: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-scope" title="has an
6389: element in scope">has a <code>ruby</code> element in scope</a>,
6390: then <a href="#generate-implied-end-tags">generate implied end tags</a>. If the <a href="#current-node">current
6391: node</a> is not then a <code><a href="text-level-semantics.html#the-ruby-element">ruby</a></code> element, this is a
6392: <a href="#parse-error">parse error</a>; pop all the nodes from the <a href="#current-node">current
6393: node</a> up to the node immediately before the bottommost
6394: <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
6395: elements</a>.</p>
6396:
6397: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6398:
6399: </dd>
6400:
6401: <dt>An end tag whose tag name is "br"</dt>
6402: <dd>
6403: <p><a href="#parse-error">Parse error</a>. Act as if a start tag token with
6404: the tag name "br" had been seen. Ignore the end tag token.</p>
6405: </dd>
6406:
6407: <dt>A start tag whose tag name is "math"</dt>
6408: <dd>
6409:
6410: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6411: any.</p>
6412:
6413: <p><a href="#adjust-mathml-attributes">Adjust MathML attributes</a> for the token. (This
6414: fixes the case of MathML attributes that are not all
6415: lowercase.)</p>
6416:
6417: <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
6418: fixes the use of namespaced attributes, in particular XLink.)</p>
6419:
6420: <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
1.724 mike 6421: <a href="infrastructure.html#mathml-namespace">MathML namespace</a>.</p>
1.1 mike 6422:
6423: <!-- If we ever change the frameset-ok flag to an insertion mode,
6424: the following change would be implied, except we'd have to do it
6425: even in the face of a self-closed tag:
6426: <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
6427: -->
6428:
6429: <p>If the token has its <i>self-closing flag</i> set, pop the
6430: <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6431: elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
6432: flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
6433:
6434: <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
6435: "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
6436: content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
6437: the current <a href="#insertion-mode">insertion mode</a>, and then switch the
6438: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
6439: foreign content">in foreign content</a>".</p>
6440:
6441: </dd>
6442:
6443: <dt>A start tag whose tag name is "svg"</dt>
6444: <dd>
6445:
6446: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6447: any.</p>
6448:
6449: <p><a href="#adjust-svg-attributes">Adjust SVG attributes</a> for the token. (This fixes
6450: the case of SVG attributes that are not all lowercase.)</p>
6451:
6452: <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
6453: fixes the use of namespaced attributes, in particular XLink in
6454: SVG.)</p>
6455:
6456: <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
1.724 mike 6457: <a href="infrastructure.html#svg-namespace">SVG namespace</a>.</p>
1.1 mike 6458:
6459: <!-- If we ever change the frameset-ok flag to an insertion mode,
6460: the following change would be implied, except we'd have to do it
6461: even in the face of a self-closed tag:
6462: <p>Set the <span>frameset-ok flag</span> to "not ok".</p>
6463: -->
6464:
6465: <p>If the token has its <i>self-closing flag</i> set, pop the
6466: <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6467: elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
6468: flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
6469:
6470: <p>Otherwise, if the <a href="#insertion-mode">insertion mode</a> is not already
6471: "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
6472: content</a>", let the <a href="#secondary-insertion-mode">secondary insertion mode</a> be
6473: the current <a href="#insertion-mode">insertion mode</a>, and then switch the
6474: <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-inforeign" title="insertion mode: in
6475: foreign content">in foreign content</a>".</p>
6476:
6477: </dd>
6478:
6479: <dt>A start <!--or end--> tag whose tag name is one of: "caption",
6480: "col", "colgroup", "frame", "head", "tbody", "td", "tfoot", "th",
6481: "thead", "tr"</dt>
6482: <!--<dt>An end tag whose tag name is one of: "area", "base",
6483: "basefont", "bgsound", "command", "embed", "hr", "iframe", "image",
6484: "img", "input", "isindex", "keygen", "link", "meta", "noembed",
1.589 mike 6485: "noframes", "param", "script", "select", "source", "style",
1.973 ! mike 6486: "table", "textarea", "title", "track", "wbr"</dt>-->
1.1 mike 6487: <!--<dt>An end tag whose tag name is "noscript", if the
6488: <span>scripting flag</span> is enabled</dt>-->
6489: <dd>
6490: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6491: <!-- end tags are commented out because since they can never end
6492: up on the stack anyway, the default end tag clause will
6493: automatically handle them. we don't want to have text in the spec
6494: that is just an optimisation, as that detracts from the spec
6495: itself -->
6496: </dd>
6497:
6498: <dt>Any other start tag</dt>
6499: <dd>
6500:
6501: <p><a href="#reconstruct-the-active-formatting-elements">Reconstruct the active formatting elements</a>, if
6502: any.</p>
6503:
6504: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6505:
6506: <p class="note">This element will be a <a href="#phrasing">phrasing</a>
6507: element.</p>
6508:
6509: </dd>
6510:
6511: <dt>Any other end tag</dt>
6512: <dd>
6513:
1.854 mike 6514: <p>Run these steps:</p>
1.1 mike 6515:
6516: <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
6517: node</a> (the bottommost node of the stack).</p></li>
6518:
6519: <li><p>If <var title="">node</var> has the same tag name as
1.856 mike 6520: the token, then:</p>
1.1 mike 6521:
6522: <ol><li><p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p></li>
6523:
6524: <li><p>If the tag name of the end tag token does not match
6525: the tag name of the <a href="#current-node">current node</a>, this is a
6526: <a href="#parse-error">parse error</a>.</p></li>
6527:
6528: <li><p>Pop all the nodes from the <a href="#current-node">current node</a> up
6529: to <var title="">node</var>, including <var title="">node</var>, then stop these steps.</p></li>
6530:
6531: </ol></li>
6532:
6533: <li><p>Otherwise, if <var title="">node</var> is in neither the
6534: <a href="#formatting">formatting</a> category nor the <a href="#phrasing">phrasing</a>
6535: category, then this is a <a href="#parse-error">parse error</a>; ignore the
6536: token, and abort these steps.</p></li>
6537:
6538: <li><p>Set <var title="">node</var> to the previous entry in the
6539: <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
6540:
6541: <li><p>Return to step 2.</p></li>
6542:
6543: </ol></dd>
6544:
1.895 mike 6545: </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 6546:
6547: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incdata" title="insertion
1.540 mike 6548: mode: text">text</a>", tokens must be handled as follows:</p>
1.1 mike 6549:
6550: <dl class="switch"><dt>A character token</dt>
6551: <dd>
6552:
6553: <p><a href="#insert-a-character" title="insert a character">Insert the token's
6554: character</a> into the <a href="#current-node">current node</a>.</p>
6555:
6556: </dd>
6557:
6558: <dt>An end-of-file token</dt>
6559: <dd>
6560:
6561: <!-- can't be the fragment case -->
6562: <p><a href="#parse-error">Parse error</a>.</p>
6563:
6564: <p>If the <a href="#current-node">current node</a> is a <code><a href="semantics.html#script">script</a></code>
1.484 mike 6565: element, mark the <code><a href="semantics.html#script">script</a></code> element as <a href="semantics.html#already-started">"already
6566: started"</a>.</p>
1.1 mike 6567:
6568: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6569: elements</a>.</p>
6570:
6571: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6572: insertion mode</a> and reprocess the current token.</p>
6573:
6574: </dd>
6575:
1.878 mike 6576: <dt id="scriptEndTag">An end tag whose tag name is "script"</dt>
1.1 mike 6577: <dd>
6578:
6579: <p>Let <var title="">script</var> be the <a href="#current-node">current node</a>
6580: (which will be a <code><a href="semantics.html#script">script</a></code> element).</p>
6581:
6582: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6583: elements</a>.</p>
6584:
6585: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6586: insertion mode</a>.</p>
6587:
6588: <p>Let the <var title="">old insertion point</var> have the
6589: same value as the current <a href="#insertion-point">insertion point</a>. Let
6590: the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
6591: input character</a>.</p>
6592:
6593: <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
6594: one.</p>
6595:
6596: <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 6597: which might cause <a href="embedded-content-0.html#dom-document-write" title="dom-document-write">new characters
1.1 mike 6598: to be inserted into the tokenizer</a>, and might cause the
6599: tokenizer to output more tokens, resulting in a <a href="#nestedParsing">reentrant invocation of the parser</a>.</p>
6600:
6601: <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
6602: one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
6603: then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
6604:
6605: <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
6606: <a href="#insertion-point">insertion point</a> to its previous value. This value
6607: might be the "undefined" value.)</p>
6608:
6609: <p id="scriptTagParserResumes">At this stage, if there is a
1.484 mike 6610: <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking script</a>, then:</p>
1.1 mike 6611:
6612: <dl class="switch"><dt>If the <a href="#script-nesting-level">script nesting level</a> is not zero:</dt>
6613:
6614: <dd>
6615:
6616: <p>Set the <a href="#parser-pause-flag">parser pause flag</a> to true, and abort the
6617: processing of any nested invocations of the tokenizer, yielding
6618: control back to the caller. (Tokenization will resume when the
6619: caller returns to the "outer" tree construction stage.)</p>
6620:
6621: <p class="note">The tree construction stage of this particular
6622: parser is <a href="#nestedParsing">being called reentrantly</a>,
1.159 mike 6623: 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 6624:
6625: </dd>
6626:
6627:
6628: <dt>Otherwise:</dt>
6629:
6630: <dd>
6631:
1.854 mike 6632: <p>Run these steps:</p>
1.1 mike 6633:
1.484 mike 6634: <ol><li><p>Let <var title="">the script</var> be the <a href="semantics.html#pending-parsing-blocking-script">pending
6635: parsing-blocking script</a>. There is no longer a <a href="semantics.html#pending-parsing-blocking-script">pending
6636: parsing-blocking script</a>.</p></li>
6637:
6638: <li><p>Block the <a href="#tokenization" title="tokenization">tokenizer</a>
6639: for this instance of the <a href="#html-parser">HTML parser</a>, such that
1.794 mike 6640: 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 6641:
1.794 mike 6642: <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 6643: scripts</a> and <var title="">the script</var>'s
6644: <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag is set.</p></li>
6645:
6646: <li><p>Unblock the <a href="#tokenization" title="tokenization">tokenizer</a>
6647: for this instance of the <a href="#html-parser">HTML parser</a>, such that
1.794 mike 6648: <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 6649: run.</p></li>
1.1 mike 6650:
6651: <li><p>Let the <a href="#insertion-point">insertion point</a> be just before the
6652: <a href="#next-input-character">next input character</a>.</p></li>
6653:
6654: <li><p>Increment the parser's <a href="#script-nesting-level">script nesting level</a>
6655: by one (it should be zero before this step, so this sets it to
6656: one).</p></li>
6657:
1.484 mike 6658: <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a>
6659: <var title="">the script</var>.</p></li>
1.1 mike 6660:
6661: <li><p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a>
6662: by one. If the parser's <a href="#script-nesting-level">script nesting level</a> is
6663: zero (which it always should be at this point), then set the
6664: <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
6665:
6666: </li><li><p>Let the <a href="#insertion-point">insertion point</a> be undefined
6667: again.</p></li>
6668:
1.484 mike 6669: <li><p>If there is once again a <a href="semantics.html#pending-parsing-blocking-script">pending parsing-blocking
1.1 mike 6670: script</a>, then repeat these steps from step 1.</p></li>
6671:
6672: </ol></dd>
6673:
6674: </dl></dd>
6675:
6676: <dt>Any other end tag</dt>
6677: <dd>
6678:
6679: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
6680: elements</a>.</p>
6681:
6682: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6683: insertion mode</a>.</p>
6684:
6685: </dd>
6686:
1.895 mike 6687: </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 6688:
6689: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion
6690: mode: in table">in table</a>", tokens must be handled as follows:</p>
6691:
6692: <dl class="switch"><dt>A character token</dt>
6693: <dd>
6694:
6695: <p>Let the <dfn id="pending-table-character-tokens"><var>pending table character tokens</var></dfn>
6696: be an empty list of tokens.</p>
6697:
6698: <p>Let the <a href="#original-insertion-mode">original insertion mode</a> be the current
6699: <a href="#insertion-mode">insertion mode</a>.</p>
6700:
6701: <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
6702: reprocess the token.</p>
6703:
6704: </dd>
6705:
6706: <dt>A comment token</dt>
6707: <dd>
1.882 mike 6708: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 6709: node</a> with the <code title="">data</code> attribute set to
6710: the data given in the comment token.</p>
6711: </dd>
6712:
6713: <dt>A DOCTYPE token</dt>
6714: <dd>
6715: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6716: </dd>
6717:
6718: <dt>A start tag whose tag name is "caption"</dt>
6719: <dd>
6720:
6721: <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
6722: below.)</p>
6723:
6724: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
6725: formatting elements</a>.</p>
6726:
6727: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
6728: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incaption" title="insertion mode: in caption">in caption</a>".</p>
6729:
6730: </dd>
6731:
6732: <dt>A start tag whose tag name is "colgroup"</dt>
6733: <dd>
6734:
6735: <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
6736: below.)</p>
6737:
6738: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
6739: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-incolgroup" title="insertion mode: in column group">in column
6740: group</a>".</p>
6741:
6742: </dd>
6743:
6744: <dt>A start tag whose tag name is "col"</dt>
6745: <dd>
6746: <p>Act as if a start tag token with the tag name "colgroup"
6747: had been seen, then reprocess the current token.</p>
6748: </dd>
6749:
6750: <dt>A start tag whose tag name is one of: "tbody", "tfoot", "thead"</dt>
6751: <dd>
6752:
6753: <p><a href="#clear-the-stack-back-to-a-table-context">Clear the stack back to a table context</a>. (See
6754: below.)</p>
6755:
6756: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then
6757: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
6758: body</a>".</p>
6759:
6760: </dd>
6761:
6762: <dt>A start tag whose tag name is one of: "td", "th", "tr"</dt>
6763: <dd>
6764: <p>Act as if a start tag token with the tag name "tbody" had
6765: been seen, then reprocess the current token.</p>
6766: </dd>
6767:
6768: <dt>A start tag whose tag name is "table"</dt>
6769: <dd>
6770:
6771: <p><a href="#parse-error">Parse error</a>. Act as if an end tag token with
6772: the tag name "table" had been seen, then, if that token wasn't
6773: ignored, reprocess the current token.</p>
6774:
6775: <p class="note">The fake end tag token here can only be
6776: ignored in the <a href="#fragment-case">fragment case</a>.</p>
6777:
6778: </dd>
6779:
6780: <dt>An end tag whose tag name is "table"</dt>
6781: <dd>
6782:
6783: <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
6784: scope</a> with the same tag name as the token, this is a
6785: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
6786: case</a>)</p>
6787:
6788: <p>Otherwise:</p>
6789:
6790: <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-table-element">table</a></code>
6791: element has been popped from the stack.</p>
6792:
6793: <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
6794:
6795: </dd>
6796:
6797: <dt>An end tag whose tag name is one of: "body", "caption",
6798: "col", "colgroup", "html", "tbody", "td", "tfoot", "th",
6799: "thead", "tr"</dt>
6800: <dd>
6801: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6802: </dd>
6803:
6804: <dt>A start tag whose tag name is one of: "style", "script"</dt>
6805: <dd>
6806:
6807: <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
6808: mode</a>.</p>
6809:
6810: </dd>
6811:
6812: <dt>A start tag whose tag name is "input"</dt>
6813: <dd>
6814:
6815: <p>If the token does not have an attribute with the name "type",
6816: or if it does, but that attribute's value is not an <a href="infrastructure.html#ascii-case-insensitive">ASCII
6817: case-insensitive</a> match for the string "<code title="">hidden</code>", then: act as described in the "anything
6818: else" entry below.</p>
6819:
6820: <p>Otherwise:</p>
6821:
6822: <p><a href="#parse-error">Parse error</a>.</p>
6823:
6824: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6825:
6826: <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
6827: open elements</a>.</p>
6828:
6829: </dd>
6830:
1.603 mike 6831: <dt>A start tag whose tag name is "form"</dt>
6832: <dd>
6833:
6834: <p><a href="#parse-error">Parse error</a>.</p>
6835:
1.717 mike 6836: <p>If the <a href="#form-element-pointer"><code title="form">form</code> element
6837: pointer</a> is not null, ignore the token.</p>
6838:
6839: <p>Otherwise:</p>
6840:
1.603 mike 6841: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
6842:
1.637 mike 6843: <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 6844: open elements</a>.</p>
6845:
6846: </dd>
6847:
1.721 mike 6848: <!-- "form" end tag falls through to in-body, which does the right thing -->
1.717 mike 6849:
1.1 mike 6850: <dt>An end-of-file token</dt>
6851: <dd>
6852:
6853: <p>If the <a href="#current-node">current node</a> is not the root
1.159 mike 6854: <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 6855: error</a>.</p>
6856:
6857: <p class="note">It can only be the <a href="#current-node">current node</a> in
6858: the <a href="#fragment-case">fragment case</a>.</p>
6859:
6860: <p><a href="#stop-parsing">Stop parsing</a>.</p>
6861:
6862: </dd>
6863:
6864: <dt>Anything else</dt>
6865: <dd>
6866:
6867: <p><a href="#parse-error">Parse error</a>. Process the token <a href="#using-the-rules-for">using the
6868: rules for</a> the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
6869: body</a>" <a href="#insertion-mode">insertion mode</a>, except that if the
6870: <a href="#current-node">current node</a> is a <code><a href="tabular-data.html#the-table-element">table</a></code>,
6871: <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
6872: <code><a href="tabular-data.html#the-tr-element">tr</a></code> element, then, whenever a node would be inserted
6873: into the <a href="#current-node">current node</a>, it must instead be <a href="#foster-parent" title="foster parent">foster parented</a>.</p>
6874:
6875: </dd>
6876:
6877: </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-context">clear the stack
6878: back to a table context</dfn>, it means that the UA must, while
6879: 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 6880: element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1 mike 6881: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
6882:
6883: <p class="note">The <a href="#current-node">current node</a> being an
1.159 mike 6884: <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 6885: case</a>.</p>
6886:
6887:
6888:
1.895 mike 6889: <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 6890:
6891: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intabletext" title="insertion
6892: mode: in table text">in table text</a>", tokens must be handled
6893: as follows:</p>
6894:
6895: <dl class="switch"><dt>A character token</dt>
6896: <dd>
6897:
6898: <p>Append the character token to the <var><a href="#pending-table-character-tokens">pending table character
6899: tokens</a></var> list.</p>
6900:
6901: </dd>
6902:
6903:
6904: <dt>Anything else</dt>
6905: <dd>
6906:
6907: <p>If any of the tokens in the <var><a href="#pending-table-character-tokens">pending table character
6908: tokens</a></var> list are character tokens that are not one of U+0009
6909: CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED
1.882 mike 6910: (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE, then
1.1 mike 6911: reprocess those character tokens using the rules given in the
6912: "anything else" entry in the <a href="#parsing-main-intable" title="insertion mode: in
6913: table">in table</a>" insertion mode.</p>
6914:
6915: <p>Otherwise, <a href="#insert-a-character" title="insert a character">insert the
6916: characters</a> given by the <var><a href="#pending-table-character-tokens">pending table character
6917: tokens</a></var> list into the <a href="#current-node">current node</a>.</p>
6918:
6919: <p>Switch the <a href="#insertion-mode">insertion mode</a> to the <a href="#original-insertion-mode">original
6920: insertion mode</a> and reprocess the token.</p>
6921:
6922: </dd>
6923:
1.895 mike 6924: </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 6925:
6926: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incaption" title="insertion
6927: mode: in caption">in caption</a>", tokens must be handled as follows:</p>
6928:
6929: <dl class="switch"><dt>An end tag whose tag name is "caption"</dt>
6930: <dd>
6931:
6932: <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
6933: scope</a> with the same tag name as the token, this is a
6934: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
6935: case</a>)</p>
6936:
6937: <p>Otherwise:</p>
6938:
6939: <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
6940:
6941: <p>Now, if the <a href="#current-node">current node</a> is not a
6942: <code><a href="tabular-data.html#the-caption-element">caption</a></code> element, then this is a <a href="#parse-error">parse
6943: error</a>.</p>
6944:
6945: <p>Pop elements from this stack until a <code><a href="tabular-data.html#the-caption-element">caption</a></code>
6946: element has been popped from the stack.</p>
6947:
6948: <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
6949: the last marker</a>.</p>
6950:
6951: <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>
6952:
6953: </dd>
6954:
6955: <dt>A start tag whose tag name is one of: "caption", "col",
6956: "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
6957: <dt>An end tag whose tag name is "table"</dt>
6958: <dd>
6959:
6960: <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
6961: name "caption" had been seen, then, if that token wasn't
6962: ignored, reprocess the current token.</p>
6963:
6964: <p class="note">The fake end tag token here can only be
6965: ignored in the <a href="#fragment-case">fragment case</a>.</p>
6966:
6967: </dd>
6968:
6969: <dt>An end tag whose tag name is one of: "body", "col",
6970: "colgroup", "html", "tbody", "td", "tfoot", "th", "thead",
6971: "tr"</dt>
6972: <dd>
6973: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
6974: </dd>
6975:
6976: <dt>Anything else</dt>
6977: <dd>
6978: <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
6979: mode</a>.</p>
6980: </dd>
6981:
1.895 mike 6982: </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 6983:
6984: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-incolgroup" title="insertion
6985: mode: in column group">in column group</a>", tokens must be handled as follows:</p>
6986:
6987: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
6988: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 6989: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 6990: <dd>
6991: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
6992: the <a href="#current-node">current node</a>.</p>
6993: </dd>
6994:
6995: <dt>A comment token</dt>
6996: <dd>
1.882 mike 6997: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 6998: node</a> with the <code title="">data</code> attribute set to
6999: the data given in the comment token.</p>
7000: </dd>
7001:
7002: <dt>A DOCTYPE token</dt>
7003: <dd>
7004: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7005: </dd>
7006:
7007: <dt>A start tag whose tag name is "html"</dt>
7008: <dd>
7009: <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
7010: mode</a>.</p>
7011: </dd>
7012:
7013: <dt>A start tag whose tag name is "col"</dt>
7014: <dd>
7015:
7016: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token. Immediately
7017: pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
7018: elements</a>.</p>
7019:
7020: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
7021: token's <i>self-closing flag</i></a>, if it is set.</p>
7022:
7023: </dd>
7024:
7025: <dt>An end tag whose tag name is "colgroup"</dt>
7026: <dd>
7027:
7028: <p>If the <a href="#current-node">current node</a> is the root
1.159 mike 7029: <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 7030: error</a>; ignore the token. (<a href="#fragment-case">fragment
7031: case</a>)</p>
7032:
7033: <p>Otherwise, pop the <a href="#current-node">current node</a> (which will be
7034: 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
7035: elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
7036: "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
7037:
7038: </dd>
7039:
7040: <dt>An end tag whose tag name is "col"</dt>
7041: <dd>
7042: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7043: </dd>
7044:
7045: <dt>An end-of-file token</dt>
7046: <dd>
7047:
1.159 mike 7048: <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 7049: element, then <a href="#stop-parsing">stop parsing</a>. (<a href="#fragment-case">fragment
7050: case</a>)</p>
7051:
7052: <p>Otherwise, act as described in the "anything else" entry
7053: below.</p>
7054:
7055: </dd>
7056:
7057: <dt>Anything else</dt>
7058: <dd>
7059:
7060: <p>Act as if an end tag with the tag name "colgroup" had been
7061: seen, and then, if that token wasn't ignored, reprocess the
7062: current token.</p>
7063:
7064: <p class="note">The fake end tag token here can only be
7065: ignored in the <a href="#fragment-case">fragment case</a>.</p>
7066:
7067: </dd>
7068:
1.895 mike 7069: </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 7070:
7071: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion
7072: mode: in table body">in table body</a>", tokens must be handled as follows:</p>
7073:
7074: <dl class="switch"><dt>A start tag whose tag name is "tr"</dt>
7075: <dd>
7076:
7077: <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
7078: context</a>. (See below.)</p>
7079:
7080: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
7081: the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intr" title="insertion mode:
7082: in row">in row</a>".</p>
7083:
7084: </dd>
7085:
7086: <dt>A start tag whose tag name is one of: "th", "td"</dt>
7087: <dd>
7088: <p><a href="#parse-error">Parse error</a>. Act as if a start tag with
7089: the tag name "tr" had been seen, then reprocess the current
7090: token.</p>
7091: </dd>
7092:
7093: <dt>An end tag whose tag name is one of: "tbody", "tfoot",
7094: "thead"</dt>
7095: <dd>
7096:
7097: <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
7098: scope</a> with the same tag name as the token, this is a
7099: <a href="#parse-error">parse error</a>. Ignore the token.</p>
7100:
7101: <p>Otherwise:</p>
7102:
7103: <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
7104: context</a>. (See below.)</p>
7105:
7106: <p>Pop the <a href="#current-node">current node</a> from the <a href="#stack-of-open-elements">stack of
7107: open elements</a>. Switch the <a href="#insertion-mode">insertion mode</a>
7108: to "<a href="#parsing-main-intable" title="insertion mode: in table">in table</a>".</p>
7109:
7110: </dd>
7111:
7112: <dt>A start tag whose tag name is one of: "caption", "col",
7113: "colgroup", "tbody", "tfoot", "thead"</dt>
7114: <dt>An end tag whose tag name is "table"</dt>
7115: <dd>
7116:
7117: <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
7118: <code>tbody</code>, <code>thead</code>, or <code>tfoot</code>
7119: element in table scope</a>, this is a <a href="#parse-error">parse
7120: error</a>. Ignore the token. (<a href="#fragment-case">fragment
7121: case</a>)</p>
7122:
7123: <p>Otherwise:</p>
7124:
7125: <p><a href="#clear-the-stack-back-to-a-table-body-context">Clear the stack back to a table body
7126: context</a>. (See below.)</p>
7127:
7128: <p>Act as if an end tag with the same tag name as the
7129: <a href="#current-node">current node</a> ("tbody", "tfoot", or "thead") had
7130: been seen, then reprocess the current token.</p>
7131:
7132: </dd>
7133:
7134: <dt>An end tag whose tag name is one of: "body", "caption",
7135: "col", "colgroup", "html", "td", "th", "tr"</dt>
7136: <dd>
7137: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7138: </dd>
7139:
7140: <dt>Anything else</dt>
7141: <dd>
7142: <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
7143: mode</a>.</p>
7144: </dd>
7145:
7146: </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-body-context">clear the stack
7147: back to a table body context</dfn>, it means that the UA must,
7148: 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 7149: <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 7150: element, pop elements from the <a href="#stack-of-open-elements">stack of open
7151: elements</a>.</p>
7152:
7153: <p class="note">The <a href="#current-node">current node</a> being an
1.159 mike 7154: <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 7155: case</a>.</p>
7156:
7157:
1.895 mike 7158: <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 7159:
7160: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
7161: mode: in row">in row</a>", tokens must be handled as follows:</p>
7162:
7163: <dl class="switch"><dt>A start tag whose tag name is one of: "th", "td"</dt>
7164: <dd>
7165:
7166: <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
7167: context</a>. (See below.)</p>
7168:
7169: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token, then switch
7170: the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-intd" title="insertion mode:
7171: in cell">in cell</a>".</p>
7172:
7173: <p>Insert a marker at the end of the <a href="#list-of-active-formatting-elements">list of active
7174: formatting elements</a>.</p>
7175:
7176: </dd>
7177:
7178: <dt>An end tag whose tag name is "tr"</dt>
7179: <dd>
7180:
7181: <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
7182: scope</a> with the same tag name as the token, this is a
7183: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
7184: case</a>)</p>
7185:
7186: <p>Otherwise:</p>
7187:
7188: <p><a href="#clear-the-stack-back-to-a-table-row-context">Clear the stack back to a table row
7189: context</a>. (See below.)</p>
7190:
7191: <p>Pop the <a href="#current-node">current node</a> (which will be a
7192: <code><a href="tabular-data.html#the-tr-element">tr</a></code> element) from the <a href="#stack-of-open-elements">stack of open
7193: elements</a>. Switch the <a href="#insertion-mode">insertion mode</a> to
7194: "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
7195: body</a>".</p>
7196:
7197: </dd>
7198:
7199: <dt>A start tag whose tag name is one of: "caption", "col",
7200: "colgroup", "tbody", "tfoot", "thead", "tr"</dt>
7201: <dt>An end tag whose tag name is "table"</dt>
7202: <dd>
7203:
7204: <p>Act as if an end tag with the tag name "tr" had been seen,
7205: then, if that token wasn't ignored, reprocess the current
7206: token.</p>
7207:
7208: <p class="note">The fake end tag token here can only be
7209: ignored in the <a href="#fragment-case">fragment case</a>.</p>
7210:
7211: </dd>
7212:
7213: <dt>An end tag whose tag name is one of: "tbody", "tfoot",
7214: "thead"</dt>
7215: <dd>
7216:
7217: <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
7218: scope</a> with the same tag name as the token, this is a
7219: <a href="#parse-error">parse error</a>. Ignore the token.</p>
7220:
7221: <p>Otherwise, act as if an end tag with the tag name "tr" had
7222: been seen, then reprocess the current token.</p>
7223:
7224: </dd>
7225:
7226: <dt>An end tag whose tag name is one of: "body", "caption",
7227: "col", "colgroup", "html", "td", "th"</dt>
7228: <dd>
7229: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7230: </dd>
7231:
7232: <dt>Anything else</dt>
7233: <dd>
7234: <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
7235: mode</a>.</p>
7236: </dd>
7237:
7238: </dl><p>When the steps above require the UA to <dfn id="clear-the-stack-back-to-a-table-row-context">clear the stack
7239: back to a table row context</dfn>, it means that the UA must,
7240: 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 7241: element or an <code><a href="semantics.html#the-html-element-0">html</a></code> element, pop elements from the
1.1 mike 7242: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
7243:
7244: <p class="note">The <a href="#current-node">current node</a> being an
1.159 mike 7245: <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 7246: case</a>.</p>
7247:
7248:
1.895 mike 7249: <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 7250:
7251: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intd" title="insertion
7252: mode: in cell">in cell</a>", tokens must be handled as follows:</p>
7253:
7254: <dl class="switch"><dt>An end tag whose tag name is one of: "td", "th"</dt>
7255: <dd>
7256:
7257: <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
7258: scope</a> with the same tag name as that of the token, then
7259: this is a <a href="#parse-error">parse error</a> and the token must be
7260: ignored.</p>
7261:
7262: <p>Otherwise:</p>
7263:
7264: <p><a href="#generate-implied-end-tags">Generate implied end tags</a>.</p>
7265:
7266: <p>Now, if the <a href="#current-node">current node</a> is not an element
7267: with the same tag name as the token, then this is a
7268: <a href="#parse-error">parse error</a>.</p>
7269:
1.856 mike 7270: <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a> stack
7271: until an element with the same tag name as the token has been
7272: popped from the stack.</p>
1.1 mike 7273:
7274: <p><a href="#clear-the-list-of-active-formatting-elements-up-to-the-last-marker">Clear the list of active formatting elements up to
7275: the last marker</a>.</p>
7276:
7277: <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
7278: <a href="#current-node">current node</a> will be a <code><a href="tabular-data.html#the-tr-element">tr</a></code> element at
7279: this point.)</p>
7280:
7281: </dd>
7282:
7283: <dt>A start tag whose tag name is one of: "caption", "col",
7284: "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"</dt>
7285: <dd>
7286:
7287: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> does
7288: <em>not</em> <a href="#has-an-element-in-table-scope" title="has an element in table scope">have
7289: a <code>td</code> or <code>th</code> element in table
7290: scope</a>, then this is a <a href="#parse-error">parse error</a>; ignore
7291: the token. (<a href="#fragment-case">fragment case</a>)</p>
7292:
7293: <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
7294: reprocess the current token.</p>
7295:
7296: </dd>
7297:
7298: <dt>An end tag whose tag name is one of: "body", "caption",
7299: "col", "colgroup", "html"</dt>
7300: <dd>
7301: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7302: </dd>
7303:
7304: <dt>An end tag whose tag name is one of: "table", "tbody",
7305: "tfoot", "thead", "tr"</dt>
7306: <dd>
7307:
7308: <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
7309: scope</a> with the same tag name as that of the token
7310: (which can only happen for "tbody", "tfoot" and "thead", or,
7311: in the <a href="#fragment-case">fragment case</a>), then this is a <a href="#parse-error">parse
7312: error</a> and the token must be ignored.</p>
7313:
7314: <p>Otherwise, <a href="#close-the-cell">close the cell</a> (see below) and
7315: reprocess the current token.</p>
7316:
7317: </dd>
7318:
7319: <dt>Anything else</dt>
7320: <dd>
7321: <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
7322: mode</a>.</p>
7323: </dd>
7324:
7325: </dl><p>Where the steps above say to <dfn id="close-the-cell">close the cell</dfn>, they
7326: mean to run the following algorithm:</p>
7327:
7328: <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>
7329: element in table scope</a>, then act as if an end tag token
7330: with the tag name "td" had been seen.</p></li>
7331:
7332: <li><p>Otherwise, the <a href="#stack-of-open-elements">stack of open elements</a> will
7333: <a href="#has-an-element-in-table-scope" title="has an element in table scope">have a
7334: <code>th</code> element in table scope</a>; act as if an end
7335: tag token with the tag name "th" had been seen.</p></li>
7336:
7337: </ol><p class="note">The <a href="#stack-of-open-elements">stack of open elements</a> cannot
7338: 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
7339: the same time, nor can it have neither when the <a href="#insertion-mode">insertion
7340: mode</a> is "<a href="#parsing-main-intd" title="insertion mode: in cell">in
7341: cell</a>".</p>
7342:
7343:
1.895 mike 7344: <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 7345:
7346: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselect" title="insertion
7347: mode: in select">in select</a>", tokens must be handled as follows:</p>
7348:
7349: <dl class="switch"><dt>A character token</dt>
7350: <dd>
7351: <p><a href="#insert-a-character" title="insert a character">Insert the token's
7352: character</a> into the <a href="#current-node">current node</a>.</p>
7353: </dd>
7354:
7355: <dt>A comment token</dt>
7356: <dd>
1.882 mike 7357: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 7358: node</a> with the <code title="">data</code> attribute set to
7359: the data given in the comment token.</p>
7360: </dd>
7361:
7362: <dt>A DOCTYPE token</dt>
7363: <dd>
7364: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7365: </dd>
7366:
7367: <dt>A start tag whose tag name is "html"</dt>
7368: <dd>
7369: <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
7370: mode</a>.</p>
7371: </dd>
7372:
7373: <dt>A start tag whose tag name is "option"</dt>
7374: <dd>
7375:
7376: <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
7377: element, act as if an end tag with the tag name "option" had
7378: been seen.</p>
7379:
7380: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
7381:
7382: </dd>
7383:
7384: <dt>A start tag whose tag name is "optgroup"</dt>
7385: <dd>
7386:
7387: <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
7388: element, act as if an end tag with the tag name "option" had
7389: been seen.</p>
7390:
7391: <p>If the <a href="#current-node">current node</a> is an
7392: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, act as if an end tag with the
7393: tag name "optgroup" had been seen.</p>
7394:
7395: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
7396:
7397: </dd>
7398:
7399: <dt>An end tag whose tag name is "optgroup"</dt>
7400: <dd>
7401:
7402: <p>First, if the <a href="#current-node">current node</a> is an
7403: <code><a href="forms.html#the-option-element">option</a></code> element, and the node immediately before
7404: it in the <a href="#stack-of-open-elements">stack of open elements</a> is an
7405: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then act as if an end tag with
7406: the tag name "option" had been seen.</p>
7407:
7408: <p>If the <a href="#current-node">current node</a> is an
7409: <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element, then pop that node from the
7410: <a href="#stack-of-open-elements">stack of open elements</a>. Otherwise, this is a
7411: <a href="#parse-error">parse error</a>; ignore the token.</p>
7412:
7413: </dd>
7414:
7415: <dt>An end tag whose tag name is "option"</dt>
7416: <dd>
7417:
7418: <p>If the <a href="#current-node">current node</a> is an <code><a href="forms.html#the-option-element">option</a></code>
7419: element, then pop that node from the <a href="#stack-of-open-elements">stack of open
7420: elements</a>. Otherwise, this is a <a href="#parse-error">parse
7421: error</a>; ignore the token.</p>
7422:
7423: </dd>
7424:
7425: <dt>An end tag whose tag name is "select"</dt>
7426: <dd>
7427:
7428: <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
7429: scope</a> with the same tag name as the token, this is a
7430: <a href="#parse-error">parse error</a>. Ignore the token. (<a href="#fragment-case">fragment
7431: case</a>)</p>
7432:
7433: <p>Otherwise:</p>
7434:
7435: <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a>
7436: until a <code><a href="forms.html#the-select-element">select</a></code> element has been popped from the
7437: stack.</p>
7438:
7439: <p><a href="#reset-the-insertion-mode-appropriately">Reset the insertion mode appropriately</a>.</p>
7440:
7441: </dd>
7442:
7443: <dt>A start tag whose tag name is "select"</dt>
7444: <dd>
7445:
7446: <p><a href="#parse-error">Parse error</a>. Act as if the token had been
7447: an end tag with the tag name "select" instead.</p>
7448:
7449: </dd>
7450:
7451: <dt>A start tag whose tag name is one of: "input", "keygen", "textarea"</dt>
7452: <dd>
1.73 mike 7453:
7454: <p><a href="#parse-error">Parse error</a>.</p>
7455:
1.124 mike 7456: <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>
7457: element in table scope</a>, ignore the token. (<a href="#fragment-case">fragment
7458: case</a>)</p>
1.73 mike 7459:
7460: <p>Otherwise, act as if an end tag with the tag name "select" had
7461: been seen, and reprocess the token.</p>
7462:
1.1 mike 7463: </dd>
7464:
7465: <dt>A start tag token whose tag name is "script"</dt>
7466: <dd>
7467: <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
7468: mode</a>.</p>
7469: </dd>
7470:
7471: <dt>An end-of-file token</dt>
7472: <dd>
7473:
7474: <p>If the <a href="#current-node">current node</a> is not the root
1.159 mike 7475: <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 7476: error</a>.</p>
7477:
7478: <p class="note">It can only be the <a href="#current-node">current node</a> in
7479: the <a href="#fragment-case">fragment case</a>.</p>
7480:
7481: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7482:
7483: </dd>
7484:
7485: <dt>Anything else</dt>
7486: <dd>
7487: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7488: </dd>
7489:
1.895 mike 7490: </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 7491:
7492: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inselectintable" title="insertion
7493: mode: in select in table">in select in table</a>", tokens must be handled as follows:</p>
7494:
7495: <dl class="switch"><dt>A start tag whose tag name is one of: "caption", "table",
7496: "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
7497: <dd>
7498: <p><a href="#parse-error">Parse error</a>. Act as if an end tag with the tag
7499: name "select" had been seen, and reprocess the token.</p>
7500: </dd>
7501:
7502: <dt>An end tag whose tag name is one of: "caption", "table",
7503: "tbody", "tfoot", "thead", "tr", "td", "th"</dt>
7504: <dd>
7505:
7506: <p><a href="#parse-error">Parse error</a>.</p>
7507:
7508: <p>If the <a href="#stack-of-open-elements">stack of open elements</a> <a href="#has-an-element-in-table-scope">has an
7509: element in table scope</a> with the same tag name as that
7510: of the token, then act as if an end tag with the tag name
7511: "select" had been seen, and reprocess the token. Otherwise,
7512: ignore the token.</p>
7513:
7514: </dd>
7515:
7516: <dt>Anything else</dt>
7517: <dd>
7518: <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
7519: mode</a>.</p>
7520: </dd>
7521:
1.895 mike 7522: </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 7523:
7524: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inforeign" title="insertion
7525: mode: in foreign content">in foreign content</a>", tokens must be
7526: handled as follows:</p>
7527:
7528: <dl class="switch"><dt>A character token</dt>
7529: <dd>
7530:
7531: <p><a href="#insert-a-character" title="insert a character">Insert the token's
7532: character</a> into the <a href="#current-node">current node</a>.</p>
7533:
7534: <p>If the token is not one of U+0009 CHARACTER TABULATION, U+000A
1.882 mike 7535: LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN
7536: (CR), or U+0020 SPACE, then set the <a href="#frameset-ok-flag">frameset-ok
1.1 mike 7537: flag</a> to "not ok".</p>
7538:
7539: </dd>
7540:
7541: <dt>A comment token</dt>
7542: <dd>
1.882 mike 7543: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 7544: node</a> with the <code title="">data</code> attribute set to
7545: the data given in the comment token.</p>
7546: </dd>
7547:
7548: <dt>A DOCTYPE token</dt>
7549: <dd>
7550: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7551: </dd>
7552:
1.878 mike 7553: <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 7554: <dd>
7555:
7556: <p>Pop the <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
7557: elements</a>.</p>
7558:
7559: <p>Let the <var title="">old insertion point</var> have the
7560: same value as the current <a href="#insertion-point">insertion point</a>. Let
7561: the <a href="#insertion-point">insertion point</a> be just before the <a href="#next-input-character">next
7562: input character</a>.</p>
7563:
7564: <p>Increment the parser's <a href="#script-nesting-level">script nesting level</a> by
7565: one. Set the <a href="#parser-pause-flag">parser pause flag</a> to true.</p>
7566:
7567: <p><a href="http://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing">Process
7568: the <code title="">script</code> element</a> according to the SVG
1.187 mike 7569: rules, if the user agent supports SVG. <a href="references.html#refsSVG">[SVG]</a></p>
1.1 mike 7570:
1.159 mike 7571: <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 7572: tokenizer</a>, the parser will not be executed reentrantly,
7573: since the <a href="#parser-pause-flag">parser pause flag</a> is true.</p>
7574:
7575: <p>Decrement the parser's <a href="#script-nesting-level">script nesting level</a> by
7576: one. If the parser's <a href="#script-nesting-level">script nesting level</a> is zero,
7577: then set the <a href="#parser-pause-flag">parser pause flag</a> to false.</p>
7578:
7579: <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
7580: <a href="#insertion-point">insertion point</a> to its previous value. This value
7581: might be the "undefined" value.)</p>
7582:
7583: </dd>
7584:
1.855 mike 7585: <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>
7586:
7587: <dd>
7588:
7589: <p>Run these steps:</p>
7590:
7591: <ol><li><p>Initialize <var title="">node</var> to be the <a href="#current-node">current
7592: node</a> (the bottommost node of the stack).</p></li>
7593:
7594: <li><p>If <var title="">node</var> is not an element with the
7595: same tag name as the token, then this is a <a href="#parse-error">parse
7596: error</a>.</p></li>
7597:
7598: <li><p><i>Loop</i>: If <var title="">node</var> has the same tag
7599: name as the token, pop elements from the <a href="#stack-of-open-elements">stack of
7600: open elements</a> until <var title="">node</var> has been
7601: popped from the stack, and then abort these steps.</p></li>
7602:
7603: <li><p>Set <var title="">node</var> to the previous entry in the
7604: <a href="#stack-of-open-elements">stack of open elements</a>.</p></li>
7605:
7606: <li>
7607:
7608: <p>If <var title="">node</var> is an element in the <a href="infrastructure.html#html-namespace-0">HTML
7609: namespace</a>, process the token <a href="#using-the-rules-for">using the rules
7610: for</a> the <a href="#secondary-insertion-mode">secondary insertion mode</a>. If, after
7611: 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
7612: content</a>", but there is no element <a href="#has-an-element-in-scope" title="has an
7613: element in scope">in scope</a> that has a namespace other
7614: than the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, switch the <a href="#insertion-mode">insertion
7615: mode</a> to the <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
7616:
7617: </li>
7618:
7619: <li><p>Return to the step labeled <i>loop</i>.</p></li>
7620:
7621: </ol></dd>
7622:
1.724 mike 7623: <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>
7624: <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>
7625: <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>
7626: <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>
7627: <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>
7628: <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>
7629: <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>
7630: <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>
7631: <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>
7632: <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 7633: <dt>Any other end tag</dt>
1.1 mike 7634: <dd>
7635:
7636: <p>Process the token <a href="#using-the-rules-for">using the rules for</a> the
7637: <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
7638:
7639: <p>If, after doing so, the <a href="#insertion-mode">insertion mode</a> is still
7640: "<a href="#parsing-main-inforeign" title="insertion mode: in foreign content">in foreign
1.336 mike 7641: content</a>", but there is no element <a href="#has-an-element-in-scope" title="has an
7642: element in scope">in scope</a> that has a namespace other than
1.724 mike 7643: the <a href="infrastructure.html#html-namespace-0">HTML namespace</a>, switch the <a href="#insertion-mode">insertion
1.1 mike 7644: mode</a> to the <a href="#secondary-insertion-mode">secondary insertion mode</a>.</p>
7645:
7646: </dd>
7647:
7648: <dt>A start tag whose tag name is one of: <!--"a",--> "b", "big",
7649: "blockquote", "body"<!--by inspection-->, "br", "center", "code",
1.422 mike 7650: "dd", "div", "dl", "dt"<!-- so that dd and dt can be handled
7651: uniformly throughout the parser -->, "em", "embed", "h1", "h2",
7652: "h3", "h4"<!--for completeness-->, "h5", "h6"<!--for
1.1 mike 7653: completeness-->, "head"<!--by inspection-->, "hr", "i", "img",
7654: "li", "listing"<!-- so that pre and listing can be handled
7655: uniformly throughout the parser -->, "menu", "meta", "nobr",
7656: "ol"<!-- so that dl, ul, and ol can be handled uniformly throughout
7657: the parser -->, "p", "pre", "ruby", "s", <!--"script",--> "small",
7658: "span", "strong", "strike"<!-- so that s and strike can be handled
7659: uniformly throughout the parser -->, <!--"style",--> "sub", "sup",
1.305 mike 7660: "table"<!--by inspection-->, "tt", "u", "ul", "var"</dt> <!-- this
7661: list was determined empirically by studying over 6,000,000,000
1.422 mike 7662: pages that were specifically not XML pages -->
7663: <dt>A start tag whose tag name is "font", if the token has any
7664: attributes named "color", "face", or "size"</dt> <!-- the
7665: attributes here are required so that SVG <font> will go through as
7666: SVG but legacy <font>s won't -->
7667: <dt>An end-of-file token</dt> <dd>
1.1 mike 7668:
7669: <p><a href="#parse-error">Parse error</a>.</p>
7670:
7671: <p>Pop elements from the <a href="#stack-of-open-elements">stack of open elements</a> until
1.857 mike 7672: 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
7673: has been popped from the stack, and reprocess the token.</p>
1.1 mike 7674:
7675: </dd>
7676:
7677: <dt>Any other start tag</dt>
7678: <dd>
7679:
7680: <p>If the <a href="#current-node">current node</a> is an element in the
1.724 mike 7681: <a href="infrastructure.html#mathml-namespace">MathML namespace</a>, <a href="#adjust-mathml-attributes">adjust MathML
1.1 mike 7682: attributes</a> for the token. (This fixes the case of MathML
7683: attributes that are not all lowercase.)</p>
7684:
1.724 mike 7685: <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 7686: namespace</a>, and the token's tag name is one of the ones in
7687: the first column of the following table, change the tag name to
7688: the name given in the corresponding cell in the second
7689: column. (This fixes the case of SVG elements that are not all
7690: lowercase.)</p>
7691:
7692: <table><thead><tr><th> Tag name </th><th> Element name
7693: </th></tr></thead><tbody><tr><td> <code title="">altglyph</code> </td><td> <code title="">altGlyph</code>
7694: </td></tr><tr><td> <code title="">altglyphdef</code> </td><td> <code title="">altGlyphDef</code>
7695: </td></tr><tr><td> <code title="">altglyphitem</code> </td><td> <code title="">altGlyphItem</code>
7696: </td></tr><tr><td> <code title="">animatecolor</code> </td><td> <code title="">animateColor</code>
7697: </td></tr><tr><td> <code title="">animatemotion</code> </td><td> <code title="">animateMotion</code>
7698: </td></tr><tr><td> <code title="">animatetransform</code> </td><td> <code title="">animateTransform</code>
7699: </td></tr><tr><td> <code title="">clippath</code> </td><td> <code title="">clipPath</code>
7700: </td></tr><tr><td> <code title="">feblend</code> </td><td> <code title="">feBlend</code>
7701: </td></tr><tr><td> <code title="">fecolormatrix</code> </td><td> <code title="">feColorMatrix</code>
7702: </td></tr><tr><td> <code title="">fecomponenttransfer</code> </td><td> <code title="">feComponentTransfer</code>
7703: </td></tr><tr><td> <code title="">fecomposite</code> </td><td> <code title="">feComposite</code>
7704: </td></tr><tr><td> <code title="">feconvolvematrix</code> </td><td> <code title="">feConvolveMatrix</code>
7705: </td></tr><tr><td> <code title="">fediffuselighting</code> </td><td> <code title="">feDiffuseLighting</code>
7706: </td></tr><tr><td> <code title="">fedisplacementmap</code> </td><td> <code title="">feDisplacementMap</code>
7707: </td></tr><tr><td> <code title="">fedistantlight</code> </td><td> <code title="">feDistantLight</code>
7708: </td></tr><tr><td> <code title="">feflood</code> </td><td> <code title="">feFlood</code>
7709: </td></tr><tr><td> <code title="">fefunca</code> </td><td> <code title="">feFuncA</code>
7710: </td></tr><tr><td> <code title="">fefuncb</code> </td><td> <code title="">feFuncB</code>
7711: </td></tr><tr><td> <code title="">fefuncg</code> </td><td> <code title="">feFuncG</code>
7712: </td></tr><tr><td> <code title="">fefuncr</code> </td><td> <code title="">feFuncR</code>
7713: </td></tr><tr><td> <code title="">fegaussianblur</code> </td><td> <code title="">feGaussianBlur</code>
7714: </td></tr><tr><td> <code title="">feimage</code> </td><td> <code title="">feImage</code>
7715: </td></tr><tr><td> <code title="">femerge</code> </td><td> <code title="">feMerge</code>
7716: </td></tr><tr><td> <code title="">femergenode</code> </td><td> <code title="">feMergeNode</code>
7717: </td></tr><tr><td> <code title="">femorphology</code> </td><td> <code title="">feMorphology</code>
7718: </td></tr><tr><td> <code title="">feoffset</code> </td><td> <code title="">feOffset</code>
7719: </td></tr><tr><td> <code title="">fepointlight</code> </td><td> <code title="">fePointLight</code>
7720: </td></tr><tr><td> <code title="">fespecularlighting</code> </td><td> <code title="">feSpecularLighting</code>
7721: </td></tr><tr><td> <code title="">fespotlight</code> </td><td> <code title="">feSpotLight</code>
7722: </td></tr><tr><td> <code title="">fetile</code> </td><td> <code title="">feTile</code>
7723: </td></tr><tr><td> <code title="">feturbulence</code> </td><td> <code title="">feTurbulence</code>
7724: </td></tr><tr><td> <code title="">foreignobject</code> </td><td> <code title="">foreignObject</code>
7725: </td></tr><tr><td> <code title="">glyphref</code> </td><td> <code title="">glyphRef</code>
7726: </td></tr><tr><td> <code title="">lineargradient</code> </td><td> <code title="">linearGradient</code>
7727: </td></tr><tr><td> <code title="">radialgradient</code> </td><td> <code title="">radialGradient</code>
7728: <!--<tr> <td> <code title="">solidcolor</code> <td> <code title="">solidColor</code> (SVG 1.2)-->
7729: </td></tr><tr><td> <code title="">textpath</code> </td><td> <code title="">textPath</code>
1.724 mike 7730: </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 7731: namespace</a>, <a href="#adjust-svg-attributes">adjust SVG attributes</a> for the
7732: token. (This fixes the case of SVG attributes that are not all
7733: lowercase.)</p>
7734:
7735: <p><a href="#adjust-foreign-attributes">Adjust foreign attributes</a> for the token. (This
7736: fixes the use of namespaced attributes, in particular XLink in
7737: SVG.)</p>
7738:
7739: <p><a href="#insert-a-foreign-element">Insert a foreign element</a> for the token, in the
7740: same namespace as the <a href="#current-node">current node</a>.</p>
7741:
7742: <p>If the token has its <i>self-closing flag</i> set, pop the
7743: <a href="#current-node">current node</a> off the <a href="#stack-of-open-elements">stack of open
7744: elements</a> and <a href="#acknowledge-self-closing-flag" title="acknowledge self-closing
7745: flag">acknowledge the token's <i>self-closing flag</i></a>.</p>
7746:
7747: </dd>
7748:
1.895 mike 7749: </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 7750:
7751: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterbody" title="insertion
7752: mode: after body">after body</a>", tokens must be handled as follows:</p>
7753:
7754: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
7755: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 7756: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 7757: <dd>
7758: <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
7759: mode</a>.</p>
7760: </dd>
7761:
7762: <dt>A comment token</dt>
7763: <dd>
1.882 mike 7764: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the first element in
1.159 mike 7765: 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 7766: element), with the <code title="">data</code> attribute set to
7767: the data given in the comment token.</p>
7768: </dd>
7769:
7770: <dt>A DOCTYPE token</dt>
7771: <dd>
7772: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7773: </dd>
7774:
7775: <dt>A start tag whose tag name is "html"</dt>
7776: <dd>
7777: <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
7778: mode</a>.</p>
7779: </dd>
7780:
7781: <dt>An end tag whose tag name is "html"</dt>
7782: <dd>
7783:
7784: <p>If the parser was originally created as part of the <a href="#html-fragment-parsing-algorithm">HTML
7785: fragment parsing algorithm</a>, this is a <a href="#parse-error">parse
7786: error</a>; ignore the token. (<a href="#fragment-case">fragment case</a>)</p>
7787:
7788: <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
7789: body</a>".</p>
7790:
7791: </dd>
7792:
7793: <dt>An end-of-file token</dt>
7794: <dd>
7795: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7796: </dd>
7797:
7798: <dt>Anything else</dt>
7799: <dd>
7800:
7801: <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion
7802: mode</a> to "<a href="#parsing-main-inbody" title="insertion mode: in body">in
7803: body</a>" and reprocess the token.</p>
7804:
7805: </dd>
7806:
1.895 mike 7807: </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 7808:
7809: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-inframeset" title="insertion
7810: mode: in frameset">in frameset</a>", tokens must be handled as follows:</p>
7811:
7812: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
7813: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 7814: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 7815: <dd>
7816: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
7817: the <a href="#current-node">current node</a>.</p>
7818: </dd>
7819:
7820: <dt>A comment token</dt>
7821: <dd>
1.882 mike 7822: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 7823: node</a> with the <code title="">data</code> attribute set to
7824: the data given in the comment token.</p>
7825: </dd>
7826:
7827: <dt>A DOCTYPE token</dt>
7828: <dd>
7829: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7830: </dd>
7831:
7832: <dt>A start tag whose tag name is "html"</dt>
7833: <dd>
7834: <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
7835: mode</a>.</p>
7836: </dd>
7837:
7838: <dt>A start tag whose tag name is "frameset"</dt>
7839: <dd>
7840: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.</p>
7841: </dd>
7842:
7843: <dt>An end tag whose tag name is "frameset"</dt>
7844: <dd>
7845:
7846: <p>If the <a href="#current-node">current node</a> is the root
1.159 mike 7847: <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 7848: error</a>; ignore the token. (<a href="#fragment-case">fragment
7849: case</a>)</p>
7850:
7851: <p>Otherwise, pop the <a href="#current-node">current node</a> from the
7852: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
7853:
7854: <p>If the parser was <em>not</em> originally created as part
7855: of the <a href="#html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>
7856: (<a href="#fragment-case">fragment case</a>), and the <a href="#current-node">current
1.5 mike 7857: node</a> is no longer a <code><a href="obsolete.html#frameset">frameset</a></code> element, then
1.1 mike 7858: switch the <a href="#insertion-mode">insertion mode</a> to "<a href="#parsing-main-afterframeset" title="insertion mode: after frameset">after
7859: frameset</a>".</p>
7860:
7861: </dd>
7862:
7863: <dt>A start tag whose tag name is "frame"</dt>
7864: <dd>
7865:
7866: <p><a href="#insert-an-html-element">Insert an HTML element</a> for the token.
7867: Immediately pop the <a href="#current-node">current node</a> off the
7868: <a href="#stack-of-open-elements">stack of open elements</a>.</p>
7869:
7870: <p><a href="#acknowledge-self-closing-flag" title="acknowledge self-closing flag">Acknowledge the
7871: token's <i>self-closing flag</i></a>, if it is set.</p>
7872:
7873: </dd>
7874:
7875: <dt>A start tag whose tag name is "noframes"</dt>
7876: <dd>
7877: <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
7878: mode</a>.</p>
7879: </dd>
7880:
7881: <dt>An end-of-file token</dt>
7882: <dd>
7883:
7884: <p>If the <a href="#current-node">current node</a> is not the root
1.159 mike 7885: <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 7886: error</a>.</p>
7887:
7888: <p class="note">It can only be the <a href="#current-node">current node</a> in
7889: the <a href="#fragment-case">fragment case</a>.</p>
7890:
7891: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7892:
7893: </dd>
7894:
7895: <dt>Anything else</dt>
7896: <dd>
7897: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7898: </dd>
7899:
1.895 mike 7900: </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 7901:
7902: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-afterframeset" title="insertion
7903: mode: after frameset">after frameset</a>", tokens must be handled as follows:</p>
7904:
7905: <!-- due to rules in the "in frameset" mode, this can't be entered in the fragment case -->
7906: <dl class="switch"><dt>A character token that is one of U+0009 CHARACTER
7907: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 7908: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 7909: <dd>
7910: <p><a href="#insert-a-character" title="insert a character">Insert the character</a> into
7911: the <a href="#current-node">current node</a>.</p>
7912: </dd>
7913:
7914: <dt>A comment token</dt>
7915: <dd>
1.882 mike 7916: <p>Append a <code><a href="infrastructure.html#comment-0">Comment</a></code> node to the <a href="#current-node">current
1.1 mike 7917: node</a> with the <code title="">data</code> attribute set to
7918: the data given in the comment token.</p>
7919: </dd>
7920:
7921: <dt>A DOCTYPE token</dt>
7922: <dd>
7923: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7924: </dd>
7925:
7926: <dt>A start tag whose tag name is "html"</dt>
7927: <dd>
7928: <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
7929: mode</a>.</p>
7930: </dd>
7931:
7932: <dt>An end tag whose tag name is "html"</dt>
7933: <dd>
7934: <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
7935: frameset</a>".</p>
7936: </dd>
7937:
7938: <dt>A start tag whose tag name is "noframes"</dt>
7939: <dd>
7940: <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
7941: mode</a>.</p>
7942: </dd>
7943:
7944: <dt>An end-of-file token</dt>
7945: <dd>
7946: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7947: </dd>
7948:
7949: <dt>Anything else</dt>
7950: <dd>
7951: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
7952: </dd>
7953:
1.895 mike 7954: </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 7955:
7956: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-body-insertion-mode" title="insertion
7957: mode: after after body">after after body</a>", tokens must be handled as follows:</p>
7958:
7959: <dl class="switch"><dt>A comment token</dt>
7960: <dd>
1.882 mike 7961: <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 7962: object with the <code title="">data</code> attribute set to the
7963: data given in the comment token.</p>
7964: </dd>
7965:
7966: <dt>A DOCTYPE token</dt>
7967: <dt>A character token that is one of U+0009 CHARACTER
7968: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 7969: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 7970: <dt>A start tag whose tag name is "html"</dt>
7971: <dd>
7972: <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
7973: mode</a>.</p>
7974: </dd>
7975:
7976: <dt>An end-of-file token</dt>
7977: <dd>
7978: <p><a href="#stop-parsing">Stop parsing</a>.</p>
7979: </dd>
7980:
7981: <dt>Anything else</dt>
7982: <dd>
7983: <p><a href="#parse-error">Parse error</a>. Switch the <a href="#insertion-mode">insertion mode</a>
7984: to "<a href="#parsing-main-inbody" title="insertion mode: in body">in body</a>" and
7985: reprocess the token.</p>
7986: </dd>
7987:
1.895 mike 7988: </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 7989:
7990: <p>When the <a href="#insertion-mode">insertion mode</a> is "<a href="#the-after-after-frameset-insertion-mode" title="insertion
7991: mode: after after frameset">after after frameset</a>", tokens must be handled as follows:</p>
7992:
7993: <dl class="switch"><dt>A comment token</dt>
7994: <dd>
1.882 mike 7995: <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 7996: object with the <code title="">data</code> attribute set to the
7997: data given in the comment token.</p>
7998: </dd>
7999:
8000: <dt>A DOCTYPE token</dt>
8001: <dt>A character token that is one of U+0009 CHARACTER
8002: TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
1.882 mike 8003: U+000D CARRIAGE RETURN (CR), or U+0020 SPACE</dt>
1.1 mike 8004: <dt>A start tag whose tag name is "html"</dt>
8005: <dd>
8006: <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
8007: mode</a>.</p>
8008: </dd>
8009:
8010: <dt>An end-of-file token</dt>
8011: <dd>
8012: <p><a href="#stop-parsing">Stop parsing</a>.</p>
8013: </dd>
8014:
8015: <dt>A start tag whose tag name is "noframes"</dt>
8016: <dd>
8017: <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
8018: mode</a>.</p>
8019: </dd>
8020:
8021: <dt>Anything else</dt>
8022: <dd>
8023: <p><a href="#parse-error">Parse error</a>. Ignore the token.</p>
8024: </dd>
8025:
1.266 mike 8026: </dl></div><div class="impl">
8027:
1.895 mike 8028: <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 8029:
8030: <p>Once the user agent <dfn id="stop-parsing" title="stop parsing">stops parsing</dfn>
1.484 mike 8031: the document, the user agent must run the following steps:</p>
1.1 mike 8032:
1.484 mike 8033: <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
8034: "interactive" <!-- this also synchronously fires an event --> and
8035: the <a href="#insertion-point">insertion point</a> to undefined.</p></li>
8036:
1.838 mike 8037: <li><p>Pop <em>all</em> the nodes off the <a href="#stack-of-open-elements">stack of open
8038: elements</a>.</p></li>
8039:
1.484 mike 8040: <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
8041: document has finished parsing</a> is not empty, run these
8042: substeps:</p>
8043:
1.794 mike 8044: <ol><li><p><a href="webappapis.html#spin-the-event-loop">Spin the event loop</a> until the first
1.484 mike 8045: <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
8046: execute when the document has finished parsing</a> has its
8047: <a href="semantics.html#ready-to-be-parser-executed">"ready to be parser-executed"</a> flag set <em>and</em> there
8048: is no <a href="semantics.html#a-style-sheet-blocking-scripts" title="a style sheet blocking scripts">style sheet
8049: blocking scripts</a>.</p></li>
8050:
8051: <li><p><a href="semantics.html#executing-a-script-block" title="executing a script block">Execute</a> the
8052: 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
8053: execute when the document has finished parsing</a>.</p></li>
8054:
8055: <li><p>Remove the first <code><a href="semantics.html#script">script</a></code> element from the
8056: <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
8057: finished parsing</a> (i.e. shift out the first entry in the
8058: list).</p></li>
1.920 mike 8059:
1.484 mike 8060: <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
8061: document has finished parsing</a> is still not empty, repeat
8062: these substeps again from substep 1.</p>
8063:
8064: </li></ol></li>
8065:
1.794 mike 8066: <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 8067: event</a> named <code title="event-DOMContentLoaded">DOMContentLoaded</code> at the
1.810 mike 8068: <code><a href="infrastructure.html#document">Document</a></code>.</p></li>
1.484 mike 8069:
1.879 mike 8070: <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 8071: scripts that will execute as soon as possible</a> is
8072: empty.</p></li> <!-- this step is redundant with the next one,
8073: really, since all those scripts also delay the load event. It's
8074: here in case we add an event between this step and the next or if
8075: we move the previous step (DOMContentLoaded) down again. -->
8076:
1.794 mike 8077: <li><p><a href="webappapis.html#spin-the-event-loop">Spin the event loop</a> until there is nothing that
1.484 mike 8078: <dfn id="delay-the-load-event" title="delay the load event">delays the load event</dfn> in
1.810 mike 8079: the <code><a href="infrastructure.html#document">Document</a></code>.</p></li>
1.484 mike 8080:
1.794 mike 8081: <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 8082: readiness</a> to "complete". <!-- this also fires an event
8083: synchronously during the task --></p></li>
1.1 mike 8084:
1.810 mike 8085: <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 8086: 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 8087: simple event</a> named <code title="event-load">load</code> at
1.810 mike 8088: 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 8089: its <code title="dom-event-target"><a href="infrastructure.html#dom-event-target">target</a></code> set to the
1.810 mike 8090: <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 8091: <code><a href="browsers.html#window">Window</a></code> object).</p></li>
1.1 mike 8092:
1.810 mike 8093: <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 8094: 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
8095: <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 8096: its <code title="dom-event-target"><a href="infrastructure.html#dom-event-target">target</a></code> set to the
1.852 mike 8097: <code><a href="infrastructure.html#document">Document</a></code> object (and the <code title="dom-event-currentTarget">currentTarget</code> set to the
8098: <code><a href="browsers.html#window">Window</a></code> object), using the
8099: <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>
8100: attribute set to false. This event must not bubble, must not be
8101: cancelable, and has no default action.</p></li>
1.569 mike 8102:
1.810 mike 8103: <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 8104: 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 8105: <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 8106: <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
8107: current value of the <a href="history.html#pending-state-object">pending state object</a>. This event
1.484 mike 8108: must bubble but not be cancelable and has no default
8109: action.</p></li>
1.1 mike 8110:
1.810 mike 8111: <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 8112: 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 8113: the list of <a href="offline.html#pending-application-cache-download-process-tasks">pending application cache download process
8114: tasks</a>, and then empty the list of <a href="offline.html#pending-application-cache-download-process-tasks">pending application
1.794 mike 8115: cache download process tasks</a>. The <a href="webappapis.html#task-source">task source</a>
8116: for these <a href="webappapis.html#concept-task" title="concept-task">tasks</a> is the
8117: <a href="webappapis.html#networking-task-source">networking task source</a>.</p></li>
1.725 mike 8118:
1.810 mike 8119: <li><p>The <code><a href="infrastructure.html#document">Document</a></code> is now <dfn id="completely-loaded">completely
1.725 mike 8120: loaded</dfn>.</p></li>
8121:
1.838 mike 8122: </ol><p>When the user agent is to <dfn id="abort-an-html-parser">abort an HTML parser</dfn>, it
8123: must run the following steps:</p>
8124:
8125: <ol><li><p>Throw away any pending content in the <a href="#the-input-stream">input
8126: stream</a>, and discard any future content that would have been
8127: added to it.</p></li>
8128:
8129: <li><p>Pop <em>all</em> the nodes off the <a href="#stack-of-open-elements">stack of open
8130: elements</a>.</p></li>
8131:
8132: <!-- anything else? this is things that happen when you call
8133: document.open() on a document that's still being parsed. Should the
8134: pending scripts be blown away or anything? -->
8135:
1.794 mike 8136: </ol><p>Except where otherwise specified, the <a href="webappapis.html#task-source">task source</a>
8137: for the <a href="webappapis.html#concept-task" title="concept-task">tasks</a> mentioned in this
8138: section is the <a href="webappapis.html#dom-manipulation-task-source">DOM manipulation task source</a>.</p>
1.1 mike 8139:
1.266 mike 8140: </div><div class="impl">
1.1 mike 8141:
1.895 mike 8142: <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 8143:
8144: <p>When an application uses an <a href="#html-parser">HTML parser</a> in
8145: conjunction with an XML pipeline, it is possible that the
8146: constructed DOM is not compatible with the XML tool chain in certain
8147: subtle ways. For example, an XML toolchain might not be able to
8148: represent attributes with the name <code title="">xmlns</code>,
8149: since they conflict with the Namespaces in XML syntax. There is also
8150: some data that the <a href="#html-parser">HTML parser</a> generates that isn't
8151: included in the DOM itself. This section specifies some rules for
8152: handling these issues.</p>
8153:
8154: <p>If the XML API being used doesn't support DOCTYPEs, the tool may
8155: drop DOCTYPEs altogether.</p>
8156:
8157: <p>If the XML API doesn't support attributes in no namespace that
8158: are named "<code title="">xmlns</code>", attributes whose names
8159: start with "<code title="">xmlns:</code>", or attributes in the
1.724 mike 8160: <a href="infrastructure.html#xmlns-namespace">XMLNS namespace</a>, then the tool may drop such
1.1 mike 8161: attributes.</p>
8162:
8163: <p>The tool may annotate the output with any namespace declarations
8164: required for proper operation.</p>
8165:
8166: <p>If the XML API being used restricts the allowable characters in
8167: the local names of elements and attributes, then the tool may map
8168: all element and attribute local names that the API wouldn't support
8169: to a set of names that <em>are</em> allowed, by replacing any
8170: character that isn't supported with the uppercase letter U and the
8171: six digits of the character's Unicode code point when expressed in
8172: hexadecimal, using digits 0-9 and capital letters A-F as the
8173: symbols, in increasing numeric order.</p>
8174:
8175: <p class="example">For example, the element name <code title="">foo<bar</code>, which can be output by the <a href="#html-parser">HTML
8176: parser</a>, though it is neither a legal HTML element name nor a
8177: well-formed XML element name, would be converted into <code title="">fooU00003Cbar</code>, which <em>is</em> a well-formed XML
8178: element name (though it's still not legal in HTML by any means).</p>
8179:
8180: <p class="example">As another example, consider the attribute
8181: <code>xlink:href</code>. Used on a MathML element, it becomes, after
8182: being <a href="#adjust-foreign-attributes" title="adjust foreign attributes">adjusted</a>, an
8183: attribute with a prefix "<code title="">xlink</code>" and a local
8184: name "<code title="">href</code>". However, used on an HTML element,
8185: it becomes an attribute with no prefix and the local name "<code title="">xlink:href</code>", which is not a valid NCName, and thus
8186: might not be accepted by an XML API. It could thus get converted,
8187: becoming "<code title="">xlinkU00003Ahref</code>".</p>
8188:
8189: <p class="note">The resulting names from this conversion
8190: conveniently can't clash with any attribute generated by the
8191: <a href="#html-parser">HTML parser</a>, since those are all either lowercase or
8192: those listed in the <a href="#adjust-foreign-attributes">adjust foreign attributes</a>
8193: algorithm's table.</p>
8194:
8195: <p>If the XML API restricts comments from having two consecutive
8196: U+002D HYPHEN-MINUS characters (--), the tool may insert a single
8197: U+0020 SPACE character between any such offending characters.</p>
8198:
8199: <p>If the XML API restricts comments from ending in a
8200: U+002D HYPHEN-MINUS character (-), the tool may insert a single
8201: U+0020 SPACE character at the end of such comments.</p>
8202:
8203: <p>If the XML API restricts allowed characters in character data,
1.439 mike 8204: attribute values, or comments, the tool may replace any U+000C FORM
8205: FEED (FF) character with a U+0020 SPACE character, and any other
8206: literal non-XML character with a U+FFFD REPLACEMENT CHARACTER.</p>
1.1 mike 8207:
8208: <p>If the tool has no way to convey out-of-band information, then
8209: the tool may drop the following information:</p>
8210:
1.880 mike 8211: <ul><li>Whether the document is set to <i><a href="dom.html#no-quirks-mode">no-quirks mode</a></i>,
8212: <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 8213:
8214: <li>The association between form controls and forms that aren't
8215: their nearest <code><a href="forms.html#the-form-element">form</a></code> element ancestor (use of the
8216: <a href="#form-element-pointer"><code>form</code> element pointer</a> in the parser)</li>
8217:
8218: </ul><p class="note">The mutations allowed by this section apply
8219: <em>after</em> the <a href="#html-parser">HTML parser</a>'s rules have been
8220: applied. For example, a <code title=""><a::></code> start tag
8221: will be closed by a <code title=""></a::></code> end tag, and
8222: never by a <code title=""></aU00003AU00003A></code> end tag, even
8223: if the user agent is using the rules above to then generate an
8224: actual element in the DOM with the name <code title="">aU00003AU00003A</code> for that start tag.</p>
8225:
1.266 mike 8226: </div><div class="impl">
1.1 mike 8227:
1.895 mike 8228: <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 8229:
8230: <p><i>This section is non-normative.</i></p>
8231:
8232: <p>This section examines some erroneous markup and discusses how
8233: the <a href="#html-parser">HTML parser</a> handles these cases.</p>
8234:
8235:
1.755 mike 8236: <h5 id="misnested-tags:-b-i-b-i"><span class="secno">8.2.8.1 </span>Misnested tags: <b><i></b></i></h5>
1.1 mike 8237:
8238: <p><i>This section is non-normative.</i></p>
8239:
8240: <p>The most-often discussed example of erroneous markup is as
8241: follows:</p>
8242:
8243: <pre><p>1<b>2<i>3</b>4</i>5</p></pre>
8244:
8245: <p>The parsing of this markup is straightforward up to the "3". At
8246: this point, the DOM looks like this:</p>
8247:
1.159 mike 8248: <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
8249: 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 8250: <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
8251: formatting elements</a> just has two: <code><a href="text-level-semantics.html#the-b-element">b</a></code> and
8252: <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>
8253:
8254: <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is
8255: invoked. This is a simple case, in that the <var title="">formatting
8256: element</var> is the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element, and there is no
8257: <var title="">furthest block</var>. Thus, the <a href="#stack-of-open-elements">stack of open
1.159 mike 8258: elements</a> ends up with just three elements: <code><a href="semantics.html#the-html-element-0">html</a></code>,
8259: <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 8260: active formatting elements</a> has just one: <code><a href="text-level-semantics.html#the-i-element">i</a></code>. The
8261: DOM tree is unmodified at this point.</p>
8262:
8263: <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
8264: the active formatting elements</a>, in this case just the
8265: <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
8266: for the "4" text node. After the end tag token for the "i" is also
8267: received, and the "5" text node is inserted, the DOM looks as
8268: follows:</p>
8269:
1.755 mike 8270: <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: <b><p></b></p></h5>
1.1 mike 8271:
8272: <p><i>This section is non-normative.</i></p>
8273:
8274: <p>A case similar to the previous one is the following:</p>
8275:
8276: <pre><b>1<p>2</b>3</p></pre>
8277:
8278: <p>Up to the "2" the parsing here is straightforward:</p>
8279:
1.159 mike 8280: <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 8281: "b" is parsed.</p>
8282:
8283: <p>Before that token is seen, the <a href="#stack-of-open-elements">stack of open
1.159 mike 8284: elements</a> has four elements on it: <code><a href="semantics.html#the-html-element-0">html</a></code>,
8285: <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 8286: <a href="#list-of-active-formatting-elements">list of active formatting elements</a> just has the one:
8287: <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>
8288:
8289: <p>Upon receiving the end tag token with the tag name "b", the "<a href="#adoptionAgency">adoption agency algorithm</a>" is invoked, as
8290: in the previous example. However, in this case, there <em>is</em> a
8291: <var title="">furthest block</var>, namely the <code><a href="semantics.html#the-p-element">p</a></code> element. Thus,
8292: this time the adoption agency algorithm isn't skipped over.</p>
8293:
1.159 mike 8294: <p>The <var title="">common ancestor</var> is the <code><a href="semantics.html#the-body-element-0">body</a></code>
1.1 mike 8295: element. A conceptual "bookmark" marks the position of the
8296: <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
8297: elements</a>, but since that list has only one element in it,
8298: it won't have much effect.</p>
8299:
8300: <p>As the algorithm progresses, <var title="">node</var> ends up set
8301: to the formatting element (<code><a href="text-level-semantics.html#the-b-element">b</a></code>), and <var title="">last
8302: node</var> ends up set to the <var title="">furthest block</var>
8303: (<code><a href="semantics.html#the-p-element">p</a></code>).</p>
8304:
8305: <p>The <var title="">last node</var> gets appended (moved) to the
8306: <var title="">common ancestor</var>, so that the DOM looks like:</p>
8307:
1.159 mike 8308: <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 8309: <code><a href="semantics.html#the-p-element">p</a></code> element are moved to it:</p>
8310:
1.159 mike 8311: <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 8312: <code><a href="semantics.html#the-p-element">p</a></code> element, so that the DOM looks like:</p>
8313:
1.159 mike 8314: <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 8315: active formatting elements</a> and the <a href="#stack-of-open-elements">stack of open
8316: elements</a>, so that when the "3" is parsed, it is appended to
8317: the <code><a href="semantics.html#the-p-element">p</a></code> element:</p>
8318:
1.895 mike 8319: <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 8320:
8321: <p><i>This section is non-normative.</i></p>
8322:
8323: <p>Error handling in tables is, for historical reasons, especially
8324: strange. For example, consider the following markup:</p>
8325:
8326: <pre><table><strong><b></strong><tr><td>aaa</td></tr><strong>bbb</strong></table>ccc</pre>
8327:
8328: <p>The highlighted <code><a href="text-level-semantics.html#the-b-element">b</a></code> element start tag is not allowed
8329: directly inside a table like that, and the parser handles this case
8330: 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
8331: examining the DOM tree as it stands just after the
8332: <code><a href="tabular-data.html#the-table-element">table</a></code> element's start tag has been seen:</p>
8333:
1.159 mike 8334: <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 8335: tag has been seen:</p>
8336:
1.159 mike 8337: <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
8338: 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 8339: <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
8340: resulting DOM tree); the <a href="#list-of-active-formatting-elements">list of active formatting
8341: elements</a> just has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it; and the
8342: <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intable" title="insertion mode: in
8343: table">in table</a>".</p>
8344:
8345: <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
8346: to be popped off the stack and a <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> start tag to be
8347: 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
8348: then handled in a rather straight-forward manner, taking the parser
8349: through the "<a href="#parsing-main-intbody" title="insertion mode: in table body">in table
8350: body</a>" and "<a href="#parsing-main-intr" title="insertion mode: in row">in
8351: row</a>" insertion modes, after which the DOM looks as
8352: follows:</p>
8353:
1.159 mike 8354: <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
8355: 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 8356: <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
8357: formatting elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in
8358: it; and the <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intr" title="insertion
8359: mode: in row">in row</a>".</p>
8360:
8361: <p>The <code><a href="tabular-data.html#the-td-element">td</a></code> element start tag token, after putting a
8362: <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
8363: 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
8364: mode</a>).</p>
8365:
1.159 mike 8366: <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 8367: no <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created to hold the resulting text
8368: node:</p>
8369:
1.159 mike 8370: <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 8371: handling them, the <a href="#stack-of-open-elements">stack of open elements</a> has on it the
1.159 mike 8372: 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 8373: 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
8374: elements</a> still has the <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it (the
8375: marker having been removed by the "td" end tag token); and the
8376: <a href="#insertion-mode">insertion mode</a> is "<a href="#parsing-main-intbody" title="insertion mode: in
8377: table body">in table body</a>".</p>
8378:
8379: <p>Thus it is that the "bbb" character tokens are found. These
8380: trigger the "<a href="#parsing-main-intabletext" title="insertion mode: in table text">in table
8381: text</a>" insertion mode to be used (with the <a href="#original-insertion-mode">original
8382: insertion mode</a> set to "<a href="#parsing-main-intbody" title="insertion mode: in table
8383: body">in table body</a>"). The character tokens are collected,
8384: and when the next token (the <code><a href="tabular-data.html#the-table-element">table</a></code> element end tag) is
8385: seen, they are processed as a group. Since they are not all spaces,
8386: 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,
8387: which defer to the "<a href="#parsing-main-inbody" title="insertion mode: in body">in
8388: body</a>" insertion mode but with <a href="#foster-parent" title="foster
8389: parent">foster parenting</a>.</p>
8390:
8391: <p>When <a href="#reconstruct-the-active-formatting-elements" title="reconstruct the active formatting elements">the
8392: active formatting elements are reconstructed</a>, a
8393: <code><a href="text-level-semantics.html#the-b-element">b</a></code> element is created and <a href="#foster-parent" title="foster
8394: parent">foster parented</a>, and then the "bbb" text node is
8395: appended to it:</p>
8396:
1.159 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><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
8398: <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 8399: <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
8400: this doesn't match the resulting tree!); the <a href="#list-of-active-formatting-elements">list of active
8401: formatting elements</a> has the new <code><a href="text-level-semantics.html#the-b-element">b</a></code> element in it;
8402: and the <a href="#insertion-mode">insertion mode</a> is still "<a href="#parsing-main-intbody" title="insertion
8403: mode: in table body">in table body</a>".</p>
8404:
8405: <p>Had the character tokens been only <a href="infrastructure.html#space-character" title="space
8406: character">space characters</a> instead of "bbb", then those
8407: <a href="infrastructure.html#space-character" title="space character">space characters</a> would just be
8408: appended to the <code><a href="tabular-data.html#the-tbody-element">tbody</a></code> element.</p>
8409:
8410: <p>Finally, the <code><a href="tabular-data.html#the-table-element">table</a></code> is closed by a "table" end
8411: tag. This pops all the nodes from the <a href="#stack-of-open-elements">stack of open
8412: elements</a> up to and including the <code><a href="tabular-data.html#the-table-element">table</a></code> element,
8413: but it doesn't affect the <a href="#list-of-active-formatting-elements">list of active formatting
8414: elements</a>, so the "ccc" character tokens after the table
8415: result in yet another <code><a href="text-level-semantics.html#the-b-element">b</a></code> element being created, this
8416: time after the table:</p>
8417:
1.895 mike 8418: <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 8419:
8420: <p><i>This section is non-normative.</i></p>
8421:
8422: <p>Consider the following markup, which for this example we will
8423: 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 8424: content of an <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code> in another document with the
1.1 mike 8425: <a href="infrastructure.html#url">URL</a> <code title="">http://example.com/outer</code>:</p>
8426:
8427: <pre><div id=a>
8428: <script>
8429: var div = document.getElementById('a');
8430: parent.document.body.appendChild(div);
8431: </script>
8432: <script>
8433: alert(document.URL);
8434: </script>
8435: </div>
8436: <script>
8437: alert(document.URL);
8438: </script></pre>
8439:
8440: <p>Up to the first "script" end tag, before the script is parsed,
8441: the result is relatively straightforward:</p>
8442:
1.306 mike 8443: <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="">
8444: </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'); ⏎ 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 8445: and its child <code><a href="semantics.html#script">script</a></code> element are gone:</p>
8446:
1.810 mike 8447: <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 8448: aforementioned outer <a href="browsers.html#browsing-context">browsing context</a>. However, the
8449: <a href="#stack-of-open-elements">stack of open elements</a> <em>still contains the
1.306 mike 8450: <code><a href="semantics.html#the-div-element">div</a></code> element</em>.</p>
1.1 mike 8451:
8452: <p>Thus, when the second <code><a href="semantics.html#script">script</a></code> element is parsed, it
1.810 mike 8453: is inserted <em>into the outer <code><a href="infrastructure.html#document">Document</a></code>
1.1 mike 8454: object</em>.</p>
8455:
1.794 mike 8456: <p>This also means that the <a href="webappapis.html#script-s-global-object">script's global object</a> is
1.1 mike 8457: the outer <a href="browsers.html#browsing-context">browsing context</a>'s <code><a href="browsers.html#window">Window</a></code>
8458: object, <em>not</em> the <code><a href="browsers.html#window">Window</a></code> object inside the
1.159 mike 8459: <code><a href="text-level-semantics.html#the-iframe-element">iframe</a></code>.</p>
1.1 mike 8460:
8461: <p class="note">This isn't a security problem since the script that
1.810 mike 8462: 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
8463: only do so because the two <code><a href="infrastructure.html#document">Document</a></code> object have the
1.714 mike 8464: same <a href="browsers.html#origin">origin</a>.</p>
1.1 mike 8465:
8466: <p>Thus, the first alert says "http://example.com/outer".</p>
8467:
1.306 mike 8468: <p>Once the <code><a href="semantics.html#the-div-element">div</a></code> element's end tag is parsed, the
8469: <code><a href="semantics.html#the-div-element">div</a></code> element is popped off the stack, and so the next
1.810 mike 8470: <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 8471:
1.159 mike 8472: <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 8473:
8474:
8475:
8476:
1.895 mike 8477: <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 8478:
8479: <p>The following steps form the <dfn id="html-fragment-serialization-algorithm">HTML fragment serialization
8480: algorithm</dfn>. The algorithm takes as input a DOM
1.810 mike 8481: <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 8482: exception.</p>
8483:
8484: <p class="note">This algorithm serializes the <em>children</em> of
8485: the node being serialized, not the node itself.</p>
8486:
8487: <ol><li><p>Let <var title="">s</var> be a string, and initialize it to
8488: the empty string.</p></li>
8489:
8490: <li>
8491:
8492: <p>For each child node of <var title="">the node</var>, in
8493: <a href="infrastructure.html#tree-order">tree order</a>, run the following steps:
8494:
8495: </p><ol><li><p>Let <var title="">current node</var> be the child node
8496: being processed.</p></li>
8497:
8498: <li>
8499:
8500: <p>Append the appropriate string from the following list to
8501: <var title="">s</var>:</p>
8502:
8503: <dl class="switch"><dt>If <var title="">current node</var> is an <code title="">Element</code></dt>
8504:
8505: <dd>
8506:
1.588 mike 8507: <p>Append a U+003C LESS-THAN SIGN character character (<),
8508: followed by the element's tag name. (For nodes created by the
8509: <a href="#html-parser">HTML parser</a> or <code title="">Document.createElement()</code>, the tag name will be
1.1 mike 8510: lowercase.)</p>
8511:
8512: <p>For each attribute that the element has, append a U+0020
8513: SPACE character, the attribute's name (which, for attributes
8514: 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 8515: U+003D EQUALS SIGN character (=), a U+0022 QUOTATION MARK
8516: character ("), the attribute's value, <a href="#escapingString" title="escaping a string">escaped as described below</a> in
8517: <i>attribute mode</i>, and a second U+0022 QUOTATION MARK
8518: character (").</p>
1.1 mike 8519:
8520: <p>While the exact order of attributes is UA-defined, and may
8521: depend on factors such as the order that the attributes were
8522: given in the original markup, the sort order must be stable,
8523: such that consecutive invocations of this algorithm serialize an
8524: element's attributes in the same order.</p>
8525:
1.588 mike 8526: <p>Append a U+003E GREATER-THAN SIGN character (>).</p>
1.1 mike 8527:
8528: <p>If <var title="">current node</var> is an
1.5 mike 8529: <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.893 mike 8530: <code><a href="obsolete.html#bgsound">bgsound</a></code>, <code><a href="text-level-semantics.html#the-br-element">br</a></code>, <code><a href="tabular-data.html#the-col-element">col</a></code>,
1.159 mike 8531: <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>,
8532: <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 8533: <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.893 mike 8534: <code><a href="text-level-semantics.html#the-wbr-element">wbr</a></code> element, then continue on to the next child
1.589 mike 8535: node at this point.</p> <!-- also, i guess: image and isindex,
8536: but we don't list those because we don't consider those
8537: "elements", more "macros", and thus we should never serialize
8538: them -->
1.1 mike 8539:
8540: <p>If <var title="">current node</var> is a <code><a href="semantics.html#the-pre-element">pre</a></code>,
1.42 mike 8541: <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 8542: a U+000A LINE FEED (LF) character.</p>
8543:
8544: <p>Append the value of running the <a href="#html-fragment-serialization-algorithm">HTML fragment
8545: serialization algorithm</a> on the <var title="">current
8546: node</var> element (thus recursing into this algorithm for
1.588 mike 8547: that element), followed by a U+003C LESS-THAN SIGN character
8548: (<), a U+002F SOLIDUS character (/), the element's tag name
8549: again, and finally a U+003E GREATER-THAN SIGN character
8550: (>).</p>
1.1 mike 8551:
8552: </dd>
8553:
8554:
8555: <dt>If <var title="">current node</var> is a <code title="">Text</code> or <code title="">CDATASection</code>
8556: node</dt>
8557:
8558: <dd>
8559:
1.19 mike 8560: <p>If the parent of <var title="">current node</var> is a
1.42 mike 8561: <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 8562: <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 8563: <code><a href="obsolete.html#noframes">noframes</a></code>, or <code><a href="obsolete.html#plaintext">plaintext</a></code> element, or
8564: if the parent of <var title="">current node</var> is
1.794 mike 8565: <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 8566: node, then append the value of <var title="">current
8567: node</var>'s <code title="">data</code> IDL attribute
8568: literally.</p>
1.1 mike 8569:
8570: <p>Otherwise, append the value of <var title="">current
1.192 mike 8571: node</var>'s <code title="">data</code> IDL attribute, <a href="#escapingString" title="escaping a string">escaped as described
1.1 mike 8572: below</a>.</p>
8573:
8574: </dd>
8575:
8576:
8577: <dt>If <var title="">current node</var> is a <code title="">Comment</code></dt>
8578:
8579: <dd>
8580:
8581: <p>Append the literal string <code><!--</code> (U+003C
8582: LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS,
1.192 mike 8583: U+002D HYPHEN-MINUS), followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1 mike 8584: attribute, followed by the literal string <code>--></code>
8585: (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN
8586: SIGN).</p>
8587:
8588: </dd>
8589:
8590:
8591: <dt>If <var title="">current node</var> is a <code title="">ProcessingInstruction</code></dt>
8592:
8593: <dd>
8594:
8595: <p>Append the literal string <code><?</code> (U+003C
8596: LESS-THAN SIGN, U+003F QUESTION MARK), followed by the value
1.192 mike 8597: of <var title="">current node</var>'s <code title="">target</code> IDL attribute, followed by a single
8598: U+0020 SPACE character, followed by the value of <var title="">current node</var>'s <code title="">data</code> IDL
1.1 mike 8599: attribute, followed by a single U+003E GREATER-THAN SIGN
1.464 mike 8600: character (>).</p>
1.1 mike 8601:
8602: </dd>
8603:
8604:
8605: <dt>If <var title="">current node</var> is a <code title="">DocumentType</code></dt>
8606:
8607: <dd>
8608:
8609: <p>Append the literal string <code><!DOCTYPE</code> (U+003C
8610: LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+0044 LATIN CAPITAL
8611: LETTER D, U+004F LATIN CAPITAL LETTER O, U+0043 LATIN CAPITAL
8612: LETTER C, U+0054 LATIN CAPITAL LETTER T, U+0059 LATIN CAPITAL
8613: LETTER Y, U+0050 LATIN CAPITAL LETTER P, U+0045 LATIN CAPITAL
8614: LETTER E), followed by a space (U+0020 SPACE), followed by the
1.192 mike 8615: value of <var title="">current node</var>'s <code title="">name</code> IDL attribute, followed by the literal
1.1 mike 8616: string <code>></code> (U+003E GREATER-THAN SIGN).</p>
8617:
8618: </dd>
8619:
8620:
8621: </dl><p>Other node types (e.g. <code title="">Attr</code>) cannot
8622: occur as children of elements. If, despite this, they somehow do
8623: occur, this algorithm must raise an
8624: <code><a href="infrastructure.html#invalid_state_err">INVALID_STATE_ERR</a></code> exception.</p>
8625:
8626: </li>
8627:
8628: </ol></li>
8629:
8630: <li><p>The result of the algorithm is the string <var title="">s</var>.</p></li>
8631:
8632: </ol><p><dfn id="escapingString">Escaping a string</dfn> (for the
8633: purposes of the algorithm above) consists of replacing any
8634: occurrences of the "<code title="">&</code>" character by the
8635: string "<code title="">&amp;</code>", any occurrences of the
8636: U+00A0 NO-BREAK SPACE character by the string "<code title="">&nbsp;</code>", and, if the algorithm was invoked in
8637: the <i>attribute mode</i>, any occurrences of the "<code title="">"</code>" character by the string "<code title="">&quot;</code>", or if it was not, any occurrences of
8638: the "<code title=""><</code>" character by the string "<code title="">&lt;</code>", any occurrences of the "<code title="">></code>" character by the string "<code title="">&gt;</code>".</p>
8639:
8640: <p class="note">Entity reference nodes are <a href="infrastructure.html#entity-references">assumed to be expanded</a> by the user
8641: agent, and are therefore not covered in the algorithm above.</p>
8642:
8643: <p class="note">It is possible that the output of this algorithm, if
8644: parsed with an <a href="#html-parser">HTML parser</a>, will not return the
8645: original tree structure. For instance, if a <code><a href="forms.html#the-textarea-element">textarea</a></code>
8646: element to which a <code title="">Comment</code> node has been
8647: appended is serialized and the output is then reparsed, the comment
8648: will end up being displayed in the text field. Similarly, if, as a
8649: result of DOM manipulation, an element contains a comment that
8650: contains the literal string "<code title="">--></code>", then
8651: when the result of serializing the element is parsed, the comment
8652: will be truncated at that point and the rest of the comment will be
8653: interpreted as markup. More examples would be making a
8654: <code><a href="semantics.html#script">script</a></code> element contain a text node with the text string
8655: "<code></script></code>", or having a <code><a href="semantics.html#the-p-element">p</a></code> element that
8656: 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
8657: <a href="#syntax-start-tag" title="syntax-start-tag">start tag</a> would imply the end
8658: tag for the <code><a href="semantics.html#the-p-element">p</a></code>).</p>
8659:
8660:
1.895 mike 8661: <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 8662:
8663: <p>The following steps form the <dfn id="html-fragment-parsing-algorithm">HTML fragment parsing
8664: algorithm</dfn>. The algorithm optionally takes as input an
1.810 mike 8665: <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 8666: parser, as well as <var title="">input</var>, a string to parse, and
8667: returns a list of zero or more nodes.</p>
8668:
8669: <p class="note">Parts marked <dfn id="fragment-case">fragment case</dfn> in algorithms
8670: in the parser section are parts that only occur if the parser was
8671: created for the purposes of this algorithm (and with a <var title="">context</var> element). The algorithms have been annotated
8672: with such markings for informational purposes only; such markings
8673: have no normative weight. If it is possible for a condition
8674: described as a <a href="#fragment-case">fragment case</a> to occur even when the
8675: parser wasn't created for the purposes of handling this algorithm,
8676: then that is an error in the specification.</p>
8677:
8678: <ol><li>
8679:
1.810 mike 8680: <p>Create a new <code><a href="infrastructure.html#document">Document</a></code> node, and mark it as being
1.1 mike 8681: an <a href="dom.html#html-documents" title="HTML documents">HTML document</a>.</p>
8682:
8683: </li>
8684:
8685: <li>
8686:
8687: <p>If there is a <var title="">context</var> element, and the
1.810 mike 8688: <code><a href="infrastructure.html#document">Document</a></code> of the <var title="">context</var> element
8689: is in <a href="dom.html#quirks-mode">quirks mode</a>, then let the <code><a href="infrastructure.html#document">Document</a></code>
8690: 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 8691: the <var title="">context</var> element is in <a href="dom.html#limited-quirks-mode">limited-quirks
1.810 mike 8692: mode</a>, then let the <code><a href="infrastructure.html#document">Document</a></code> be in
1.880 mike 8693: <a href="dom.html#limited-quirks-mode">limited-quirks mode</a>. Otherwise, leave the
8694: <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 8695:
8696: </li>
8697:
8698: <li>
8699:
8700: <p>Create a new <a href="#html-parser">HTML parser</a>, and associate it with
1.810 mike 8701: the just created <code><a href="infrastructure.html#document">Document</a></code> node.</p>
1.1 mike 8702:
8703: </li>
8704:
8705: <li>
8706:
8707: <p>If there is a <var title="">context</var> element, run these
8708: substeps:</p>
8709:
8710: <ol><li>
8711:
1.541 mike 8712: <p>Set the state of the <a href="#html-parser">HTML parser</a>'s
8713: <a href="#tokenization">tokenization</a> stage as follows:</p>
1.1 mike 8714:
1.159 mike 8715: <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 8716: element</dt>
8717:
1.541 mike 8718: <dd>Switch the tokenizer to the <a href="#rcdata-state">RCDATA state</a>.</dd>
1.1 mike 8719:
8720:
1.672 mike 8721: <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>,
8722: <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 8723: <code><a href="obsolete.html#noframes">noframes</a></code> element</dt>
1.1 mike 8724:
1.541 mike 8725: <dd>Switch the tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>.</dd>
1.1 mike 8726:
8727:
1.672 mike 8728: <dt>If it is a <code><a href="semantics.html#script">script</a></code> element</dt>
8729:
8730: <dd>Switch the tokenizer to the <a href="#script-data-state">script data state</a>.</dd>
8731:
8732:
1.1 mike 8733: <dt>If it is a <code><a href="semantics.html#the-noscript-element">noscript</a></code> element</dt>
8734:
1.541 mike 8735: <dd>If the <a href="#scripting-flag">scripting flag</a> is enabled, switch the
8736: tokenizer to the <a href="#rawtext-state">RAWTEXT state</a>. Otherwise,
8737: leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1 mike 8738:
8739:
1.42 mike 8740: <dt>If it is a <code><a href="obsolete.html#plaintext">plaintext</a></code> element</dt>
1.1 mike 8741:
1.541 mike 8742: <dd>Switch the tokenizer to the <a href="#plaintext-state">PLAINTEXT
8743: state</a>.</dd>
1.1 mike 8744:
8745:
8746: <dt>Otherwise</dt>
8747:
1.541 mike 8748: <dd>Leave the tokenizer in the <a href="#data-state">data state</a>.</dd>
1.1 mike 8749:
1.672 mike 8750: </dl><p class="note">For performance reasons, an implementation that
1.756 mike 8751: does not report errors and that uses the actual state machine
8752: described in this specification directly could use the PLAINTEXT
8753: state instead of the RAWTEXT and script data states where those
8754: are mentioned in the list above. Except for rules regarding
8755: parse errors, they are equivalent, since there is no
8756: <a href="#appropriate-end-tag-token">appropriate end tag token</a> in the fragment case, yet
8757: they involve far fewer state transitions.</p>
1.672 mike 8758:
8759: </li>
1.1 mike 8760:
8761: <li>
8762:
1.159 mike 8763: <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 8764: with no attributes.</p>
8765:
8766: </li>
8767:
8768: <li>
8769:
8770: <p>Append the element <var title="">root</var> to the
1.810 mike 8771: <code><a href="infrastructure.html#document">Document</a></code> node created above.</p>
1.1 mike 8772:
8773: </li>
8774:
8775: <li>
8776:
8777: <p>Set up the parser's <a href="#stack-of-open-elements">stack of open elements</a> so that
8778: it contains just the single element <var title="">root</var>.</p>
8779:
8780: </li>
8781:
8782: <li>
8783:
8784: <p><a href="#reset-the-insertion-mode-appropriately" title="reset the insertion mode appropriately">Reset the
8785: parser's insertion mode appropriately</a>.</p>
8786:
8787: <p class="note">The parser will reference the <var title="">context</var> element as part of that algorithm.</p>
8788:
8789: </li>
8790:
8791: <li>
8792:
8793: <p>Set the parser's <a href="#form-element-pointer"><code>form</code> element pointer</a>
8794: to the nearest node to the <var title="">context</var> element
8795: that is a <code><a href="forms.html#the-form-element">form</a></code> element (going straight up the
8796: ancestor chain, and including the element itself, if it is a
8797: <code><a href="forms.html#the-form-element">form</a></code> element), or, if there is no such
8798: <code><a href="forms.html#the-form-element">form</a></code> element, to null.</p>
8799:
8800: </li>
8801:
8802: </ol></li>
8803:
8804: <li>
8805:
8806: <p>Place into the <a href="#the-input-stream">input stream</a> for the <a href="#html-parser">HTML
8807: parser</a> just created the <var title="">input</var>. The
8808: encoding <a href="#concept-encoding-confidence" title="concept-encoding-confidence">confidence</a> is
8809: <i>irrelevant</i>.</p>
8810:
8811: </li>
8812:
8813: <li>
8814:
8815: <p>Start the parser and let it run until it has consumed all the
8816: characters just inserted into the input stream.</p>
8817:
8818: </li>
8819:
8820: <li>
8821:
8822: <p>If there is a <var title="">context</var> element, return the
8823: child nodes of <var title="">root</var>, in <a href="infrastructure.html#tree-order">tree
8824: order</a>.</p>
8825:
1.810 mike 8826: <p>Otherwise, return the children of the <code><a href="infrastructure.html#document">Document</a></code>
1.1 mike 8827: object, in <a href="infrastructure.html#tree-order">tree order</a>.</p>
8828:
8829: </li>
8830:
1.123 mike 8831: </ol></div></body></html>
Webmaster